summaryrefslogtreecommitdiff
path: root/build-0.3/bootstrap.make
diff options
context:
space:
mode:
Diffstat (limited to 'build-0.3/bootstrap.make')
-rw-r--r--build-0.3/bootstrap.make88
1 files changed, 66 insertions, 22 deletions
diff --git a/build-0.3/bootstrap.make b/build-0.3/bootstrap.make
index c45f952..44eb57e 100644
--- a/build-0.3/bootstrap.make
+++ b/build-0.3/bootstrap.make
@@ -1,10 +1,7 @@
# file : build/bootstrap.make
-# author : Boris Kolpackov <boris@codesynthesis.com>
-# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC
+# copyright : Copyright (c) 2004-2012 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
-
-
# First time bootstrap.make is read
#
ifndef %makefile%
@@ -61,7 +58,16 @@ export MAKE
# also it will be consistent.
#
-%makefile% := $(abspath $(firstword $(MAKEFILE_LIST)))
+# By convention, the makefile name is the second or third last word from
+# the end. If it is the third, then the second one should be end with
+# bootstrap.make
+#
+%makefile% := $(subst $(lastword $(MAKEFILE_LIST)),,$(MAKEFILE_LIST))
+ifneq ($(filter %bootstrap.make,$(lastword $(%makefile%))),)
+%makefile% := $(subst $(lastword $(%makefile%)),,$(%makefile%))
+endif
+%makefile% := $(abspath $(lastword $(%makefile%)))
+
%makefile_realpath% := $(realpath $(%makefile%))
@@ -91,21 +97,21 @@ $(call include-search-dirs,$1,$(wordlist 2,$(words $2),$2))))
endef
# Test if $1 is a 'foreign' makefile, i.e., does not reside in
-# src_root, out_root, or bld_root.
+# src_root, out_root, or bld_root. Use shadows for src and out
+# roots to catch cases where these were reset before inclusion.
+# This happens in import stubs.
#
%frame_exclude% += include-test-foreign
define include-test-foreign
-$(if $(%foreign%),t,\
-$(if $(filter $(bld_root)/% $(src_root)/% $(out_root)/%,$1),,t))
+$(if $(%foreign%),t,$(if $(filter $(bld_root)/% $(src_root_shadow)/% $(out_root_shadow)/%,$1),,t))
endef
-
%frame_exclude% += include-body
define include-body
%interactive% :=
%makefile% := $(call include-find-makefile,$2)
-%makefile_realpath% := $(realpath $(%makefile%))
-%foreign% := $(call include-test-foreign,$(%makefile%))
+%makefile_realpath% := $$(realpath $$(%makefile%))
+%foreign% := $$(call include-test-foreign,$$(%makefile%))
$1 $$(if $$(%makefile%),$$(%makefile%),$2)
@@ -154,7 +160,7 @@ define include-once-file-body
%interactive% :=
%makefile% := $2
%makefile_realpath% := $(realpath $2)
-%foreign% := $(call include-test-foreign,$(%makefile%))
+%foreign% := $$(call include-test-foreign,$$(%makefile%))
%included_files% += $$(%makefile_realpath%)
@@ -185,7 +191,7 @@ define include-once-value-body
%interactive% :=
%makefile% := $2
%makefile_realpath% := $(realpath $2)
-%foreign% := $(call include-test-foreign,$(%makefile%))
+%foreign% := $$(call include-test-foreign,$$(%makefile%))
%include_once_$$(%makefile_realpath%)% += $7
@@ -257,7 +263,10 @@ src_base := $(abspath $(dir $(%makefile%)))
ifneq ($(src_root),$(src_base))
-ifeq ($(origin out_root),undefined)
+# In recursive make invocation, out_root may come from the environment
+# in which case we need to override it.
+#
+ifneq ($(origin out_root),file)
out_root := $(abspath $(patsubst \
%$(subst $(src_root)/,,$(src_base)),%,$(CURDIR)))
endif
@@ -266,7 +275,10 @@ out_base := $(out_root)/$(subst $(src_root)/,,$(src_base))
else
-ifeq ($(origin out_root),undefined)
+# In recursive make invocation, out_root may come from the environment
+# in which case we need to override it.
+#
+ifneq ($(origin out_root),file)
out_root := $(abspath $(CURDIR))
endif
@@ -277,15 +289,20 @@ endif
scf_root := $(src_root)/build
dcf_root := $(out_root)/build
+src_root_shadow := $(src_root)
+out_root_shadow := $(out_root)
+
$(out_root)/%: export out_root := $(out_root)
$(out_root)/%: export src_root := $(src_root)
$(out_root)/%: export scf_root := $(scf_root)
$(out_root)/%: export dcf_root := $(dcf_root)
$(out_root)/%: export project_name := $(project_name)
+# @@ Why do I need out_root here?
+#
$(out_base)/%: out_root := $(out_root)
-$(out_base)/%: out_base := $(out_base)
-$(out_base)/%: src_base := $(src_base)
+$(out_base)/%: export out_base := $(out_base)
+$(out_base)/%: export src_base := $(src_base)
ifdef build_debug
@@ -324,18 +341,45 @@ ifneq ($(bld_root),$(scf_root))
$(call -include,$(scf_root)/configuration-static.make)
endif
-
# `disfigure' target.
#
.PHONY: disfigure
+.PHONY: $(dcf_root)/.disfigure $(out_root)/.disfigure
disfigure:: $(build_absolute_clean_target)
+disfigure:: $(dcf_root)/.disfigure
+disfigure:: $(out_root)/.disfigure
+
+ifneq ($(out_root),$(out_base))
+.PHONY: $(out_base)/.disfigure
+$(out_root)/.disfigure:: $(out_base)/.disfigure
+endif
-#@@ Is there a better way?
+# Clean up generated makefiles.
#
-ifeq ($(.DEFAULT_GOAL),disfigure)
-.DEFAULT_GOAL :=
+ifndef %foreign%
+ifneq ($(out_root),$(src_root))
+$(out_base)/.disfigure::
+ $(call message, rm $$1,rm -f $$1,$(out_base)/makefile)
+endif
endif
-# Dynamic configuration.
+# Dynamic configuration (interactive check is to make sure we only do
+# this once).
#
+ifdef %interactive%
+ifneq ($(out_root),$(src_root))
+
+$(call -include,$(dcf_root)/bootstrap-dynamic.make)
+
+$(dcf_root)/bootstrap-dynamic.make: | $(dcf_root)/.
+ $(call message,,echo "src_root := $(src_root)" >$@)
+
+$(dcf_root)/.disfigure::
+ $(call message, rm $$1,rm -f $$1,$(dcf_root)/bootstrap-dynamic.make)
+endif
+endif
+
+ifeq ($(.DEFAULT_GOAL),disfigure)
+.DEFAULT_GOAL :=
+endif