31 _NATIVE_COMPILATION_GMK := 1 |
31 _NATIVE_COMPILATION_GMK := 1 |
32 |
32 |
33 ifeq (,$(_MAKEBASE_GMK)) |
33 ifeq (,$(_MAKEBASE_GMK)) |
34 $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk) |
34 $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk) |
35 endif |
35 endif |
|
36 |
|
37 ################################################################################ |
|
38 # Create exported symbols file for static libraries |
|
39 ################################################################################ |
|
40 |
|
41 # get the exported symbols from mapfiles and if there |
|
42 # is no mapfile, get them from the archive |
|
43 define GetSymbols |
|
44 $(RM) $$(@D)/$$(basename $$(@F)).symbols; \ |
|
45 if [ ! -z $$($1_MAPFILE) -a -e $$($1_MAPFILE) ]; then \ |
|
46 $(ECHO) "Getting symbols from mapfile $$($1_MAPFILE)"; \ |
|
47 $(AWK) '/global:/','/local:/' $$($1_MAPFILE) | \ |
|
48 $(SED) -e 's/#.*//;s/global://;s/local://;s/\;//;s/^[ ]*/_/;/^_$$$$/d' | \ |
|
49 $(EGREP) -v "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" > \ |
|
50 $$(@D)/$$(basename $$(@F)).symbols || true; \ |
|
51 $(NM) $$($1_TARGET) | $(GREP) " T " | \ |
|
52 $(EGREP) "JNI_OnLoad|JNI_OnUnload|Agent_OnLoad|Agent_OnUnload|Agent_OnAttach" | \ |
|
53 $(CUT) -d ' ' -f 3 >> $$(@D)/$$(basename $$(@F)).symbols || true;\ |
|
54 else \ |
|
55 $(ECHO) "Getting symbols from nm"; \ |
|
56 $(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ |
|
57 $(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \ |
|
58 $(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \ |
|
59 fi |
|
60 endef |
36 |
61 |
37 ################################################################################ |
62 ################################################################################ |
38 # Define a native toolchain configuration that can be used by |
63 # Define a native toolchain configuration that can be used by |
39 # SetupNativeCompilation calls |
64 # SetupNativeCompilation calls |
40 # |
65 # |
273 # STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it |
298 # STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it |
274 # STRIPFLAGS Optionally change the flags given to the strip command |
299 # STRIPFLAGS Optionally change the flags given to the strip command |
275 SetupNativeCompilation = $(NamedParamsMacroTemplate) |
300 SetupNativeCompilation = $(NamedParamsMacroTemplate) |
276 define SetupNativeCompilationBody |
301 define SetupNativeCompilationBody |
277 |
302 |
|
303 # If we're doing a static build and producing a library |
|
304 # force it to be a static library and remove the -l libraries |
|
305 ifeq ($(STATIC_BUILD), true) |
|
306 ifneq ($$($1_LIBRARY),) |
|
307 $1_STATIC_LIBRARY := $$($1_LIBRARY) |
|
308 $1_LIBRARY := |
|
309 endif |
|
310 endif |
|
311 |
278 ifneq (,$$($1_BIN)) |
312 ifneq (,$$($1_BIN)) |
279 $$(error BIN has been replaced with OBJECT_DIR) |
313 $$(error BIN has been replaced with OBJECT_DIR) |
280 endif |
314 endif |
281 |
315 |
282 ifneq (,$$($1_LIB)) |
316 ifneq (,$$($1_LIB)) |
492 endif |
526 endif |
493 |
527 |
494 ifneq (,$$($1_REORDER)) |
528 ifneq (,$$($1_REORDER)) |
495 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
529 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
496 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
530 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
|
531 endif |
|
532 |
|
533 # Pass the library name for static JNI library naming |
|
534 ifneq ($$($1_STATIC_LIBRARY),) |
|
535 $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY) |
|
536 $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_STATIC_LIBRARY) |
497 endif |
537 endif |
498 |
538 |
499 # Pick up disabled warnings, if possible on this platform. |
539 # Pick up disabled warnings, if possible on this platform. |
500 ifneq ($(DISABLE_WARNING_PREFIX),) |
540 ifneq ($(DISABLE_WARNING_PREFIX),) |
501 $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE))) |
541 $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE))) |
724 # Generating a static library, ie object file archive. |
764 # Generating a static library, ie object file archive. |
725 $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) |
765 $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) |
726 $(ECHO) $(LOG_INFO) "Archiving $$($1_STATIC_LIBRARY)" |
766 $(ECHO) $(LOG_INFO) "Archiving $$($1_STATIC_LIBRARY)" |
727 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ |
767 $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \ |
728 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ |
768 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ |
729 $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)) |
769 $$($1_RES)) |
|
770 ifeq ($(STATIC_BUILD), true) |
|
771 $(GetSymbols) |
|
772 endif |
730 endif |
773 endif |
731 |
774 |
732 ifneq (,$$($1_PROGRAM)) |
775 ifneq (,$$($1_PROGRAM)) |
733 # A executable binary has been specified, setup the target for it. |
776 # A executable binary has been specified, setup the target for it. |
734 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) |
777 $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) |