1 | # $Id: subheader.kmk 743 2006-12-17 08:12:30Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of a makefile or sub-makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2006 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 | #
|
---|
28 | # Sanity check.
|
---|
29 | #
|
---|
30 | ifdef __footer_kmk__
|
---|
31 | $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!)
|
---|
32 | endif
|
---|
33 |
|
---|
34 | ifndef _SUB_MAKEFILE_NOT_FIRST
|
---|
35 |
|
---|
36 | #
|
---|
37 | # The first time we just take the makefile context set by header.kmk.
|
---|
38 | #
|
---|
39 | _SUB_MAKEFILE_NOT_FIRST := 1
|
---|
40 | include $(PATH_KBUILD)/header.kmk
|
---|
41 |
|
---|
42 | else
|
---|
43 |
|
---|
44 | #
|
---|
45 | # Set the default path and makefile for all new targets.
|
---|
46 | #
|
---|
47 | define def_subfooter
|
---|
48 | ifndef $(target)_PATH
|
---|
49 | $(target)_PATH := $(PATH_SUB_CURRENT)
|
---|
50 | endif
|
---|
51 | ifndef $(target)_MAKEFILE
|
---|
52 | $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
|
---|
53 | endif
|
---|
54 | ifndef PATH_$(target)
|
---|
55 | PATH_$(target) := $(call TARGET_PATH,$(target))
|
---|
56 | endif
|
---|
57 | endef
|
---|
58 |
|
---|
59 | $(foreach target,\
|
---|
60 | $(ALL_TARGETS) \
|
---|
61 | $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
62 | $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
63 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
|
---|
64 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
65 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
66 | $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
67 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
68 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
69 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
70 | $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
|
---|
71 | ,$(eval $(def_subfooter)))
|
---|
72 |
|
---|
73 |
|
---|
74 | #
|
---|
75 | # Switch context.
|
---|
76 | #
|
---|
77 |
|
---|
78 | # push the current old makefile onto the stack.
|
---|
79 | $(call stack-push,_SUB_MAKEFILE_STACK,$(MAKEFILE_CURRENT))
|
---|
80 |
|
---|
81 | # the current makefile is the 2nd from the end of the MAKEFILE_LIST (we're the last one).
|
---|
82 | __tmp := $(MAKEFILE_LIST)
|
---|
83 | $(call stack-popv,__tmp)
|
---|
84 | MAKEFILE_CURRENT := $(call stack-top,__tmp)
|
---|
85 | PATH_SUB_CURRENT := $(abspath $(dir $(MAKEFILE_CURRENT)))
|
---|
86 | endif
|
---|
87 |
|
---|