[69] | 1 | # $Id: header.kmk 70 2004-05-29 08:53:13Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
| 4 | # kBuild - File included at top of makefile.
|
---|
| 5 | #
|
---|
| 6 | # Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
| 7 | #
|
---|
| 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | #
|
---|
| 25 | #
|
---|
| 26 |
|
---|
| 27 | ifndef __header_kmk__
|
---|
| 28 | # start-of-file-content
|
---|
| 29 |
|
---|
| 30 | #
|
---|
| 31 | # default rule
|
---|
| 32 | #
|
---|
| 33 | all: all_recursive
|
---|
| 34 |
|
---|
| 35 | #
|
---|
| 36 | # Try avoid inference rules.
|
---|
| 37 | #
|
---|
| 38 | .SUFFIXES:
|
---|
| 39 | SUFFIXES :=
|
---|
| 40 |
|
---|
| 41 | #
|
---|
| 42 | # Environment unifications
|
---|
| 43 | #
|
---|
| 44 | ifndef BUILD_TYPE
|
---|
| 45 | ifndef BUILD_MODE
|
---|
| 46 | $(error "define BUILD_TYPE you moron!")
|
---|
| 47 | endif
|
---|
| 48 | BUILD_TYPE := $(BUILD_MODE)
|
---|
| 49 | endif
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | #
|
---|
[70] | 53 | # .
|
---|
| 54 | #
|
---|
| 55 | PATH_ROOT := $(CURDIR)
|
---|
| 56 | define def_root_dir
|
---|
| 57 | PATH_ROOT := $(dir $(PATH_ROOT))
|
---|
| 58 | endef
|
---|
| 59 | PATH_ROOT
|
---|
| 60 |
|
---|
| 61 | #
|
---|
[69] | 62 | # Common definitions.
|
---|
| 63 | #
|
---|
| 64 | PATH_CURRENT := $(CURDIR)
|
---|
[70] | 65 | # Get the real root path.
|
---|
| 66 | PATH_ROOT := $(CURDIR)
|
---|
| 67 | ifneq ($(DEPTH),.)
|
---|
| 68 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
[69] | 69 | endif
|
---|
[70] | 70 | # Subdirectory relative to the root.
|
---|
| 71 | DIR_DEPTH := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
|
---|
| 72 | # Output directories.
|
---|
[69] | 73 | PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
|
---|
| 74 | PATH_OBJ := $(PATH_OUT)/obj
|
---|
| 75 | PATH_BIN := $(PATH_OUT)/bin
|
---|
| 76 | PATH_LIB := $(PATH_OUT)/lib
|
---|
| 77 | PATH_DOC := $(PATH_ROOT)/out/doc
|
---|
[70] | 78 | PATH_TARGET = $(PATH_OUT)/$(DIR_DEPTH)
|
---|
| 79 |
|
---|
| 80 | # Usually kBuild is external to the source tree.
|
---|
| 81 | ifndef PATH_KBUILD
|
---|
| 82 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
| 83 | endif
|
---|
| 84 | # kBuild tools
|
---|
[69] | 85 | PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
|
---|
| 86 | PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
|
---|
| 87 | PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
|
---|
| 88 | # kBuild files which might be of interest.
|
---|
| 89 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
| 90 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
| 91 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | #
|
---|
| 95 | # Get rid of the GNU Make default stuff
|
---|
| 96 | #
|
---|
| 97 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | #
|
---|
| 101 | # PLATFORMS (host)
|
---|
| 102 | #
|
---|
| 103 | _BUILD_PLATFORM_OK := 0
|
---|
| 104 | # OS/2
|
---|
| 105 | ifeq ($(BUILD_PLATFORM),OS2)
|
---|
| 106 | _BUILD_PLATFORM_OK := 1
|
---|
| 107 | ifndef BUILD_TARGET
|
---|
| 108 | BUILD_TARGET := OS2
|
---|
| 109 | endif
|
---|
| 110 | PATH_TOOLS := $(PATH_TOOLS_OS2)
|
---|
| 111 | EXEC_X86_WIN32 := $(PATH_TOOLS)/bin/innopec.exe
|
---|
| 112 | HOSTSUFF_EXE := .exe
|
---|
| 113 | endif
|
---|
| 114 |
|
---|
| 115 | # Linux
|
---|
| 116 | ifeq ($(BUILD_PLATFORM),LINUX)
|
---|
| 117 | _BUILD_PLATFORM_OK := 1
|
---|
| 118 | ifndef BUILD_TARGET
|
---|
| 119 | BUILD_TARGET := LINUX
|
---|
| 120 | endif
|
---|
| 121 | PATH_TOOLS := $(PATH_TOOLS_LNX)
|
---|
| 122 | EXEC_X86_WIN32 := wine
|
---|
| 123 | HOSTSUFF_EXE :=
|
---|
| 124 | endif
|
---|
[70] | 125 |
|
---|
[69] | 126 | # Win32
|
---|
| 127 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
| 128 | ifndef BUILD_TARGET
|
---|
| 129 | BUILD_TARGET := WIN32
|
---|
| 130 | endif
|
---|
| 131 | _BUILD_PLATFORM_OK := 1
|
---|
| 132 | PATH_TOOLS := $(PATH_TOOLS_W32)
|
---|
| 133 | EXEC_X86_WIN32 :=
|
---|
| 134 | HOSTSUFF_EXE := .exe
|
---|
| 135 | endif
|
---|
| 136 |
|
---|
| 137 | # assert build platform
|
---|
| 138 | ifeq ($(_BUILD_PLATFORM_OK),0)
|
---|
| 139 | $(error "BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized")
|
---|
| 140 | endif
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | #
|
---|
| 144 | # Standard kBuild tools.
|
---|
| 145 | #
|
---|
| 146 | DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
| 147 | # Standard Unix shell utils.
|
---|
| 148 | MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
|
---|
| 149 | RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
|
---|
| 150 | CP := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
|
---|
| 151 | MV := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
|
---|
| 152 | SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
|
---|
| 153 | CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
|
---|
| 154 | # Bourn shell clone.
|
---|
| 155 | MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
|
---|
| 156 | SHELL := $(MAKESHELL)
|
---|
| 157 | export SHELL MAKESHELL
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | #
|
---|
| 161 | # This is how we find the closest config.kmk.
|
---|
| 162 | # It's a little hacky but I think it works fine.
|
---|
[70] | 163 | #
|
---|
| 164 | _CFGDIR := .
|
---|
| 165 | _CFGFILES :=
|
---|
[69] | 166 | define def_include_config
|
---|
[70] | 167 | _CFGDIR := $(_CFGDIR)/$(1)
|
---|
| 168 | _CFGFILES += $(wildcard $(_CFGDIR)/config.kmk $(_CFGDIR)/config.kMk)
|
---|
[69] | 169 | endef
|
---|
| 170 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
| 171 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval $(call def_include_config,$(d))) )
|
---|
| 172 | # add the default config file.
|
---|
[70] | 173 | _CFGFILE := $(firstword $(_CFGFILES) $(FILE_KBUILD_CONFIG))
|
---|
[69] | 174 | _CFGFILES :=
|
---|
| 175 | _CFGDIR :=
|
---|
| 176 |
|
---|
| 177 | # Include the config.kmk we found file (or the default one).
|
---|
| 178 | include $(_CFGFILE)
|
---|
| 179 |
|
---|
| 180 |
|
---|
| 181 | # end-of-file-content
|
---|
| 182 | __header_kmk__ := 1
|
---|
| 183 | endif # __header_kmk__
|
---|