181 -e 's/^[ ]*//' \ |
181 -e 's/^[ ]*//' \ |
182 -e '/^$$$$/ d' \ |
182 -e '/^$$$$/ d' \ |
183 -e 's/$$$$/ :/' \ |
183 -e 's/$$$$/ :/' \ |
184 # |
184 # |
185 |
185 |
186 define add_native_source |
186 ################################################################################ |
187 # param 1 = BUILD_MYPACKAGE |
187 # Create the recipe needed to compile a single native source file. |
188 # parma 2 = the source file name (..../alfa.c or .../beta.cpp) |
188 # |
189 # param 3 = the bin dir that stores all .o (.obj) and .d files. |
189 # Parameter 1 is the name of the rule, based on the name of the library/ |
190 # param 4 = the c flags to the compiler |
190 # program being build and the name of the source code file, e.g. |
191 # param 5 = the c compiler |
191 # BUILD_LIBFOO_fooMain.cpp. |
192 # param 6 = the c++ flags to the compiler |
192 # |
193 # param 7 = the c++ compiler |
193 # Remaining parameters are named arguments: |
194 # param 8 = the flags to the assembler |
194 # FILE - The full path of the source file to compiler |
195 # param 9 = set to disable THIS_FILE |
195 # BASE - The name of the rule for the entire binary to build ($1) |
196 |
196 # DISABLE_THIS_FILE_DEFINE - Set to true to disable the THIS_FILE define. |
197 ifeq ($9, ) |
197 # |
198 $1_$2_THIS_FILE = -DTHIS_FILE='"$$(<F)"' |
198 SetupCompileNativeFile = $(NamedParamsMacroTemplate) |
199 endif |
199 define SetupCompileNativeFileBody |
200 |
200 $1_FILENAME := $$(notdir $$($1_FILE)) |
201 ifeq ($$($1_$(notdir $2)_OPTIMIZATION), ) |
201 |
202 $1_$(notdir $2)_OPT_CFLAGS := $$($1_OPT_CFLAGS) |
202 # The target file to be generated. |
203 $1_$(notdir $2)_OPT_CXXFLAGS := $$($1_OPT_CXXFLAGS) |
203 $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \ |
204 else |
204 $$($1_FILENAME)) |
205 ifeq (NONE, $$($1_$(notdir $2)_OPTIMIZATION)) |
205 |
206 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NONE) |
206 # Only continue if this object file hasn't been processed already. This lets |
207 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE) |
207 # the first found source file override any other with the same name. |
208 else ifeq (LOW, $$($1_$(notdir $2)_OPTIMIZATION)) |
208 ifeq ($$(findstring $$($1_OBJ), $$($$($1_BASE)_OBJS_SO_FAR)), ) |
209 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_NORM) |
209 $$($1_BASE)_OBJS_SO_FAR += $$($1_OBJ) |
210 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM) |
210 # This is the definite source file to use for $1_FILENAME. |
211 else ifeq (HIGH, $$($1_$(notdir $2)_OPTIMIZATION)) |
211 $1_SRC_FILE := $$($1_FILE) |
212 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HI) |
212 |
213 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HI) |
213 ifneq ($$($1_DISABLE_THIS_FILE_DEFINE), true) |
214 else ifeq (HIGHEST, $$($1_$(notdir $2)_OPTIMIZATION)) |
214 $1_THIS_FILE = -DTHIS_FILE='"$$(<F)"' |
215 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST) |
215 endif |
216 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST) |
216 |
217 else ifeq (HIGHEST_JVM, $$($1_$(notdir $2)_OPTIMIZATION)) |
217 ifeq ($$($1_OPTIMIZATION), ) |
218 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM) |
218 $1_OPT_CFLAGS := $$($$($1_BASE)_OPT_CFLAGS) |
219 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM) |
219 $1_OPT_CXXFLAGS := $$($$($1_BASE)_OPT_CXXFLAGS) |
220 else ifeq (SIZE, $$($1_$(notdir $2)_OPTIMIZATION)) |
|
221 $1_$(notdir $2)_OPT_CFLAGS := $(C_O_FLAG_SIZE) |
|
222 $1_$(notdir $2)_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE) |
|
223 else |
220 else |
224 $$(error Unknown value for OPTIMIZATION: $$($1_$(notdir $2)_OPTIMIZATION)) |
221 ifeq ($$($1_OPTIMIZATION), NONE) |
225 endif |
222 $1_OPT_CFLAGS := $(C_O_FLAG_NONE) |
226 endif |
223 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE) |
227 |
224 else ifeq ($$($1_OPTIMIZATION), LOW) |
228 ifneq ($$($1_PRECOMPILED_HEADER), ) |
225 $1_OPT_CFLAGS := $(C_O_FLAG_NORM) |
229 ifeq ($$(filter $$(notdir $2), $$($1_PRECOMPILED_HEADER_EXCLUDE)), ) |
226 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM) |
230 $1_$2_USE_PCH_FLAGS := $$($1_USE_PCH_FLAGS) |
227 else ifeq ($$($1_OPTIMIZATION), HIGH) |
231 endif |
228 $1_OPT_CFLAGS := $(C_O_FLAG_HI) |
232 endif |
229 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HI) |
233 |
230 else ifeq ($$($1_OPTIMIZATION), HIGHEST) |
234 ifneq ($$(filter %.c, $2), ) |
231 $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST) |
235 # Compile as a C file |
232 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST) |
236 $1_$2_FLAGS := $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \ |
233 else ifeq ($$($1_OPTIMIZATION), HIGHEST_JVM) |
237 $$($1_$(notdir $2)_OPT_CFLAGS) \ |
234 $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM) |
238 $$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c |
235 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM) |
239 $1_$2_COMP := $5 |
236 else ifeq ($$($1_OPTIMIZATION), SIZE) |
240 $1_$2_DEP_FLAG := $(C_FLAG_DEPS) |
237 $1_OPT_CFLAGS := $(C_O_FLAG_SIZE) |
241 else ifneq ($$(filter %.m, $2), ) |
238 $1_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE) |
242 # Compile as an Objective-C file |
239 else |
243 $1_$2_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $4 \ |
240 $$(error Unknown value for file OPTIMIZATION: $$($1_OPTIMIZATION)) |
244 $$($1_$(notdir $2)_OPT_CFLAGS) \ |
241 endif |
245 $$($1_$(notdir $2)_CFLAGS) $$($1_$2_THIS_FILE) -c |
242 endif |
246 $1_$2_COMP := $5 |
243 |
247 $1_$2_DEP_FLAG := $(C_FLAG_DEPS) |
244 ifneq ($$($$($1_BASE)_PRECOMPILED_HEADER), ) |
248 else ifneq ($$(filter %.s %.S, $2), ) |
245 ifeq ($$(filter $$($1_FILENAME), $$($$($1_BASE)_PRECOMPILED_HEADER_EXCLUDE)), ) |
249 # Compile as assembler file |
246 $1_USE_PCH_FLAGS := $$($$($1_BASE)_USE_PCH_FLAGS) |
250 $1_$2_FLAGS := $8 |
247 endif |
251 $1_$2_COMP := $(AS) |
248 endif |
252 $1_$2_DEP_FLAG := |
249 |
253 else ifneq ($$(filter %.cpp, $2)$$(filter %.cc, $2)$$(filter %.mm, $2), ) |
250 $1_BASE_CFLAGS := $$($$($1_BASE)_CFLAGS) $$($$($1_BASE)_EXTRA_CFLAGS) \ |
254 # Compile as a C++ or Objective-C++ file |
251 $$($$($1_BASE)_SYSROOT_CFLAGS) |
255 $1_$2_FLAGS := $(CFLAGS_CCACHE) $$($1_$2_USE_PCH_FLAGS) $6 \ |
252 $1_BASE_CXXFLAGS := $$($$($1_BASE)_CXXFLAGS) $$($$($1_BASE)_EXTRA_CXXFLAGS) \ |
256 $$($1_$(notdir $2)_OPT_CXXFLAGS) \ |
253 $$($$($1_BASE)_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS) |
257 $$($1_$(notdir $2)_CXXFLAGS) $$($1_$2_THIS_FILE) -c |
254 |
258 $1_$2_COMP := $7 |
255 ifneq ($$(filter %.c, $$($1_FILENAME)), ) |
259 $1_$2_DEP_FLAG := $(CXX_FLAG_DEPS) |
256 # Compile as a C file |
260 else |
257 $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CFLAGS) \ |
261 $$(error Internal error in NativeCompilation.gmk: no compiler for file $2) |
258 $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c |
262 endif |
259 $1_COMPILER := $$($$($1_BASE)_CC) |
263 # Generate the .o (.obj) file name and place it in the bin dir. |
260 $1_DEP_FLAG := $(C_FLAG_DEPS) |
264 $1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2)) |
261 else ifneq ($$(filter %.m, $$($1_FILENAME)), ) |
265 # Only continue if this object file hasn't been processed already. This lets the first found |
262 # Compile as an Objective-C file |
266 # source file override any other with the same name. |
263 $1_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) \ |
267 ifeq ($$(findstring $$($1_$2_OBJ), $$($1_OBJS_SO_FAR)), ) |
264 $$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c |
268 $1_OBJS_SO_FAR += $$($1_$2_OBJ) |
265 $1_COMPILER := $$($$($1_BASE)_CC) |
269 ifeq ($$(filter %.s %.S, $2), ) |
266 $1_DEP_FLAG := $(C_FLAG_DEPS) |
|
267 else ifneq ($$(filter %.s %.S, $$($1_FILENAME)), ) |
|
268 # Compile as assembler file |
|
269 $1_FLAGS := $$($$($1_BASE)_ASFLAGS) |
|
270 $1_COMPILER := $(AS) |
|
271 $1_DEP_FLAG := |
|
272 else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), ) |
|
273 # Compile as a C++ or Objective-C++ file |
|
274 $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \ |
|
275 $$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) $$($1_THIS_FILE) -c |
|
276 $1_COMPILER := $$($$($1_BASE)_CXX) |
|
277 $1_DEP_FLAG := $(CXX_FLAG_DEPS) |
|
278 else |
|
279 $$(error Internal error in NativeCompilation.gmk: no compiler for file $$($1_FILENAME)) |
|
280 endif |
|
281 |
|
282 ifeq ($$(filter %.s %.S, $$($1_FILENAME)), ) |
270 # And this is the dependency file for this obj file. |
283 # And this is the dependency file for this obj file. |
271 $1_$2_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) |
284 $1_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_OBJ)) |
272 # The dependency target file lists all dependencies as empty targets |
285 # The dependency target file lists all dependencies as empty targets to |
273 # to avoid make error "No rule to make target" for removed files |
286 # avoid make error "No rule to make target" for removed files |
274 $1_$2_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ)) |
287 $1_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_OBJ)) |
275 |
288 |
276 # Include previously generated dependency information. (if it exists) |
289 # Include previously generated dependency information. (if it exists) |
277 -include $$($1_$2_DEP) |
290 -include $$($1_DEP) |
278 -include $$($1_$2_DEP_TARGETS) |
291 -include $$($1_DEP_TARGETS) |
279 |
292 endif |
280 ifeq ($(TOOLCHAIN_TYPE), microsoft) |
293 |
281 # To avoid name clashes between pdbs for objects and libs/execs, put |
294 ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), ) |
282 # object pdbs in a separate subdir. |
295 $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION) |
283 $1_$2_DEBUG_OUT_FLAGS := -Fd$$(strip $$(patsubst $$($1_OBJECT_DIR)/%, \ |
296 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_OBJ).vardeps) |
284 $$($1_OBJECT_DIR)/pdb/%, $$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)))) |
297 endif |
285 endif |
298 |
286 endif |
299 $$($1_OBJ): $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \ |
287 |
300 $$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE) | $$($$($1_BASE)_BUILD_INFO) |
288 ifneq ($$(strip $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \ |
301 $$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME))) |
289 $$($1_$(notdir $2)_OPTIMIZATION)), ) |
302 $$(call MakeDir, $$(@D)) |
290 $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \ |
|
291 $$($1_$(notdir $2)_OPT_CFLAGS) $$($1_$(notdir $2)_OPT_CXXFLAGS) |
|
292 $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, $$($1_$2_OBJ).vardeps) |
|
293 endif |
|
294 |
|
295 $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO) |
|
296 $$(call LogInfo, Compiling $$(notdir $2) (for $$($1_BASENAME))) |
|
297 $$(call MakeDir, $$(@D) $$(@D)/pdb) |
|
298 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
303 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
299 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $2), solstudio) |
304 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), solstudio) |
300 # The Solaris studio compiler doesn't output the full path to the object file in the |
305 # The Solaris studio compiler doesn't output the full path to the |
301 # generated deps files. Fixing it with sed. If compiling assembly, don't try this. |
306 # object file in the generated deps files. Fixing it with sed. If |
|
307 # compiling assembly, don't try this. |
302 $$(call ExecuteWithLog, $$@, \ |
308 $$(call ExecuteWithLog, $$@, \ |
303 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) |
309 $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP).tmp \ |
304 $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) |
310 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) |
|
311 $(SED) 's|^$$(@F):|$$@:|' $$($1_DEP).tmp > $$($1_DEP) |
305 else |
312 else |
306 $$(call ExecuteWithLog, $$@, \ |
313 $$(call ExecuteWithLog, $$@, \ |
307 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) |
314 $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP) \ |
|
315 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) |
308 endif |
316 endif |
309 # Create a dependency target file from the dependency file. |
317 # Create a dependency target file from the dependency file. |
310 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ |
318 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ |
311 ifneq ($$($1_$2_DEP), ) |
319 ifneq ($$($1_DEP), ) |
312 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) |
320 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS) |
313 endif |
321 endif |
314 else |
322 else |
315 # The Visual Studio compiler lacks a feature for generating make dependencies, but by |
323 # The Visual Studio compiler lacks a feature for generating make |
316 # setting -showIncludes, all included files are printed. These are filtered out and |
324 # dependencies, but by setting -showIncludes, all included files are |
317 # parsed into make dependences. |
325 # printed. These are filtered out and parsed into make dependences. |
318 # Keep as much as possible on one execution line for best performance on Windows. |
326 # |
319 # No need to save exit code from compilation since pipefail is always active on |
327 # Keep as much as possible on one execution line for best performance |
320 # Windows. |
328 # on Windows. No need to save exit code from compilation since |
|
329 # pipefail is always active on Windows. |
321 $$(call ExecuteWithLog, $$@, \ |
330 $$(call ExecuteWithLog, $$@, \ |
322 $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ |
331 $$($1_COMPILER) $$($1_FLAGS) -showIncludes \ |
323 $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \ |
332 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) \ |
324 | $(GREP) -v -e "^Note: including file:" \ |
333 | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \ |
325 -e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \ |
334 -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \ |
326 $(ECHO) $$@: \\ > $$($1_$2_DEP) ; \ |
335 $(ECHO) $$@: \\ > $$($1_DEP) ; \ |
327 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_OBJ).log \ |
336 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_OBJ).log \ |
328 | $(SORT) -u >> $$($1_$2_DEP) ; \ |
337 | $(SORT) -u >> $$($1_DEP) ; \ |
329 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) |
338 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS) |
330 endif |
339 endif |
331 endif |
340 endif |
332 endef |
341 endef |
333 |
342 |
334 # Setup make rules for creating a native binary (a shared library or an |
343 # Setup make rules for creating a native binary (a shared library or an |
846 $1_STRIPFLAGS ?= $(STRIPFLAGS) |
866 $1_STRIPFLAGS ?= $(STRIPFLAGS) |
847 $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET) |
867 $1_STRIP_CMD := $$($1_STRIP) $$($1_STRIPFLAGS) $$($1_TARGET) |
848 endif |
868 endif |
849 endif |
869 endif |
850 |
870 |
851 ifeq ($$($1_TYPE), LIBRARY) |
871 ifeq ($$($1_TYPE), STATIC_LIBRARY) |
852 # Generating a dynamic library. |
872 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \ |
853 $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) |
873 $$($1_EXTRA_LIBS) |
|
874 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ |
|
875 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) |
|
876 |
|
877 # Generating a static library, ie object file archive. |
|
878 ifeq ($(STATIC_BUILD), true) |
|
879 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
|
880 STATIC_MAPFILE_DEP := $$($1_MAPFILE) |
|
881 endif |
|
882 endif |
|
883 |
|
884 $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) |
|
885 |
|
886 $$($1_TARGET): $$($1_TARGET_DEPS) |
|
887 $$(call LogInfo, Building static library $$($1_BASENAME)) |
|
888 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
|
889 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ |
|
890 $$($1_RES)) |
|
891 ifeq ($(STATIC_BUILD), true) |
|
892 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
|
893 $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols |
|
894 else |
|
895 $(GetSymbols) |
|
896 endif |
|
897 endif |
|
898 else |
|
899 # A shared dynamic library or an executable binary has been specified |
|
900 ifeq ($$($1_TYPE), LIBRARY) |
|
901 # Generating a dynamic library. |
|
902 $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) |
|
903 |
|
904 # Create loadmap on AIX. Helps in diagnosing some problems. |
|
905 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), ) |
|
906 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap |
|
907 endif |
|
908 endif |
|
909 |
854 ifeq ($(OPENJDK_TARGET_OS), windows) |
910 ifeq ($(OPENJDK_TARGET_OS), windows) |
855 $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_NAME).lib" |
911 ifeq ($$($1_EMBED_MANIFEST), true) |
856 # Create a rule for the import lib so that other rules may depend on it |
912 $1_EXTRA_LDFLAGS += -manifest:embed |
857 $$($1_OBJECT_DIR)/$$($1_NAME).lib: $$($1_TARGET) |
913 endif |
858 endif |
914 |
859 |
915 $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib |
860 # Create loadmap on AIX. Helps in diagnosing some problems. |
916 $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)" |
861 ifneq ($(COMPILER_BINDCMD_FILE_FLAG), ) |
917 ifeq ($$($1_TYPE), LIBRARY) |
862 $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap |
918 # To properly trigger downstream dependants of the import library, just as |
|
919 # for debug files, we must have a recipe in the rule. To avoid rerunning |
|
920 # the recipe every time have it touch the target. If an import library |
|
921 # file is deleted by something external, explicitly delete the target to |
|
922 # trigger a rebuild of both. |
|
923 ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY)) |
|
924 $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing) |
|
925 $$(shell $(RM) $$($1_TARGET)) |
|
926 endif |
|
927 $$($1_IMPORT_LIBRARY): $$($1_TARGET) |
|
928 $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \ |
|
929 $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \ |
|
930 ) |
|
931 $(TOUCH) $$@ |
|
932 endif |
863 endif |
933 endif |
864 |
934 |
865 $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ |
935 $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ |
866 $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \ |
936 $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ |
|
937 $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \ |
867 $$($1_STRIP_CMD) |
938 $$($1_STRIP_CMD) |
868 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ |
939 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ |
869 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) |
940 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) |
870 |
941 |
871 $1_LD_OBJ_ARG := $$($1_ALL_OBJS) |
942 $1_LD_OBJ_ARG := $$($1_ALL_OBJS) |
915 # on Windows |
988 # on Windows |
916 $$(call LogInfo, Linking $$($1_BASENAME)) |
989 $$(call LogInfo, Linking $$($1_BASENAME)) |
917 ifeq ($(OPENJDK_TARGET_OS), windows) |
990 ifeq ($(OPENJDK_TARGET_OS), windows) |
918 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
991 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
919 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
992 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
920 $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ |
993 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
921 $$($1_EXTRA_LIBS)) \ |
994 $$($1_LIBS) $$($1_EXTRA_LIBS)) \ |
922 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ |
995 | $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \ |
923 test "$$$$?" = "1" ; \ |
996 test "$$$$?" = "1" ; \ |
924 $$($1_CREATE_DEBUGINFO_CMDS) |
997 $$($1_CREATE_DEBUGINFO_CMDS) |
925 $$($1_STRIP_CMD) |
998 $$($1_STRIP_CMD) |
926 else |
999 else |
927 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
1000 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
928 $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ |
1001 $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ |
929 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
1002 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
930 $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ |
1003 $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \ |
931 $$($1_EXTRA_LIBS)) ; \ |
1004 $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \ |
932 $$($1_CREATE_DEBUGINFO_CMDS) |
1005 $$($1_CREATE_DEBUGINFO_CMDS) |
933 $$($1_STRIP_CMD) |
1006 $$($1_STRIP_CMD) |
934 endif |
1007 endif |
935 |
|
936 endif |
|
937 |
|
938 ifeq ($$($1_TYPE), STATIC_LIBRARY) |
|
939 $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \ |
|
940 $$($1_EXTRA_LIBS) |
|
941 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ |
|
942 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) |
|
943 |
|
944 # Generating a static library, ie object file archive. |
|
945 ifeq ($(STATIC_BUILD), true) |
|
946 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
|
947 STATIC_MAPFILE_DEP := $$($1_MAPFILE) |
|
948 endif |
|
949 endif |
|
950 |
|
951 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) |
|
952 $$(call LogInfo, Building static library $$($1_BASENAME)) |
|
953 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
|
954 $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ |
|
955 $$($1_RES)) |
|
956 ifeq ($(STATIC_BUILD), true) |
|
957 ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) |
|
958 $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols |
|
959 else |
|
960 $(GetSymbols) |
|
961 endif |
|
962 endif |
|
963 endif |
|
964 |
|
965 ifeq ($$($1_TYPE), EXECUTABLE) |
|
966 # A executable binary has been specified, setup the target for it. |
|
967 $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \ |
|
968 $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \ |
|
969 $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \ |
|
970 $$($1_STRIP_CMD) |
|
971 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ |
|
972 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) |
|
973 |
|
974 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
975 ifeq ($$($1_EMBED_MANIFEST), true) |
|
976 $1_EXTRA_LDFLAGS += -manifest:embed |
|
977 endif |
|
978 endif |
|
979 |
|
980 $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ |
|
981 $$($1_VARDEPS_FILE) |
|
982 $$(call LogInfo, Linking executable $$($1_BASENAME)) |
|
983 $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ |
|
984 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \ |
|
985 $(EXE_OUT_OPTION)$$($1_TARGET) \ |
|
986 $$($1_ALL_OBJS) $$($1_RES) \ |
|
987 $$($1_LIBS) $$($1_EXTRA_LIBS)) |
|
988 ifeq ($(OPENJDK_TARGET_OS), windows) |
1008 ifeq ($(OPENJDK_TARGET_OS), windows) |
989 ifneq ($$($1_MANIFEST), ) |
1009 ifneq ($$($1_MANIFEST), ) |
990 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 |
1010 $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 |
991 endif |
1011 endif |
992 endif |
1012 endif |