49 # param 3 = the bin dir that stores all .o (.obj) and .d files. |
49 # param 3 = the bin dir that stores all .o (.obj) and .d files. |
50 # param 4 = the c flags to the compiler |
50 # param 4 = the c flags to the compiler |
51 # param 5 = the c compiler |
51 # param 5 = the c compiler |
52 # param 6 = the c++ flags to the compiler |
52 # param 6 = the c++ flags to the compiler |
53 # param 7 = the c++ compiler |
53 # param 7 = the c++ compiler |
|
54 # param 8 = the flags to the assembler |
54 |
55 |
55 ifneq (,$$(filter %.c,$2)) |
56 ifneq (,$$(filter %.c,$2)) |
56 # Compile as a C file |
57 # Compile as a C file |
57 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) |
58 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -c |
58 $1_$2_COMP=$5 |
59 $1_$2_COMP=$5 |
59 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
60 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
60 else ifneq (,$$(filter %.m,$2)) |
61 else ifneq (,$$(filter %.m,$2)) |
61 # Compile as a objective-c file |
62 # Compile as a objective-c file |
62 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) |
63 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -c |
63 $1_$2_COMP=$5 |
64 $1_$2_COMP=$5 |
64 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
65 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
|
66 else ifneq (,$$(filter %.s,$2)) |
|
67 # Compile as assembler file |
|
68 $1_$2_FLAGS=$8 |
|
69 $1_$2_COMP=$(AS) |
|
70 $1_$2_DEP_FLAG:= |
65 else |
71 else |
66 # Compile as a C++ file |
72 # Compile as a C++ file |
67 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) |
73 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -c |
68 $1_$2_COMP=$7 |
74 $1_$2_COMP=$7 |
69 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
75 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
70 endif |
76 endif |
71 # Generate the .o (.obj) file name and place it in the bin dir. |
77 # Generate the .o (.obj) file name and place it in the bin dir. |
72 $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(notdir $2)))) |
78 $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(patsubst %.s,%$(OBJ_SUFFIX),$$(notdir $2))))) |
73 # Only continue if this object file hasn't been processed already. This lets the first found |
79 # Only continue if this object file hasn't been processed already. This lets the first found |
74 # source file override any other with the same name. |
80 # source file override any other with the same name. |
75 ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR))) |
81 ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR))) |
76 $1_OBJS_SO_FAR+=$$($1_$2_OBJ) |
82 $1_OBJS_SO_FAR+=$$($1_$2_OBJ) |
77 # And this is the dependency file for this obj file. |
83 ifeq (,$$(filter %.s,$2)) |
78 $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) |
84 # And this is the dependency file for this obj file. |
79 # Include previously generated dependency information. (if it exists) |
85 $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) |
80 -include $$($1_$2_DEP) |
86 # Include previously generated dependency information. (if it exists) |
81 |
87 -include $$($1_$2_DEP) |
82 ifeq ($(COMPILER_TYPE),CL) |
88 |
83 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ |
89 ifeq ($(COMPILER_TYPE),CL) |
84 -Fm$$(patsubst %$(OBJ_SUFFIX),%.map,$$($1_$2_OBJ)) |
90 $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ |
|
91 -Fm$$(patsubst %$(OBJ_SUFFIX),%.map,$$($1_$2_OBJ)) |
|
92 endif |
85 endif |
93 endif |
86 |
94 |
87 $$($1_$2_OBJ) : $2 |
95 $$($1_$2_OBJ) : $2 |
88 ifeq ($(COMPILER_TYPE),CC) |
96 ifeq ($(COMPILER_TYPE),CC) |
89 $$(call COMPILING_MSG,$$(notdir $2)) |
97 $$(call COMPILING_MSG,$$(notdir $2)) |
90 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) -c $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
98 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
91 endif |
99 endif |
92 ifeq ($(COMPILER_TYPE),CL) |
100 ifeq ($(COMPILER_TYPE),CL) |
93 $$(call COMPILING_MSG,$$(notdir $2)) |
101 $$(call COMPILING_MSG,$$(notdir $2)) |
94 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) -c $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
102 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
95 endif |
103 endif |
96 endif |
104 endif |
97 endef |
105 endef |
98 |
106 |
99 define SetupNativeCompilation |
107 define SetupNativeCompilation |
135 $(if $(16),$1_$(strip $(16))) |
146 $(if $(16),$1_$(strip $(16))) |
136 $(if $(17),$1_$(strip $(17))) |
147 $(if $(17),$1_$(strip $(17))) |
137 $(if $(18),$1_$(strip $(18))) |
148 $(if $(18),$1_$(strip $(18))) |
138 $(if $(19),$1_$(strip $(19))) |
149 $(if $(19),$1_$(strip $(19))) |
139 $(if $(20),$1_$(strip $(20))) |
150 $(if $(20),$1_$(strip $(20))) |
|
151 $(if $(21),$1_$(strip $(21))) |
|
152 $(if $(22),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
|
153 |
|
154 ifneq (,$$($1_BIN)) |
|
155 $$(error BIN has been replaced with OBJECT_DIR) |
|
156 endif |
|
157 |
|
158 ifneq (,$$($1_LIB)) |
|
159 $$(error LIB has been replaced with LIBRARY) |
|
160 endif |
|
161 |
|
162 ifneq (,$$($1_EXE)) |
|
163 $$(error EXE has been replaced with PROGRAM) |
|
164 endif |
|
165 |
|
166 ifneq (,$$($1_LIBRARY)) |
|
167 ifeq (,$$($1_OUTPUT_DIR)) |
|
168 $$(error LIBRARY requires OUTPUT_DIR) |
|
169 endif |
|
170 |
|
171 ifneq ($$($1_LIBRARY),$(basename $$($1_LIBRARY))) |
|
172 $$(error directory of LIBRARY should be specified using OUTPUT_DIR) |
|
173 endif |
|
174 |
|
175 ifneq (,$(findstring $(SHARED_LIBRARY_SUFFIX),$$($1_LIBRARY))) |
|
176 $$(error LIBRARY should be specified without SHARED_LIBRARY_SUFFIX: $(SHARED_LIBRARY_SUFFIX)) |
|
177 endif |
|
178 |
|
179 ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_LIBRARY))) |
|
180 $$(error LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) |
|
181 endif |
|
182 |
|
183 $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_LIBRARY)$(SHARED_LIBRARY_SUFFIX) |
|
184 $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) |
|
185 |
|
186 endif |
|
187 |
|
188 ifneq (,$$($1_STATIC_LIBRARY)) |
|
189 ifeq (,$$($1_OUTPUT_DIR)) |
|
190 $$(error STATIC_LIBRARY requires OUTPUT_DIR) |
|
191 endif |
|
192 |
|
193 ifneq ($$($1_STATIC_LIBRARY),$(basename $$($1_STATIC_LIBRARY))) |
|
194 $$(error directory of STATIC_LIBRARY should be specified using OUTPUT_DIR) |
|
195 endif |
|
196 |
|
197 ifneq (,$(findstring $(STATIC_LIBRARY_SUFFIX),$$($1_STATIC_LIBRARY))) |
|
198 $$(error STATIC_LIBRARY should be specified without STATIC_LIBRARY_SUFFIX: $(STATIC_LIBRARY_SUFFIX)) |
|
199 endif |
|
200 |
|
201 ifneq (,$(findstring $(LIBRARY_PREFIX),$$($1_STATIC_LIBRARY))) |
|
202 $$(error STATIC_LIBRARY should be specified without LIBRARY_PREFIX: $(LIBRARY_PREFIX)) |
|
203 endif |
|
204 |
|
205 $1_BASENAME:=$(LIBRARY_PREFIX)$$($1_STATIC_LIBRARY)$(STATIC_LIBRARY_SUFFIX) |
|
206 $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) |
|
207 endif |
|
208 |
|
209 ifneq (,$$($1_PROGRAM)) |
|
210 ifeq (,$$($1_OUTPUT_DIR)) |
|
211 $$(error PROGRAM requires OUTPUT_DIR) |
|
212 endif |
|
213 |
|
214 ifneq ($$($1_PROGRAM),$(basename $$($1_PROGRAM))) |
|
215 $$(error directory of PROGRAM should be specified using OUTPUT_DIR) |
|
216 endif |
|
217 |
|
218 ifneq (,$(findstring $(EXE_SUFFIX),$$($1_PROGRAM))) |
|
219 $$(error PROGRAM should be specified without EXE_SUFFIX: $(EXE_SUFFIX)) |
|
220 endif |
|
221 |
|
222 $1_BASENAME:=$$($1_PROGRAM)$(EXE_SUFFIX) |
|
223 $1_TARGET:=$$($1_OUTPUT_DIR)/$$($1_BASENAME) |
|
224 |
|
225 endif |
|
226 |
|
227 ifeq (,$$($1_TARGET)) |
|
228 $$(error Neither PROGRAM, LIBRARY nor STATIC_LIBRARY has been specified for SetupNativeCompilation) |
|
229 endif |
140 |
230 |
141 ifeq (,$$($1_LANG)) |
231 ifeq (,$$($1_LANG)) |
142 $$(error You have to specify LANG for native compilation $1) |
232 $$(error You have to specify LANG for native compilation $1) |
143 endif |
233 endif |
144 ifeq (C,$$($1_LANG)) |
234 ifeq (C,$$($1_LANG)) |
|
235 ifeq ($$($1_LDEXE),) |
|
236 $1_LDEXE:=$(LDEXE) |
|
237 endif |
145 $1_LD:=$(LD) |
238 $1_LD:=$(LD) |
146 $1_LDEXE:=$(LDEXE) |
|
147 else |
239 else |
148 ifeq (C++,$$($1_LANG)) |
240 ifeq (C++,$$($1_LANG)) |
149 $1_LD:=$(LDCXX) |
241 $1_LD:=$(LDCXX) |
150 $1_LDEXE:=$(LDEXECXX) |
242 $1_LDEXE:=$(LDEXECXX) |
151 else |
243 else |
152 $$(error Unknown native language $$($1_LANG) for $1) |
244 $$(error Unknown native language $$($1_LANG) for $1) |
153 endif |
245 endif |
154 endif |
246 endif |
155 |
247 |
|
248 ifeq ($$($1_CC),) |
|
249 $1_CC:=$(CC) |
|
250 endif |
|
251 |
156 # Make sure the dirs exist. |
252 # Make sure the dirs exist. |
157 $$(shell $(MKDIR) -p $$($1_SRC) $$($1_BIN) $$(dir $$($1_LIB)) $$(dir $$($1_EXE))) |
253 $$(shell $(MKDIR) -p $$($1_SRC) $$($1_OBJECT_DIR) $$($1_OUTPUT_DIR)) |
158 # Find all files in the source trees. Sort to remove duplicates. |
254 # Find all files in the source trees. Sort to remove duplicates. |
159 $1_ALL_SRCS := $$(sort $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f))) |
255 $1_ALL_SRCS := $$(sort $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f))) |
160 # Extract the C/C++ files. |
256 # Extract the C/C++ files. |
161 $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_EXCLUDE_FILES))) |
257 $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_EXCLUDE_FILES))) |
162 $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) |
258 $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) |
163 ifneq ($$($1_EXCLUDE_FILES),) |
259 ifneq ($$($1_EXCLUDE_FILES),) |
164 $1_EXCLUDE_FILES:=$$(addprefix %,$$($1_EXCLUDE_FILES)) |
260 $1_EXCLUDE_FILES:=$$(addprefix %,$$($1_EXCLUDE_FILES)) |
165 endif |
261 endif |
166 $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter %.c %.cpp %.m,$$($1_ALL_SRCS))) |
262 $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter %.s %.c %.cpp %.m,$$($1_ALL_SRCS))) |
167 ifneq (,$$(strip $$($1_INCLUDE_FILES))) |
263 ifneq (,$$(strip $$($1_INCLUDE_FILES))) |
168 $1_SRCS := $$(filter $$($1_INCLUDE_FILES),$$($1_SRCS)) |
264 $1_SRCS := $$(filter $$($1_INCLUDE_FILES),$$($1_SRCS)) |
169 endif |
265 endif |
170 ifeq (,$$($1_SRCS)) |
266 ifeq (,$$($1_SRCS)) |
171 $$(error No sources found for $1 when looking inside the dirs $$($1_SRC)) |
267 $$(error No sources found for $1 when looking inside the dirs $$($1_SRC)) |
172 endif |
268 endif |
173 # There can be only a single bin dir root, no need to foreach over the roots. |
269 # There can be only a single bin dir root, no need to foreach over the roots. |
174 $1_BINS := $$(wildcard $$($1_BIN)/*$(OBJ_SUFFIX)) |
270 $1_BINS := $$(wildcard $$($1_OBJECT_DIR)/*$(OBJ_SUFFIX)) |
175 # Now we have a list of all c/c++ files to compile: $$($1_SRCS) |
271 # Now we have a list of all c/c++ files to compile: $$($1_SRCS) |
176 # and we have a list of all existing object files: $$($1_BINS) |
272 # and we have a list of all existing object files: $$($1_BINS) |
177 |
273 |
178 # Prepend the source/bin path to the filter expressions. Then do the filtering. |
274 # Prepend the source/bin path to the filter expressions. Then do the filtering. |
179 ifneq ($$($1_INCLUDES),) |
275 ifneq ($$($1_INCLUDES),) |
185 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) |
281 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) |
186 endif |
282 endif |
187 |
283 |
188 # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides |
284 # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides |
189 # a reproducable order on the input files to the linker). |
285 # a reproducable order on the input files to the linker). |
190 $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_BIN)/,$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(notdir $$($1_SRCS))))))) |
286 $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)))))))) |
191 $1 := $$($1_EXPECTED_OBJS) |
|
192 # Are there too many object files on disk? Perhaps because some source file was removed? |
287 # Are there too many object files on disk? Perhaps because some source file was removed? |
193 $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) |
288 $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) |
194 # Clean out the superfluous object files. |
289 # Clean out the superfluous object files. |
195 $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) |
290 $$(shell $(RM) -f $$($1_SUPERFLUOUS_OBJS)) |
196 |
291 |
197 # Pickup extra HOST_OS_API and/or PLATFORM dependent variables for CFLAGS. |
292 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables for CFLAGS. |
198 $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(HOST_OS_API)) $$($1_CFLAGS_$(PLATFORM)) |
293 $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) |
199 ifneq ($(DEBUG_LEVEL),release) |
294 ifneq ($(DEBUG_LEVEL),release) |
200 # Pickup extra debug dependent variables for CFLAGS |
295 # Pickup extra debug dependent variables for CFLAGS |
201 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) |
296 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) |
202 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(HOST_OS_API)_debug) |
297 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_debug) |
203 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(PLATFORM)_debug) |
298 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) |
204 else |
299 else |
205 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) |
300 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) |
206 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(HOST_OS_API)_release) |
301 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
207 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(PLATFORM)_release) |
302 $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) |
208 endif |
303 endif |
209 |
304 |
210 # Pickup extra HOST_OS_API and/or PLATFORM dependent variables for CXXFLAGS. |
305 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. |
211 $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(HOST_OS_API)) $$($1_CXXFLAGS_$(PLATFORM)) |
306 $1_EXTRA_CXXFLAGS:=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) |
212 ifneq ($(DEBUG_LEVEL),release) |
307 ifneq ($(DEBUG_LEVEL),release) |
213 # Pickup extra debug dependent variables for CXXFLAGS |
308 # Pickup extra debug dependent variables for CXXFLAGS |
214 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) |
309 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_debug) |
215 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(HOST_OS_API)_debug) |
310 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_debug) |
216 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(PLATFORM)_debug) |
311 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug) |
217 else |
312 else |
218 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
313 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
219 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(HOST_OS_API)_release) |
314 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
220 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(PLATFORM)_release) |
315 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) |
221 endif |
316 endif |
222 |
317 |
223 ifeq ($$($1_CXXFLAGS),) |
318 ifeq ($$($1_CXXFLAGS),) |
224 $1_CXXFLAGS:=$$($1_CFLAGS) |
319 $1_CXXFLAGS:=$$($1_CFLAGS) |
225 endif |
320 endif |
230 ifneq (,$$($1_REORDER)) |
325 ifneq (,$$($1_REORDER)) |
231 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
326 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
232 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
327 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
233 endif |
328 endif |
234 |
329 |
|
330 ifneq (no, $(ENABLE_DEBUG_SYMBOLS)) |
|
331 ifneq ($(OPENJDK_TARGET_OS), solaris) |
|
332 # <weird code /> |
|
333 # There is very weird code in Defs-solaris.gmk that first sets variables as decribed below |
|
334 # and then a couple of hundreds of line below resets them... |
|
335 # this feels like a sure bug...but before this is confirmed, mimic this behaviour |
|
336 # (note: skip indenting this as it will surely be removed anyway) |
|
337 # <weird code /> |
|
338 |
|
339 ifneq (,$$($1_DEBUG_SYMBOLS)) |
|
340 $1_OPTIMIZATION := LOW |
|
341 $1_EXTRA_CFLAGS += $(CFLAGS_DEBUG_SYMBOLS) |
|
342 $1_EXTRA_CXXFLAGS += $(CXXFLAGS_DEBUG_SYMBOLS) |
|
343 endif |
|
344 |
|
345 # <weird code /> |
|
346 endif |
|
347 # <weird code /> |
|
348 endif |
|
349 |
|
350 ifeq (NONE, $$($1_OPTIMIZATION)) |
|
351 $1_EXTRA_CFLAGS += $$(C_O_FLAG_NONE) |
|
352 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NONE) |
|
353 else ifeq (LOW, $$($1_OPTIMIZATION)) |
|
354 $1_EXTRA_CFLAGS += $$(C_O_FLAG_NORM) |
|
355 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NORM) |
|
356 else ifeq (HIGH, $$($1_OPTIMIZATION)) |
|
357 $1_EXTRA_CFLAGS += $$(C_O_FLAG_HI) |
|
358 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HI) |
|
359 else ifeq (HIGHEST, $$($1_OPTIMIZATION)) |
|
360 $1_EXTRA_CFLAGS += $$(C_O_FLAG_HIGHEST) |
|
361 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HIGHEST) |
|
362 else ifneq (, $$($1_OPTIMIZATION)) |
|
363 $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) |
|
364 endif |
|
365 |
235 # Now create a list of the packages that are about to compile. Used when sending source |
366 # Now create a list of the packages that are about to compile. Used when sending source |
236 # in a batch to the compiler. |
367 # in a batch to the compiler. |
237 $$(shell $(RM) $$($1_BIN)/_the.list_of_sources) |
368 $$(shell $(RM) $$($1_OBJECT_DIR)/_the.list_of_sources) |
238 $$(eval $$(call ListPathsSafelyNow,$1_SRCS,\n, >> $$($1_BIN)/_the.list_of_sources)) |
369 $$(eval $$(call ListPathsSafelyNow,$1_SRCS,\n, >> $$($1_OBJECT_DIR)/_the.list_of_sources)) |
239 |
370 |
240 # Now call add_native_source for each source file we are going to compile. |
371 # Now call add_native_source for each source file we are going to compile. |
241 $$(foreach p,$$($1_SRCS),\ |
372 $$(foreach p,$$($1_SRCS),\ |
242 $$(eval $$(call add_native_source,$1,$$p,$$($1_BIN),\ |
373 $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR),\ |
243 $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$(CC),\ |
374 $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC),\ |
244 $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX)))) |
375 $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS)))) |
245 |
376 |
246 # On windows we need to create a resource file |
377 # On windows we need to create a resource file |
247 ifeq ($(HOST_OS_API), winapi) |
378 ifeq ($(OPENJDK_TARGET_OS_API), winapi) |
248 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
379 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
249 ifneq (,$$($1_LIB)) |
380 $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res |
250 $1_BASENAME:=$$(basename $$(notdir $$($1_LIB))) |
|
251 endif |
|
252 ifneq (,$$($1_EXE)) |
|
253 $1_BASENAME:=$$(basename $$(notdir $$($1_EXE))) |
|
254 endif |
|
255 $1_RES:=$$($1_BIN)/$$($1_BASENAME).res |
|
256 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
381 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
257 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
382 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
258 endif |
383 endif |
259 ifneq (,$$($1_MANIFEST)) |
384 ifneq (,$$($1_MANIFEST)) |
260 $1_PROGRAM:=$$(basename $$(notdir $$($1_EXE))) |
385 $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest |
261 $1_GEN_MANIFEST:=$$($1_BIN)/$$($1_PROGRAM).manifest |
|
262 IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) |
386 IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) |
263 $$($1_GEN_MANIFEST): $$($1_MANIFEST) |
387 $$($1_GEN_MANIFEST): $$($1_MANIFEST) |
264 $(SED) 's%IMVERSION%$$(IMVERSIONVALUE)%g;s%PROGRAM%$$($1_PROGRAM)%g' $$< > $$@ |
388 $(SED) 's%IMVERSION%$$(IMVERSIONVALUE)%g;s%PROGRAM%$$($1_PROGRAM)%g' $$< > $$@ |
265 endif |
389 endif |
266 endif |
390 endif |
267 |
391 |
268 # mapfile doesnt seem to be implemented on macosx (yet??) |
392 # mapfile doesnt seem to be implemented on macosx (yet??) |
269 ifneq ($(HOST_OS),macosx) |
393 ifneq ($(OPENJDK_TARGET_CPU),ppc) |
270 ifneq ($(HOST_OS),windows) |
394 ifneq ($(OPENJDK_TARGET_CPU),arm) |
271 $1_REAL_MAPFILE := $$($1_MAPFILE) |
395 ifneq ($(OPENJDK_TARGET_OS),macosx) |
|
396 ifneq ($(OPENJDK_TARGET_OS),windows) |
|
397 $1_REAL_MAPFILE:=$$($1_MAPFILE) |
272 ifneq (,$$($1_REORDER)) |
398 ifneq (,$$($1_REORDER)) |
273 $1_REAL_MAPFILE := $$($1_BIN)/mapfile |
399 $1_REAL_MAPFILE:=$$($1_OBJECT_DIR)/mapfile |
274 |
400 |
275 $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) |
401 $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) |
276 $$(MKDIR) -p $$(@D) |
402 $$(MKDIR) -p $$(@D) |
277 $$(CP) $$($1_MAPFILE) $$@.tmp |
403 $$(CP) $$($1_MAPFILE) $$@.tmp |
278 $$(SED) -e 's=OUTPUTDIR=$$($1_BIN)=' $$($1_REORDER) >> $$@.tmp |
404 $$(SED) -e 's=OUTPUTDIR=$$($1_OBJECT_DIR)=' $$($1_REORDER) >> $$@.tmp |
279 $$(MV) $$@.tmp $$@ |
405 $$(MV) $$@.tmp $$@ |
280 endif |
406 endif |
281 endif |
407 endif |
282 endif |
408 endif |
283 |
409 endif |
284 # Pickup extra HOST_OS_API dependent variables (posix or winapi) and |
410 endif |
|
411 |
|
412 # Pickup extra OPENJDK_TARGET_OS_API dependent variables (posix or winapi) and |
285 # (linux,solaris,windows,bsd) for LDFLAGS and LDFLAGS_SUFFIX |
413 # (linux,solaris,windows,bsd) for LDFLAGS and LDFLAGS_SUFFIX |
286 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(HOST_OS_API)) $$($1_LDFLAGS_$(PLATFORM)) |
414 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) |
287 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(HOST_OS_API)) $$($1_LDFLAGS_SUFFIX_$(PLATFORM)) |
415 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) |
288 ifneq (,$$($1_REAL_MAPFILE)) |
416 ifneq (,$$($1_REAL_MAPFILE)) |
289 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
417 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
290 endif |
418 endif |
291 |
419 |
292 ifneq (,$$($1_LIB)) |
420 $1 := $$($1_TARGET) |
293 ifeq (dynamic,$$(patsubst %$(SHARED_LIBRARY_SUFFIX),dynamic,$$($1_LIB))) |
421 ifneq (,$$($1_LIBRARY)) |
294 # Generating a dynamic library. |
422 # Generating a dynamic library. |
295 $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$(notdir $$($1_LIB))) |
423 $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME)) |
296 $$($1_LIB) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) |
424 ifeq ($(OPENJDK_TARGET_OS), windows) |
297 $$(call LINKING_MSG,$$(notdir $$($1_LIB))) |
425 $1_EXTRA_LDFLAGS+="-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib" |
298 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$($1_LIB) \ |
426 endif |
299 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) |
427 |
300 else |
428 ifneq (,$$($1_DEBUG_SYMBOLS)) |
301 # Generating a static library, ie object file archive. |
429 ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) |
302 $$($1_LIB) : $$($1_EXPECTED_OBJS) $$($1_RES) |
430 ifeq ($(OPENJDK_TARGET_OS), windows) |
303 $$(call ARCHIVING_MSG,$$(notdir $$($1_LIB))) |
431 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_LIBRARY).pdb" \ |
304 $(AR) $$($1_AR_FLAGS) $(AR_OUT_OPTION)$$($1_LIB) $$($1_EXPECTED_OBJS) \ |
432 "-map:$$($1_OBJECT_DIR)/$$($1_LIBRARY).map" |
|
433 endif |
|
434 |
|
435 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
|
436 $(CP) $$< $$@ |
|
437 |
|
438 |
|
439 ifeq ($(OPENJDK_TARGET_OS), solaris) |
|
440 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. |
|
441 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from |
|
442 # empty section headers until a fixed $(OBJCOPY) is available. |
|
443 # An empty section header has sh_addr == 0 and sh_size == 0. |
|
444 # This problem has only been seen on Solaris X64, but we call this tool |
|
445 # on all Solaris builds just in case. |
|
446 # |
|
447 # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. |
|
448 # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. |
|
449 $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ |
|
450 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) |
|
451 $(RM) $$@ |
|
452 $(FIX_EMPTY_SEC_HDR_FLAGS) $$< |
|
453 $(OBJCOPY) --only-keep-debug $$< $$@ |
|
454 $(ADD_GNU_DEBUGLINK) $$@ $$< |
|
455 else # not solaris |
|
456 $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) |
|
457 $(RM) $$@ |
|
458 $(OBJCOPY) --only-keep-debug $$< $$@ |
|
459 $(OBJCOPY) --add-gnu-debuglink=$$@ $$< |
|
460 endif |
|
461 |
|
462 ifeq ($(ZIP_DEBUGINFO_FILES), 1) |
|
463 $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz |
|
464 |
|
465 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
466 $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz : $$($1_TARGET) |
|
467 $(CD) $$($1_OBJECT_DIR) \ |
|
468 && $(ZIP) -q $$@ $$($1_LIBRARY).map $$($1_LIBRARY).pdb |
|
469 else |
|
470 $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz : $$($1_TARGET) \ |
|
471 $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo |
|
472 $(CD) $$($1_OBJECT_DIR) \ |
|
473 && $(ZIP) -q $$@ $$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo |
|
474 endif |
|
475 else |
|
476 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
477 $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \ |
|
478 $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb |
|
479 else |
|
480 $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo |
|
481 endif |
|
482 endif |
|
483 endif |
|
484 endif |
|
485 |
|
486 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) |
|
487 $$(call LINKING_MSG,$$($1_BASENAME)) |
|
488 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \ |
|
489 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ |
|
490 $$($1_EXTRA_LDFLAGS_SUFFIX) |
|
491 |
|
492 endif |
|
493 |
|
494 ifneq (,$$($1_STATIC_LIBRARY)) |
|
495 # Generating a static library, ie object file archive. |
|
496 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) |
|
497 $$(call ARCHIVING_MSG,$$($1_LIBRARY)) |
|
498 $(AR) $$($1_AR_FLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \ |
305 $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) |
499 $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) |
306 endif |
500 endif |
307 endif |
501 |
308 ifneq (,$$($1_EXE)) |
502 ifneq (,$$($1_PROGRAM)) |
309 # A executable binary has been specified, setup the target for it. |
503 # A executable binary has been specified, setup the target for it. |
310 $$($1_EXE) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) |
504 ifneq (,$$($1_DEBUG_SYMBOLS)) |
311 $$(call LINKING_EXE_MSG,$$(notdir $$($1_EXE))) |
505 ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) |
312 $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_EXE) \ |
506 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
507 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_PROGRAM).pdb" \ |
|
508 "-map:$$($1_OBJECT_DIR)/$$($1_PROGRAM).map" |
|
509 endif |
|
510 |
|
511 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
|
512 $(CP) $$< $$@ |
|
513 |
|
514 ifeq ($(OPENJDK_TARGET_OS), solaris) |
|
515 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. |
|
516 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from |
|
517 # empty section headers until a fixed $(OBJCOPY) is available. |
|
518 # An empty section header has sh_addr == 0 and sh_size == 0. |
|
519 # This problem has only been seen on Solaris X64, but we call this tool |
|
520 # on all Solaris builds just in case. |
|
521 # |
|
522 # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. |
|
523 # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. |
|
524 $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ |
|
525 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) |
|
526 $(RM) $$@ |
|
527 $(FIX_EMPTY_SEC_HDR_FLAGS) $$< |
|
528 $(OBJCOPY) --only-keep-debug $$< $$@ |
|
529 $(ADD_GNU_DEBUGLINK) $$@ $$< |
|
530 else # not solaris |
|
531 $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) |
|
532 $(RM) $$@ |
|
533 $(OBJCOPY) --only-keep-debug $$< $$@ |
|
534 $(OBJCOPY) --add-gnu-debuglink=$$@ $$< |
|
535 endif |
|
536 |
|
537 ifeq ($(ZIP_DEBUGINFO_FILES), 1) |
|
538 $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).diz |
|
539 |
|
540 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
541 $$($1_OBJECT_DIR)/$$($1_PROGRAM).diz : $$($1_TARGET) |
|
542 $(CD) $$($1_OBJECT_DIR) \ |
|
543 && $(ZIP) -q $$@ $$($1_PROGRAM).map $$($1_PROGRAM).pdb |
|
544 else |
|
545 $$($1_OBJECT_DIR)/$$(PROGRAM_PREFIX)$$($1_PROGRAM).diz : $$($1_TARGET) \ |
|
546 $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo |
|
547 $(CD) $$($1_OBJECT_DIR) \ |
|
548 && $(ZIP) -q $$@ $$($1_PROGRAM).debuginfo |
|
549 endif |
|
550 else |
|
551 ifeq ($(OPENJDK_TARGET_OS), windows) |
|
552 $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \ |
|
553 $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb |
|
554 else |
|
555 $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo |
|
556 endif |
|
557 endif |
|
558 endif |
|
559 endif |
|
560 |
|
561 $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) |
|
562 $$(call LINKING_EXE_MSG,$$($1_BASENAME)) |
|
563 $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \ |
313 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ |
564 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ |
314 $$($1_EXTRA_LDFLAGS_SUFFIX) |
565 $$($1_EXTRA_LDFLAGS_SUFFIX) |
315 ifneq (,$$($1_GEN_MANIFEST)) |
566 ifneq (,$$($1_GEN_MANIFEST)) |
316 $(MT) -nologo /manifest $$($1_GEN_MANIFEST) /outputresource:$$@;#1 |
567 $(MT) -nologo /manifest $$($1_GEN_MANIFEST) /outputresource:$$@;#1 |
317 endif |
568 endif |
|
569 |
318 endif |
570 endif |
319 endef |
571 endef |