Fix crash in unit tests.
[beanstalkd.git] / Makefile
blob8efa449ddcdd1acb686e588c09ff69a5ebd649b5
1 program := beanstalkd
2 export CFLAGS := $(CFLAGS) -Wall -Werror
3 export LDFLAGS := $(LDFLAGS) -levent
5 sources := $(shell ls *.c | fgrep -v $(program))
6 objects := $(sources:.c=.o)
7 tests := $(sources:%=tests/test_%)
9 all: export CFLAGS := $(CFLAGS) -O2
10 all: $(program)
12 debug: export CFLAGS := $(CFLAGS) -g -pg -DDEBUG
13 debug: export LDFLAGS := $(LDFLAGS) -pg
14 debug: $(program)
16 check: export CFLAGS := $(CFLAGS) -g -pg
17 check: export LDFLAGS := $(LDFLAGS) -pg -levent
18 check: tests/cutcheck $(objects)
19 ./tests/cutcheck
20 @echo
22 #ifneq ($(MAKECMDGOALS),clean)
23 -include $(sources:%.c=.%.d) .$(program).d
24 #endif
26 $(program): $(objects) $(program).o
28 check: export CFLAGS := $(CFLAGS) -D__LINUX__
29 tests/cutgen: tests/cutgen.c
31 tests/cutcheck.c: $(tests) tests/cutgen
32 ./tests/cutgen -o tests/cutcheck.c $(tests)
34 tests/cutcheck: tests/cutcheck.o $(objects) $(tests:.c=.o)
36 pkg: check-for-version $(program)-$(VERSION).tar.gz
38 check-for-version:
39 @test "$(VERSION)" || { echo Usage: make pkg 'VERSION=<vers>'; false; }
41 $(program)-%.tar.gz:
42 ./pkg.sh $(program) $* $@
44 clean:
45 rm -f $(program) *.o .*.d tests/*.o core core.* gmon.out
46 rm -f $(program) tests/cutcheck* tests/cutgen
47 rm -f $(program)-*.tar.gz
49 # .DELETE_ON_ERROR:
50 .PHONY: all debug check pkg check-for-version clean
52 # This tells make how to generate dependency files
53 .%.d: %.c
54 @$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
55 | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
56 [ -s $@ ] || rm -f $@'