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
12 debug
: export CFLAGS
:= $(CFLAGS
) -g
-pg
-DDEBUG
13 debug
: export LDFLAGS
:= $(LDFLAGS
) -pg
16 check: export CFLAGS
:= $(CFLAGS
) -g
-pg
17 check: export LDFLAGS
:= $(LDFLAGS
) -pg
-levent
18 check: tests
/cutcheck
$(objects
)
22 #ifneq ($(MAKECMDGOALS),clean)
23 -include $(sources
:%.c
=.
%.d
) .
$(program
).d
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
39 @
test "$(VERSION)" ||
{ echo Usage
: make pkg
'VERSION=<vers>'; false
; }
42 .
/pkg.sh
$(program
) $* $@
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
50 .PHONY
: all debug
check pkg check-for-version
clean
52 # This tells make how to generate dependency files
54 @
$(SHELL
) -ec
'$(CC) -MM $(CPPFLAGS) $< \
55 | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
56 [ -s $@ ] || rm -f $@'