chiark / gitweb /
etc/android-cross-config.site: Use `ccache' if available.
[mdw-cross] / Makefile
1 ### -*-makefile-*-
2
3 .SECONDEXPANSION: #sorry
4 all::
5
6 CROSSDIR                := $(shell pwd)
7
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
25
26 V                        = 0
27 v_tag                    = $(call v_tag_$V,$1)
28 v_tag_0                  = @printf "  %-8s %s\n" "$1" "$@";
29 V_AT                     = $(V_AT_$V)
30 V_AT_0                   = @
31
32 define define-setup
33 SETUPS                  += etc/$2-setup.sh
34 $2_FLAVOUR               = $1
35 endef
36 $(foreach f,$(FLAVOURS), \
37         $(foreach a,$($f_ARCHS), \
38                 $(eval $(call define-setup,$f,$a))))
39
40 TARGETS                 += $(SETUPS)
41 setup-flavour            = $($1_FLAVOUR)
42
43 $(SETUPS): etc/%-setup.sh: $$(call setup-flavour,$$*)-setup.sh.in Makefile
44         $(V_AT)mkdir -p $(dir $@)
45         $(call v_tag,SED)sed 's/@arch@/$($*_ARCH)/g' $< >$@.new && \
46                 mv $@.new $@
47
48 SCRIPTS                  = mdw-cross crosstool
49 BINSCRIPTS               = $(addprefix bin/,$(SCRIPTS))
50 TARGETS                 += $(BINSCRIPTS)
51 $(BINSCRIPTS): bin/%: src/%.in
52         $(V_AT)mkdir -p $(dir $@)
53         $(call v_tag,SED)sed 's\a@crossdir@\a$(CROSSDIR)\a' $< >$@.new && \
54                 chmod +x $@.new && mv $@.new $@
55
56 all:: $(TARGETS)
57
58 CLEANFILES              += $(TARGETS)
59 clean::; rm -f $(CLEANFILES)
60
61 show:; : $(VAR)