summaryrefslogtreecommitdiff
path: root/build-0.3/generator
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:25:44 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:25:44 +0200
commit8286ac511144e4f17d34eac9affb97e50646344a (patch)
treef1af7320d7b6be6be059216d0ad08ac7b4f73fd0 /build-0.3/generator
parenta15cf65c44d5c224169c32ef5495b68c758134b7 (diff)
Imported Upstream version 4.0.0upstream/4.0.0
Diffstat (limited to 'build-0.3/generator')
-rw-r--r--build-0.3/generator90
1 files changed, 90 insertions, 0 deletions
diff --git a/build-0.3/generator b/build-0.3/generator
new file mode 100644
index 0000000..6ab29f2
--- /dev/null
+++ b/build-0.3/generator
@@ -0,0 +1,90 @@
+# file : build/generator
+# copyright : Copyright (c) 2004-2012 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+# This makefile is an optional, transparent generator of "thunk" makefiles
+# for the build setups with separate src and out directories. Without the
+# generator, the make invocation for this setup has the following general
+# form:
+#
+# make -C out_root/subdir -f src_root/subdir/makefile
+#
+# With the generator enabled, the same can be achieved with the following
+# shorter command:
+#
+# make -C out_root/subdir
+#
+# Or, if the subdir directory may not yet exist, with this variant:
+#
+# make -C out_root dir=subdir
+#
+# To enable the generator, you will need to instruct make to pre-load it
+# for every invocation by adding it to the MAKEFILES environment variable:
+#
+# export MAKEFILES=build-X.Y/generator
+#
+# The thunk makefiles for individual sub-directories are generated as
+# needed and are automatically removed by the disfigure target.
+#
+
+ifdef dir
+
+.PHONY: _all
+_all:
+ @mkdir -p $(dir)
+ @$(MAKE) -C $(dir) dir= $(MAKECMDGOALS)
+
+ifneq ($(MAKECMDGOALS),)
+.PHONY: $(MAKECMDGOALS)
+$(MAKECMDGOALS): _all
+else
+.DEFAULT_GOAL := _all
+endif
+
+else
+ifeq ($(wildcard makefile Makefile GNUmakefile),)
+
+define literal_newline
+
+
+endef
+
+makefile: empty :=
+makefile: space := $(empty) #
+makefile: tab := $(empty) $(empty)
+makefile: newline := $(literal_newline)
+
+
+# Find the src_root directory.
+#
+# $1 - current directory
+#
+makefile: find = \
+$(if $1,$(if $(wildcard $1/build/bootstrap-dynamic.make),$1,$(call \
+find,$(patsubst %/,%,$(dir $1)))))
+
+# Convert /foo/bar to ../../.
+#
+# $1 - relative path from $(CURDIR)
+#
+makefile: path = $(subst $(space),,$(foreach d,$(subst /, ,$1/),../))
+
+# $1 - relative path from $(CURDIR)
+#
+makefile: command_body = \
+@echo '\# Automatically generated by build.' >$@$(newline)\
+$(tab)@echo 'ifndef dir' >>$@$(newline)\
+$(tab)@echo 'override dir :=' >>$@$(newline)\
+$(tab)@echo 'include $(if $1,$(call path,$1))build/bootstrap-dynamic.make' >>$@$(newline)\
+$(tab)@echo 'include $$(src_root)$1/makefile' >>$@$(newline)\
+$(tab)@echo 'endif' >>$@
+
+# $1 - output root directory or empty if none were found
+#
+makefile: command = $(if $1,$(call command_body,$(subst $1,,$(CURDIR))))
+
+makefile:
+ $(call command,$(call find,$(CURDIR)))
+
+endif # makefile
+endif # dir