1# SPDX-License-Identifier: GPL-2.0-only
2# Makefile for libcpupower's Python bindings
3#
4# This Makefile expects you have already run the makefile for cpupower to build
5# the .o files in the lib directory for the bindings to be created.
6
7CC=gcc
8
9LIB_DIR = ../../lib
10BIND_DIR = .
11PY_INCLUDE := $(firstword $(shell python-config --includes))
12#PY_INCLUDE = $(shell python-config --includes | awk '{ print $1 }')
13
14OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o)
15OBJECTS_BIND = $(wildcard $(BIND_DIR)/*.o)
16
17all: _raw_pylibcpupower.so
18
19_raw_pylibcpupower.so: raw_pylibcpupower_wrap.o
20	$(CC) -shared $(OBJECTS_LIB) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so # raw_pylibcpupower_wrap.o
21#	$(CC) -shared $(OBJECTS_BIND) $(OBJECTS_LIB) -o _raw_pylibcpupower.so # raw_pylibcpupower_wrap.o
22
23raw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c
24	$(CC) -fPIC -c raw_pylibcpupower_wrap.c $(PY_INCLUDE)
25
26raw_pylibcpupower_wrap.c: raw_pylibcpupower.i
27	swig -python raw_pylibcpupower.i
28
29# Will only clean the bindings folder; will not clean the actual cpupower folder
30clean:
31	rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so
32