# $Id: subheader.kmk 979 2007-05-27 19:05:11Z bird $ ## @file # # kBuild - File included at top of a makefile or sub-makefile. # # Copyright (c) 2006-2007 knut st. osmundsen # # # This file is part of kBuild. # # kBuild is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # kBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with kBuild; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # # Sanity check. # ifdef __footer_kmk__ $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!) endif ifndef _SUB_MAKEFILE_NOT_FIRST # # The first time we just take the makefile context set by header.kmk. # _SUB_MAKEFILE_NOT_FIRST := 1 include $(PATH_KBUILD)/header.kmk else # # Set the default path and makefile for all new targets. # define def_subfooter ifndef $(target)_PATH $(target)_PATH := $(PATH_SUB_CURRENT) endif ifndef $(target)_MAKEFILE $(target)_MAKEFILE := $(MAKEFILE_CURRENT) endif ifndef PATH_$(target) PATH_$(target) := $(call TARGET_PATH,$(target)) endif endef $(foreach target,\ $(ALL_TARGETS) \ $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \ $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \ ,$(eval $(def_subfooter))) # # Switch context. # # push the current old makefile onto the stack. $(stack-push _SUB_MAKEFILE_STACK,$(MAKEFILE_CURRENT)) # the current makefile is the 2nd from the end of the MAKEFILE_LIST (we're the last one). __tmp := $(MAKEFILE_LIST) $(stack-popv __tmp) MAKEFILE_CURRENT := $(stack-top __tmp) PATH_SUB_CURRENT := $(abspath $(dir $(MAKEFILE_CURRENT))) endif