From 704b1fb1e7a68f334832c4de7312a2da513f10f3 Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 8 Jan 2021 23:00:24 +0100 Subject: [PATCH] Example module - add static linking option --- gen/examples/ext/synth_shed/Makefile | 23 ++++++++++++++++------- gen/examples/ext/synth_shed/Makefile.conf | 5 +++++ gen/examples/ext/synth_shed/gen/Makefile | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gen/examples/ext/synth_shed/Makefile b/gen/examples/ext/synth_shed/Makefile index 7c9f0ed..ac0b67d 100644 --- a/gen/examples/ext/synth_shed/Makefile +++ b/gen/examples/ext/synth_shed/Makefile @@ -1,6 +1,7 @@ include Makefile.conf -TARGET_MODULE=synth_shed.so +TARGET_MODULE_DYN=synth_shed.so +TARGET_MODULE_STATIC=synth_shed.so CXX=clang CXXFLAGS+=-std=c++11 -g @@ -8,23 +9,31 @@ SRCS+=$(wildcard *.cc) OBJS+=$(SRCS:.cc=.o) CXXFLAGS+=$(INCLUDES) -I$(PREFIX)/include -LDFLAGS+=-undefined dynamic_lookup $(LIBS_PATH) $(LIBS) +LDFLAGS_DYN+=-undefined dynamic_lookup $(LIBS_PATH) $(LIBS) +LDFLAGS_STATIC+=-undefined dynamic_lookup $(info -----BUILD INFO----) $(info SRCS $(SRCS)) $(info OBJS $(OBJS)) -.PHONY: all gen module clean +.PHONY: all gen module_dyn module_static clean -all: gen module +static: gen module_static + +dyn: gen module_dyn gen: $(MAKE) -C gen -module: $(TARGET_MODULE) +module_dyn: $(TARGET_MODULE_DYN) + +$(TARGET_MODULE_DYN) : $(OBJS) + $(CXX) $(LDFLAGS_DYN) -o $@ $^ + +module_static: $(TARGET_MODULE_STATIC) -$(TARGET_MODULE) : $(OBJS) - $(CXX) $(LDFLAGS) -o $@ $^ +$(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC) + $(CXX) $(LDFLAGS_STATIC) -o $@ $^ clean: $(MAKE) -C gen clean diff --git a/gen/examples/ext/synth_shed/Makefile.conf b/gen/examples/ext/synth_shed/Makefile.conf index 803c484..0ec5cd1 100644 --- a/gen/examples/ext/synth_shed/Makefile.conf +++ b/gen/examples/ext/synth_shed/Makefile.conf @@ -14,5 +14,10 @@ INCLUDES+=-I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/ # example lib INCLUDES+=-I../../lib/lib_synth_shed + +# static lib (.a) +LIBS_STATIC+=../../lib/lib_synth_shed/libsynth_shed.a + +# dynamic lib (.so) LIBS+=-lsynth_shed LIBS_PATH+=-L../../lib/lib_synth_shed/ diff --git a/gen/examples/ext/synth_shed/gen/Makefile b/gen/examples/ext/synth_shed/gen/Makefile index 7d67702..7fc1c43 100644 --- a/gen/examples/ext/synth_shed/gen/Makefile +++ b/gen/examples/ext/synth_shed/gen/Makefile @@ -8,7 +8,7 @@ CC_FILE=py_module.cc all: yml cc yml: - $(pEpACIDgen_ROOT)/bin/pEp_acid_gen.py $(abspath config.json) + $(pEpACIDgen_ROOT)/bin/pEp_acid_gen $(abspath config.json) cc : $(YML2_FILE) $(YML2_PROC) -y $(pEpACIDgen_ROOT)/pEpACIDgen/gen_backend/gen_cc.ysl2 $(YML2_FILE)