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# 4338f490eSJohn B. Wyatt IV# This Makefile expects you have already run the makefile for cpupower to build 5338f490eSJohn B. Wyatt IV# the .o files in the lib directory for the bindings to be created. 6338f490eSJohn B. Wyatt IV 780e67f18SJohn B. Wyatt IVCC := gcc 880e67f18SJohn B. Wyatt IVHAVE_SWIG := $(shell if which swig >/dev/null 2>&1; then echo 1; else echo 0; fi) 980e67f18SJohn B. Wyatt IVHAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; else echo 0; fi) 10338f490eSJohn B. Wyatt IV 1180e67f18SJohn B. Wyatt IVLIB_DIR := ../../lib 1280e67f18SJohn B. Wyatt IVPY_INCLUDE = $(firstword $(shell python-config --includes)) 13338f490eSJohn B. Wyatt IVOBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o) 14338f490eSJohn B. Wyatt IV 15338f490eSJohn B. Wyatt IVall: _raw_pylibcpupower.so 16338f490eSJohn B. Wyatt IV 17338f490eSJohn B. Wyatt IV_raw_pylibcpupower.so: raw_pylibcpupower_wrap.o 1880e67f18SJohn B. Wyatt IV $(CC) -shared $(OBJECTS_LIB) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so 19338f490eSJohn B. Wyatt IV 20338f490eSJohn B. Wyatt IVraw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c 21338f490eSJohn B. Wyatt IV $(CC) -fPIC -c raw_pylibcpupower_wrap.c $(PY_INCLUDE) 22338f490eSJohn B. Wyatt IV 23*313312c8SMin-Hua Chenraw_pylibcpupower_wrap.c: raw_pylibcpupower.swg 2480e67f18SJohn B. Wyatt IVifeq ($(HAVE_SWIG),0) 2580e67f18SJohn B. Wyatt IV $(error "swig was not found. Make sure you have it installed and in the PATH to generate the bindings.") 2680e67f18SJohn B. Wyatt IVelse ifeq ($(HAVE_PYCONFIG),0) 2780e67f18SJohn B. Wyatt IV $(error "python-config was not found. Make sure you have it installed and in the PATH to generate the bindings.") 2880e67f18SJohn B. Wyatt IVendif 29*313312c8SMin-Hua Chen swig -python raw_pylibcpupower.swg 30338f490eSJohn B. Wyatt IV 31338f490eSJohn B. Wyatt IV# Will only clean the bindings folder; will not clean the actual cpupower folder 32338f490eSJohn B. Wyatt IVclean: 33338f490eSJohn B. Wyatt IV rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so 34