pm:cpupower: Add SWIG bindings files for libcpupower
SWIG is a tool packaged in Fedora and other distros that can generate bindings from C and C++ code for several languages including Python, Perl, and Go. These bindings allows users to easily write scripts that use and extend libcpupower's functionality. Currently, only Python is provided in the makefile, but additional languages may be added if there is demand. Added suggestions from Shuah Khan for the README and license discussion. Note that while SWIG itself is GPL v3+ licensed; the resulting output, the bindings code, is permissively licensed + the license of the .o files. Please see https://swig.org/legal.html and [1] for more details. [1] https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup/ Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: John B. Wyatt IV <jwyatt@redhat.com> Signed-off-by: John B. Wyatt IV <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
committed by
Shuah Khan
parent
4b80294fb5
commit
338f490e07
@@ -0,0 +1,31 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Makefile for libcpupower's Python bindings
|
||||
#
|
||||
# This Makefile expects you have already run the makefile for cpupower to build
|
||||
# the .o files in the lib directory for the bindings to be created.
|
||||
|
||||
CC=gcc
|
||||
|
||||
LIB_DIR = ../../lib
|
||||
BIND_DIR = .
|
||||
PY_INCLUDE := $(firstword $(shell python-config --includes))
|
||||
#PY_INCLUDE = $(shell python-config --includes | awk '{ print $1 }')
|
||||
|
||||
OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o)
|
||||
OBJECTS_BIND = $(wildcard $(BIND_DIR)/*.o)
|
||||
|
||||
all: _raw_pylibcpupower.so
|
||||
|
||||
_raw_pylibcpupower.so: raw_pylibcpupower_wrap.o
|
||||
$(CC) -shared $(OBJECTS_LIB) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so # raw_pylibcpupower_wrap.o
|
||||
# $(CC) -shared $(OBJECTS_BIND) $(OBJECTS_LIB) -o _raw_pylibcpupower.so # raw_pylibcpupower_wrap.o
|
||||
|
||||
raw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c
|
||||
$(CC) -fPIC -c raw_pylibcpupower_wrap.c $(PY_INCLUDE)
|
||||
|
||||
raw_pylibcpupower_wrap.c: raw_pylibcpupower.i
|
||||
swig -python raw_pylibcpupower.i
|
||||
|
||||
# Will only clean the bindings folder; will not clean the actual cpupower folder
|
||||
clean:
|
||||
rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so
|
||||
Reference in New Issue
Block a user