1338f490eSJohn B. Wyatt IV# SPDX-License-Identifier: GPL-2.0-only 2338f490eSJohn B. Wyatt IV# Makefile for libcpupower's Python bindings 3338f490eSJohn B. Wyatt IV# 499d2fce9SJohn B. Wyatt IV# This Makefile expects you have already run `make install-lib` in the lib 599d2fce9SJohn B. Wyatt IV# directory for the bindings to be created. 6338f490eSJohn B. Wyatt IV 7*b74710eaSJohn B. Wyatt IVCC ?= gcc 8*b74710eaSJohn B. Wyatt IV# CFLAGS ?= 9*b74710eaSJohn B. Wyatt IVLDFLAGS ?= -lcpupower 1080e67f18SJohn B. Wyatt IVHAVE_SWIG := $(shell if which swig >/dev/null 2>&1; then echo 1; else echo 0; fi) 1180e67f18SJohn B. Wyatt IVHAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; else echo 0; fi) 12338f490eSJohn B. Wyatt IV 13*b74710eaSJohn B. Wyatt IVPY_INCLUDE ?= $(firstword $(shell python-config --includes)) 14*b74710eaSJohn B. Wyatt IVINSTALL_DIR ?= $(shell python3 -c "import site; print(site.getsitepackages()[0])") 15338f490eSJohn B. Wyatt IV 16338f490eSJohn B. Wyatt IVall: _raw_pylibcpupower.so 17338f490eSJohn B. Wyatt IV 18338f490eSJohn B. Wyatt IV_raw_pylibcpupower.so: raw_pylibcpupower_wrap.o 19*b74710eaSJohn B. Wyatt IV $(CC) -shared $(LDFLAGS) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so 20338f490eSJohn B. Wyatt IV 21338f490eSJohn B. Wyatt IVraw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c 22*b74710eaSJohn B. Wyatt IV $(CC) $(CFLAGS) $(PY_INCLUDE) -fPIC -c raw_pylibcpupower_wrap.c 23338f490eSJohn B. Wyatt IV 24313312c8SMin-Hua Chenraw_pylibcpupower_wrap.c: raw_pylibcpupower.swg 2580e67f18SJohn B. Wyatt IVifeq ($(HAVE_SWIG),0) 2680e67f18SJohn B. Wyatt IV $(error "swig was not found. Make sure you have it installed and in the PATH to generate the bindings.") 2780e67f18SJohn B. Wyatt IVelse ifeq ($(HAVE_PYCONFIG),0) 2880e67f18SJohn B. Wyatt IV $(error "python-config was not found. Make sure you have it installed and in the PATH to generate the bindings.") 2980e67f18SJohn B. Wyatt IVendif 30313312c8SMin-Hua Chen swig -python raw_pylibcpupower.swg 31338f490eSJohn B. Wyatt IV 326de02569SJohn B. Wyatt IV# Only installs the Python bindings 336de02569SJohn B. Wyatt IVinstall: _raw_pylibcpupower.so 346de02569SJohn B. Wyatt IV install -D _raw_pylibcpupower.so $(INSTALL_DIR)/_raw_pylibcpupower.so 356de02569SJohn B. Wyatt IV install -D raw_pylibcpupower.py $(INSTALL_DIR)/raw_pylibcpupower.py 366de02569SJohn B. Wyatt IV 376de02569SJohn B. Wyatt IVuninstall: 386de02569SJohn B. Wyatt IV rm -f $(INSTALL_DIR)/_raw_pylibcpupower.so 396de02569SJohn B. Wyatt IV rm -f $(INSTALL_DIR)/raw_pylibcpupower.py 406de02569SJohn B. Wyatt IV 41338f490eSJohn B. Wyatt IV# Will only clean the bindings folder; will not clean the actual cpupower folder 42338f490eSJohn B. Wyatt IVclean: 43338f490eSJohn B. Wyatt IV rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so 44