This repository has been archived by the owner on Oct 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Makefile
133 lines (100 loc) · 3.33 KB
/
Makefile
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# See LICENSE file for license and copyright information
include config.mk
include colors.mk
include common.mk
SOURCE = $(wildcard ${PROJECT}/*.c)
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${SOURCE:.c=.o})
ifeq "${ARCH}" "armv7"
include config-arm.mk
CPPFLAGS += -DARM_DEVICE
endif
ifeq "${ARCH}" "armv8"
include config-arm64.mk
CPPFLAGS += -D__ARM_ARCH_8A__
endif
ifneq (${WITH_THREADS}, 0)
CPPFLAGS += -DWITH_THREADS
LIBS += -pthread
endif
ifneq (${WITH_ANDROID}, 0)
CPPFLAGS += -DWITH_ANDROID
endif
all: options ${PROJECT}
# pkg-config based version checks
.version-checks/%: config.mk
$(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
${PKG_CONFIG} --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
echo "The minimum required version of $(*) is $($(*)_MIN_VERSION)" && \
false \
)
@mkdir -p .version-checks
$(QUIET)touch $@
options:
@echo ${PROJECT} build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LIBS = ${LIBS}"
@echo "DFLAGS = ${DFLAGS}"
@echo "CC = ${CC}"
# release build
${OBJECTS}: config.mk .version-checks/LIBFLUSH
${BUILDDIR_RELEASE}/%.o: %.c
$(call colorecho,CC,$<)
@mkdir -p ${DEPENDDIR}/$(dir $@)
@mkdir -p $(dir $(abspath $@))
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF ${DEPENDDIR}/[email protected]
${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}: ${OBJECTS}
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} \
-o ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT} ${OBJECTS} ${LIBS}
${PROJECT}: ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
release: ${PROJECT}
run: release
$(QUIET)./${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT}
# debug build
${OBJECTS_DEBUG}: config.mk .version-checks/LIBFLUSH
${BUILDDIR_DEBUG}/%.o: %.c
$(call colorecho,CC,$<)
@mkdir -p ${DEPENDDIR}/$(dir $@)
@mkdir -p $(dir $(abspath $@))
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} \
-o $@ $< -MMD -MF ${DEPENDDIR}/[email protected]
${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}: ${OBJECTS_DEBUG}
$(call colorecho,CC,$@)
@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
$(QUIET)${CC} ${LDFLAGS} \
-o ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT} ${OBJECTS_DEBUG} ${LIBS}
debug: ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
run-debug: debug
$(QUIET)./${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
# clean
clean:
$(QUIET)rm -rf \
${BUILDDIR} \
${DEPENDDIR} \
${TARFILE} \
${TARDIR} \
valgrind: debug
$(QUIET)G_SLICE=always-malloc G_DEBUG=gc-friendly ${VALGRIND} ${VALGRIND_ARGUMENTS} \
${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
gdb: debug
$(QUIET)cgdb ${BUILDDIR_DEBUG}/${BINDIR}/${PROJECT}
dist: clean
$(QUIET)tar -czf $(TARFILE) --exclude=.gitignore \
--transform 's,^,${PROJECT}-$(VERSION)/,' \
`git ls-files`
install: all
$(call colorecho,INSTALL,"executeable file")
$(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin
$(QUIET)install -m 755 ${BUILDDIR_RELEASE}/${BINDIR}/${PROJECT} ${DESTDIR}${PREFIX}/bin
uninstall:
$(ECHO) removing executable file
$(call colorecho,UNINSTALL,"executeable")
$(QUIET)rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT}
DEPENDS = ${DEPENDDIRS:^=${DEPENDDIR}/}$(addprefix ${DEPENDDIR}/,${OBJECTS:.o=.o.dep})
-include ${DEPENDS}
.PHONY: all options clean doc debug valgrind gdb dist install uninstall