Changeset 978 for trunk/kBuild
- Timestamp:
- May 27, 2007, 8:58:51 PM (18 years ago)
- Location:
- trunk/kBuild
- Files:
-
- 3 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/header.kmk
r972 r978 2 2 ## @file 3 3 # 4 # kBuild - File included at top of makefile.4 # kBuild - File included at top of a makefile. 5 5 # 6 6 # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net> … … 28 28 # start-of-file-content 29 29 30 # 31 # default rule 30 31 # 32 # Check make version before we do anything else. 33 # 34 ifndef KMK_VERSION 35 $(error kBuild: The kmk default variable KMK_VERSION isn't defined! Make sure you are using 'kmk' and not 'make', 'gmake', 'kmk_gmake', 'dmake' or any other make program.) 36 endif 37 ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1) 38 ifneq ($(KBUILD_VERSION_MAJOR),0) 39 $(warning kBuild: kmk major version mismatch, expected '0' found '$(KBUILD_VERSION_MAJOR)'!) 40 else 41 $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!) 42 endif 43 endif 44 45 # 46 # The revision in which this file was last modified. 47 # This can be useful when using development versions of kBuild. 48 # 49 KMK_REVISION := $(patsubst %:,, $Rev$ ) 50 51 52 # 53 # Define the default goal. 32 54 # 33 55 all: all_recursive 34 56 35 57 # 36 # The FORCE rule.58 # The phony FORCE target. 37 59 # 38 60 FORCE: 39 61 40 # 41 # Try avoid inference rules. 42 # 43 .SUFFIXES: 44 SUFFIXES := 45 46 # 47 # Enable delete (targets) on error. 62 63 # 64 # Enable delete on error and second expansion of prerequisites. 48 65 # 49 66 .DELETE_ON_ERROR: 50 67 51 #52 # Enable second expansion of prerequisites.53 #54 68 .SECONDEXPANSION: 55 69 … … 58 72 # General purpose macros. 59 73 # 60 61 ## get last word in a list.62 # @returns last word in $1.63 # @param $1 Word list.64 lastword = $(word $(words $(1)), $(1))65 74 66 75 ## … … 115 124 116 125 # 126 # The OSes and Architectures that kBuild recognizes. 127 # 128 # When kBuild is ported to a new OS or architecture a unique keyword needs 129 # to be assigned to it and added here. This strictness is required because 130 # this keyword namespace is shared between OSes, architectures, cpus and 131 # build types. 132 # 133 KBUILD_OSES = darwin freebsd l4 linux netbsd nt openbsd os2 solaris win 134 KBUILD_ARCHES = x86 amd64 sparc32 sparc64 mips32 mips64 ppc32 ppc64 135 136 137 # 117 138 # Set default build type. 118 139 # 119 140 ifndef BUILD_TYPE 120 ifdef BUILD_MODE 121 # BUILD_MODE is legacy from the OS/2 build system. :) 122 BUILD_TYPE := $(tolower $(BUILD_MODE)) 123 else 124 BUILD_TYPE := release 125 endif 126 endif 127 128 129 # 130 # Assert build platform. 131 # 132 ifndef BUILD_PLATFORM 133 $(error kBuild: BUILD_PLATFORM is undefined!) 134 else 135 BUILD_PLATFORM := $(strip $(BUILD_PLATFORM)) 136 ifneq ($(words $(BUILD_PLATFORM))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_PLATFORM)),1) 137 # OS/2 (have uppercase legacy) 138 ifeq ($(BUILD_PLATFORM),OS2) 139 $(error kBuild: BUILD_PLATFORM must be all lowercase!) 140 endif 141 $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recognized!) 142 endif 143 endif 144 145 # Fill in defaults if needed. 146 ifndef BUILD_PLATFORM_ARCH 147 ifeq ($(filter-out win64,$(BUILD_PLATFORM)),) 148 BUILD_PLATFORM_ARCH := amd64 149 else 150 BUILD_PLATFORM_ARCH := x86 151 endif 152 endif 153 ifndef BUILD_PLATFORM_CPU 154 ifeq ($(filter-out amd64,$(BUILD_PLATFORM_ARCH)),) 155 BUILD_PLATFORM_CPU:= k8 156 else 157 BUILD_PLATFORM_CPU:= i586 158 endif 159 endif 160 161 162 # 163 # Assert target platform. 141 BUILD_TYPE := release 142 else 143 ifneq ($(filter $(BUILD_TYPE),$(KBUILD_OSES) $(KBUILD_ARCHES)),) 144 $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' is an OS or architecture!) 145 endif 146 ifneq (.$(words $(BUILD_TYPE)).$(BUILD_TYPE).,.1.$(strip $(BUILD_TYPE)).) 147 $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' contains spaces/tabs!) 148 endif 149 endif 150 151 152 # 153 # Assert valid build platform variables. 154 # 155 # All these are set by kmk so they shouldn't be any trouble 156 # unless the user starts messing about with environment variables. 157 # 158 ifneq (.$(words $(BUILD_PLATFORM)).$(BUILD_PLATFORM).,.1.$(strip $(BUILD_PLATFORM)).) 159 $(error kBuild: The BUILD_PLATFORM value '$(BUILD_PLATFORM)' contains spaces/tabs!) 160 endif 161 ifneq ($(words $(filter $(BUILD_PLATFORM),$(KBUILD_OSES))),1) 162 $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' is not recognized (valid: $(KBUILD_OSES))) 163 endif 164 165 ifneq (.$(BUILD_PLATFORM_ARCH).,.$(strip $(BUILD_PLATFORM_ARCH)).) 166 $(error kBuild: The BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' contains spaces/tabs!) 167 endif 168 ifneq ($(words $(filter $(BUILD_PLATFORM_ARCH),$(KBUILD_ARCHES))),1) 169 $(error kBuild: BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' is not recognized (valid: $(KBUILD_ARCHES))) 170 endif 171 172 ifeq ($(strip $(BUILD_PLATFORM_CPU)),) 173 $(error kBuild: The BUILD_PLATFORM_CPU value is missing (should be set by kmk)!) 174 endif 175 ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).) 176 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!) 177 endif 178 ifneq ($(filter $(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),) 179 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!) 180 endif 181 ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE)) 182 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!) 183 endif 184 185 186 # 187 # Assert or set default target platform. 188 # When not defined use the corresponding BUILD_PLATFORM value. 164 189 # 165 190 ifndef BUILD_TARGET 166 # not defined, set to the same as build platform 167 BUILD_TARGET := $(BUILD_PLATFORM) 168 else 169 BUILD_TARGET := $(strip $(BUILD_TARGET)) 170 ifneq ($(words $(BUILD_TARGET))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_TARGET)),1) 171 # OS/2 (have uppercase legacy) 172 ifeq ($(BUILD_TARGET),OS2) 173 $(error kBuild: BUILD_TARGET must be all lowercase!) 174 endif 175 $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recognized!) 176 endif 177 endif 178 179 # Fill in defaults if needed. 191 BUILD_TARGET := $(BUILD_PLATFORM) 192 else 193 ifneq (.$(words $(BUILD_TARGET)).$(BUILD_TARGET).,.$(strip $(BUILD_TARGET)).) 194 $(error kBuild: The BUILD_TARGET value '$(BUILD_TARGET)' contains spaces/tabs!) 195 endif 196 ifneq ($(words $(filter $(BUILD_TARGET),$(KBUILD_OSES))),1) 197 $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES))) 198 endif 199 endif 200 180 201 ifndef BUILD_TARGET_ARCH 181 BUILD_TARGET_ARCH := x86 182 endif 202 BUILD_TARGET_ARCH := $(BUILD_PLATFORM_ARCH) 203 else 204 ifneq (.$(BUILD_TARGET_ARCH).,.$(strip $(BUILD_TARGET_ARCH)).) 205 $(error kBuild: The BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' contains spaces/tabs!) 206 endif 207 ifneq ($(words $(filter $(BUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1) 208 $(error kBuild: BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES))) 209 endif 210 endif 211 183 212 ifndef BUILD_TARGET_CPU 184 BUILD_TARGET_CPU := i586 185 endif 186 187 # Adjust the DEPTH definition first 188 ifeq ($(strip $(DEPTH)),) 189 DEPTH := . 190 endif 191 192 # 193 # Common definitions. 194 # 213 BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU) 214 else 215 ifeq ($(strip $(BUILD_TARGET_CPU)),) 216 $(error kBuild: The BUILD_TARGET_CPU value is missing (should be set by kmk)!) 217 endif 218 ifneq (.$(words $(BUILD_TARGET_CPU)).$(BUILD_TARGET_CPU).,.1.$(strip $(BUILD_TARGET_CPU)).) 219 $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' contains spaces/tabs!) 220 endif 221 ifneq ($(filter $(BUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),) 222 $(error kBuild: The BUILD_TARGET_CPU value was found in the OS or architecture keywords!) 223 endif 224 ifeq ($(BUILD_TARGET_CPU),$(BUILD_TYPE)) 225 $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' is the same as the BUILD_TYPE!) 226 endif 227 endif 228 229 230 # 231 # Paths and stuff. 232 # 233 234 # Adjust DEPTH first. 235 DEPTH := $(strip $(DEPTH)) 236 ifeq ($(DEPTH),) 237 DEPTH := . 238 endif 239 195 240 ## PATH_CURRENT is the current directory (getcwd). 196 241 PATH_CURRENT := $(abspath $(CURDIR)) … … 202 247 ## PATH_SUB_ROOT points to the directory of the top-level makefile. 203 248 ifneq ($(strip $(SUB_DEPTH)),) 249 SUB_DEPTH := $(strip $(SUB_DEPTH)) 204 250 PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH)) 205 251 else … … 235 281 PATH_DOC = $(PATH_INS)/doc 236 282 237 # Usually kBuild is external to the source tree. 238 ifndef PATH_KBUILD 239 PATH_KBUILD := $(PATH_ROOT)/kBuild 240 endif 241 PATH_KBUILD := $(abspath $(PATH_KBUILD)) 283 # PATH_KBUILD is determined by kmk. 284 ifeq ($(strip $(PATH_KBUILD)),) 285 $(error kBuild: PATH_KBUILD is missing or empty! kmk is supposed to set it.) 286 endif 287 # PATH_KBUILD_BIN is determined by kmk. 288 ifeq ($(strip $(PATH_KBUILD_BIN)),) 289 $(error kBuild: PATH_KBUILD_BIN is missing or empty! kmk is supposed to set it.) 290 endif 291 242 292 # kBuild files which might be of interest. 243 293 FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk … … 245 295 FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk 246 296 247 SUFF_DEP := .dep248 297 ## MAKEFILE is the name of the main makefile. 249 298 MAKEFILE := $(firstword $(MAKEFILE_LIST)) … … 254 303 255 304 # 256 # Check make version.257 #258 ifdef KMK_VERSION259 ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)260 ifneq ($(KBUILD_VERSION_MAJOR),0)261 $(warning kBuild: kmk major version mismatch, expected '0' found '$(KBUILD_VERSION_MAJOR)'!)262 else263 $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)264 endif265 endif266 endif267 268 269 #270 # The revision in which this file was last modified.271 # This can be useful when using development versions of kBuild.272 #273 KMK_REVISION := $(patsubst %:,, $Rev$ )274 275 276 #277 305 # Build platform setup. 278 306 # … … 313 341 endif 314 342 315 ifndef PATH_KBUILD_BIN316 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)317 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)318 ifeq ($(BUILD_TARGET_ARCH),amd64)319 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).x86320 endif321 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)322 ifeq ($(filter-out win64 win32 win nt ,$(BUILD_PLATFORM)),)323 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/win.x86324 endif325 endif326 ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)327 # give up328 PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)329 endif330 endif331 endif332 333 343 334 344 # 335 345 # Build target setup. 336 346 # 347 SUFF_DEP := .dep 337 348 ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),) 338 349 SUFF_OBJ := .obj … … 371 382 # Standard kBuild tools. 372 383 # 373 ifeq ($(MAKE),kmk) 374 MAKE := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE) 375 endif 384 ifeq ($(KMK),kmk) 385 KMK := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE) 386 endif 387 MAKE := $(KMK) 376 388 377 389 DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE) … … 397 409 398 410 APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE) 399 ifeq ($(filter append,$(KMK_BUILTIN)),append)400 411 APPEND := kmk_builtin_append 401 else402 APPEND := $(APPEND_EXT)403 endif404 412 405 413 CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE) 406 ifeq ($(filter cat,$(KMK_BUILTIN)),cat)407 414 CAT := kmk_builtin_cat 408 else409 CAT := $(CAT_EXT)410 endif411 415 412 416 CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE) 413 ifeq ($(filter cp,$(KMK_BUILTIN)),cp)414 417 CP := kmk_builtin_cp 415 else416 CP := $(CP_EXT)417 endif418 418 419 419 ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE) 420 ifeq ($(filter echo,$(KMK_BUILTIN)),echo)421 420 ECHO := kmk_builtin_echo 422 else423 ECHO := $(ECHO_EXT)424 endif425 421 426 422 INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE) 427 ifeq ($(filter install,$(KMK_BUILTIN)),install)428 423 INSTALL := kmk_builtin_install 429 else430 INSTALL := $(INSTALL_EXT)431 endif432 424 433 425 LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE) 434 ifeq ($(filter ln,$(KMK_BUILTIN)),ln)435 426 LN := kmk_builtin_ln 436 else437 LN := $(LN_EXT)438 endif439 427 440 428 MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE) 441 ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)442 429 MKDIR := kmk_builtin_mkdir 443 else444 MKDIR := $(MKDIR_EXT)445 endif446 430 447 431 MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE) 448 ifeq ($(filter mv,$(KMK_BUILTIN)),mv)449 432 MV := kmk_builtin_mv 450 else451 MV := $(MV_EXT)452 endif453 433 454 434 PRINTF_EXT := $(PATH_KBUILD_BIN)/kmk_printf$(HOSTSUFF_EXE) 455 ifeq ($(filter printf,$(KMK_BUILTIN)),printf)456 435 PRINTF := kmk_builtin_printf 457 else458 PRINTF := $(PRINTF_EXT)459 endif460 436 461 437 RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE) 462 ifeq ($(filter rm,$(KMK_BUILTIN)),rm)463 438 RM := kmk_builtin_rm 464 else465 RM := $(RM_EXT)466 endif467 439 468 440 RMDIR_EXT := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE) 469 ifeq ($(filter rmdir,$(KMK_BUILTIN)),rmdir)470 441 RMDIR := kmk_builtin_rmdir 471 else472 RMDIR := $(RMDIR_EXT)473 endif474 442 475 443 SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE) 476 444 ifeq ($(filter sed,$(KMK_BUILTIN)),sed) 477 SED := kmk_builtin_sed 478 else 445 SED_INT := kmk_builtin_sed 446 else 447 SED_INT := $(SED_EXT) 448 endif 479 449 SED := $(SED_EXT) 480 endif481 450 482 451 # Our default shell is the Almquist shell from *BSD. … … 517 486 else 518 487 CYGPATHMIXED = $(1) 519 endif520 521 ifneq ($(filter xargs,$(KMK_FEATURES)),xargs) ## @todo Retire this to gnumake-header.kmk when it has been implemented.522 ##523 # Fake xargs without doing any commandline splitting.524 # @param $1 The initial command.525 # @param $2 The command for the subseqent command lines. optional526 # @param $3 The command for the final command lines. optional527 # @param $($#) The arguments.528 xargs = $(1) $(if $(4),$(4),$(if $(3),$(3),$(2)))529 488 endif 530 489 … … 745 704 746 705 # 747 # Include the gnumake header hacks if we're not using kmk.748 #749 ifndef KMK_VERSION750 include $(PATH_KBUILD)/gnumake-header.kmk751 endif752 753 754 #755 706 # This is how we find the closest config.kmk. 756 707 # It's a little hacky but I think it works fine. … … 771 722 $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)') 772 723 endif 724 773 725 774 726 # … … 955 907 endif # __header_kmk__ 956 908 957
Note:
See TracChangeset
for help on using the changeset viewer.