mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-29 13:33:07 +00:00
Installs the .so and .py files generated by SWIG to system's site packages directory. This allows the Python bindings to be used system wide. This commit also includes documentation on setting up and installing the Python bindings. Link: https://lore.kernel.org/r/20241219012606.38963-1-jwyatt@redhat.com 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>
44 lines
1.7 KiB
Makefile
44 lines
1.7 KiB
Makefile
# 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
|
|
HAVE_SWIG := $(shell if which swig >/dev/null 2>&1; then echo 1; else echo 0; fi)
|
|
HAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; else echo 0; fi)
|
|
|
|
LIB_DIR := ../../lib
|
|
PY_INCLUDE = $(firstword $(shell python-config --includes))
|
|
OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o)
|
|
INSTALL_DIR = $(shell python3 -c "import site; print(site.getsitepackages()[0])")
|
|
|
|
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: raw_pylibcpupower_wrap.c
|
|
$(CC) -fPIC -c raw_pylibcpupower_wrap.c $(PY_INCLUDE)
|
|
|
|
raw_pylibcpupower_wrap.c: raw_pylibcpupower.swg
|
|
ifeq ($(HAVE_SWIG),0)
|
|
$(error "swig was not found. Make sure you have it installed and in the PATH to generate the bindings.")
|
|
else ifeq ($(HAVE_PYCONFIG),0)
|
|
$(error "python-config was not found. Make sure you have it installed and in the PATH to generate the bindings.")
|
|
endif
|
|
swig -python raw_pylibcpupower.swg
|
|
|
|
# Only installs the Python bindings
|
|
install: _raw_pylibcpupower.so
|
|
install -D _raw_pylibcpupower.so $(INSTALL_DIR)/_raw_pylibcpupower.so
|
|
install -D raw_pylibcpupower.py $(INSTALL_DIR)/raw_pylibcpupower.py
|
|
|
|
uninstall:
|
|
rm -f $(INSTALL_DIR)/_raw_pylibcpupower.so
|
|
rm -f $(INSTALL_DIR)/raw_pylibcpupower.py
|
|
|
|
# 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
|