-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.build
81 lines (67 loc) · 2.07 KB
/
Makefile.build
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
75
76
77
78
79
80
81
.PHONY: clone config build install uninstall clean
# platform information
HOST_QUERY = $(subst -, ,$(shell $(CC) -dumpmachine 2>/dev/null))
ifneq ($(findstring mingw, $(HOST_QUERY)),)
HOST_PLATFORM := WINDOWS
else ifneq ($(findstring apple, $(HOST_QUERY)),)
HOST_PLATFORM := MACOS
else ifneq ($(findstring linux, $(HOST_QUERY)),)
HOST_PLATFORM := LINUX
else
HOST_PLATFORM := UNKNOWN
endif
# debug commands
ifeq (${PRINT_DEBUG}, y)
OUTPUT_DEV =
else
OUTPUT_DEV = > /dev/null 2>&1
endif
# common macros
# $(call patchme,DIRECTORY_TO_BE_PATCHED)
define patchme
if [ -d "$(1)" ] && [ -d "patches" ] && [ ! -f ".patched" ]; then \
$(foreach F, $(wildcard $(shell find patches -type f \( -name "*.patch" \) | sort)), patch -d $(1) -p1 < $(F); echo $(F) >> .patched;) \
fi
endef
# make targets
clone: __FORCE
@echo "\033[1;31m CLONE ${target_name}\033[0m"
@if [ ! -f .cloned ]; then \
${MAKE} ${target_name}_clone $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .cloned; fi; \
fi;
config: clone __FORCE
@echo "\033[0;36m CONFIG ${target_name}\033[0m"
@if [ ! -f .configured ]; then \
${MAKE} ${target_name}_config $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .configured; fi; \
fi;
build: config __FORCE
@echo "\033[0;35m BUILD ${target_name}\033[0m"
@if [ ! -f .built ]; then \
${MAKE} ${target_name}_build $(OUTPUT_DEV); \
if [ $$? -ne 0 ] ; then exit 1; else touch .built; fi; \
fi;
clean: __FORCE
@echo "\033[0;33m CLEAN ${target_name}\033[0m"
@${MAKE} ${target_name}_clean $(OUTPUT_DEV);
@rm -rf .built
@rm -rf .configured
@rm -rf .patched
@rm -rf .cloned
distclean: __FORCE
@echo "\033[0;31m DISTCLEAN ${target_name}\033[0m"
@${MAKE} ${target_name}_distclean $(OUTPUT_DEV);
@rm -rf .built
@rm -rf .configured
@rm -rf .patched
@rm -rf .cloned
install: build __FORCE
@echo "\033[1;34m INSTALL ${target_name}\033[0m"
@${MAKE} ${target_name}_install $(OUTPUT_DEV);
uninstall: __FORCE
@echo "\033[1;31m UNINSTALL ${target_name}\033[0m"
@${MAKE} ${target_name}_uninstall $(OUTPUT_DEV);
all: install
__FORCE:
@true