forked from smaeul/timer-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (88 loc) · 2.38 KB
/
Makefile
File metadata and controls
117 lines (88 loc) · 2.38 KB
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
#
# Copyright © 2017-2019 Samuel Holland <samuel@sholland.org>
# SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
#
SRC = .
OBJ = build
TGT = $(OBJ)/target
CROSS_COMPILE ?=
AR = $(CROSS_COMPILE)gcc-ar
CC = $(CROSS_COMPILE)gcc
HOSTAR = ar
HOSTCC = cc
COMMON_CFLAGS = -Os -pipe -std=c11 \
-fdata-sections \
-ffunction-sections \
-fno-common \
-fvar-tracking-assignments \
-g$(if $(DEBUG),gdb,0) \
-pthread \
-Wall -Wextra -Wformat=2 -Wpedantic -Wshadow \
-Werror=implicit-function-declaration \
-Werror=implicit-int \
-Werror=pointer-arith \
-Werror=pointer-sign \
-Werror=strict-prototypes \
-Werror=undef \
-Werror=vla \
-Wno-missing-field-initializers
COMMON_CPPFLAGS = -D_GNU_SOURCE \
-D_XOPEN_SOURCE=700 \
-I$(SRC)/include
AFLAGS = -Wa,--fatal-warnings
CFLAGS = $(COMMON_CFLAGS)
CPPFLAGS = $(COMMON_CPPFLAGS) \
-include $(SRC)/include/compiler.h
LDFLAGS = -Wl,-O1 \
-Wl,--fatal-warnings \
-Wl,--gc-sections
LDLIBS =
HOSTCFLAGS = $(COMMON_CFLAGS)
HOSTCPPFLAGS = $(COMMON_CPPFLAGS)
HOSTLDFLAGS =
HOSTLDLIBS =
###############################################################################
.DEFAULT_GOAL := all
MAKEFLAGS += -Rr
include $(SRC)/scripts/Makefile.kbuild
$(call descend,src)
###############################################################################
M := @$(if $(filter-out 0,$(V)),:,exec printf ' %-7s %s\n')
Q := $(if $(filter-out 0,$(V)),,@)exec
all: $(bin-all)
check: $(test-all:%=%.test)
clean:
$(Q) rm -fr $(TGT)
clobber:
$(Q) rm -fr $(OBJ)
distclean:
$(Q) rm -fr $(OBJ)
format: $(wildcard $(SRC)/include/*.h $(SRC)/src/*.c)
$(Q) clang-format -i $^
tools: $(tools-all)
%/.:
$(Q) mkdir -p $*
%.d:;
$(OBJ)/%.test: $(SRC)/scripts/test.sh $(OBJ)/%
$(M) TEST $@
$(Q) $^ $@
$(OBJ)/%: $(OBJ)/%.o
$(M) HOSTLD $@
$(Q) $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLDLIBS)
$(OBJ)/%.o: $(SRC)/%.c
$(M) HOSTCC $@
$(Q) $(HOSTCC) $(HOSTCPPFLAGS) $(HOSTCFLAGS) -MMD -c -o $@ $<
$(TGT)/%: $(TGT)/%.o
$(M) LD $@
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(TGT)/%.o: $(SRC)/%.c
$(M) CC $@
$(Q) $(CC) $(CPPFLAGS) $(CFLAGS) $(AFLAGS) -MMD -c -o $@ $<
$(TGT)/%.o: $(SRC)/%.S
$(M) AS $@
$(Q) $(CC) $(CPPFLAGS) $(AFLAGS) -MMD -c -o $@ $<
$(SRC)/Makefile:;
$(SRC)/%.h:;
.PHONY: all check clean distclean format tools
.SECONDARY:
.SUFFIXES: