ohair@425: # kevinw@2206: # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. ohair@425: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@425: # ohair@425: # This code is free software; you can redistribute it and/or modify it ohair@425: # under the terms of the GNU General Public License version 2 only, as ohair@425: # published by the Free Software Foundation. Oracle designates this ohair@425: # particular file as subject to the "Classpath" exception as provided ohair@425: # by Oracle in the LICENSE file that accompanied this code. ohair@425: # ohair@425: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@425: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@425: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@425: # version 2 for more details (a copy is included in the LICENSE file that ohair@425: # accompanied this code). ohair@425: # ohair@425: # You should have received a copy of the GNU General Public License version ohair@425: # 2 along with this work; if not, write to the Free Software Foundation, ohair@425: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@425: # ohair@425: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@425: # or visit www.oracle.com if you need additional information or have any ohair@425: # questions. ohair@425: # ohair@425: ohair@425: # When you read this source. Remember that $(sort ...) has the side effect ohair@425: # of removing duplicates. It is actually this side effect that is ohair@425: # desired whenever sort is used below! ohair@425: ihse@839: ifeq (,$(_MAKEBASE_GMK)) ihse@839: $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk) ohair@425: endif ohair@425: kevinw@2206: ifneq ($(TOOLCHAIN_TYPE), microsoft) ihse@839: COMPILING_MSG=echo $(LOG_INFO) "Compiling $(notdir $1) (for $(notdir $2))" ihse@839: LINKING_MSG=echo $(LOG_INFO) "Linking $1" ihse@839: LINKING_EXE_MSG=echo $(LOG_INFO) "Linking executable $1" ihse@839: ARCHIVING_MSG=echo $(LOG_INFO) "Archiving $1" ohair@425: else ihse@839: COMPILING_MSG= ihse@839: LINKING_MSG= ihse@839: LINKING_EXE_MSG= ihse@839: ARCHIVING_MSG= ohair@425: endif ohair@425: kevinw@2219: ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) kevinw@2219: UNIX_PATH_PREFIX := /cygdrive kevinw@2219: else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) kevinw@2219: UNIX_PATH_PREFIX := kevinw@2219: endif kevinw@2219: ohair@425: define add_native_source ihse@839: # param 1 = BUILD_MYPACKAGE ihse@839: # parma 2 = the source file name (..../alfa.c or .../beta.cpp) ihse@839: # param 3 = the bin dir that stores all .o (.obj) and .d files. ihse@839: # param 4 = the c flags to the compiler ihse@839: # param 5 = the c compiler ihse@839: # param 6 = the c++ flags to the compiler ihse@839: # param 7 = the c++ compiler ihse@839: # param 8 = the flags to the assembler ohair@425: ihse@839: ifneq (,$$(filter %.c,$2)) ihse@839: # Compile as a C file ihse@839: $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$( $$($1_$2_DEP) erikj@699: else ihse@839: $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 ihse@839: endif erikj@699: endif erikj@699: # The Visual Studio compiler lacks a feature for generating make dependencies, but by ihse@839: # setting -showIncludes, all included files are printed. These are filtered out and erikj@699: # parsed into make dependences. kevinw@2206: ifeq ($(TOOLCHAIN_TYPE), microsoft) ihse@839: ($$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ ihse@839: $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 ; echo $$$$? > $$($1_$2_DEP).exitvalue) \ ihse@839: | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v "^Note: including file:" \ ihse@839: && exit `cat $$($1_$2_DEP).exitvalue` ihse@839: $(RM) $$($1_$2_DEP).exitvalue ihse@839: ($(ECHO) $$@: \\ \ ihse@839: && $(SED) -e '/^Note: including file:/!d' \ ihse@839: -e 's|Note: including file: *||' \ kevinw@2217: -e 's|\r||g' \ ihse@839: -e 's|\\|/|g' \ kevinw@2219: -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \ ihse@839: -e '/$(subst /,\/,$(TOPDIR))/!d' \ ihse@839: -e 's|$$$$| \\|g' \ ihse@839: $$($1_$2_DEP).raw) > $$($1_$2_DEP) ohair@425: endif ihse@839: endif ohair@425: endef ohair@425: ohair@425: define SetupNativeCompilation ihse@839: # param 1 is for example BUILD_MYPACKAGE ihse@839: # param 2,3,4,5,6,7,8 are named args. ihse@839: # SRC one or more directory roots to scan for C/C++ files. ihse@839: # LANG C or C++ ihse@839: # CFLAGS the compiler flags to be used, used both for C and C++. ihse@839: # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS. ihse@839: # LDFLAGS the linker flags to be used, used both for C and C++. ihse@839: # LDFLAGS_SUFFIX the linker flags to be added last on the commandline ihse@839: # typically the libraries linked to. ihse@839: # ARFLAGS the archiver flags to be used ihse@839: # OBJECT_DIR the directory where we store the object files ihse@839: # LIBRARY the resulting library file ihse@839: # PROGRAM the resulting exec file ihse@839: # INCLUDES only pick source from these directories ihse@839: # EXCLUDES do not pick source from these directories ihse@839: # INCLUDE_FILES only compile exactly these files! ihse@839: # EXCLUDE_FILES with these names ihse@839: # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run ihse@839: # RC_FLAGS flags for RC. ihse@839: # MAPFILE mapfile ihse@839: # REORDER reorder file ihse@839: # DEBUG_SYMBOLS add debug symbols (if configured on) ihse@839: # CC the compiler to use, default is $(CC) ihse@839: # LDEXE the linker to use for linking executables, default is $(LDEXE) ihse@839: # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST ihse@839: $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) ihse@839: $(call LogSetupMacroEntry,SetupNativeCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26)) ihse@839: $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) erikj@458: ihse@839: ifneq (,$$($1_BIN)) ihse@839: $$(error BIN has been replaced with OBJECT_DIR) ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_LIB)) ihse@839: $$(error LIB has been replaced with LIBRARY) ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_EXE)) ihse@839: $$(error EXE has been replaced with PROGRAM) ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_LIBRARY)) ihse@839: ifeq (,$$($1_OUTPUT_DIR)) ihse@839: $$(error LIBRARY requires OUTPUT_DIR) erikj@458: endif erikj@458: ihse@839: ifneq ($$($1_LIBRARY),$(basename $$($1_LIBRARY))) ihse@839: $$(error directory of LIBRARY should be specified using OUTPUT_DIR) erikj@458: endif erikj@458: ihse@839: ifneq (,$(findstring $(SHARED_LIBRARY_SUFFIX),$$($1_LIBRARY))) ihse@839: $$(error LIBRARY should be specified without SHARED_LIBRARY_SUFFIX: $(SHARED_LIBRARY_SUFFIX)) erikj@458: endif erikj@458: ihse@839: ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_LIBRARY))) ihse@839: $$(error LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) erikj@458: endif erikj@458: ihse@839: $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_LIBRARY)$(SHARED_LIBRARY_SUFFIX) ihse@839: $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) erikj@458: ihse@839: endif erikj@458: ihse@839: ifneq (,$$($1_STATIC_LIBRARY)) ihse@839: ifeq (,$$($1_OUTPUT_DIR)) ihse@839: $$(error STATIC_LIBRARY requires OUTPUT_DIR) erikj@458: endif erikj@458: ihse@839: ifneq ($$($1_STATIC_LIBRARY),$(basename $$($1_STATIC_LIBRARY))) ihse@839: $$(error directory of STATIC_LIBRARY should be specified using OUTPUT_DIR) erikj@458: endif erikj@458: ihse@839: ifneq (,$(findstring $(STATIC_LIBRARY_SUFFIX),$$($1_STATIC_LIBRARY))) ihse@839: $$(error STATIC_LIBRARY should be specified without STATIC_LIBRARY_SUFFIX: $(STATIC_LIBRARY_SUFFIX)) erikj@458: endif ohair@425: ihse@839: ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_STATIC_LIBRARY))) ihse@839: $$(error STATIC_LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) ohair@425: endif ohair@425: ihse@839: $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)$(STATIC_LIBRARY_SUFFIX) ihse@839: $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_PROGRAM)) ihse@839: ifeq (,$$($1_OUTPUT_DIR)) ihse@839: $$(error PROGRAM requires OUTPUT_DIR) erikj@458: endif erikj@458: ihse@839: ifneq ($$($1_PROGRAM),$(basename $$($1_PROGRAM))) ihse@839: $$(error directory of PROGRAM should be specified using OUTPUT_DIR) ohair@425: endif ohair@425: ihse@839: ifneq (,$(findstring $(EXE_SUFFIX),$$($1_PROGRAM))) ihse@839: $$(error PROGRAM should be specified without EXE_SUFFIX: $(EXE_SUFFIX)) ohair@494: endif ohair@425: ihse@839: $1_BASENAME:=$$($1_PROGRAM)$(EXE_SUFFIX) ihse@839: $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) ihse@839: ihse@839: endif ihse@839: ihse@839: ifeq (,$$($1_TARGET)) ihse@839: $$(error Neither PROGRAM, LIBRARY nor STATIC_LIBRARY has been specified for SetupNativeCompilation) ihse@839: endif ihse@839: ihse@839: ifeq (,$$($1_LANG)) ihse@839: $$(error You have to specify LANG for native compilation $1) ihse@839: endif ihse@839: ifeq (C,$$($1_LANG)) ihse@839: ifeq ($$($1_LDEXE),) ihse@839: $1_LDEXE:=$(LDEXE) ihse@839: endif ihse@839: $1_LD:=$(LD) ihse@839: else ihse@839: ifeq (C++,$$($1_LANG)) ihse@839: $1_LD:=$(LDCXX) ihse@839: $1_LDEXE:=$(LDEXECXX) ohair@425: else ihse@839: $$(error Unknown native language $$($1_LANG) for $1) ohair@425: endif ihse@839: endif ohair@425: ihse@839: ifeq ($$($1_CC),) ihse@839: $1_CC:=$(CC) ihse@839: endif ihse@839: sgehwolf@2236: ifeq ($$($1_STRIP_POLICY),) sgehwolf@2236: $1_STRIP_POLICY:=$$(STRIP_POLICY) sgehwolf@2236: endif sgehwolf@2236: ihse@839: # Make sure the dirs exist. ihse@839: $$(eval $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))) ihse@839: $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d))) ihse@839: ihse@839: # Find all files in the source trees. Sort to remove duplicates. ihse@839: $1_ALL_SRCS := $$(sort $$(call CacheFind,$$($1_SRC))) ihse@839: # Extract the C/C++ files. ihse@839: $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_EXCLUDE_FILES))) ihse@839: $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) ihse@839: ifneq ($$($1_EXCLUDE_FILES),) ihse@839: $1_EXCLUDE_FILES:=$$(addprefix %,$$($1_EXCLUDE_FILES)) ihse@839: endif ihse@839: $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter %.s %.c %.cpp %.m,$$($1_ALL_SRCS))) ihse@839: ifneq (,$$(strip $$($1_INCLUDE_FILES))) ihse@839: $1_SRCS := $$(filter $$($1_INCLUDE_FILES),$$($1_SRCS)) ihse@839: endif ihse@839: ifeq (,$$($1_SRCS)) ihse@839: $$(error No sources found for $1 when looking inside the dirs $$($1_SRC)) ihse@839: endif ihse@839: # There can be only a single bin dir root, no need to foreach over the roots. ihse@839: $1_BINS := $$(wildcard $$($1_OBJECT_DIR)/*$(OBJ_SUFFIX)) ihse@839: # Now we have a list of all c/c++ files to compile: $$($1_SRCS) ihse@839: # and we have a list of all existing object files: $$($1_BINS) ihse@839: ihse@839: # Prepend the source/bin path to the filter expressions. Then do the filtering. ihse@839: ifneq ($$($1_INCLUDES),) ihse@839: $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) ihse@839: $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS)) ihse@839: endif ihse@839: ifneq ($$($1_EXCLUDES),) ihse@839: $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) ihse@839: $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) ihse@839: endif ihse@839: ihse@839: # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides ihse@839: # a reproducable order on the input files to the linker). ihse@839: $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_OBJECT_DIR)/,$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(patsubst %.s,%$(OBJ_SUFFIX),$$(notdir $$($1_SRCS)))))))) ihse@839: # Are there too many object files on disk? Perhaps because some source file was removed? ihse@839: $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) ihse@839: # Clean out the superfluous object files. ihse@839: ifneq ($$($1_SUPERFLUOUS_OBJS),) ihse@839: $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) ihse@839: endif ihse@839: gromero@1879: # Pickup extra OPENJDK_TARGET_OS_API, OPENJDK_TARGET_OS, and/or OPENJDK_TARGET_OS plus gromero@1879: # OPENJDK_TARGET_CPU pair dependent variables for CFLAGS. gromero@1879: $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) \ gromero@1879: $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)) ihse@839: ifneq ($(DEBUG_LEVEL),release) ihse@839: # Pickup extra debug dependent variables for CFLAGS ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_debug) ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) gromero@1879: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_debug) ihse@839: else ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_release) ihse@839: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) gromero@1879: $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_release) ihse@839: endif ihse@839: ihse@839: # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. ihse@839: $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) ihse@839: ifneq ($(DEBUG_LEVEL),release) ihse@839: # Pickup extra debug dependent variables for CXXFLAGS ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_debug) ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug) ihse@839: else ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_release) ihse@839: $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) ihse@839: endif ihse@839: omajid@1409: ifeq ($$($1_CXXFLAGS),) omajid@1409: $1_CXXFLAGS:=$$($1_CFLAGS) omajid@1409: endif omajid@1409: ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),) omajid@1409: $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS) omajid@1409: endif omajid@1409: ihse@839: ifneq (,$$($1_DEBUG_SYMBOLS)) ihse@839: ifeq ($(ENABLE_DEBUG_SYMBOLS), true) ihse@839: ifdef OPENJDK ihse@839: # Always add debug symbols ihse@839: $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) ihse@839: $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) ihse@839: else ihse@839: # Programs don't get the debug symbols added in the old build. It's not clear if ihse@839: # this is intentional. ihse@839: ifeq ($$($1_PROGRAM),) ihse@839: $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) ihse@839: $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) ihse@839: endif ihse@839: endif ohair@425: endif ihse@839: endif ohair@425: ihse@839: ifneq (,$$($1_REORDER)) ihse@839: $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) ihse@839: $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) ihse@839: endif ihse@839: ihse@839: ifeq (NONE, $$($1_OPTIMIZATION)) ihse@839: $1_EXTRA_CFLAGS += $(C_O_FLAG_NONE) ihse@839: $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NONE) ihse@839: else ifeq (LOW, $$($1_OPTIMIZATION)) ihse@839: $1_EXTRA_CFLAGS += $(C_O_FLAG_NORM) ihse@839: $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NORM) ihse@839: else ifeq (HIGH, $$($1_OPTIMIZATION)) ihse@839: $1_EXTRA_CFLAGS += $(C_O_FLAG_HI) ihse@839: $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HI) ihse@839: else ifeq (HIGHEST, $$($1_OPTIMIZATION)) ihse@839: $1_EXTRA_CFLAGS += $(C_O_FLAG_HIGHEST) ihse@839: $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST) ihse@839: else ifneq (, $$($1_OPTIMIZATION)) ihse@839: $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) ihse@839: endif ihse@839: kevinw@2215: # Add sys root specific cflags last kevinw@2215: $1_EXTRA_CFLAGS += $(SYSROOT_CFLAGS) kevinw@2215: $1_EXTRA_CXXFLAGS += $(SYSROOT_CFLAGS) kevinw@2215: ihse@839: # Now call add_native_source for each source file we are going to compile. ihse@839: $$(foreach p,$$($1_SRCS), \ ihse@839: $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \ ihse@839: $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC), \ ihse@839: $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS)))) ihse@839: ihse@839: # On windows we need to create a resource file ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: ifneq (,$$($1_VERSIONINFO_RESOURCE)) ihse@839: $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res ihse@839: $$($1_RES): $$($1_VERSIONINFO_RESOURCE) ihse@839: $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) ohair@478: endif ihse@839: ifneq (,$$($1_MANIFEST)) ihse@839: $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest ihse@839: IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) ihse@839: $$($1_GEN_MANIFEST): $$($1_MANIFEST) ihse@839: $(SED) 's%IMVERSION%$$(IMVERSIONVALUE)%g;s%PROGRAM%$$($1_PROGRAM)%g' $$< > $$@ ihse@839: endif ihse@839: endif ohair@478: ihse@839: # mapfile doesnt seem to be implemented on macosx (yet??) ihse@839: ifneq ($(OPENJDK_TARGET_OS),macosx) ihse@839: ifneq ($(OPENJDK_TARGET_OS),windows) ihse@839: $1_REAL_MAPFILE:=$$($1_MAPFILE) ihse@839: ifneq (,$$($1_REORDER)) ihse@839: $1_REAL_MAPFILE:=$$($1_OBJECT_DIR)/mapfile ohair@425: ihse@839: $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) erikj@445: $$(MKDIR) -p $$(@D) erikj@445: $$(CP) $$($1_MAPFILE) $$@.tmp erikj@458: $$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp erikj@445: $$(MV) $$@.tmp $$@ ihse@839: endif erikj@445: endif ihse@839: endif ihse@839: ihse@839: # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables ihse@839: # for LDFLAGS and LDFLAGS_SUFFIX ihse@839: $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) ihse@839: $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) ihse@839: ifneq (,$$($1_REAL_MAPFILE)) ihse@839: $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) ihse@839: endif ihse@839: kevinw@2215: $1_EXTRA_LDFLAGS += $(SYSROOT_LDFLAGS) kevinw@2215: ihse@839: $1 := $$($1_TARGET) ihse@839: ifneq (,$$($1_LIBRARY)) ihse@839: # Generating a dynamic library. ihse@839: $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $1_EXTRA_LDFLAGS+="-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib" ohair@425: endif erikj@445: ihse@839: $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) erikj@458: ihse@839: ifneq (,$$($1_DEBUG_SYMBOLS)) ihse@839: ifeq ($(ENABLE_DEBUG_SYMBOLS), true) erikj@458: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_LIBRARY).pdb" \ ihse@839: "-map:$$($1_OBJECT_DIR)/$$($1_LIBRARY).map" erikj@458: endif erikj@458: ihse@839: ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) ihse@839: $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% ihse@839: $(CP) $$< $$@ ihse@839: endif erikj@458: dcubed@874: ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X dcubed@874: ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows dcubed@874: ifeq ($(OPENJDK_TARGET_OS), solaris) sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. sgehwolf@2236: # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from sgehwolf@2236: # empty section headers until a fixed $(OBJCOPY) is available. sgehwolf@2236: # An empty section header has sh_addr == 0 and sh_size == 0. sgehwolf@2236: # This problem has only been seen on Solaris X64, but we call this tool sgehwolf@2236: # on all Solaris builds just in case. sgehwolf@2236: # sgehwolf@2236: # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. sgehwolf@2236: # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. sgehwolf@2236: $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ dcubed@874: $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) dcubed@874: $(RM) $$@ dcubed@874: $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< dcubed@874: $(OBJCOPY) --only-keep-debug $$< $$@ dcubed@874: $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< sgehwolf@2236: endif dcubed@874: else # not solaris sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) dcubed@874: $(RM) $$@ dcubed@874: $(OBJCOPY) --only-keep-debug $$< $$@ dcubed@874: $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< sgehwolf@2236: endif dcubed@874: endif # Touch to not retrigger rule on rebuild sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) ihse@839: $(TOUCH) $$@ sgehwolf@2236: endif dcubed@874: endif # !windows dcubed@874: endif # !macosx erikj@458: ihse@839: ifeq ($(ZIP_DEBUGINFO_FILES), true) dcubed@874: ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet andrew@2403: ifneq ($$($1_STRIP_POLICY), no_strip) ihse@839: $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz erikj@458: ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz : $$($1_TARGET) ihse@839: $(CD) $$($1_OBJECT_DIR) \ ihse@839: && $(ZIP) -q $$@ $$($1_LIBRARY).map $$($1_LIBRARY).pdb ihse@839: else ihse@839: $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz : $$($1_TARGET) \ ihse@839: $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo ihse@839: $(CD) $$($1_OBJECT_DIR) \ ihse@839: && $(ZIP) -q $$@ $$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo ihse@839: endif andrew@2403: endif # not possible when stripping is disabled dcubed@874: endif # no MacOS X support yet ihse@839: else ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \ ihse@839: $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb dcubed@874: else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo sgehwolf@2236: endif ihse@839: endif ihse@839: endif ihse@839: endif erikj@738: endif erikj@738: ihse@839: $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) ihse@839: $$(call LINKING_MSG,$$($1_BASENAME)) ihse@839: $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \ ihse@839: $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ ihse@839: $$($1_EXTRA_LDFLAGS_SUFFIX) ihse@839: ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_STATIC_LIBRARY)) ihse@839: # Generating a static library, ie object file archive. ihse@839: $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) ihse@839: $$(call ARCHIVING_MSG,$$($1_LIBRARY)) kvn@972: $(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ ihse@839: $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) ihse@839: endif ihse@839: ihse@839: ifneq (,$$($1_PROGRAM)) ihse@839: # A executable binary has been specified, setup the target for it. ihse@839: ifneq (,$$($1_DEBUG_SYMBOLS)) ihse@839: ifeq ($(ENABLE_DEBUG_SYMBOLS), true) erikj@738: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_PROGRAM).pdb" \ ihse@839: "-map:$$($1_OBJECT_DIR)/$$($1_PROGRAM).map" erikj@458: endif erikj@458: ihse@839: ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) ihse@839: $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% ihse@839: $(CP) $$< $$@ erikj@738: endif erikj@458: dcubed@874: ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X dcubed@874: ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows dcubed@874: ifeq ($(OPENJDK_TARGET_OS), solaris) sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. sgehwolf@2236: # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from sgehwolf@2236: # empty section headers until a fixed $(OBJCOPY) is available. sgehwolf@2236: # An empty section header has sh_addr == 0 and sh_size == 0. sgehwolf@2236: # This problem has only been seen on Solaris X64, but we call this tool sgehwolf@2236: # on all Solaris builds just in case. sgehwolf@2236: # sgehwolf@2236: # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. sgehwolf@2236: # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. sgehwolf@2236: $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ dcubed@874: $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) dcubed@874: $(RM) $$@ dcubed@874: $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< dcubed@874: $(OBJCOPY) --only-keep-debug $$< $$@ dcubed@874: $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< sgehwolf@2236: endif dcubed@874: else # not solaris sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) dcubed@874: $(RM) $$@ dcubed@874: $(OBJCOPY) --only-keep-debug $$< $$@ dcubed@874: $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< sgehwolf@2236: endif dcubed@874: endif sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) dcubed@874: $(TOUCH) $$@ sgehwolf@2236: endif dcubed@874: endif # !windows dcubed@874: endif # !macosx erikj@458: ihse@839: ifeq ($(ZIP_DEBUGINFO_FILES), true) dcubed@874: ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet andrew@2403: ifneq ($$($1_STRIP_POLICY), no_strip) ihse@839: $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).diz erikj@458: ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $$($1_OBJECT_DIR)/$$($1_PROGRAM).diz : $$($1_TARGET) ihse@839: $(CD) $$($1_OBJECT_DIR) \ ihse@839: && $(ZIP) -q $$@ $$($1_PROGRAM).map $$($1_PROGRAM).pdb ihse@839: else ihse@839: $$($1_OBJECT_DIR)/$$(PROGRAM_PREFIX)$$($1_PROGRAM).diz : $$($1_TARGET) \ ihse@839: $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo ihse@839: $(CD) $$($1_OBJECT_DIR) \ ihse@839: && $(ZIP) -q $$@ $$($1_PROGRAM).debuginfo ihse@839: endif andrew@2403: endif dcubed@874: endif # no MacOS X support yet ihse@839: else ihse@839: ifeq ($(OPENJDK_TARGET_OS), windows) ihse@839: $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \ ihse@839: $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb dcubed@874: else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files sgehwolf@2236: ifneq ($$($1_STRIP_POLICY), no_strip) sgehwolf@2236: $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo sgehwolf@2236: endif ihse@839: endif erikj@458: endif ihse@839: endif erikj@738: endif erikj@458: ihse@839: $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX) aharlap@703: ihse@839: $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) ihse@839: $$(call LINKING_EXE_MSG,$$($1_BASENAME)) ihse@839: $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \ ihse@839: $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ ihse@839: $$($1_EXTRA_LDFLAGS_SUFFIX) erikj@445: ifneq (,$$($1_GEN_MANIFEST)) ihse@839: $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1 erikj@445: endif erikj@725: # This only works if the openjdk_codesign identity is present on the system. Let erikj@725: # silently fail otherwise. erikj@725: ifneq (,$(CODESIGN)) ihse@839: ifneq (,$$($1_CODESIGN)) ihse@839: $(CODESIGN) -s openjdk_codesign $$@ ihse@839: endif erikj@725: endif ihse@839: endif ohair@425: endef