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 tests
/cutcheck.c
: $(tests
)
29 cutgen
-o tests
/cutcheck.c
$(tests
)
31 tests
/cutcheck
: tests
/cutcheck.o
$(objects
) $(tests
:.c
=.o
)
33 pkg
: check-for-version
$(program
)-$(VERSION
).
tar.gz
36 @
test "$(VERSION)" ||
{ echo Usage
: make pkg
'VERSION=<vers>'; false
; }
39 .
/pkg.sh
$(program
) $* $@
42 rm -f
$(program
) *.o .
*.d tests
/*.o tests
/cutcheck
* core gmon.out
43 rm -f
$(program
)-*.
tar.gz
46 .PHONY
: all debug
check pkg check-for-version
clean
48 # This tells make how to generate dependency files
50 @
$(SHELL
) -ec
'$(CC) -MM $(CPPFLAGS) $< \
51 | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
52 [ -s $@ ] || rm -f $@'