Use pkg-config to find dependency locations, add gdb debug flags.
authorMahlon E. Smith <mahlon@martini.nu>
Thu, 22 Sep 2011 21:43:50 -0700
changeset 6 85718bc3ff47
parent 5 7718f04c8cd1
child 7 e4f1a551d45c
Use pkg-config to find dependency locations, add gdb debug flags.
Makefile
--- a/Makefile	Thu Sep 22 21:43:25 2011 -0700
+++ b/Makefile	Thu Sep 22 21:43:50 2011 -0700
@@ -1,10 +1,10 @@
-
-CFLAGS       = -O2
-CFLAGS_DEBUG = -Wall -L /opt/local/lib -I /opt/local/include -DDEBUG -DPROG='"volta (debugmode)"'
-LIBS         = -lsqlite3
-LIBS_DEBUG   = -lprofiler  # requires proftools
+DEPS         = sqlite3
+DEPS_DEBUG   = sqlite3 libprofiler
+CFLAGS       = $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS)) -O2
+LIBS         = $(shell pkg-config --libs-only-l $(DEPS))
 #OBJS         = $(patsubst %.c,%.o,$(wildcard *.c)) parser.o
 OBJS         = accept_loop.o db.o main.o parser.o util.o
+RAGEL_FLAGS  = -LCe -G2
 
 ########################################################################
 ### P R O D U C T I O N
@@ -17,26 +17,26 @@
 $(OBJS): volta.h
 
 # don't actually depend on parser.rl, so distributions don't require ragel
-# ragel -C -T0 parser.rl -o $@
 parser.c:
-	ragel -L -C -e -G2 parser.rl -o $@
+	ragel $(RAGEL_FLAGS) -s parser.rl -o $@
 
 
 ########################################################################
 ### D E B U G
 ########################################################################
 
-debug: CFLAGS += $(CFLAGS_DEBUG)
-debug: LIBS   += $(LIBS_DEBUG)
-debug: volta-debug parser_graph.xml parser_graph.png parser_graph.dot
+debug: CFLAGS = -ggdb -Wall -DDEBUG -DPROG='"volta (debugmode)"'\
+	$(shell pkg-config --cflags-only-I --libs-only-L $(DEPS_DEBUG))
+debug: LIBS = $(shell pkg-config --libs-only-l $(DEPS_DEBUG))
+debug: volta-debug parser_graph.xml parser_graph.pdf parser_graph.dot
 
 volta-debug: $(OBJS)
 	$(CC) $(CFLAGS) $(LIBS) -o volta $(OBJS)
 
-parser_graph.xml parser_graph.png parser_graph.dot: parser.rl
-	ragel -Vp parser.rl > parser_graph.dot
-	ragel -C -e -G2 -x parser.rl -o parser_graph.xml
-	dot -Tpng parser_graph.dot > parser_graph.png
+parser_graph.xml parser_graph.pdf parser_graph.dot: parser.rl
+#	ragel -Vp parser.rl > parser_graph.dot
+#	ragel $(RAGEL_FLAGS) -x parser.rl -o parser_graph.xml
+#	dot -Tpdf parser_graph.dot > parser_graph.pdf
 
 # export CPUPROFILE="cpu.prof" before running volta for cpu profiling
 # export CPUPROFILE_FREQUENCY=100 (default)