Changeset 978


Ignore:
Timestamp:
May 27, 2007, 8:58:51 PM (18 years ago)
Author:
bird
Message:

We can drop all the hacks required to make it work with GNU make 3.81 since we no longer need this for bootstrapping. Also drop feature tests for kmk features present in the current code.

Location:
trunk/kBuild
Files:
3 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/header.kmk

    r972 r978  
    22## @file
    33#
    4 # kBuild - File included at top of makefile.
     4# kBuild - File included at top of a makefile.
    55#
    66# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
     
    2828# start-of-file-content
    2929
    30 #
    31 # default rule
     30
     31#
     32# Check make version before we do anything else.
     33#
     34ifndef 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.)
     36endif
     37ifneq ($(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
     43endif
     44
     45#
     46# The revision in which this file was last modified.
     47# This can be useful when using development versions of kBuild.
     48#
     49KMK_REVISION := $(patsubst %:,,  $Rev$  )
     50
     51
     52#
     53# Define the default goal.
    3254#
    3355all: all_recursive
    3456
    3557#
    36 # The FORCE rule.
     58# The phony FORCE target.
    3759#
    3860FORCE:
    3961
    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.
    4865#
    4966.DELETE_ON_ERROR:
    5067
    51 #
    52 # Enable second expansion of prerequisites.
    53 #
    5468.SECONDEXPANSION:
    5569
     
    5872# General purpose macros.
    5973#
    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))
    6574
    6675##
     
    115124
    116125#
     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#
     133KBUILD_OSES   = darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
     134KBUILD_ARCHES = x86 amd64 sparc32 sparc64 mips32 mips64 ppc32 ppc64
     135
     136
     137#
    117138# Set default build type.
    118139#
    119140ifndef 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
     142else
     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
     149endif
     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#
     158ifneq (.$(words $(BUILD_PLATFORM)).$(BUILD_PLATFORM).,.1.$(strip $(BUILD_PLATFORM)).)
     159 $(error kBuild: The BUILD_PLATFORM value '$(BUILD_PLATFORM)' contains spaces/tabs!)
     160endif
     161ifneq ($(words $(filter $(BUILD_PLATFORM),$(KBUILD_OSES))),1)
     162 $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' is not recognized (valid: $(KBUILD_OSES)))
     163endif
     164
     165ifneq (.$(BUILD_PLATFORM_ARCH).,.$(strip $(BUILD_PLATFORM_ARCH)).)
     166 $(error kBuild: The BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' contains spaces/tabs!)
     167endif
     168ifneq ($(words $(filter $(BUILD_PLATFORM_ARCH),$(KBUILD_ARCHES))),1)
     169 $(error kBuild: BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
     170endif
     171
     172ifeq ($(strip $(BUILD_PLATFORM_CPU)),)
     173 $(error kBuild: The BUILD_PLATFORM_CPU value is missing (should be set by kmk)!)
     174endif
     175ifneq (.$(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!)
     177endif
     178ifneq ($(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!)
     180endif
     181ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
     182 $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
     183endif
     184
     185
     186#
     187# Assert or set default target platform.
     188# When not defined use the corresponding BUILD_PLATFORM value.
    164189#
    165190ifndef 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)
     192else
     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
     199endif
     200
    180201ifndef BUILD_TARGET_ARCH
    181  BUILD_TARGET_ARCH  := x86
    182 endif
     202 BUILD_TARGET_ARCH := $(BUILD_PLATFORM_ARCH)
     203else
     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
     210endif
     211
    183212ifndef 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)
     214else
     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
     227endif
     228
     229
     230#
     231# Paths and stuff.
     232#
     233
     234# Adjust DEPTH first.
     235DEPTH := $(strip $(DEPTH))
     236ifeq ($(DEPTH),)
     237 DEPTH := .
     238endif
     239
    195240## PATH_CURRENT is the current directory (getcwd).
    196241PATH_CURRENT        := $(abspath $(CURDIR))
     
    202247## PATH_SUB_ROOT points to the directory of the top-level makefile.
    203248ifneq ($(strip $(SUB_DEPTH)),)
     249 SUB_DEPTH          := $(strip $(SUB_DEPTH))
    204250 PATH_SUB_ROOT      := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
    205251else
     
    235281PATH_DOC             = $(PATH_INS)/doc
    236282
    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.
     284ifeq ($(strip $(PATH_KBUILD)),)
     285 $(error kBuild: PATH_KBUILD is missing or empty! kmk is supposed to set it.)
     286endif
     287# PATH_KBUILD_BIN is determined by kmk.
     288ifeq ($(strip $(PATH_KBUILD_BIN)),)
     289 $(error kBuild: PATH_KBUILD_BIN is missing or empty! kmk is supposed to set it.)
     290endif
     291
    242292# kBuild files which might be of interest.
    243293FILE_KBUILD_HEADER  := $(PATH_KBUILD)/header.kmk
     
    245295FILE_KBUILD_FOOTER  := $(PATH_KBUILD)/footer.kmk
    246296
    247 SUFF_DEP            := .dep
    248297## MAKEFILE is the name of the main makefile.
    249298MAKEFILE            := $(firstword $(MAKEFILE_LIST))
     
    254303
    255304#
    256 # Check make version.
    257 #
    258 ifdef KMK_VERSION
    259  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   else
    263    $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)
    264   endif
    265  endif
    266 endif
    267 
    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 #
    277305# Build platform setup.
    278306#
     
    313341endif
    314342
    315 ifndef PATH_KBUILD_BIN
    316  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).x86
    320   endif
    321   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.x86
    324    endif
    325   endif
    326   ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
    327    # give up
    328    PATH_KBUILD_BIN  := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
    329   endif
    330  endif
    331 endif
    332 
    333343
    334344#
    335345# Build target setup.
    336346#
     347SUFF_DEP            := .dep
    337348ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),)
    338349SUFF_OBJ            := .obj
     
    371382# Standard kBuild tools.
    372383#
    373 ifeq ($(MAKE),kmk)
    374 MAKE        := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
    375 endif
     384ifeq ($(KMK),kmk)
     385KMK         := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
     386endif
     387MAKE        := $(KMK)
    376388
    377389DEP_EXT     := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
     
    397409
    398410APPEND_EXT  := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
    399 ifeq ($(filter append,$(KMK_BUILTIN)),append)
    400411APPEND      := kmk_builtin_append
    401 else
    402 APPEND      := $(APPEND_EXT)
    403 endif
    404412
    405413CAT_EXT     := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
    406 ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
    407414CAT         := kmk_builtin_cat
    408 else
    409 CAT         := $(CAT_EXT)
    410 endif
    411415
    412416CP_EXT      := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
    413 ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
    414417CP          := kmk_builtin_cp
    415 else
    416 CP          := $(CP_EXT)
    417 endif
    418418
    419419ECHO_EXT    := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
    420 ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
    421420ECHO        := kmk_builtin_echo
    422 else
    423 ECHO        := $(ECHO_EXT)
    424 endif
    425421
    426422INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
    427 ifeq ($(filter install,$(KMK_BUILTIN)),install)
    428423INSTALL     := kmk_builtin_install
    429 else
    430 INSTALL     := $(INSTALL_EXT)
    431 endif
    432424
    433425LN_EXT      := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
    434 ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
    435426LN          := kmk_builtin_ln
    436 else
    437 LN          := $(LN_EXT)
    438 endif
    439427
    440428MKDIR_EXT   := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
    441 ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
    442429MKDIR       := kmk_builtin_mkdir
    443 else
    444 MKDIR       := $(MKDIR_EXT)
    445 endif
    446430
    447431MV_EXT      := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
    448 ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
    449432MV          := kmk_builtin_mv
    450 else
    451 MV          := $(MV_EXT)
    452 endif
    453433
    454434PRINTF_EXT  := $(PATH_KBUILD_BIN)/kmk_printf$(HOSTSUFF_EXE)
    455 ifeq ($(filter printf,$(KMK_BUILTIN)),printf)
    456435PRINTF      := kmk_builtin_printf
    457 else
    458 PRINTF      := $(PRINTF_EXT)
    459 endif
    460436
    461437RM_EXT      := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
    462 ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
    463438RM          := kmk_builtin_rm
    464 else
    465 RM          := $(RM_EXT)
    466 endif
    467439
    468440RMDIR_EXT   := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
    469 ifeq ($(filter rmdir,$(KMK_BUILTIN)),rmdir)
    470441RMDIR       := kmk_builtin_rmdir
    471 else
    472 RMDIR       := $(RMDIR_EXT)
    473 endif
    474442
    475443SED_EXT     := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
    476444ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
    477 SED         := kmk_builtin_sed
    478 else
     445SED_INT     := kmk_builtin_sed
     446else
     447SED_INT     := $(SED_EXT)
     448endif
    479449SED         := $(SED_EXT)
    480 endif
    481450
    482451# Our default shell is the Almquist shell from *BSD.
     
    517486else
    518487 CYGPATHMIXED = $(1)
    519 endif
    520 
    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. optional
    526 # @param    $3          The command for the final command lines. optional
    527 # @param    $($#)   The arguments.
    528 xargs = $(1) $(if $(4),$(4),$(if $(3),$(3),$(2)))
    529488endif
    530489
     
    745704
    746705#
    747 # Include the gnumake header hacks if we're not using kmk.
    748 #
    749 ifndef KMK_VERSION
    750  include $(PATH_KBUILD)/gnumake-header.kmk
    751 endif
    752 
    753 
    754 #
    755706# This is how we find the closest config.kmk.
    756707# It's a little hacky but I think it works fine.
     
    771722$(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
    772723endif
     724
    773725
    774726#
     
    955907endif # __header_kmk__
    956908
    957 
Note: See TracChangeset for help on using the changeset viewer.