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 |
36 |
37 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
37 # Extensions of files handled by this macro. |
38 COMPILING_MSG=echo $(LOG_INFO) "Compiling $(notdir $1) (for $(notdir $2))" |
38 NATIVE_SOURCE_EXTENSIONS := %.s %.c %.cpp %.m %.mm |
39 LINKING_MSG=echo $(LOG_INFO) "Linking $1" |
39 |
40 LINKING_EXE_MSG=echo $(LOG_INFO) "Linking executable $1" |
40 # Replaces native source extensions with the object file extension in a string. |
41 ARCHIVING_MSG=echo $(LOG_INFO) "Archiving $1" |
41 # Param 1: the string containing source file names with extensions |
42 else |
42 # The surrounding strip is needed to keep additional whitespace out |
43 COMPILING_MSG= |
43 define replace_with_obj_extension |
44 LINKING_MSG= |
44 $(strip \ |
45 LINKING_EXE_MSG= |
45 $(foreach extension, $(NATIVE_SOURCE_EXTENSIONS), \ |
46 ARCHIVING_MSG= |
46 $(patsubst $(extension),%$(OBJ_SUFFIX),$(filter $(extension),$1))) \ |
47 endif |
47 ) |
|
48 endef |
48 |
49 |
49 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) |
50 ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) |
50 UNIX_PATH_PREFIX := /cygdrive |
51 UNIX_PATH_PREFIX := /cygdrive |
51 else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) |
52 else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys) |
52 UNIX_PATH_PREFIX := |
53 UNIX_PATH_PREFIX := |
53 endif |
54 endif |
|
55 |
|
56 WINDOWS_SHOWINCLUDE_SED_PATTERN := \ |
|
57 -e '/^Note: including file:/!d' \ |
|
58 -e 's|Note: including file: *||' \ |
|
59 -e 's|\\|/|g' \ |
|
60 -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \ |
|
61 -e '/$(subst /,\/,$(TOPDIR))/!d' \ |
|
62 -e 's|$$$$| \\|g' \ |
|
63 # |
54 |
64 |
55 define add_native_source |
65 define add_native_source |
56 # param 1 = BUILD_MYPACKAGE |
66 # param 1 = BUILD_MYPACKAGE |
57 # parma 2 = the source file name (..../alfa.c or .../beta.cpp) |
67 # parma 2 = the source file name (..../alfa.c or .../beta.cpp) |
58 # param 3 = the bin dir that stores all .o (.obj) and .d files. |
68 # param 3 = the bin dir that stores all .o (.obj) and .d files. |
59 # param 4 = the c flags to the compiler |
69 # param 4 = the c flags to the compiler |
60 # param 5 = the c compiler |
70 # param 5 = the c compiler |
61 # param 6 = the c++ flags to the compiler |
71 # param 6 = the c++ flags to the compiler |
62 # param 7 = the c++ compiler |
72 # param 7 = the c++ compiler |
63 # param 8 = the flags to the assembler |
73 # param 8 = the objc compiler |
|
74 # param 9 = the flags to the assembler |
64 |
75 |
65 ifneq (,$$(filter %.c,$2)) |
76 ifneq (,$$(filter %.c,$2)) |
66 # Compile as a C file |
77 # Compile as a C file |
67 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
78 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
68 $1_$2_COMP=$5 |
79 $1_$2_COMP=$5 |
69 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
80 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
70 else ifneq (,$$(filter %.m,$2)) |
81 else ifneq (,$$(filter %.m,$2)) |
71 # Compile as a objective-c file |
82 # Compile as a objective-c file |
72 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
83 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
73 $1_$2_COMP=$5 |
84 $1_$2_COMP=$8 |
74 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
85 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
75 else ifneq (,$$(filter %.s,$2)) |
86 else ifneq (,$$(filter %.s,$2)) |
76 # Compile as assembler file |
87 # Compile as assembler file |
77 $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"' |
88 $1_$2_FLAGS=$9 -DTHIS_FILE='"$$(<F)"' |
78 $1_$2_COMP=$(AS) |
89 $1_$2_COMP=$(AS) |
79 $1_$2_DEP_FLAG:= |
90 $1_$2_DEP_FLAG:= |
80 else |
91 else ifneq (,$$(filter %.cpp,$2)$$(filter %.mm,$2)) |
81 # Compile as a C++ file |
92 # Compile as a C++ file |
82 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
93 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
83 $1_$2_COMP=$7 |
94 $1_$2_COMP=$7 |
84 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
95 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
|
96 else |
|
97 $$(error Internal error in NativeCompilation.gmk: no compiler for file $2) |
85 endif |
98 endif |
86 # Generate the .o (.obj) file name and place it in the bin dir. |
99 # Generate the .o (.obj) file name and place it in the bin dir. |
87 $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(patsubst %.s,%$(OBJ_SUFFIX),$$(notdir $2))))) |
100 $1_$2_OBJ := $3/$$(call replace_with_obj_extension, $$(notdir $2)) |
88 # Only continue if this object file hasn't been processed already. This lets the first found |
101 # Only continue if this object file hasn't been processed already. This lets the first found |
89 # source file override any other with the same name. |
102 # source file override any other with the same name. |
90 ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR))) |
103 ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_ALL_OBJS))) |
91 $1_OBJS_SO_FAR+=$$($1_$2_OBJ) |
104 $1_ALL_OBJS+=$$($1_$2_OBJ) |
92 ifeq (,$$(filter %.s,$2)) |
105 ifeq (,$$(filter %.s,$2)) |
93 # And this is the dependency file for this obj file. |
106 # And this is the dependency file for this obj file. |
94 $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) |
107 $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) |
95 # Include previously generated dependency information. (if it exists) |
108 # Include previously generated dependency information. (if it exists) |
96 -include $$($1_$2_DEP) |
109 -include $$($1_$2_DEP) |
99 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ |
112 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ |
100 -Fm$$(patsubst %$(OBJ_SUFFIX),%.map,$$($1_$2_OBJ)) |
113 -Fm$$(patsubst %$(OBJ_SUFFIX),%.map,$$($1_$2_OBJ)) |
101 endif |
114 endif |
102 endif |
115 endif |
103 |
116 |
104 $$($1_$2_OBJ) : $2 |
117 $$($1_$2_OBJ) : $2 | $$($1_BUILD_INFO) |
|
118 $(ECHO) $(LOG_INFO) "Compiling $$(notdir $2) (for $$(notdir $$($1_TARGET)))" |
105 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
119 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
106 $$(call COMPILING_MSG,$2,$$($1_TARGET)) |
|
107 # The Solaris studio compiler doesn't output the full path to the object file in the |
120 # The Solaris studio compiler doesn't output the full path to the object file in the |
108 # generated deps files. Fixing it with sed. If compiling assembly, don't try this. |
121 # generated deps files. Fixing it with sed. If compiling assembly, don't try this. |
109 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) |
122 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) |
110 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
123 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
111 $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) |
124 $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP) |
117 # setting -showIncludes, all included files are printed. These are filtered out and |
130 # setting -showIncludes, all included files are printed. These are filtered out and |
118 # parsed into make dependences. |
131 # parsed into make dependences. |
119 ifeq ($(TOOLCHAIN_TYPE), microsoft) |
132 ifeq ($(TOOLCHAIN_TYPE), microsoft) |
120 ($$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ |
133 ($$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \ |
121 $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 ; echo $$$$? > $$($1_$2_DEP).exitvalue) \ |
134 $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 ; echo $$$$? > $$($1_$2_DEP).exitvalue) \ |
122 | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v "^Note: including file:" \ |
135 | $(TEE) $$($1_$2_DEP).raw | $(GREP) -v -e "^Note: including file:" \ |
123 && exit `cat $$($1_$2_DEP).exitvalue` |
136 -e "^$(notdir $2)$$$$" ; exit `cat $$($1_$2_DEP).exitvalue` |
124 $(RM) $$($1_$2_DEP).exitvalue |
137 $(RM) $$($1_$2_DEP).exitvalue |
125 ($(ECHO) $$@: \\ \ |
138 ($(ECHO) $$@: \\ \ |
126 && $(SED) -e '/^Note: including file:/!d' \ |
139 && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) > $$($1_$2_DEP) |
127 -e 's|Note: including file: *||' \ |
|
128 -e 's|\\|/|g' \ |
|
129 -e 's|^\([a-zA-Z]\):|$(UNIX_PATH_PREFIX)/\1|g' \ |
|
130 -e '/$(subst /,\/,$(TOPDIR))/!d' \ |
|
131 -e 's|$$$$| \\|g' \ |
|
132 $$($1_$2_DEP).raw) > $$($1_$2_DEP) |
|
133 endif |
140 endif |
134 endif |
141 endif |
135 endef |
142 endef |
136 |
143 |
|
144 # Setup make rules for creating a native binary (a shared library or an |
|
145 # executable). |
|
146 # |
|
147 # Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
148 # and the targets generated are listed in a variable by that name. |
|
149 # |
|
150 # Remaining parameters are named arguments. These include: |
|
151 # SRC one or more directory roots to scan for C/C++ files. |
|
152 # LANG C or C++ |
|
153 # CFLAGS the compiler flags to be used, used both for C and C++. |
|
154 # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS. |
|
155 # LDFLAGS the linker flags to be used, used both for C and C++. |
|
156 # LDFLAGS_SUFFIX the linker flags to be added last on the commandline |
|
157 # typically the libraries linked to. |
|
158 # ARFLAGS the archiver flags to be used |
|
159 # OBJECT_DIR the directory where we store the object files |
|
160 # LIBRARY the resulting library file |
|
161 # PROGRAM the resulting exec file |
|
162 # INCLUDES only pick source from these directories |
|
163 # EXCLUDES do not pick source from these directories |
|
164 # INCLUDE_FILES only compile exactly these files! |
|
165 # EXCLUDE_FILES with these names |
|
166 # EXTRA_FILES List of extra files not in any of the SRC dirs |
|
167 # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run |
|
168 # RC_FLAGS flags for RC. |
|
169 # MAPFILE mapfile |
|
170 # REORDER reorder file |
|
171 # DEBUG_SYMBOLS add debug symbols (if configured on) |
|
172 # CC the compiler to use, default is $(CC) |
|
173 # LDEXE the linker to use for linking executables, default is $(LDEXE) |
|
174 # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST |
137 define SetupNativeCompilation |
175 define SetupNativeCompilation |
138 # param 1 is for example BUILD_MYPACKAGE |
176 $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
139 # param 2,3,4,5,6,7,8 are named args. |
177 $(call EvalDebugWrapper,$(strip $1),$(call SetupNativeCompilationInner,$(strip $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))) |
140 # SRC one or more directory roots to scan for C/C++ files. |
178 endef |
141 # LANG C or C++ |
179 |
142 # CFLAGS the compiler flags to be used, used both for C and C++. |
180 define SetupNativeCompilationInner |
143 # CXXFLAGS the compiler flags to be used for c++, if set overrides CFLAGS. |
|
144 # LDFLAGS the linker flags to be used, used both for C and C++. |
|
145 # LDFLAGS_SUFFIX the linker flags to be added last on the commandline |
|
146 # typically the libraries linked to. |
|
147 # ARFLAGS the archiver flags to be used |
|
148 # OBJECT_DIR the directory where we store the object files |
|
149 # LIBRARY the resulting library file |
|
150 # PROGRAM the resulting exec file |
|
151 # INCLUDES only pick source from these directories |
|
152 # EXCLUDES do not pick source from these directories |
|
153 # INCLUDE_FILES only compile exactly these files! |
|
154 # EXCLUDE_FILES with these names |
|
155 # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run |
|
156 # RC_FLAGS flags for RC. |
|
157 # MAPFILE mapfile |
|
158 # REORDER reorder file |
|
159 # DEBUG_SYMBOLS add debug symbols (if configured on) |
|
160 # CC the compiler to use, default is $(CC) |
|
161 # LDEXE the linker to use for linking executables, default is $(LDEXE) |
|
162 # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST |
|
163 $(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)) |
181 $(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)) |
164 $(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)) |
182 $(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)) |
165 $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
183 $(if $(27),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
166 |
184 |
167 ifneq (,$$($1_BIN)) |
185 ifneq (,$$($1_BIN)) |
296 $1_SRC_EXCLUDES := $$(addsuffix /%,$$($1_EXCLUDES)) |
338 $1_SRC_EXCLUDES := $$(addsuffix /%,$$($1_EXCLUDES)) |
297 $1_SRC_EXCLUDES += $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) |
339 $1_SRC_EXCLUDES += $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) |
298 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) |
340 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) |
299 endif |
341 endif |
300 |
342 |
|
343 $1_SRCS += $$($1_EXTRA_FILES) |
|
344 |
301 # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides |
345 # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides |
302 # a reproducable order on the input files to the linker). |
346 # a reproducable order on the input files to the linker). |
303 $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)))))))) |
347 $1_EXPECTED_OBJS_FILENAMES := $$(call replace_with_obj_extension, $$(notdir $$($1_SRCS))) |
|
348 $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_OBJECT_DIR)/,$$($1_EXPECTED_OBJS_FILENAMES))) |
304 # Are there too many object files on disk? Perhaps because some source file was removed? |
349 # Are there too many object files on disk? Perhaps because some source file was removed? |
305 $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) |
350 $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) |
306 # Clean out the superfluous object files. |
351 # Clean out the superfluous object files. |
307 ifneq ($$($1_SUPERFLUOUS_OBJS),) |
352 ifneq ($$($1_SUPERFLUOUS_OBJS),) |
308 $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) |
353 $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) |
309 endif |
354 endif |
310 |
355 |
311 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables for CFLAGS. |
356 # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CFLAGS. |
312 $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) |
357 $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) |
313 ifneq ($(DEBUG_LEVEL),release) |
358 ifneq ($(DEBUG_LEVEL),release) |
314 # Pickup extra debug dependent variables for CFLAGS |
359 # Pickup extra debug dependent variables for CFLAGS |
315 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) |
360 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) |
316 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_debug) |
361 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug) |
317 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) |
362 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) |
318 else |
363 else |
319 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) |
364 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) |
320 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
365 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release) |
321 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) |
366 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) |
322 endif |
367 endif |
323 |
368 |
324 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. |
369 # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. |
325 $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) |
370 $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) |
326 ifneq ($(DEBUG_LEVEL),release) |
371 ifneq ($(DEBUG_LEVEL),release) |
327 # Pickup extra debug dependent variables for CXXFLAGS |
372 # Pickup extra debug dependent variables for CXXFLAGS |
328 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) |
373 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) |
329 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_debug) |
374 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug) |
330 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug) |
375 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug) |
331 else |
376 else |
332 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
377 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
333 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
378 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release) |
334 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) |
379 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) |
335 endif |
380 endif |
336 |
381 |
337 ifneq (,$$($1_DEBUG_SYMBOLS)) |
382 ifeq ($$($1_DEBUG_SYMBOLS), true) |
338 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) |
383 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) |
339 ifdef OPENJDK |
384 ifdef OPENJDK |
340 # Always add debug symbols |
385 # Always add debug symbols |
341 $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) |
386 $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) |
342 $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) |
387 $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) |
377 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST) |
422 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST) |
378 else ifneq (, $$($1_OPTIMIZATION)) |
423 else ifneq (, $$($1_OPTIMIZATION)) |
379 $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) |
424 $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) |
380 endif |
425 endif |
381 |
426 |
382 # Add sys root specific cflags last |
427 $1_BUILD_INFO := $$($1_OBJECT_DIR)/_build-info.marker |
383 $1_EXTRA_CFLAGS += $(SYSROOT_CFLAGS) |
428 |
384 $1_EXTRA_CXXFLAGS += $(SYSROOT_CFLAGS) |
429 # Setup rule for printing progress info when compiling source files. |
|
430 # This is a rough heuristic and may not always print accurate information. |
|
431 $$($1_BUILD_INFO): $$($1_SRCS) |
|
432 ifeq ($$(wildcard $$($1_TARGET)),) |
|
433 $(ECHO) 'Creating $$($1_BASENAME) from $$(words $$?) file(s)' |
|
434 else |
|
435 $(ECHO) 'Updating $$($1_BASENAME) from $$(words $$?) file(s)' |
|
436 endif |
|
437 $(TOUCH) $$@ |
385 |
438 |
386 # Now call add_native_source for each source file we are going to compile. |
439 # Now call add_native_source for each source file we are going to compile. |
387 $$(foreach p,$$($1_SRCS), \ |
440 $$(foreach p,$$($1_SRCS), \ |
388 $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \ |
441 $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \ |
389 $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC), \ |
442 $(SYSROOT_CFLAGS) $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC), \ |
390 $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS)))) |
443 $(SYSROOT_CFLAGS) $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$$($1_CXX),$$($1_OBJC),$$($1_ASFLAGS)))) |
391 |
444 |
392 # On windows we need to create a resource file |
445 # On windows we need to create a resource file |
393 ifeq ($(OPENJDK_TARGET_OS), windows) |
446 ifeq ($(OPENJDK_TARGET_OS), windows) |
394 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
447 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
395 $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res |
448 $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res |
|
449 $1_RES_DEP:=$$($1_RES).d |
|
450 -include $$($1_RES_DEP) |
396 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
451 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
|
452 $(ECHO) $(LOG_INFO) "Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$(notdir $$($1_TARGET)))" |
397 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
453 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
|
454 # Windows RC compiler does not support -showIncludes, so we mis-use CL for this. |
|
455 $(CC) $$($1_RC_FLAGS) -showIncludes -nologo -TC \ |
|
456 $(CC_OUT_OPTION)$$($1_RES_DEP).obj $$($1_VERSIONINFO_RESOURCE) > $$($1_RES_DEP).raw 2>&1 || exit 0 |
|
457 ($(ECHO) $$($1_RES): \\ \ |
|
458 && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).raw) > $$($1_RES_DEP) |
398 endif |
459 endif |
399 ifneq (,$$($1_MANIFEST)) |
460 ifneq (,$$($1_MANIFEST)) |
400 $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest |
461 $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest |
401 IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) |
462 IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) |
402 $$($1_GEN_MANIFEST): $$($1_MANIFEST) |
463 $$($1_GEN_MANIFEST): $$($1_MANIFEST) |
418 $$(MV) $$@.tmp $$@ |
479 $$(MV) $$@.tmp $$@ |
419 endif |
480 endif |
420 endif |
481 endif |
421 endif |
482 endif |
422 |
483 |
423 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables |
484 # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables |
424 # for LDFLAGS and LDFLAGS_SUFFIX |
485 # for LDFLAGS and LDFLAGS_SUFFIX |
425 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) |
486 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) |
426 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) |
487 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) |
427 ifneq (,$$($1_REAL_MAPFILE)) |
488 ifneq (,$$($1_REAL_MAPFILE)) |
428 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
489 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
429 endif |
490 endif |
430 |
|
431 $1_EXTRA_LDFLAGS += $(SYSROOT_LDFLAGS) |
|
432 |
491 |
433 # Need to make sure TARGET is first on list |
492 # Need to make sure TARGET is first on list |
434 $1 := $$($1_TARGET) |
493 $1 := $$($1_TARGET) |
435 ifeq ($$($1_STATIC_LIBRARY),) |
494 ifeq ($$($1_STATIC_LIBRARY),) |
436 ifneq ($$($1_DEBUG_SYMBOLS),) |
495 ifeq ($$($1_DEBUG_SYMBOLS), true) |
437 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) |
496 ifeq ($(ENABLE_DEBUG_SYMBOLS), true) |
438 ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet |
497 ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet |
439 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) |
498 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) |
440 # The dependency on TARGET is needed on windows for debuginfo files |
499 # The dependency on TARGET is needed on windows for debuginfo files |
441 # to be rebuilt properly. |
500 # to be rebuilt properly. |