-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
41 lines (29 loc) · 878 Bytes
/
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
CC := gcc
CFLAGS := -O2
HEADERS = -I.
LIBS = -L.
LIB = -lgeoffrey
AR = ar
ARFLAGS = rcs
all: libgeoffrey.a
.PHONY: test
test: runtests
@./runtests
runtests: libgeoffrey.a tests/main.o tests/test_message.o tests/test_helpers.o
$(CC) -g $(CFLAGS) -Wl,--start-group $^ -Wl,--end-group -o $@
libgeoffrey.a: src/net.o src/main.o src/helpers.o src/message.o
$(AR) $(ARFLAGS) $@ $^
src/%.o: src/%.c
$(CC) $(CFLAGS) $(HEADERS) -c $^ -o $@
tests/%.o: tests/%.c tests/greatest/greatest.h
$(CC) $(CFLAGS) $(HEADERS) -c $< -o $@
examples/%.o: examples/%.c
$(CC) $(CFLAGS) $(HEADERS) -c $^ -o $@
bin/%: examples/%.o libgeoffrey.a
@mkdir -p bin
$(CC) $(CFLAGS) $^ -o $@
examples: bin/echo bin/logger bin/relay
clean:
rm -rf *.a src/*.o examples/*.o bin tests/*.o runtests
tests/greatest/greatest.h:
git clone https://github.com/silentbicycle/greatest.git tests/greatest