-
Notifications
You must be signed in to change notification settings - Fork 407
/
makefile
163 lines (136 loc) · 3.7 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
BINARY = linux_spiffs_test
############
#
# Paths
#
############
sourcedir = src
builddir = build
#############
#
# Build tools
#
#############
CC ?= gcc
LD ?= ld
GDB ?= gdb
OBJCOPY ?= objcopy
OBJDUMP ?= objdump
MKDIR ?= mkdir -p
###############
#
# Files and libs
#
###############
NO_TEST ?= 0
CFLAGS = $(FLAGS)
ifeq (1, $(strip $(NO_TEST)))
CFILES_TEST = main.c
CFLAGS += -DNO_TEST -Werror
else
CFILES_TEST = main.c \
test_spiffs.c \
test_dev.c \
test_check.c \
test_hydrogen.c \
test_bugreports.c \
testsuites.c \
testrunner.c
CFLAGS += -D_SPIFFS_TEST
endif
include files.mk
INCLUDE_DIRECTIVES = -I./${sourcedir} -I./${sourcedir}/default -I./${sourcedir}/test
COMPILEROPTIONS = $(INCLUDE_DIRECTIVES)
COMPILEROPTIONS_APP = $(INCLUDE_DIRECTIVES) \
-Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
-Wshadow -Wcast-align -Wchar-subscripts -Winline -Wnested-externs\
-Wredundant-decls
############
#
# Tasks
#
############
vpath %.c ${sourcedir} ${sourcedir}/default ${sourcedir}/test
OBJFILES = $(CFILES:%.c=${builddir}/%.o)
OBJFILES_TEST = $(CFILES_TEST:%.c=${builddir}/%.o)
DEPFILES = $(CFILES:%.c=${builddir}/%.d) $(CFILES_TEST:%.c=${builddir}/%.d)
ALLOBJFILES += $(OBJFILES) $(OBJFILES_TEST)
DEPENDENCIES = $(DEPFILES)
# link object files, create binary
$(BINARY): $(ALLOBJFILES)
@echo "... linking"
@${CC} $(LINKEROPTIONS) -o ${builddir}/$(BINARY) $(ALLOBJFILES) $(LIBS)
ifeq (1, $(strip $(NO_TEST)))
@echo "size: `du -b ${builddir}/${BINARY} | sed 's/\([0-9]*\).*/\1/g '` bytes"
endif
-include $(DEPENDENCIES)
# compile c files
$(OBJFILES) : ${builddir}/%.o:%.c
@echo "... compile $@"
@${CC} $(COMPILEROPTIONS_APP) $(CFLAGS) -g -c -o $@ $<
$(OBJFILES_TEST) : ${builddir}/%.o:%.c
@echo "... compile $@"
@${CC} ${COMPILEROPTIONS} $(CFLAGS) -g -c -o $@ $<
# make dependencies
# @echo "... depend $@";
$(DEPFILES) : ${builddir}/%.d:%.c
@rm -f $@; \
${CC} $(COMPILEROPTIONS) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*, ${builddir}/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
all: mkdirs $(BINARY)
mkdirs:
-@${MKDIR} ${builddir}
-@${MKDIR} test_data
FILTER ?=
test: $(BINARY)
ifdef $(FILTER)
./build/$(BINARY)
else
./build/$(BINARY) -f $(FILTER)
endif
test_failed: $(BINARY)
./build/$(BINARY) _tests_fail
clean:
@echo ... removing build files in ${builddir}
@rm -f ${builddir}/*.o
@rm -f ${builddir}/*.d
@rm -f ${builddir}/*.elf
ONOFF = 1 0
OFFON = 0 1
build-all:
@for rdonly in $(ONOFF); do \
for singleton in $(ONOFF); do \
for hal_cb_xtra in $(OFFON); do \
for cache in $(OFFON); do \
for magic in $(OFFON); do \
for temporal_cache in $(OFFON); do \
for ix_map in $(OFFON); do \
echo; \
echo ============================================================; \
echo SPIFFS_READ_ONLY=$$rdonly; \
echo SPIFFS_SINGLETON=$$singleton; \
echo SPIFFS_HAL_CALLBACK_EXTRA=$$hal_cb_xtra; \
echo SPIFFS_CACHE, SPIFFS_CACHE_WR=$$cache; \
echo SPIFFS_USE_MAGIC, SPIFFS_USE_MAGIC_LENGTH=$$magic; \
echo SPIFFS_TEMPORAL_FD_CACHE=$$temporal_cache; \
echo SPIFFS_IX_MAP=$$ix_map; \
$(MAKE) clean && $(MAKE) FLAGS="\
-DSPIFFS_HAL_CALLBACK_EXTRA=$$hal_cb_xtra \
-DSPIFFS_SINGLETON=$$singleton \
-DSPIFFS_CACHE=$$cache \
-DSPIFFS_CACHE_WR=$$cache \
-DSPIFFS_READ_ONLY=$$rdonly \
-DSPIFFS_USE_MAGIC=$$magic \
-DSPIFFS_USE_MAGIC_LENGTH=$$magic \
-DSPIFFS_TEMPORAL_FD_CACHE=$$temporal_cache \
-DSPIFFS_IX_MAP=$$ix_map \
" NO_TEST=1; \
done || exit 1; \
done \
done \
done \
done \
done \
done