53 # param 7 = the c++ compiler |
53 # param 7 = the c++ compiler |
54 # param 8 = the flags to the assembler |
54 # param 8 = the flags to the assembler |
55 |
55 |
56 ifneq (,$$(filter %.c,$2)) |
56 ifneq (,$$(filter %.c,$2)) |
57 # Compile as a C file |
57 # Compile as a C file |
58 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -c |
58 $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
59 $1_$2_COMP=$5 |
59 $1_$2_COMP=$5 |
60 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
60 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
61 else ifneq (,$$(filter %.m,$2)) |
61 else ifneq (,$$(filter %.m,$2)) |
62 # Compile as a objective-c file |
62 # Compile as a objective-c file |
63 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -c |
63 $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
64 $1_$2_COMP=$5 |
64 $1_$2_COMP=$5 |
65 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
65 $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) |
66 else ifneq (,$$(filter %.s,$2)) |
66 else ifneq (,$$(filter %.s,$2)) |
67 # Compile as assembler file |
67 # Compile as assembler file |
68 $1_$2_FLAGS=$8 |
68 $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"' |
69 $1_$2_COMP=$(AS) |
69 $1_$2_COMP=$(AS) |
70 $1_$2_DEP_FLAG:= |
70 $1_$2_DEP_FLAG:= |
71 else |
71 else |
72 # Compile as a C++ file |
72 # Compile as a C++ file |
73 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -c |
73 $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c |
74 $1_$2_COMP=$7 |
74 $1_$2_COMP=$7 |
75 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
75 $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) |
76 endif |
76 endif |
77 # 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. |
78 $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(patsubst %.s,%$(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))))) |
96 ifeq ($(COMPILER_TYPE),CC) |
96 ifeq ($(COMPILER_TYPE),CC) |
97 $$(call COMPILING_MSG,$$(notdir $2)) |
97 $$(call COMPILING_MSG,$$(notdir $2)) |
98 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(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 |
99 endif |
99 endif |
100 ifeq ($(COMPILER_TYPE),CL) |
100 ifeq ($(COMPILER_TYPE),CL) |
101 $$(call COMPILING_MSG,$$(notdir $2)) |
|
102 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
101 $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEBUG_OUT_FLAGS) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 |
103 endif |
102 endif |
104 endif |
103 endif |
105 endef |
104 endef |
106 |
105 |
127 # MAPFILE mapfile |
126 # MAPFILE mapfile |
128 # REORDER reorder file |
127 # REORDER reorder file |
129 # DEBUG_SYMBOLS add debug symbols (if configured on) |
128 # DEBUG_SYMBOLS add debug symbols (if configured on) |
130 # CC the compiler to use, default is $(CC) |
129 # CC the compiler to use, default is $(CC) |
131 # LDEXE the linker to use for linking executables, default is $(LDEXE) |
130 # LDEXE the linker to use for linking executables, default is $(LDEXE) |
|
131 # OPTIMIZATION sets optimization level to NONE, LOW, HIGH, HIGHEST |
132 $(if $2,$1_$(strip $2)) |
132 $(if $2,$1_$(strip $2)) |
133 $(if $3,$1_$(strip $3)) |
133 $(if $3,$1_$(strip $3)) |
134 $(if $4,$1_$(strip $4)) |
134 $(if $4,$1_$(strip $4)) |
135 $(if $5,$1_$(strip $5)) |
135 $(if $5,$1_$(strip $5)) |
136 $(if $6,$1_$(strip $6)) |
136 $(if $6,$1_$(strip $6)) |
147 $(if $(17),$1_$(strip $(17))) |
147 $(if $(17),$1_$(strip $(17))) |
148 $(if $(18),$1_$(strip $(18))) |
148 $(if $(18),$1_$(strip $(18))) |
149 $(if $(19),$1_$(strip $(19))) |
149 $(if $(19),$1_$(strip $(19))) |
150 $(if $(20),$1_$(strip $(20))) |
150 $(if $(20),$1_$(strip $(20))) |
151 $(if $(21),$1_$(strip $(21))) |
151 $(if $(21),$1_$(strip $(21))) |
152 $(if $(22),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
152 $(if $(22),$1_$(strip $(22))) |
|
153 $(if $(23),$1_$(strip $(23))) |
|
154 $(if $(24),$1_$(strip $(24))) |
|
155 $(if $(25),$1_$(strip $(25))) |
|
156 $(if $(26),$(error Internal makefile error: Too many arguments to SetupNativeCompilation, please update NativeCompilation.gmk)) |
153 |
157 |
154 ifneq (,$$($1_BIN)) |
158 ifneq (,$$($1_BIN)) |
155 $$(error BIN has been replaced with OBJECT_DIR) |
159 $$(error BIN has been replaced with OBJECT_DIR) |
156 endif |
160 endif |
157 |
161 |
313 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
317 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_release) |
314 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
318 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_API)_release) |
315 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) |
319 $1_EXTRA_CXXFLAGS+=$$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release) |
316 endif |
320 endif |
317 |
321 |
|
322 ifneq (,$$($1_DEBUG_SYMBOLS)) |
|
323 ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) |
|
324 # Programs don't get the debug symbols added in the old build. It's not clear if |
|
325 # this is intentional. |
|
326 ifeq ($$($1_PROGRAM),) |
|
327 $1_EXTRA_CFLAGS+=$(CFLAGS_DEBUG_SYMBOLS) |
|
328 $1_EXTRA_CXXFLAGS+=$(CXXFLAGS_DEBUG_SYMBOLS) |
|
329 endif |
|
330 endif |
|
331 endif |
|
332 |
318 ifeq ($$($1_CXXFLAGS),) |
333 ifeq ($$($1_CXXFLAGS),) |
319 $1_CXXFLAGS:=$$($1_CFLAGS) |
334 $1_CXXFLAGS:=$$($1_CFLAGS) |
320 endif |
335 endif |
321 ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),) |
336 ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)),) |
322 $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS) |
337 $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS) |
325 ifneq (,$$($1_REORDER)) |
340 ifneq (,$$($1_REORDER)) |
326 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
341 $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) |
327 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
342 $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) |
328 endif |
343 endif |
329 |
344 |
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)) |
345 ifeq (NONE, $$($1_OPTIMIZATION)) |
351 $1_EXTRA_CFLAGS += $$(C_O_FLAG_NONE) |
346 $1_EXTRA_CFLAGS += $(C_O_FLAG_NONE) |
352 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NONE) |
347 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NONE) |
353 else ifeq (LOW, $$($1_OPTIMIZATION)) |
348 else ifeq (LOW, $$($1_OPTIMIZATION)) |
354 $1_EXTRA_CFLAGS += $$(C_O_FLAG_NORM) |
349 $1_EXTRA_CFLAGS += $(C_O_FLAG_NORM) |
355 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_NORM) |
350 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NORM) |
356 else ifeq (HIGH, $$($1_OPTIMIZATION)) |
351 else ifeq (HIGH, $$($1_OPTIMIZATION)) |
357 $1_EXTRA_CFLAGS += $$(C_O_FLAG_HI) |
352 $1_EXTRA_CFLAGS += $(C_O_FLAG_HI) |
358 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HI) |
353 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HI) |
359 else ifeq (HIGHEST, $$($1_OPTIMIZATION)) |
354 else ifeq (HIGHEST, $$($1_OPTIMIZATION)) |
360 $1_EXTRA_CFLAGS += $$(C_O_FLAG_HIGHEST) |
355 $1_EXTRA_CFLAGS += $(C_O_FLAG_HIGHEST) |
361 $1_EXTRA_CXXFLAGS += $$(CXX_O_FLAG_HIGHEST) |
356 $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_HIGHEST) |
362 else ifneq (, $$($1_OPTIMIZATION)) |
357 else ifneq (, $$($1_OPTIMIZATION)) |
363 $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) |
358 $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION)) |
364 endif |
359 endif |
365 |
360 |
366 # Now create a list of the packages that are about to compile. Used when sending source |
361 # Now create a list of the packages that are about to compile. Used when sending source |
367 # in a batch to the compiler. |
362 # in a batch to the compiler. |
368 $$(shell $(RM) $$($1_OBJECT_DIR)/_the.list_of_sources) |
363 $$(shell $(RM) $$($1_OBJECT_DIR)/_the.list_of_sources) |
373 $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR),\ |
368 $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR),\ |
374 $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC),\ |
369 $$($1_CFLAGS) $$($1_EXTRA_CFLAGS),$$($1_CC),\ |
375 $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS)))) |
370 $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS),$(CXX),$$($1_ASFLAGS)))) |
376 |
371 |
377 # On windows we need to create a resource file |
372 # On windows we need to create a resource file |
378 ifeq ($(OPENJDK_TARGET_OS_API), winapi) |
373 ifeq ($(OPENJDK_TARGET_OS), windows) |
379 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
374 ifneq (,$$($1_VERSIONINFO_RESOURCE)) |
380 $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res |
375 $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res |
381 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
376 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) |
382 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
377 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) |
383 endif |
378 endif |
407 endif |
402 endif |
408 endif |
403 endif |
409 endif |
404 endif |
410 endif |
405 endif |
411 |
406 |
412 # Pickup extra OPENJDK_TARGET_OS_API dependent variables (posix or winapi) and |
407 # Pickup extra OPENJDK_TARGET_OS_API and/or OPENJDK_TARGET_OS dependent variables |
413 # (linux,solaris,windows,bsd) for LDFLAGS and LDFLAGS_SUFFIX |
408 # for LDFLAGS and LDFLAGS_SUFFIX |
414 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) |
409 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) |
415 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) |
410 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS_API)) $$($1_LDFLAGS_SUFFIX_$(OPENJDK_TARGET_OS)) |
416 ifneq (,$$($1_REAL_MAPFILE)) |
411 ifneq (,$$($1_REAL_MAPFILE)) |
417 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
412 $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) |
418 endif |
413 endif |
430 ifeq ($(OPENJDK_TARGET_OS), windows) |
425 ifeq ($(OPENJDK_TARGET_OS), windows) |
431 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_LIBRARY).pdb" \ |
426 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_LIBRARY).pdb" \ |
432 "-map:$$($1_OBJECT_DIR)/$$($1_LIBRARY).map" |
427 "-map:$$($1_OBJECT_DIR)/$$($1_LIBRARY).map" |
433 endif |
428 endif |
434 |
429 |
435 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
430 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) |
|
431 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
436 $(CP) $$< $$@ |
432 $(CP) $$< $$@ |
437 |
433 endif |
438 |
434 |
439 ifeq ($(OPENJDK_TARGET_OS), solaris) |
435 ifeq ($(OPENJDK_TARGET_OS), solaris) |
440 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. |
436 # 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 |
437 # 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. |
438 # empty section headers until a fixed $(OBJCOPY) is available. |
507 ifeq ($(OPENJDK_TARGET_OS), windows) |
503 ifeq ($(OPENJDK_TARGET_OS), windows) |
508 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_PROGRAM).pdb" \ |
504 $1_EXTRA_LDFLAGS+="-pdb:$$($1_OBJECT_DIR)/$$($1_PROGRAM).pdb" \ |
509 "-map:$$($1_OBJECT_DIR)/$$($1_PROGRAM).map" |
505 "-map:$$($1_OBJECT_DIR)/$$($1_PROGRAM).map" |
510 endif |
506 endif |
511 |
507 |
512 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
508 ifneq ($$($1_OUTPUT_DIR),$$($1_OBJECT_DIR)) |
|
509 $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% |
513 $(CP) $$< $$@ |
510 $(CP) $$< $$@ |
|
511 endif |
514 |
512 |
515 ifeq ($(OPENJDK_TARGET_OS), solaris) |
513 ifeq ($(OPENJDK_TARGET_OS), solaris) |
516 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. |
514 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. |
517 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from |
515 # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from |
518 # empty section headers until a fixed $(OBJCOPY) is available. |
516 # empty section headers until a fixed $(OBJCOPY) is available. |