[819] | 1 | # $Id: subheader.kmk 2413 2010-09-11 17:43:04Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | # kBuild - File included at top of a makefile or sub-makefile.
|
---|
| 4 | #
|
---|
[1547] | 5 |
|
---|
| 6 | #
|
---|
[2413] | 7 | # Copyright (c) 2006-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
---|
[819] | 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 | #
|
---|
[1547] | 26 | # As a special exception you are granted permission to include this file, via
|
---|
[1649] | 27 | # the kmk include directive, as you wish without this in itself causing the
|
---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
---|
[1547] | 29 | # This exception does not however invalidate any other reasons why the makefile,
|
---|
| 30 | # program, whatever should not be covered the GPL.
|
---|
| 31 | #
|
---|
[2018] | 32 | #
|
---|
[819] | 33 |
|
---|
| 34 | #
|
---|
| 35 | # Sanity check.
|
---|
| 36 | #
|
---|
| 37 | ifdef __footer_kmk__
|
---|
[1669] | 38 | $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles! $(MAKEFILE_CURRENT))
|
---|
[819] | 39 | endif
|
---|
| 40 |
|
---|
| 41 | ifndef _SUB_MAKEFILE_NOT_FIRST
|
---|
| 42 |
|
---|
| 43 | #
|
---|
| 44 | # The first time we just take the makefile context set by header.kmk.
|
---|
| 45 | #
|
---|
| 46 | _SUB_MAKEFILE_NOT_FIRST := 1
|
---|
[1663] | 47 | DEPTH ?= $(SUB_DEPTH)
|
---|
[819] | 48 | include $(PATH_KBUILD)/header.kmk
|
---|
| 49 |
|
---|
| 50 | else
|
---|
| 51 |
|
---|
| 52 | #
|
---|
| 53 | # Set the default path and makefile for all new targets.
|
---|
| 54 | #
|
---|
| 55 | define def_subfooter
|
---|
| 56 | ifndef $(target)_PATH
|
---|
[1772] | 57 | ifdef $(target)_DEFPATH
|
---|
[2242] | 58 | $(target)_PATH := $($(target)_DEFPATH)
|
---|
[1772] | 59 | else
|
---|
[2242] | 60 | $(target)_PATH := $(PATH_SUB_CURRENT)
|
---|
| 61 | $(target)_DEFPATH := $(PATH_SUB_CURRENT)
|
---|
[1772] | 62 | endif
|
---|
| 63 | else ifndef $(target)_DEFPATH
|
---|
[2242] | 64 | $(target)_DEFPATH := $($(target)_PATH)
|
---|
[819] | 65 | endif
|
---|
| 66 | ifndef $(target)_MAKEFILE
|
---|
| 67 | $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
|
---|
| 68 | endif
|
---|
[2239] | 69 | ifndef $(target)_0_OUTDIR
|
---|
[2242] | 70 | $(target)_0_OUTDIR := $(call TARGET_PATH,$(target))
|
---|
| 71 | PATH_$(target) := $($(target)_0_OUTDIR)
|
---|
[819] | 72 | endif
|
---|
| 73 | endef
|
---|
| 74 |
|
---|
| 75 | $(foreach target,\
|
---|
| 76 | $(ALL_TARGETS) \
|
---|
[1649] | 77 | $(FETCHES) $(FETCHES.$(KBUILD_TARGET)) $(FETCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_ARCH)) $(FETCHES.$(KBUILD_TARGET_CPU)) $(FETCHES.$(KBUILD_TYPE)) \
|
---|
| 78 | $(PATCHES) $(PATCHES.$(KBUILD_TARGET)) $(PATCHES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_ARCH)) $(PATCHES.$(KBUILD_TARGET_CPU)) $(PATCHES.$(KBUILD_TYPE)) \
|
---|
| 79 | $(BLDPROGS) $(BLDPROGS.$(KBUILD_HOST)) $(BLDPROGS.$(KBUILD_HOST).$(BUILD_PLATFORM_ARCH)) $(BLDPROGS.$(KBUILD_HOST_ARCH)) $(BLDPROGS.$(KBUILD_HOST_CPU)) $(BLDPROGS.$(KBUILD_TYPE)) \
|
---|
| 80 | $(LIBRARIES) $(LIBRARIES.$(KBUILD_TARGET)) $(LIBRARIES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_ARCH)) $(LIBRARIES.$(KBUILD_TARGET_CPU)) $(LIBRARIES.$(KBUILD_TYPE)) \
|
---|
| 81 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(KBUILD_TARGET)) $(IMPORT_LIBS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_ARCH)) $(IMPORT_LIBS.$(KBUILD_TARGET_CPU)) $(IMPORT_LIBS.$(KBUILD_TYPE)) \
|
---|
| 82 | $(DLLS) $(DLLS.$(KBUILD_TARGET)) $(DLLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_ARCH)) $(DLLS.$(KBUILD_TARGET_CPU)) $(DLLS.$(KBUILD_TYPE)) \
|
---|
| 83 | $(PROGRAMS) $(PROGRAMS.$(KBUILD_TARGET)) $(PROGRAMS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_ARCH)) $(PROGRAMS.$(KBUILD_TARGET_CPU)) $(PROGRAMS.$(KBUILD_TYPE)) \
|
---|
| 84 | $(SYSMODS) $(SYSMODS.$(KBUILD_TARGET)) $(SYSMODS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_ARCH)) $(SYSMODS.$(KBUILD_TARGET_CPU)) $(SYSMODS.$(KBUILD_TYPE)) \
|
---|
[2084] | 85 | $(MISCBINS) $(MISCBINS.$(KBUILD_TARGET)) $(MISCBINS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_ARCH)) $(MISCBINS.$(KBUILD_TARGET_CPU)) $(MISCBINS.$(KBUILD_TYPE)) \
|
---|
[1649] | 86 | $(INSTALLS) $(INSTALLS.$(KBUILD_TARGET)) $(INSTALLS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_ARCH)) $(INSTALLS.$(KBUILD_TARGET_CPU)) $(INSTALLS.$(KBUILD_TYPE)) \
|
---|
| 87 | $(OTHERS) $(OTHERS.$(KBUILD_TARGET)) $(OTHERS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_ARCH)) $(OTHERS.$(KBUILD_TARGET_CPU)) $(OTHERS.$(KBUILD_TYPE)) \
|
---|
[2242] | 88 | ,$(evalval def_subfooter))
|
---|
[819] | 89 |
|
---|
| 90 |
|
---|
| 91 | #
|
---|
| 92 | # Switch context.
|
---|
| 93 | #
|
---|
| 94 |
|
---|
| 95 | # push the current old makefile onto the stack.
|
---|
[979] | 96 | $(stack-push _SUB_MAKEFILE_STACK,$(MAKEFILE_CURRENT))
|
---|
[819] | 97 |
|
---|
| 98 | # the current makefile is the 2nd from the end of the MAKEFILE_LIST (we're the last one).
|
---|
| 99 | __tmp := $(MAKEFILE_LIST)
|
---|
[979] | 100 | $(stack-popv __tmp)
|
---|
| 101 | MAKEFILE_CURRENT := $(stack-top __tmp)
|
---|
[819] | 102 | PATH_SUB_CURRENT := $(abspath $(dir $(MAKEFILE_CURRENT)))
|
---|
| 103 | endif
|
---|
| 104 |
|
---|