-
Notifications
You must be signed in to change notification settings - Fork 128
/
Makefile.app-tools
64 lines (55 loc) · 2.2 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
_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_FILES+= specs-compile_or_ferment specs-stub specs-bake
APP_TOOL_PASSTHROUGH= ar as cpp ld nm objcopy objdump ranlib readelf
APP_TOOL_PASSTHROUGH+= size strings strip
_APP_TOOL_TARGETS:= \
$(APP_TOOL_FILES:%=$(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-%) \
$(APP_TOOL_PASSTHROUGH:%=$(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-%)
.PHONY: app-tools
app-tools: $(_APP_TOOL_TARGETS)
APP_TOOLS_MAKE := $(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-make
APP_TOOLS_CC := $(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-cc
define APPTOOLS_templ
$(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-${1}: \
$(APP_TOOLS_DIR)/${1}.in Makefile
sed <$$< >$$@.tmp \
-e 's#!CC!#$(CC)#g;' \
-e 's#!CXX!#$(CXX)#g;' \
-e 's#!GNUPLATFORM!#$(subst \
--,-rumprun-,${APP_TOOLS_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})))
define APPTOOLS_passthrough
uptool_$1=$(shell echo $1 | tr '[:lower:]' '[:upper:]')
toolval_$1=$${$${uptool_$1}}
$(APP_TOOLS_DIR)/rumprun-$(APP_TOOLS_PLATFORM)-$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)