1CC?= gcc
2
3BIN = lib/libnmea.a
4MODULES = generate generator parse parser tok context time info gmath sentence
5SAMPLES = generate generator parse parse_file math
6
7OBJ = $(MODULES:%=build/nmea_gcc/%.o)
8LINKOBJ = $(OBJ) $(RES)
9
10SMPLS = $(SAMPLES:%=samples_%)
11SMPLOBJ = $(SAMPLES:%=samples/%/main.o)
12
13INCS = -I include
14LIBS = -lm -Llib -lnmea
15
16.PHONY: all all-before all-after clean clean-custom doc
17
18all: all-before $(BIN) samples all-after
19
20all-before:
21	mkdir -p build/nmea_gcc
22
23clean: clean-custom
24	rm -f $(LINKOBJ) $(BIN) $(SMPLOBJ) $(SMPLS)
25
26doc:
27	$(MAKE) -C doc
28
29remake: clean all
30
31$(BIN): $(LINKOBJ)
32	ar rsc $@ $^
33	ranlib $@
34
35build/nmea_gcc/%.o: src/%.c
36	$(CC) $(INCS) -c $< -o $@
37
38samples: $(SMPLS)
39
40samples_%: samples/%/main.o
41	$(CC) $< $(LIBS) -o build/$@
42
43samples/%/main.o: samples/%/main.c
44	$(CC) $(INCS) -c $< -o $@
45