1 UNAME := $(shell uname) |
|
2 DEPS = sqlite3 |
|
3 DEPS_DEBUG = sqlite3 libprofiler |
|
4 CFLAGS = -O2 -ansi $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS)) |
|
5 LIBS = $(shell pkg-config --libs-only-l $(DEPS)) |
|
6 #OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) parser.o |
|
7 OBJS = accept_loop.o db.o main.o parser.o process.o util.o |
|
8 RAGEL_FLAGS = -LCe -G2 |
|
9 |
|
10 .PHONY : parsegraph profile clean cleanall release |
|
11 |
1 |
12 ######################################################################## |
2 ######################################################################## |
13 ### P R O D U C T I O N |
3 ### S E T U P |
|
4 ######################################################################## |
|
5 |
|
6 UNAME := $(shell uname) |
|
7 DEPS_DEBUG = libprofiler |
|
8 CFLAGS = -O2 -DSQLITE_THREADSAFE=0 -DSQLITE_TEMP_STORE=2 |
|
9 CFLAGS_DEBUG = -DSQLITE_DEBUG -DDEBUG -DPROG='"volta (debugmode)"' -ggdb -ansi -Wall |
|
10 LIBS = |
|
11 OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) |
|
12 |
|
13 # not using pkg-config for sqlite3 anymore |
|
14 #DEPS = sqlite3 |
|
15 #CFLAGS = -O2 -ansi $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS)) |
|
16 #LIBS = $(shell pkg-config --libs-only-l $(DEPS)) |
|
17 |
|
18 .PHONY : parsegraph profile clean clobber release |
|
19 |
|
20 # Ubuntu: perftools doesn't currently register a .pc file, and |
|
21 # sqlite amalgamated requires -ldl |
|
22 ifeq ($(UNAME), Linux) |
|
23 volta: LIBS += -ldl |
|
24 debug: CFLAGS += $(CFLAGS_DEBUG) |
|
25 debug: LIBS = -lprofiler -ldl |
|
26 else |
|
27 debug: CFLAGS += $(CFLAGS_DEBUG)\ |
|
28 $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS_DEBUG)) |
|
29 debug: LIBS = $(shell pkg-config --libs-only-l $(DEPS_DEBUG)) |
|
30 endif |
|
31 |
|
32 # Fix parser line number display in debug mode |
|
33 ifeq (,$(findstring debug,$(MAKECMDGOALS))) |
|
34 RAGEL_FLAGS = -LCe -G2 |
|
35 else |
|
36 RAGEL_FLAGS = -Ce -G2 |
|
37 endif |
|
38 |
|
39 # Ensure the parser is included in the objs list |
|
40 # (patsubst wouldn't have found it if parser.c wasn't pre-generated.) |
|
41 ifneq (parser.o,$(findstring parser.o,$(OBJS))) |
|
42 OBJS += parser.o |
|
43 endif |
|
44 |
|
45 |
|
46 ######################################################################## |
|
47 ### B U I L D |
14 ######################################################################## |
48 ######################################################################## |
15 |
49 |
16 volta: $(OBJS) |
50 volta: $(OBJS) |
17 $(CC) $(CFLAGS) $(LIBS) -o $@ $(OBJS) |
51 $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) |
18 strip $@ |
52 strip $@ |
19 |
53 |
20 $(OBJS): volta.h |
54 $(OBJS): volta.h |
21 |
55 |
22 # don't actually depend on parser.rl, so distributions don't require ragel |
56 # don't actually depend on parser.rl, so distributions don't require ragel |
23 parser.c: |
57 parser.c: |
24 ragel $(RAGEL_FLAGS) -s parser.rl -o $@ |
58 ragel $(RAGEL_FLAGS) -s parser.rl -o $@ |
25 |
59 |
|
60 debug: $(OBJS) |
|
61 $(CC) $(CFLAGS) -o volta $(OBJS) $(LIBS) |
|
62 |
26 |
63 |
27 ######################################################################## |
64 ######################################################################## |
28 ### D E B U G |
65 ### U T I L |
29 ######################################################################## |
66 ######################################################################## |
30 |
|
31 # proftools doesn't currently register a .pc file on Ubuntu, hence these |
|
32 # Makefile gymnastics |
|
33 ifeq ($(UNAME), Linux) |
|
34 debug: CFLAGS = -ggdb -ansi -Wall -DDEBUG -DPROG='"volta (debugmode)"' |
|
35 debug: LIBS = -lsqlite3 -lprofiler |
|
36 else |
|
37 debug: CFLAGS = -ggdb -ansi -Wall -DDEBUG -DPROG='"volta (debugmode)"'\ |
|
38 $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS_DEBUG)) |
|
39 debug: LIBS = $(shell pkg-config --libs-only-l $(DEPS_DEBUG)) |
|
40 endif |
|
41 |
|
42 debug: RAGEL_FLAGS = -Ce -G2 |
|
43 debug: $(OBJS) |
|
44 ctags *.h *.c |
|
45 $(CC) $(CFLAGS) $(LIBS) -o volta $(OBJS) |
|
46 |
67 |
47 parsegraph: parser_graph.xml parser_graph.pdf parser_graph.dot |
68 parsegraph: parser_graph.xml parser_graph.pdf parser_graph.dot |
48 parser_graph.xml parser_graph.pdf parser_graph.dot: parser.rl |
69 parser_graph.xml parser_graph.pdf parser_graph.dot: parser.rl |
49 ragel -Vp parser.rl > parser_graph.dot |
70 ragel -Vp parser.rl > parser_graph.dot |
50 ragel $(RAGEL_FLAGS) -x parser.rl -o parser_graph.xml |
71 ragel $(RAGEL_FLAGS) -x parser.rl -o parser_graph.xml |
54 # export CPUPROFILE_FREQUENCY=100 (default) |
75 # export CPUPROFILE_FREQUENCY=100 (default) |
55 profile: |
76 profile: |
56 pprof --dot ./volta $(CPUPROFILE) | dot -Tpng > $(CPUPROFILE).png |
77 pprof --dot ./volta $(CPUPROFILE) | dot -Tpng > $(CPUPROFILE).png |
57 pprof --text ./volta $(CPUPROFILE) |
78 pprof --text ./volta $(CPUPROFILE) |
58 |
79 |
|
80 tags: |
|
81 ctags *.h *.c |
59 |
82 |
60 ######################################################################## |
83 clobber: clean |
61 ### U T I L |
|
62 ######################################################################## |
|
63 |
|
64 cleanall: clean |
|
65 rm -f parser.c volta.db ChangeLog tags |
84 rm -f parser.c volta.db ChangeLog tags |
66 |
85 |
67 clean: |
86 clean: |
68 -rm -f volta volta_debug* parser_graph.* *.o *.prof* |
87 -rm -f volta parser_graph.* *.o *.prof* |
69 |
88 |
|
89 # requires BSD tar |
70 release: VERSION = $(shell hg id -t | awk '{ print $$1 }') |
90 release: VERSION = $(shell hg id -t | awk '{ print $$1 }') |
71 release: cleanall parser.c |
91 release: cleanall parser.c |
72 hg log --style changelog > ChangeLog |
92 hg log --style changelog > ChangeLog |
73 tar -C .. --exclude misc --exclude .\* -s '/^volta/volta-$(VERSION)/' -czvf /tmp/volta-$(VERSION).tgz volta |
93 tar -C .. --exclude misc --exclude .\* -s '/^volta/volta-$(VERSION)/' -czvf /tmp/volta-$(VERSION).tgz volta |
74 mv /tmp/volta-$(VERSION).tgz . |
94 mv /tmp/volta-$(VERSION).tgz . |