diff --git a/bin/trick-ify b/bin/trick-ify index 83b7e98a..e778e5cb 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -46,7 +46,7 @@ GetOptions $full_build = !$no_source_build ; $val = $ARGV[$argnum + 1] ; -if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so")) ) +if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so") or ($build_type eq "dylib")) ) { print "Invalid build type {$build_type}, valid build types are {o, a, so}\n" ; exit 1 ; @@ -94,7 +94,7 @@ elsif ( $build_type eq a ) { $ENV{'TRICKIFY_BUILD_TYPE'} = STATIC ; } -elsif ( $build_type eq so ) +elsif ( $build_type eq so || $build_type eq dylib ) { $ENV{'TRICKIFY_BUILD_TYPE'} = SHARED ; } diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 839f8a2d..f5432dd0 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -130,7 +130,8 @@ UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) - SHARED_OPTIONS := -fPIC -lgcov + SHARED_OPTIONS := -fPIC + LD_OPTIONS := -Wl,-install_name,$(abspath $(TRICKIFY_OBJECT_NAME)) else SHARED_OPTIONS := endif @@ -138,31 +139,29 @@ endif .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) -.ONESHELL: $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) - echo TRICKIFICATION STEP A - @while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(PY_LINK_LIST) - echo TRICKIFICATION STEP B - @while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(IO_LINK_LIST) - echo TRICKIFICATION STEP C - @if [ "$(FULL_TRICKIFY_BUILD)" = "1" ] ; then \ - while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(OBJ_LINK_LIST) ; \ - fi - echo TRICKIFICATION STEP D - @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ - $(LD) $(LD_PARTIAL) -o $@ $$FILES ; \ - elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ] ; then \ - $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $$FILES ; \ - elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ - ar rcs $@ $ $$FILES ; \ - fi - echo TRICKIFICATION STEP E + @echo TRICKIFICATION + @sh -c '\ + FILES=""; \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(PY_LINK_LIST); \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(IO_LINK_LIST); \ + if [ "$(FULL_TRICKIFY_BUILD)" = "1" ]; then \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(OBJ_LINK_LIST); \ + fi; \ + if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ]; then \ + $(LD) $(LD_PARTIAL) -o $@ $$FILES; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ]; then \ + $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) $(LD_OPTIONS) -o $@ $$FILES; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ]; then \ + ar rcs $@ $$FILES; \ + fi; \ + ' $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @mkdir -p $@ diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 4838b1b5..ce6a7d4c 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v --source_make_args -fPIC + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b $(BUILD_TYPE) -n trickified_myproject -v --source_make_args -fPIC clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index 8f3a556b..52c8f6d1 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,14 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -export TRICKIFY_OBJECT_NAME := trickified_myproject.so +BUILD_TYPE := so +UNAME := $(shell uname) +ifeq ($(UNAME),Darwin) + BUILD_TYPE := dylib +endif + +export TRICKIFY_OBJECT_NAME := trickified_myproject.$(BUILD_TYPE) + MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME) # Tell Trick the headers and source at this location are part of a @@ -25,4 +32,4 @@ TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified # Link in the Trickified object -TRICK_LDFLAGS += $(MYPROJECT_TRICK) +TRICK_LDFLAGS += $(MYPROJECT_TRICK) -Wl,-rpath,$(MYPROJECT_HOME)/trickified