-
Notifications
You must be signed in to change notification settings - Fork 128
/
Makefile.app-tools
74 lines (63 loc) · 2.52 KB
/
Makefile.app-tools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
_APPTOOLS_PARAMS= APP_TOOLS_GNUPLATFORM APP_TOOLS_PLATFORM APP_TOOLS_DIR
_APPTOOLS_PARAMS+= APP_TOOLS_OBJS_BAKE APP_TOOLS_LDSCRIPT_BAKE
_APPTOOLS_PARAMS+= LDFLAGS_BAKE
define varchk_tmpl
ifeq ($${$1},)
_APPTOOLS_MISSING=$1
endif
endef
$(foreach var,${_APPTOOLS_PARAMS},$(eval $(call varchk_tmpl,${var})))
ifdef _APPTOOLS_MISSING
$(error ${_APPTOOLS_MISSING} not defined)
endif
APP_TOOL_FILES= cc c++ configure make gmake
APP_TOOL_SPECS= specs-compile_or_ferment specs-stub
APP_TOOL_PASSTHROUGH= ar as cpp ld nm objcopy objdump ranlib readelf
APP_TOOL_PASSTHROUGH+= size strings strip
GNUPLATFORM:= $(subst --,-rumprun-,$(APP_TOOLS_GNUPLATFORM))
_APP_TOOL_TARGETS:= \
$(APP_TOOL_FILES:%=$(APP_TOOLS_DIR)/$(GNUPLATFORM)-%) \
$(APP_TOOL_SPECS:%=$(APP_TOOLS_DIR)/%) \
$(APP_TOOL_PASSTHROUGH:%=$(APP_TOOLS_DIR)/$(GNUPLATFORM)-%) \
$(APP_TOOLS_DIR)/rumpbake \
$(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-specs-bake
.PHONY: app-tools
app-tools: $(_APP_TOOL_TARGETS)
APP_TOOLS_MAKE := $(APP_TOOLS_DIR)/$(GNUPLATFORM)-make
APP_TOOLS_CC := $(APP_TOOLS_DIR)/$(GNUPLATFORM)-cc
define APPTOOLS_templ
$(APP_TOOLS_DIR)/${2}: \
$(APP_TOOLS_DIR)/${1} Makefile
sed <$$< >$$@.tmp \
-e 's#!CC!#$(CC)#g;' \
-e 's#!CXX!#$(CXX)#g;' \
-e 's#!GNUPLATFORM!#$(GNUPLATFORM)#g;' \
-e 's#!BASE_DIR!#$(abspath ../..)#g;' \
-e 's#!APPTOOLS_DIR!#$(APP_TOOLS_DIR)#g;' \
-e 's#!APPTOOLS_PLATFORM!#$(APP_TOOLS_PLATFORM)#g;' \
-e 's#!CPPFLAGS!#$(BUILDRUMP_TOOL_CPPFLAGS)#g;' \
-e 's#!CFLAGS!#$(BUILDRUMP_TOOL_CFLAGS)#g;' \
-e 's#!CXXFLAGS!#$(BUILDRUMP_TOOL_CXXFLAGS)#g;' \
-e 's#!OBJS_BAKE!#$(APP_TOOLS_OBJS_BAKE)#g;' \
-e 's#!LDFLAGS_BAKE!#$(LDFLAGS_BAKE)#g;' \
-e 's#!LDSCRIPT_BAKE!#$(APP_TOOLS_LDSCRIPT_BAKE)#g;'
if test -x $$<; then chmod +x $$@.tmp; fi
mv -f $$@.tmp $$@
endef
$(foreach tool,${APP_TOOL_FILES},$(eval \
$(call APPTOOLS_templ,${tool}.in,$(GNUPLATFORM)-${tool})))
$(foreach spec,${APP_TOOL_SPECS},$(eval \
$(call APPTOOLS_templ,${spec}.in,${spec})))
$(eval $(call APPTOOLS_templ,rumpbake.in,rumpbake))
$(eval $(call APPTOOLS_templ,specs-bake.in,rumprun-$(APP_TOOLS_PLATFORM)-specs-bake))
define APPTOOLS_passthrough
uptool_$1=$(shell echo $1 | tr '[:lower:]' '[:upper:]')
toolval_$1=$${$${uptool_$1}}
$(APP_TOOLS_DIR)/$(GNUPLATFORM)-$1:
printf '#!/bin/sh\n\nexec %s "$$$${@}"\n' $${toolval_${1}} >$$@.tmp
chmod +x $$@.tmp
mv -f $$@.tmp $$@
endef
$(foreach t,${APP_TOOL_PASSTHROUGH},$(eval $(call APPTOOLS_passthrough,${t})))
app-tools_clean:
rm -f $(_APP_TOOL_TARGETS)