Commit | Line | Data |
---|---|---|
1a141be6 MW |
1 | ### -*-makefile-*- |
2 | ||
3 | .SECONDEXPANSION: #sorry | |
4 | all:: | |
5 | ||
62d4726c MW |
6 | CROSSDIR := $(shell pwd) |
7 | ||
a3c31732 MW |
8 | FLAVOURS += linux-cross |
9 | linux-cross_ARCHS = linux-armel linux-armhf linux-arm64 | |
10 | linux-armel_ARCH = arm-linux-gnueabi | |
11 | linux-armhf_ARCH = arm-linux-gnueabihf | |
12 | linux-arm64_ARCH = aarch64-linux-gnu | |
13 | ||
14 | FLAVOURS += linux-native | |
15 | linux-native_ARCHS = linux-i386 linux-amd64 | |
16 | linux-i386_ARCH = i686-linux-gnu | |
17 | linux-amd64_ARCH = x86_64-linux-gnu | |
18 | ||
19 | FLAVOURS += android-cross | |
20 | android-cross_ARCHS = android-arm android-arm64 android-x86 android-x86_64 | |
21 | android-arm_ARCH = arm-linux-androideabi | |
22 | android-arm64_ARCH = aarch64-linux-android | |
23 | android-x86_ARCH = i686-linux-android | |
24 | android-x86_64_ARCH = x86_64-linux-android | |
1a141be6 | 25 | |
f73a878f MW |
26 | CONFIG_VARS += FLAVOURS |
27 | CONFIG_VARS += $(foreach f,$(FLAVOURS), $f_ARCHS) | |
28 | ||
1a141be6 MW |
29 | V = 0 |
30 | v_tag = $(call v_tag_$V,$1) | |
31 | v_tag_0 = @printf " %-8s %s\n" "$1" "$@"; | |
7f281ec3 MW |
32 | V_AT = $(V_AT_$V) |
33 | V_AT_0 = @ | |
1a141be6 | 34 | |
a3c31732 MW |
35 | define define-setup |
36 | SETUPS += etc/$2-setup.sh | |
37 | $2_FLAVOUR = $1 | |
38 | endef | |
39 | $(foreach f,$(FLAVOURS), \ | |
40 | $(foreach a,$($f_ARCHS), \ | |
41 | $(eval $(call define-setup,$f,$a)))) | |
42 | ||
1a141be6 | 43 | TARGETS += $(SETUPS) |
a3c31732 | 44 | setup-flavour = $($1_FLAVOUR) |
1a141be6 | 45 | |
a3c31732 | 46 | $(SETUPS): etc/%-setup.sh: $$(call setup-flavour,$$*)-setup.sh.in Makefile |
4c9cd6c2 | 47 | $(V_AT)mkdir -p $(dir $@) |
041e5988 MW |
48 | $(call v_tag,SED)sed 's/@arch@/$($*_ARCH)/g' $< >$@.new && \ |
49 | mv $@.new $@ | |
1a141be6 | 50 | |
62d4726c MW |
51 | SCRIPTS = mdw-cross crosstool |
52 | BINSCRIPTS = $(addprefix bin/,$(SCRIPTS)) | |
53 | TARGETS += $(BINSCRIPTS) | |
54 | $(BINSCRIPTS): bin/%: src/%.in | |
55 | $(V_AT)mkdir -p $(dir $@) | |
56 | $(call v_tag,SED)sed 's\a@crossdir@\a$(CROSSDIR)\a' $< >$@.new && \ | |
57 | chmod +x $@.new && mv $@.new $@ | |
58 | ||
f73a878f MW |
59 | fix = $(subst -,_,$1) |
60 | quote = '$(subst ','\'',$1)'#' | |
61 | ||
62 | TARGETS += etc/config.sh | |
63 | etc/config.sh: Makefile | |
64 | $(V_AT)mkdir -p $(dir $@) | |
65 | $(call v_tag,GEN){ \ | |
66 | echo '### -*-sh-*- GENERATED by mdw-cross/Makefile'; \ | |
67 | $(foreach v,$(CONFIG_VARS), \ | |
68 | echo $(call fix,$v)=$(call quote,$(call quote,$($v)));) \ | |
69 | } >$@.new && mv $@.new $@ | |
70 | ||
1a141be6 MW |
71 | all:: $(TARGETS) |
72 | ||
73 | CLEANFILES += $(TARGETS) | |
74 | clean::; rm -f $(CLEANFILES) | |
a3c31732 MW |
75 | |
76 | show:; : $(VAR) |