< prev index next >

make/common/NativeCompilation.gmk

Print this page




 329           $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
 330         endif
 331   endif
 332 endef
 333 
 334 # Setup make rules for creating a native binary (a shared library or an
 335 # executable).
 336 #
 337 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 338 # and the targets generated are listed in a variable by that name.
 339 #
 340 # Remaining parameters are named arguments. These include:
 341 #   TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
 342 #   SRC one or more directory roots to scan for C/C++ files.
 343 #   CFLAGS the compiler flags to be used, used both for C and C++.
 344 #   CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.
 345 #   LDFLAGS the linker flags to be used, used both for C and C++.
 346 #   LIBS the libraries to link to
 347 #   ARFLAGS the archiver flags to be used
 348 #   OBJECT_DIR the directory where we store the object files

 349 #   LIBRARY the resulting library file
 350 #   PROGRAM the resulting exec file
 351 #   INCLUDES only pick source from these directories
 352 #   EXCLUDES do not pick source from these directories
 353 #   INCLUDE_FILES only compile exactly these files!
 354 #   EXCLUDE_FILES with these names
 355 #   EXCLUDE_PATTERN exclude files matching any of these substrings
 356 #   EXTRA_FILES List of extra files not in any of the SRC dirs
 357 #   EXTRA_OBJECT_FILES List of extra object files to include when linking
 358 #   VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
 359 #   RC_FLAGS flags for RC.
 360 #   EMBED_MANIFEST if true, embed manifest on Windows.
 361 #   MAPFILE mapfile
 362 #   REORDER reorder file
 363 #   USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
 364 #       mapfile for the output symbols file
 365 #   CC the compiler to use, default is $(CC)
 366 #   LD the linker to use, default is $(LD)
 367 #   OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
 368 #   DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain


 812   $1_EXTRA_LIBS:=$$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
 813   ifneq (,$$($1_REAL_MAPFILE))
 814     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
 815   endif
 816 
 817   # Need to make sure TARGET is first on list
 818   $1 := $$($1_TARGET)
 819 
 820   ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
 821     $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
 822   endif
 823 
 824   ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
 825     $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
 826   endif
 827 
 828   ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
 829     ifneq ($$($1_DEBUG_SYMBOLS), false)
 830       # Only copy debug symbols for dynamic libraries and programs.
 831       ifeq ($$($1_STATIC_LIBRARY), )
 832         ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
 833           # The dependency on TARGET is needed on windows for debuginfo files
 834           # to be rebuilt properly.
 835           $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
 836                 # Use cp -r since on macosx, the dSYM is a directory
 837                 $(CP) -r $$< $$@
 838         endif
 839 
 840         # Generate debuginfo files.
 841         ifeq ($(OPENJDK_TARGET_OS), windows)
 842           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
 843               "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
 844           $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
 845               $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
 846           # No separate command is needed for debuginfo on windows, instead
 847           # touch target to make sure it has a later time stamp than the debug
 848           # symbol files to avoid unnecessary relinking on rebuild.
 849           $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
 850 
 851         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
 852           $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
 853           # Setup the command line creating debuginfo files, to be run after linking.
 854           # It cannot be run separately since it updates the original target file
 855           $1_CREATE_DEBUGINFO_CMDS := \
 856             $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
 857             $(CD) $$($1_OUTPUT_DIR) && \
 858                 $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 859 
 860         else ifeq ($(OPENJDK_TARGET_OS), macosx)
 861           $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM


 862           # On Macosx, the debuginfo generation doesn't touch the linked binary, but
 863           # to avoid always relinking, touch it anyway to force a later timestamp than
 864           # the dSYM files.
 865           $1_CREATE_DEBUGINFO_CMDS := \
 866               $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
 867               $(TOUCH) $$($1_TARGET)
 868         endif # OPENJDK_TARGET_OS
 869 
 870         # This dependency dance ensures that debug info files get rebuilt
 871         # properly if deleted.
 872         $$($1_TARGET): $$($1_DEBUGINFO_FILES)
 873         $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
 874 
 875         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
 876           $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
 877           $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
 878 
 879           # The dependency on TARGET is needed for debuginfo files
 880           # to be rebuilt properly.
 881           $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
 882                 $(CD) $$($1_OBJECT_DIR) \
 883                 && $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
 884 
 885         else
 886           $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
 887         endif
 888       endif # !STATIC_LIBRARY
 889     endif # $1_DEBUG_SYMBOLS != false
 890   endif # COPY_DEBUG_SYMBOLS
 891 
 892   ifeq ($$($1_STRIP_SYMBOLS), true)
 893     ifneq ($$($1_STRIP), )
 894       # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
 895       $1_STRIPFLAGS ?= $(STRIPFLAGS)
 896       $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
 897     endif
 898   endif
 899 
 900   ifneq (,$$($1_LIBRARY))
 901     # Generating a dynamic library.
 902     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
 903     ifeq ($(OPENJDK_TARGET_OS), windows)
 904       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"


 905     endif
 906 
 907     # Create loadmap on AIX. Helps in diagnosing some problems.
 908     ifneq ($(COMPILER_BINDCMD_FILE_FLAG),)
 909       $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
 910     endif
 911 
 912     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
 913         $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
 914         $$($1_STRIP_CMD)
 915     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
 916         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
 917 
 918     $1_LD_OBJ_ARG := $$($1_ALL_OBJS)
 919 
 920     # If there are many object files, use an @-file...
 921     ifneq ($$(word 17, $$($1_ALL_OBJS)), )
 922       $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt
 923       ifneq ($(COMPILER_COMMAND_FILE_FLAG),)
 924         $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST)




 329           $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
 330         endif
 331   endif
 332 endef
 333 
 334 # Setup make rules for creating a native binary (a shared library or an
 335 # executable).
 336 #
 337 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 338 # and the targets generated are listed in a variable by that name.
 339 #
 340 # Remaining parameters are named arguments. These include:
 341 #   TOOLCHAIN Name of toolchain setup to use. Defaults to TOOLCHAIN_DEFAULT.
 342 #   SRC one or more directory roots to scan for C/C++ files.
 343 #   CFLAGS the compiler flags to be used, used both for C and C++.
 344 #   CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS.
 345 #   LDFLAGS the linker flags to be used, used both for C and C++.
 346 #   LIBS the libraries to link to
 347 #   ARFLAGS the archiver flags to be used
 348 #   OBJECT_DIR the directory where we store the object files
 349 #   OUTPUT_DIR the directory where the resulting binary is put
 350 #   LIBRARY the resulting library file
 351 #   PROGRAM the resulting exec file
 352 #   INCLUDES only pick source from these directories
 353 #   EXCLUDES do not pick source from these directories
 354 #   INCLUDE_FILES only compile exactly these files!
 355 #   EXCLUDE_FILES with these names
 356 #   EXCLUDE_PATTERN exclude files matching any of these substrings
 357 #   EXTRA_FILES List of extra files not in any of the SRC dirs
 358 #   EXTRA_OBJECT_FILES List of extra object files to include when linking
 359 #   VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
 360 #   RC_FLAGS flags for RC.
 361 #   EMBED_MANIFEST if true, embed manifest on Windows.
 362 #   MAPFILE mapfile
 363 #   REORDER reorder file
 364 #   USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
 365 #       mapfile for the output symbols file
 366 #   CC the compiler to use, default is $(CC)
 367 #   LD the linker to use, default is $(LD)
 368 #   OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST, HIGHEST_JVM, SIZE
 369 #   DISABLED_WARNINGS_<toolchain> Disable the given warnings for the specified toolchain


 813   $1_EXTRA_LIBS:=$$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
 814   ifneq (,$$($1_REAL_MAPFILE))
 815     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
 816   endif
 817 
 818   # Need to make sure TARGET is first on list
 819   $1 := $$($1_TARGET)
 820 
 821   ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
 822     $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
 823   endif
 824 
 825   ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
 826     $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
 827   endif
 828 
 829   ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
 830     ifneq ($$($1_DEBUG_SYMBOLS), false)
 831       # Only copy debug symbols for dynamic libraries and programs.
 832       ifeq ($$($1_STATIC_LIBRARY), )








 833         # Generate debuginfo files.
 834         ifeq ($(OPENJDK_TARGET_OS), windows)
 835           $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb" \
 836               "-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
 837           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
 838               $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map
 839           # No separate command is needed for debuginfo on windows, instead
 840           # touch target to make sure it has a later time stamp than the debug
 841           # symbol files to avoid unnecessary relinking on rebuild.
 842           $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
 843 
 844         else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
 845           $1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
 846           # Setup the command line creating debuginfo files, to be run after linking.
 847           # It cannot be run separately since it updates the original target file
 848           $1_CREATE_DEBUGINFO_CMDS := \
 849               $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
 850               $(CD) $$($1_OUTPUT_DIR) && \
 851                   $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 852 
 853         else ifeq ($(OPENJDK_TARGET_OS), macosx)
 854           $1_DEBUGINFO_FILES := \
 855               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
 856               $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
 857           # On Macosx, the debuginfo generation doesn't touch the linked binary, but
 858           # to avoid always relinking, touch it anyway to force a later timestamp than
 859           # the dSYM files.
 860           $1_CREATE_DEBUGINFO_CMDS := \
 861               $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
 862               $(TOUCH) $$($1_TARGET)
 863         endif # OPENJDK_TARGET_OS
 864 
 865         $$($1_DEBUGINFO_FILES): $$($1_TARGET)
 866 
 867         $1 += $$($1_DEBUGINFO_FILES)

 868 
 869         ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
 870           $1_DEBUGINFO_ZIP := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).diz
 871           $1 += $$($1_DEBUGINFO_ZIP)
 872 
 873           # The dependency on TARGET is needed for debuginfo files
 874           # to be rebuilt properly.
 875           $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
 876                 $(CD) $$($1_OUTPUT_DIR) && \
 877                     $(ZIP) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
 878 


 879         endif
 880        endif # !STATIC_LIBRARY
 881     endif # $1_DEBUG_SYMBOLS != false
 882   endif # COPY_DEBUG_SYMBOLS
 883 
 884   ifneq ($$($1_STRIP_SYMBOLS), false)
 885     ifneq ($$($1_STRIP), )
 886       # Default to using the global STRIPFLAGS. Allow for overriding with an empty value
 887       $1_STRIPFLAGS ?= $(STRIPFLAGS)
 888       $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET)
 889     endif
 890   endif
 891 
 892   ifneq (,$$($1_LIBRARY))
 893     # Generating a dynamic library.
 894     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
 895     ifeq ($(OPENJDK_TARGET_OS), windows)
 896       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
 897       # Create a rule for the import lib so that other rules may depend on it
 898       $$($1_OBJECT_DIR)/$$($1_LIBRARY).lib: $$($1_TARGET)
 899     endif
 900 
 901     # Create loadmap on AIX. Helps in diagnosing some problems.
 902     ifneq ($(COMPILER_BINDCMD_FILE_FLAG),)
 903       $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
 904     endif
 905 
 906     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
 907         $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
 908         $$($1_STRIP_CMD)
 909     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
 910         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
 911 
 912     $1_LD_OBJ_ARG := $$($1_ALL_OBJS)
 913 
 914     # If there are many object files, use an @-file...
 915     ifneq ($$(word 17, $$($1_ALL_OBJS)), )
 916       $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt
 917       ifneq ($(COMPILER_COMMAND_FILE_FLAG),)
 918         $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST)


< prev index next >