Makefile
author Mahlon E. Smith <mahlon@martini.nu>
Mon, 17 Oct 2011 09:12:00 -0700
changeset 11 9aa5114326e8
parent 10 d07309450285
child 13 23a242d7b7fa
permissions -rw-r--r--
Carry the amalgamated sqlite3 around with volta, rather than requiring it to be installed on the system -- making volta a zero dependency compile. Add some more Makefile hacks to get things consistently building across OSX, FreeBSD, and Ubuntu. (There may be more later, but I'll deal with those then.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
     1
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
     2
########################################################################
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     3
### S E T U P
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     4
########################################################################
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     5
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     6
UNAME       := $(shell uname)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     7
DEPS_DEBUG   = libprofiler
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     8
CFLAGS       = -O2 -DSQLITE_THREADSAFE=0 -DSQLITE_TEMP_STORE=2
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
     9
CFLAGS_DEBUG = -DSQLITE_DEBUG -DDEBUG -DPROG='"volta (debugmode)"' -ggdb -ansi -Wall
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    10
LIBS         = 
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    11
OBJS         = $(patsubst %.c,%.o,$(wildcard *.c))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    12
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    13
# not using pkg-config for sqlite3 anymore
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    14
#DEPS        = sqlite3
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    15
#CFLAGS      = -O2 -ansi $(shell pkg-config --cflags-only-I --libs-only-L $(DEPS))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    16
#LIBS        = $(shell pkg-config --libs-only-l $(DEPS))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    17
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    18
.PHONY : parsegraph profile clean clobber release
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    19
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    20
# Ubuntu: perftools doesn't currently register a .pc file, and
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    21
# sqlite amalgamated requires -ldl
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    22
ifeq ($(UNAME), Linux)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    23
volta: LIBS += -ldl
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    24
debug: CFLAGS += $(CFLAGS_DEBUG)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    25
debug: LIBS = -lprofiler -ldl
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    26
else
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    27
debug: CFLAGS += $(CFLAGS_DEBUG)\
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    28
	$(shell pkg-config --cflags-only-I --libs-only-L $(DEPS_DEBUG))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    29
debug: LIBS = $(shell pkg-config --libs-only-l $(DEPS_DEBUG))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    30
endif
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    31
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    32
# Fix parser line number display in debug mode
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    33
ifeq (,$(findstring debug,$(MAKECMDGOALS)))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    34
	RAGEL_FLAGS = -LCe -G2
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    35
else
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    36
	RAGEL_FLAGS = -Ce -G2
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    37
endif
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    38
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    39
# Ensure the parser is included in the objs list
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    40
# (patsubst wouldn't have found it if parser.c wasn't pre-generated.)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    41
ifneq (parser.o,$(findstring parser.o,$(OBJS)))
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    42
	OBJS += parser.o
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    43
endif
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    44
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    45
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    46
########################################################################
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    47
### B U I L D
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    48
########################################################################
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    49
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    50
volta: $(OBJS)
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    51
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    52
	strip $@
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    53
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    54
$(OBJS): volta.h
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    55
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    56
# don't actually depend on parser.rl, so distributions don't require ragel
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    57
parser.c:
6
85718bc3ff47 Use pkg-config to find dependency locations, add gdb debug flags.
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    58
	ragel $(RAGEL_FLAGS) -s parser.rl -o $@
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    59
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    60
debug: $(OBJS)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    61
	$(CC) $(CFLAGS) -o volta $(OBJS) $(LIBS)
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    62
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    63
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    64
########################################################################
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    65
### U T I L
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    66
########################################################################
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    67
8
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    68
parsegraph: parser_graph.xml parser_graph.pdf parser_graph.dot
6
85718bc3ff47 Use pkg-config to find dependency locations, add gdb debug flags.
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    69
parser_graph.xml parser_graph.pdf parser_graph.dot: parser.rl
8
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    70
	ragel -Vp parser.rl > parser_graph.dot
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    71
	ragel $(RAGEL_FLAGS) -x parser.rl -o parser_graph.xml
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    72
	dot -Tpdf parser_graph.dot > parser_graph.pdf
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    73
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    74
# export CPUPROFILE="cpu.prof" before running volta for cpu profiling
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    75
# export CPUPROFILE_FREQUENCY=100 (default)
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    76
profile:
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    77
	pprof --dot ./volta $(CPUPROFILE) | dot -Tpng > $(CPUPROFILE).png
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    78
	pprof --text ./volta $(CPUPROFILE)
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    79
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    80
tags:
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    81
	ctags *.h *.c
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    82
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    83
clobber: clean
8
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    84
	rm -f parser.c volta.db ChangeLog tags
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    85
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    86
clean:
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    87
	-rm -f volta parser_graph.* *.o *.prof*
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    88
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
    89
# requires BSD tar
8
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    90
release: VERSION = $(shell hg id -t | awk '{ print $$1 }')
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    91
release: cleanall parser.c
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    92
	hg log --style changelog > ChangeLog
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    93
	tar -C .. --exclude misc --exclude .\*  -s '/^volta/volta-$(VERSION)/' -czvf /tmp/volta-$(VERSION).tgz volta
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    94
	mv /tmp/volta-$(VERSION).tgz .
8d0f25ef038e Add common archive files (LICENCE, README, etc) and a 'release' Makefile
Mahlon E. Smith <mahlon@martini.nu>
parents: 6
diff changeset
    95