Changeset 73 for trunk/kBuild
- Timestamp:
- May 31, 2004, 3:11:52 AM (21 years ago)
- Location:
- trunk/kBuild
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer.kmk
r72 r73 30 30 # 31 31 # Variables. 32 # (Some of these need initialization before including definitions using them.) 32 33 # 33 34 … … 47 48 endef 48 49 $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := )) 50 51 # misc 52 type := 53 54 55 # 56 # Basic macros 57 # 58 59 ## Figure out the tool for a source 60 # @param $1 source file 61 # @param $2 normalized main target 62 _SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL) ) 63 64 ## Figure out where to put object files. 65 # @param $1 source file 66 # @param $2 normalized main target 67 _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1)) 68 69 ## Figure out where to put object files. 70 # @param $1 real target name. 71 # @param $2 normalized main target 72 _TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1)) 73 49 74 50 75 # … … 154 179 # 155 180 # Include SDKs 156 # 181 # 157 182 _SDKS := $(SDKS) 158 183 define def_sdks_target_source … … 175 200 $(foreach sdk, $(_SDKS), $(eval $(def_sdk))) 176 201 202 # 203 # Object processing. 204 # 205 206 ## Generic macro for processing C, C++ and Assembly sources. 207 # @param $(target) Normalized target name. 208 # @param $(source) Source file name. 209 # @param $(type) Source type. {C,CXX,AS} 210 # 211 # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug? 212 define def_target_source_c_cpp_asm 213 #$ (warning dbg: def_target_source_c_cpp_asm: source=$(source) target=$(target) type=$(type)) 214 215 $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target))) 216 $(eval defs :=\ 217 $($(target)_$(source)_$(type)DEFS)\ 218 $($(target)_$(source)_DEFS)\ 219 $($(source)_$(type)DEFS)\ 220 $($(source)_DEFS)\ 221 $($(target)_$(type)DEFS)\ 222 $($(target)_DEFS)\ 223 $(DEFS)\ 224 $(TOOL_$(tool)_$(type)DEFS)\ 225 ) 226 $(eval incs :=\ 227 $($(target)_$(source)_$(type)INCS)\ 228 $($(target)_$(source)_INCS)\ 229 $($(source)_$(type)INCS)\ 230 $($(source)_INCS)\ 231 $($(target)_$(type)INCS)\ 232 $($(target)_INCS)\ 233 $(INCS)\ 234 $(TOOL_$(tool)_$(type)INCS)\ 235 ) 236 $(eval flags :=\ 237 $(TOOL_$(tool)_$(type)FLAGS)\ 238 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\ 239 $($(type)FLAGS)\ 240 $($(type)FLAGS.$(BUILD_TYPE))\ 241 $($(target)_$(type)FLAGS)\ 242 $($(target)_$(type)FLAGS.$(BUILD_TYPE))\ 243 $($(source)_$(type)FLAGS)\ 244 $($(source)_$(type)FLAGS.$(BUILD_TYPE))\ 245 $($(target)_$(source)_$(type)FLAGS)\ 246 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\ 247 ) 248 $(eval outbase := $(call _OBJECT_BASE,$(source),$(target))) 249 $(eval dirdep := $(dir $(outbase)).dir_created) 250 $(eval objsuff := $(firstword $($(target)_$(source)_OBJSUFF) $($(source)_OBJSUFF) $($(target)_OBJSUFF) $(TOOL_$(tool)_$(type)OBJSUFF) $(SUFF_OBJ))) 251 $(eval obj := $(outbase)$(objsuff)) 252 $(eval depfile := $(outbase)$(SUFF_DEP)) 253 254 #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff)) 255 $(eval $(TOOL_$(tool)_COMPILE_$(type))) 256 257 $(eval _OBJS_$(target) += $(obj)) 258 $(eval _DEPFILES += $(dep)) 259 260 endef 261 262 ## Generic macro for processing all target sources. 263 # @param $target Normalized target name. 264 define def_target_sources 265 #$ (warning def_target_sources) 266 # C sources 267 $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES))\ 268 ,$(eval $(def_target_source_c_cpp_asm)) )) 269 270 # C++ sources 271 $(foreach type,CXX,$(foreach source, $(filter %.cpp, $($(target)_SOURCES)) $(filter %.cxx, $($(target)_SOURCES)) $(filter %.cc, $($(target)_SOURCES))\ 272 ,$(eval $(def_target_source_c_cpp_asm)) )) 273 274 # ASM sources 275 $(foreach type,AS,$(foreach source, $(filter %.asm, $($(target)_SOURCES)) $(filter %.s, $($(target)_SOURCES)) $(filter %.S, $($(target)_SOURCES))\ 276 ,$(eval $(def_target_source_c_cpp_asm)) )) 277 endef 278 177 279 178 280 # 179 281 # LIBRARIES 180 # 181 182 ## Figure out the tool for a source 183 # @param $1 source file 184 # @param $2 normalized main target 185 _SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL)) 186 ## Figure out where to put object files. 187 # @param $1 source file 188 # @param $2 normalized main target 189 _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $1) 190 282 # 283 191 284 ## Library (one). 192 285 # @param $(lib) Library name 193 286 define def_lib 194 #$ (warning dbg: Processing library $(target)) 195 196 # C++ sources 197 #$(foreach o, $(filter %.cpp,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o))) 198 #$(foreach o, $(filter %.cxx,$($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o))) 199 #$(foreach o, $(filter %.cc, $($1_SOURCES)), $(eval $(call def_lib_cxx,$1,$o))) 200 201 # C sources 202 $(foreach source, $(filter %.c, $($(target)_SOURCES)), \ 203 $(eval $(call TOOL_$(call _SOURCE_TOOL,$(source),$(target))_COMPILE_C,$(call _OBJECT_BASE,$(source),$(target)),$(source),$(target)) ) ) 204 205 ## ASM sources 206 #$(foreach o, $(filter %.asm,$($1_SOURCES)), $(eval $(call def_lib_asm,$1,$o))) 207 287 # source -> object 288 $(eval $(def_target_sources)) 289 208 290 # library 209 #$$(PATH_TARGET)/$1$(SUFF_LIB): \ 210 # $$(PATH_TARGET) \ 211 # $$(_OBJS_$1) 212 # $$(AR) $($1_ARFLAGS) $(ARFLAGS) $(AROUT)$$(@:/=\) $$(_OBJS_$1) 213 # 214 _OBJS += $(_OBJS_$(target)) 215 _LIBS += $(PATH_TARGET)/$1$(SUFF_LIB) 291 $(eval tool := $(firstword $($(target)_TOOL) $(TOOL))) 292 $(eval flags := $($(target)_ARFLAGS) $(ARFLAGS) $(TOOL_$(tool)_ARFLAGS)) 293 $(eval libsuff := $(firstword $($(target)_LIBSUFF) $($(target)_LIBSUFF) $(TOOL_$(tool)_ARLIBSUFF) $(SUFF_LIB))) 294 ## @todo prefix 295 $(eval outbase := $(call _TARGET_BASE,$(target),$(target))) 296 $(eval lib := $(outbase)$(libsuff)) 297 $(eval objs = $(_OBJS_$(target))) 298 $(eval dirdep := $(dir $(lib)).dir_created) 299 ## @todo fix dependencies 300 $(eval deps := ) 301 302 $(eval $(TOOL_$(tool)_LINK_LIBRARY)) 303 304 _OBJS += $(_OBJS_$(target)) 305 _LIBS += $(lib) 216 306 endef 217 307 … … 257 347 define def_createdir 258 348 $(dirfile): 349 $(call MSG_L1,Creating directory $$(@D)) 259 350 $(MKDIR) -p $$(@D) 260 echo dir_created > $$@351 @echo dir_created > $$@ 261 352 endef 262 353 … … 270 361 271 362 objs: $(_OBJS) 363 echo "dbg: _OBJS = $(_OBJS)" 364 365 libs: $(_LIBS) 366 echo "dbg: _LIBS = $(_LIBS)" 272 367 273 368 -
trunk/kBuild/header.kmk
r72 r73 194 194 EXEC_X86_WIN32 := 195 195 HOSTSUFF_EXE := .exe 196 endif 197 198 # 199 # Build target setup. 200 # 201 ifeq ($(BUILD_TARGET),os2) 202 SUFF_OBJ := .obj 203 SUFF_LIB := .lib 204 SUFF_DLL := .dll 205 SUFF_EXE := .exe 206 SUFF_DRV := .sys 207 SUFF_RES := .res 208 endif 209 ifeq ($(BUILD_TARGET),win32) 210 SUFF_OBJ := .obj 211 SUFF_LIB := .lib 212 SUFF_DLL := .dll 213 SUFF_EXE := .exe 214 SUFF_DRV := .sys 215 SUFF_RES := .res 216 endif 217 ifeq ($(BUILD_TARGET),linux) 218 SUFF_OBJ := .o 219 SUFF_LIB := .a 220 SUFF_DLL := .so 221 SUFF_EXE := 222 SUFF_DRV := .a 223 SUFF_RES := 196 224 endif 197 225 … … 215 243 216 244 # 245 # Message macros. 246 # 247 ifndef BUILD_QUIET 248 MSG_L1 = @echo "kBuild: $1" 249 ifdef BUILD_VERBOSE 250 MSG_L2 = @echo "kBuild: $1" 251 else 252 MSG_L2 = 253 endif 254 ifdef BUILD_DEBUG 255 MSG_L3 = @echo "kBuild: $1" 256 else 257 MSG_L3 = 258 endif 259 else 260 MSG_L1 = 261 MSG_L2 = 262 MSG_L3 = 263 endif 264 265 # 217 266 # This is how we find the closest config.kmk. 218 267 # It's a little hacky but I think it works fine. -
trunk/kBuild/tools/GCC.kmk
r72 r73 27 27 28 28 TOOL_GCC := Generic GCC 29 29 30 TOOL_GCC_CC := gcc$(HOSTSUFF_EXE) 31 TOOL_GCC_COBJSUFF := .o 30 32 TOOL_GCC_CFLAGS := -g 31 33 TOOL_GCC_CFLAGS.debug := -O0 … … 33 35 TOOL_GCC_CFLAGS.profile := -pg 34 36 TOOL_GCC_CINCS := 37 TOOL_GCC_CDEFS := 38 39 TOOL_GCC_CC := gcc$(HOSTSUFF_EXE) 40 TOOL_GCC_CXXOBJSUFF := .o 41 42 TOOL_GCC_AS := as$(HOSTSUFF_EXE) 43 TOOL_GCC_ASOBJSUFF := .o 44 45 TOOL_GCC_AR := ar$(HOSTSUFF_EXE) 46 TOOL_GCC_ARFLAGS := cr 47 TOOL_GCC_ARLIBSUFF := .a 35 48 36 49 37 50 ## Compile C source. 38 # @param $1 Output basename (full). 39 # @param $2 Source filename (relative). 40 # @param $3 Normalized main target name. 51 # @param $(target) Normalized main target name. 52 # @param $(source) Source filename (relative). 53 # @param $(obj) Object file name. This shall be (re)created by the compilation. 54 # @param $(dep) Dependcy file. This shall be (re)created by the compilation. 55 # @param $(flags) Flags. 56 # @param $(defs) Definitions. No -D or something. 57 # @param $(incs) Includes. No -I or something. 58 # @param $(dirdep) Directory creation dependency. 59 # 60 # @param $(outbase) Output basename (full). Use this for list files and such. 61 # @param $(objsuff) Object suffix. 41 62 define TOOL_GCC_COMPILE_C 42 #$ (warning dbg GCC: 1=$1 2=$2 3=$3 4=$4 5=$5) 43 $1.o: $(PATH_CURRENT)/$2 $(dir $1).dir_created 44 $(TOOL_GCC_CC) -c \ 45 $($3_$2_CFLAGS) $($3_$2_CFLAGS.$(BUILD_TYPE)) \ 46 $($2_CFLAGS) $($2_CFLAGS.$(BUILD_TYPE)) \ 47 $($3_CFLAGS) $($3_CFLAGS.$(BUILD_TYPE)) \ 48 $(TOOL_GCC_CFLAGS) $(TOOL_GCC_CFLAGS.$(BUILD_TYPE)) \ 49 $(addprefix -I, $($3_$2_CINCS) $($3_$2_INCS) $($2_CINCS) $($2_INCS) $($3_CINCS) $($3_INCS) $(INCS) \ 50 $(TOOL_GCC_CINCS)) \ 51 $(addprefix -D, $($3_$2_CDEFS) $($3_$2_DEFS) $($2_CDEFS) $($2_DEFS) $($3_CDEFS) $($3_DEFS) $(DEFS) $(TOOL_GCC_CDEFS)) \ 52 -o $$@ -Wp,-MT,$1$(SUFF_DEP) -Wp,-MD,$$@ \ 53 $(PATH_CURRENT)/$2 54 _OBJS_$(3) += $1.o 55 _DEPFILES += $1$(SUFF_DEP) 63 #$ (warning dbg: GCC: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff)) 64 $(obj): $(dirdep) $(PATH_CURRENT)/$(source) 65 $(call MSG_L2,Compiling $$@ using GCC) 66 $(TOOL_GCC_CC) -c\ 67 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ 68 -Wp,-MT,$(dep) -Wp,-MD,$$@\ 69 -o $$@\ 70 $(PATH_CURRENT)/$(source) 71 56 72 endef 57 73 74 75 ## Link library 76 # @param $(target) Normalized main target name. 77 # @param $(lib) Library name. 78 # @param $(objs) Object files to put in the library. 79 # @param $(flags) Flags. 80 # @param $(dirdep) Directory creation dependency. 81 # @param $(deps) Other dependencies. 82 # 83 # @param $(outbase) Output basename (full). Use this for list files and such. 84 define TOOL_GCC_LINK_LIBRARY 85 #$ (warning dbg: GCC: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase)) 86 $(lib): $(dirdep) $(objs) $(deps) 87 $(call MSG_L1,Creating Library $$@) 88 $(RM) -f $$@ 89 $(TOOL_GCC_AR) $(flags) $$@ $(objs) 90 91 endef 92
Note:
See TracChangeset
for help on using the changeset viewer.