From 499d389779f7881054ecd691db7ebea49eb5a492 Mon Sep 17 00:00:00 2001 From: Gus Smith Date: Fri, 29 May 2026 10:01:23 -0700 Subject: Improve makefile portability --- sources/api/pySoftMC/Makefile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sources') diff --git a/sources/api/pySoftMC/Makefile b/sources/api/pySoftMC/Makefile index 0c1d241..b03b1a9 100644 --- a/sources/api/pySoftMC/Makefile +++ b/sources/api/pySoftMC/Makefile @@ -1,21 +1,19 @@ -# https://stackoverflow.com/questions/4933285/how-to-determine-python-version-in-makefile -python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1))) -python_version := $(word 1,${python_version_full}).$(word 2,${python_version_full}) - program_NAME := pySoftMC program_CXX_SRCS := $(wildcard ../*.c) $(wildcard ../*.cpp) ./pySoftMC.cpp program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o} program_CXX_OBJS := ${program_CXX_OBJS:.c=.o} program_OBJS := $(program_CXX_OBJS) -program_INCLUDE_DIRS := . .. /usr/include/python${python_version} ../ext/pybind11/include +python_INCLUDE_FLAGS := $(shell python3-config --includes) +program_INCLUDE_DIRS := . .. ../ext/pybind11/include program_LIBRARY_DIRS := -program_LIBRARIES := python${python_version} +program_LIBRARIES := CPPFLAGS += -g -std=c++14 -pthread -O3 -fPIC -Wall -CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) -DPYSMC +CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) $(python_INCLUDE_FLAGS) -DPYSMC LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir)) LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library)) +LDFLAGS += $(shell python3-config --ldflags --embed 2>/dev/null || python3-config --ldflags) SHARED_LIB_FLAGS := -shared -fPIC -- cgit v1.2.3