Makefile: Emit a `etc/config.sh' snippet about target architectures.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 22 Dec 2018 09:27:48 +0000 (09:27 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 Dec 2018 09:30:31 +0000 (09:30 +0000)
Not needed yet, but may come in handy later.

.gitignore
Makefile

index 339c3b3..5de6399 100644 (file)
@@ -1,4 +1,5 @@
 /bin/
 /inst.*/
+/etc/config.sh
 /etc/*-setup.sh
 
index 1411e61..5c1ffc1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,9 @@ android-arm64_ARCH     = aarch64-linux-android
 android-x86_ARCH        = i686-linux-android
 android-x86_64_ARCH     = x86_64-linux-android
 
+CONFIG_VARS            += FLAVOURS
+CONFIG_VARS            += $(foreach f,$(FLAVOURS), $f_ARCHS)
+
 V                       = 0
 v_tag                   = $(call v_tag_$V,$1)
 v_tag_0                         = @printf "  %-8s %s\n" "$1" "$@";
@@ -53,6 +56,18 @@ $(BINSCRIPTS): bin/%: src/%.in
        $(call v_tag,SED)sed 's\a@crossdir@\a$(CROSSDIR)\a' $< >$@.new && \
                chmod +x $@.new && mv $@.new $@
 
+fix                     = $(subst -,_,$1)
+quote                   = '$(subst ','\'',$1)'#'
+
+TARGETS                        += etc/config.sh
+etc/config.sh: Makefile
+       $(V_AT)mkdir -p $(dir $@)
+       $(call v_tag,GEN){ \
+               echo '### -*-sh-*- GENERATED by mdw-cross/Makefile'; \
+               $(foreach v,$(CONFIG_VARS), \
+                       echo $(call fix,$v)=$(call quote,$(call quote,$($v)));) \
+       } >$@.new && mv $@.new $@
+
 all:: $(TARGETS)
 
 CLEANFILES             += $(TARGETS)