1.1 --- a/common/makefiles/NativeCompilation.gmk Fri Jun 01 14:11:59 2012 -0700 1.2 +++ b/common/makefiles/NativeCompilation.gmk Thu Jun 07 20:25:06 2012 -0700 1.3 @@ -28,7 +28,7 @@ 1.4 # desired whenever sort is used below! 1.5 1.6 ifeq (,$(_MAKEBASE_GMK)) 1.7 - $(error You must include MakeBase.gmk prior to including JavaCompilation.gmk) 1.8 + $(error You must include MakeBase.gmk prior to including NativeCompilation.gmk) 1.9 endif 1.10 1.11 ifeq ($(COMPILER_TYPE),CC) 1.12 @@ -54,15 +54,22 @@ 1.13 1.14 ifneq (,$$(filter %.c,$2)) 1.15 # Compile as a C file 1.16 - $1_$2_FLAGS=$4 1.17 + $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) 1.18 $1_$2_COMP=$5 1.19 + $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) 1.20 + else ifneq (,$$(filter %.m,$2)) 1.21 + # Compile as a objective-c file 1.22 + $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) 1.23 + $1_$2_COMP=$5 1.24 + $1_$2_DEP_FLAG:=$(C_FLAG_DEPS) 1.25 else 1.26 # Compile as a C++ file 1.27 - $1_$2_FLAGS=$6 1.28 + $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) 1.29 $1_$2_COMP=$7 1.30 + $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS) 1.31 endif 1.32 # Generate the .o (.obj) file name and place it in the bin dir. 1.33 - $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(notdir $2))) 1.34 + $1_$2_OBJ:=$3/$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(notdir $2)))) 1.35 # Only continue if this object file hasn't been processed already. This lets the first found 1.36 # source file override any other with the same name. 1.37 ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR))) 1.38 @@ -80,7 +87,7 @@ 1.39 $$($1_$2_OBJ) : $2 1.40 ifeq ($(COMPILER_TYPE),CC) 1.41 $$(call COMPILING_MSG,$$(notdir $2)) 1.42 - $$($1_$2_COMP) $$($1_$2_FLAGS) -MMD -MF $$($1_$2_DEP) -c $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 1.43 + $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) -c $(CC_OUT_OPTION)$$($1_$2_OBJ) $2 1.44 endif 1.45 ifeq ($(COMPILER_TYPE),CL) 1.46 $$(call COMPILING_MSG,$$(notdir $2)) 1.47 @@ -109,6 +116,8 @@ 1.48 # EXCLUDE_FILES with these names 1.49 # VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run 1.50 # RC_FLAGS flags for RC. 1.51 + # MAPFILE mapfile 1.52 + # REORDER reorder file 1.53 $(if $2,$1_$(strip $2)) 1.54 $(if $3,$1_$(strip $3)) 1.55 $(if $4,$1_$(strip $4)) 1.56 @@ -154,7 +163,7 @@ 1.57 ifneq ($$($1_EXCLUDE_FILES),) 1.58 $1_EXCLUDE_FILES:=$$(addprefix %,$$($1_EXCLUDE_FILES)) 1.59 endif 1.60 - $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter %.c %.cpp,$$($1_ALL_SRCS))) 1.61 + $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES),$$(filter %.c %.cpp %.m,$$($1_ALL_SRCS))) 1.62 ifneq (,$$(strip $$($1_INCLUDE_FILES))) 1.63 $1_SRCS := $$(filter $$($1_INCLUDE_FILES),$$($1_SRCS)) 1.64 endif 1.65 @@ -178,7 +187,7 @@ 1.66 1.67 # Calculate the expected output from compiling the sources (sort to remove duplicates. Also provides 1.68 # a reproducable order on the input files to the linker). 1.69 - $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_BIN)/,$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(notdir $$($1_SRCS)))))) 1.70 + $1_EXPECTED_OBJS:=$$(sort $$(addprefix $$($1_BIN)/,$$(patsubst %.cpp,%$(OBJ_SUFFIX),$$(patsubst %.c,%$(OBJ_SUFFIX),$$(patsubst %.m,%$(OBJ_SUFFIX),$$(notdir $$($1_SRCS))))))) 1.71 $1 := $$($1_EXPECTED_OBJS) 1.72 # Are there too many object files on disk? Perhaps because some source file was removed? 1.73 $1_SUPERFLOUS_OBJS:=$$(sort $$(filter-out $$($1_EXPECTED_OBJS),$$($1_BINS))) 1.74 @@ -218,6 +227,11 @@ 1.75 $1_EXTRA_CXXFLAGS:=$$($1_EXTRA_CFLAGS) 1.76 endif 1.77 1.78 + ifneq (,$$($1_REORDER)) 1.79 + $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER) 1.80 + $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER) 1.81 + endif 1.82 + 1.83 # Now create a list of the packages that are about to compile. Used when sending source 1.84 # in a batch to the compiler. 1.85 $$(shell $(RM) $$($1_BIN)/_the.list_of_sources) 1.86 @@ -233,29 +247,53 @@ 1.87 ifeq ($(HOST_OS_API), winapi) 1.88 ifneq (,$$($1_VERSIONINFO_RESOURCE)) 1.89 ifneq (,$$($1_LIB)) 1.90 - ifeq (dynamic,$$(patsubst %$(SHARED_LIBRARY_SUFFIX),dynamic,$$($1_LIB))) 1.91 - $1_RES:=$$(patsubst %$(SHARED_LIBRARY_SUFFIX),%.res,$$($1_LIB)) 1.92 - else 1.93 - $1_RES:=$$(patsubst %$(STATIC_LIBRARY_SUFFIX),%.res,$$($1_LIB)) 1.94 - endif 1.95 + $1_BASENAME:=$$(basename $$(notdir $$($1_LIB))) 1.96 endif 1.97 ifneq (,$$($1_EXE)) 1.98 - $1_RES:=$$(patsubst %$(EXE_SUFFIX),%.res,$$($1_EXE)) 1.99 + $1_BASENAME:=$$(basename $$(notdir $$($1_EXE))) 1.100 endif 1.101 + $1_RES:=$$($1_BIN)/$$($1_BASENAME).res 1.102 $$($1_RES): $$($1_VERSIONINFO_RESOURCE) 1.103 $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE) 1.104 endif 1.105 + ifneq (,$$($1_MANIFEST)) 1.106 + $1_PROGRAM:=$$(basename $$(notdir $$($1_EXE))) 1.107 + $1_GEN_MANIFEST:=$$($1_BIN)/$$($1_PROGRAM).manifest 1.108 + IMVERSIONVALUE:=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VERSION).$(COOKED_BUILD_NUMBER) 1.109 + $$($1_GEN_MANIFEST): $$($1_MANIFEST) 1.110 + $(SED) 's%IMVERSION%$$(IMVERSIONVALUE)%g;s%PROGRAM%$$($1_PROGRAM)%g' $$< > $$@ 1.111 + endif 1.112 + endif 1.113 + 1.114 + # mapfile doesnt seem to be implemented on macosx (yet??) 1.115 + ifneq ($(HOST_OS),macosx) 1.116 + ifneq ($(HOST_OS),windows) 1.117 + $1_REAL_MAPFILE := $$($1_MAPFILE) 1.118 + ifneq (,$$($1_REORDER)) 1.119 + $1_REAL_MAPFILE := $$($1_BIN)/mapfile 1.120 + 1.121 + $$($1_REAL_MAPFILE) : $$($1_MAPFILE) $$($1_REORDER) 1.122 + $$(MKDIR) -p $$(@D) 1.123 + $$(CP) $$($1_MAPFILE) $$@.tmp 1.124 + $$(SED) -e 's=OUTPUTDIR=$$($1_BIN)=' $$($1_REORDER) >> $$@.tmp 1.125 + $$(MV) $$@.tmp $$@ 1.126 + endif 1.127 + endif 1.128 endif 1.129 1.130 # Pickup extra HOST_OS_API dependent variables (posix or winapi) and 1.131 # (linux,solaris,windows,bsd) for LDFLAGS and LDFLAGS_SUFFIX 1.132 $1_EXTRA_LDFLAGS:=$$($1_LDFLAGS_$(HOST_OS_API)) $$($1_LDFLAGS_$(PLATFORM)) 1.133 $1_EXTRA_LDFLAGS_SUFFIX:=$$($1_LDFLAGS_SUFFIX_$(HOST_OS_API)) $$($1_LDFLAGS_SUFFIX_$(PLATFORM)) 1.134 + ifneq (,$$($1_REAL_MAPFILE)) 1.135 + $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE)) 1.136 + endif 1.137 + 1.138 ifneq (,$$($1_LIB)) 1.139 ifeq (dynamic,$$(patsubst %$(SHARED_LIBRARY_SUFFIX),dynamic,$$($1_LIB))) 1.140 # Generating a dynamic library. 1.141 $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$(notdir $$($1_LIB))) 1.142 - $$($1_LIB) : $$($1_EXPECTED_OBJS) $$($1_RES) 1.143 + $$($1_LIB) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) 1.144 $$(call LINKING_MSG,$$(notdir $$($1_LIB))) 1.145 $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$($1_LIB) \ 1.146 $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 1.147 @@ -269,9 +307,13 @@ 1.148 endif 1.149 ifneq (,$$($1_EXE)) 1.150 # A executable binary has been specified, setup the target for it. 1.151 - $$($1_EXE) : $$($1_EXPECTED_OBJS) $$($1_RES) 1.152 + $$($1_EXE) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) 1.153 $$(call LINKING_EXE_MSG,$$(notdir $$($1_EXE))) 1.154 $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_EXE) \ 1.155 - $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX) 1.156 + $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \ 1.157 + $$($1_EXTRA_LDFLAGS_SUFFIX) 1.158 + ifneq (,$$($1_GEN_MANIFEST)) 1.159 + $(MT) -nologo /manifest $$($1_GEN_MANIFEST) /outputresource:$$@;#1 1.160 + endif 1.161 endif 1.162 endef