--- old/make/common/NativeCompilation.gmk 2015-10-15 12:35:11.150640650 -0400 +++ new/make/common/NativeCompilation.gmk 2015-10-15 12:35:09.842567087 -0400 @@ -35,6 +35,31 @@ endif ################################################################################ +# Create exported symbols file for static libraries +################################################################################ + +# get the exported symbols from mapfiles and if there +# is no mapfile, get them from the archive +define GetSymbols + $(RM) $$(@D)/$$(basename $$(@F)).symbols; \ + if [ ! -z $$($1_MAPFILE) -a -e $$($1_MAPFILE) ]; then \ + $(ECHO) "Getting symbols from mapfile $$($1_MAPFILE)"; \ + $(AWK) '/global:/','/local:/' $$($1_MAPFILE) | \ + $(SED) -e 's/#.*//;s/global://;s/local://;s/\;//;s/^[ ]*/_/;/^_$$$$/d' | \ + $(EGREP) -v "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" > \ + $$(@D)/$$(basename $$(@F)).symbols || true; \ + $(NM) $$($1_TARGET) | $(GREP) " T " | \ + $(EGREP) "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" | \ + $(CUT) -d ' ' -f 3 >> $$(@D)/$$(basename $$(@F)).symbols || true;\ + else \ + $(ECHO) "Getting symbols from nm"; \ + $(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ + $(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \ + $(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \ + fi +endef + +################################################################################ # Define a native toolchain configuration that can be used by # SetupNativeCompilation calls # @@ -275,6 +300,15 @@ SetupNativeCompilation = $(NamedParamsMacroTemplate) define SetupNativeCompilationBody + # If we're doing a static build and producing a library + # force it to be a static library and remove the -l libraries + ifeq ($(BUILD_STATIC), true) + ifneq ($$($1_LIBRARY),) + $1_STATIC_LIBRARY := $$($1_LIBRARY) + $1_LIBRARY := + endif + endif + ifneq (,$$($1_BIN)) $$(error BIN has been replaced with OBJECT_DIR) endif @@ -496,6 +530,12 @@ $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) endif + # Pass the library name for static JNI library naming + ifneq ($$($1_STATIC_LIBRARY),) + $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY) + $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY) + endif + # Pick up disabled warnings, if possible on this platform. ifneq ($(DISABLE_WARNING_PREFIX),) $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE))) @@ -726,7 +766,10 @@ $(ECHO) $(LOG_INFO) "Archiving $$($1_STATIC_LIBRARY)" $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ - $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)) + $$($1_RES)) + ifeq ($(BUILD_STATIC), true) + $(GetSymbols) + endif endif ifneq (,$$($1_PROGRAM))