-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile.alt
55 lines (41 loc) · 1.77 KB
/
Makefile.alt
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
# CC := gcc -std=gnu99
CC := clang
CFLAGS := -g -march=native -Wall -Wno-unused-function -Wno-unused-variable -O0 -D_GNU_SOURCE # -flto -B/home/abyrd/svn/binutils/build/gold/ld-new -use-gold-plugin
LIBS := -lzmq -lczmq -lm -lwebsockets -lprotobuf-c
SOURCES := $(wildcard *.c)
OBJECTS := $(SOURCES:.c=.o)
BINS := workerrrr-web workerrrr brrrroker client lookup-console hashgrid testerrrr explorerrrr rrrrealtime otp_api otp_client struct_test rrrrealtime-viz
BIN_BASES := $(subst rrrr,r,$(BINS))
BIN_OBJECTS := $(BIN_BASES:=.o)
OTHER_OBJECTS := $(filter-out $(BIN_OBJECTS),$(OBJECTS))
.PHONY: clean show check all
all: $(BINS)
clean:
rm -f *.o *.d *~ core $(BINS)
show:
# $(SOURCES)
# $(OBJECTS)
# $(BIN_BASES)
# $(BIN_OBJECTS)
# $(OTHER_OBJECTS)
check:
check
# -MM means create dependencies files to catch header modifications
# -MD means output them to a file, appears to be missing on clang
# -MP would be better but seems broken in clang
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
$(CC) -c -MM $(CFLAGS) $*.c > $*.d
# include dependency rules for already-existing .o files
-include $(OBJECTS:.o=.d)
# re-expand variables in subsequent rules
.SECONDEXPANSION:
# each binary depends on its own .o file and the remaining library .o files
$(BINS): $$(subst rrrr,r,$$@).o $(OTHER_OBJECTS)
$(CC) $(CFLAGS) $(subst rrrr,r,$@).o $(OTHER_OBJECTS) $(LIBS) -o $@
# rrrrealtime-viz is exceptional and compiled separately because it uses libSDL, libGL, and libshp
# these targets override the wildcard rules above.
realtime-viz.o: realtime-viz.c
$(CC) -c $(CFLAGS) $(shell sdl-config --cflags) realtime-viz.c -o $@
rrrrealtime-viz: realtime-viz.o $(OTHER_OBJECTS)
$(CC) $(CFLAGS) $(shell sdl-config --cflags) realtime-viz.o $(OTHER_OBJECTS) $(LIBS) -lSDL -lGL -lshp -o $@