forked from beanstalkd/beanstalkd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
57 lines (41 loc) · 1.44 KB
/
Makefile
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
55
56
program := beanstalkd
export CFLAGS := $(CFLAGS) -Wall -Werror
export LDFLAGS := $(LDFLAGS) -levent
sources := $(shell ls *.c | fgrep -v $(program))
objects := $(sources:.c=.o)
tests := $(sources:%=tests/test_%)
all: export CFLAGS := $(CFLAGS) -O2
all: $(program)
debug: export CFLAGS := $(CFLAGS) -g -pg -DDEBUG
debug: export LDFLAGS := $(LDFLAGS) -pg
debug: $(program)
check: export CFLAGS := $(CFLAGS) -g -pg
check: export LDFLAGS := $(LDFLAGS) -pg -levent
check: tests/cutcheck $(objects)
./tests/cutcheck
@echo
#ifneq ($(MAKECMDGOALS),clean)
-include $(sources:%.c=.%.d) .$(program).d
#endif
$(program): $(objects) $(program).o
check: export CFLAGS := $(CFLAGS) -D__LINUX__
tests/cutgen: tests/cutgen.c
tests/cutcheck.c: $(tests) tests/cutgen
./tests/cutgen -o tests/cutcheck.c $(tests)
tests/cutcheck: tests/cutcheck.o $(objects) $(tests:.c=.o)
pkg: check-for-version $(program)-$(VERSION).tar.gz
check-for-version:
@test "$(VERSION)" || { echo Usage: make pkg 'VERSION=<vers>'; false; }
$(program)-%.tar.gz:
./pkg.sh $(program) $* $@
clean:
rm -f $(program) *.o .*.d tests/*.o core core.* gmon.out
rm -f $(program) tests/cutcheck* tests/cutgen
rm -f $(program)-*.tar.gz
# .DELETE_ON_ERROR:
.PHONY: all debug check pkg check-for-version clean
# This tells make how to generate dependency files
.%.d: %.c
@$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'