-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.mk
92 lines (65 loc) · 1.96 KB
/
common.mk
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
82
83
84
85
86
87
88
89
90
91
92
################ common flags and rules ########################################
.DELETE_ON_ERROR:
SHELL := /bin/bash
CXX = ${CROSS_COMPILE}g++
CC = ${CROSS_COMPILE}gcc
LD = ${CXX}
LDFLAGS =
LDLIBS =
flags = -march=armv7-a -mfpu=neon -mfloat-abi=hard -mthumb
CFLAGS = ${flags}
CXXFLAGS = ${flags}
CPPFLAGS = -I . -I include
flags += -funsigned-char
flags += -fno-strict-aliasing -fwrapv
CXXFLAGS += -std=gnu++1y
CXXFLAGS += -fno-operator-names
flags += -Og -g
flags += -Wall -Wextra
#flags += -Werror
flags += -Wno-unused-parameter -Wno-error=unused-function
CXXFLAGS += -ffunction-sections -fdata-sections
flags += -fmax-errors=3
export GCC_COLORS = 1
clean ::
${RM} *.o
################ package magic #################################################
define declare_pkg =
${pkg}_CFLAGS != pkg-config --cflags ${pkg}
${pkg}_LDLIBS != pkg-config --libs ${pkg}
endef
$(foreach pkg,${declared_pkgs}, $(eval ${declare_pkg}))
CXXFLAGS += $(foreach pkg,${pkgs},${${pkg}_CFLAGS})
LDLIBS += $(foreach pkg,${pkgs},${${pkg}_LDLIBS})
################ automatic header dependencies #################################
# a place to put them out of sight
depdir := .dep
$(shell mkdir -p ${depdir})
# generate them
CPPFLAGS += -MMD -MQ $@ -MP -MF >( cat >${depdir}/$@.d )
# use them
-include ${depdir}/*.d
# clean them up
clean ::
${RM} -r ${depdir}
# fix built-in rules that bork because they think all deps are sources
%: %.o
${LINK.o} ${^:%.h=} ${LDLIBS} ${OUTPUT_OPTION}
%: %.c
${LINK.c} ${^:%.h=} ${LDLIBS} ${OUTPUT_OPTION}
%: %.cc
${LINK.cc} ${^:%.h=} ${LDLIBS} ${OUTPUT_OPTION}
################ to check what the compiler is making of your code #############
ifdef use_clang
%.asm: %.c
$(COMPILE.c) -S -Xclang -masm-verbose $(OUTPUT_OPTION) $<
%.asm: %.cc
$(COMPILE.cc) -S -Xclang -masm-verbose $(OUTPUT_OPTION) $<
else
%.asm: %.c
$(COMPILE.c) -S -g0 -fverbose-asm $(OUTPUT_OPTION) $<
%.asm: %.cc
$(COMPILE.cc) -S -g0 -fverbose-asm $(OUTPUT_OPTION) $<
endif
clean ::
${RM} *.asm