]> mj.ucw.cz Git - netgrind.git/blob - Makefile
Bug...
[netgrind.git] / Makefile
1 CLANG=-std=gnu99
2 COPT=-O2 -fstrict-aliasing -finline-limit=2000
3 CWARNS=-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline
4 LOPT=
5 LIBS=
6 CDEBUG=-DDEBUG -ggdb
7
8 CFLAGS=$(CLANG) $(COPT) $(CDEBUG) $(CWARNS) -I.
9 LDFLAGS=$(LOPT)
10
11 .PHONY: all dust clean distclean programs dirtree
12
13 DIRS=
14 PROGS=
15
16 all: dirtree programs
17
18 dust::
19         rm -f `find . -path "*~" -or -name "\#*\#" -or -name core`
20
21 clean:: dust
22         rm -rf obj
23         rm -f depend depend.new TAGS
24
25 distclean:: clean
26
27 include lib/Makefile
28 include netgrind/Makefile
29
30 programs: $(PROGS)
31
32 dirtree: $(addsuffix /.dir-stamp,$(addprefix obj/,$(DIRS)))
33
34 tags:
35         etags `find . -name "*.[ch]"`
36
37 # Black magic with dependencies. It would be more correct to make "depend.new"
38 # a prerequisite for "depend", but "depend.new" often has the same timestamp
39 # as "depend" which would confuse make a lot and either force remaking anyway
40 # or (as in current versions of GNU make) erroneously skipping the remaking.
41
42 -include depend
43
44 depend: force
45         if [ -s depend.new ] ; then build/mergedeps depend depend.new ; >depend.new ; fi
46
47 force:
48
49 # Implicit rules
50
51 %.dir-stamp:
52         mkdir -p $(@D) && touch $@
53
54 %.a:
55         ar rcs $@ $?
56
57 obj/%.o: %.c
58         DEPENDENCIES_OUTPUT="depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
59
60 obj/%-tt.o: %.c
61         DEPENDENCIES_OUTPUT="depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
62
63 obj/%-t: obj/%-tt.o
64         $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
65
66 obj/%: obj/%.o
67         $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
68
69 obj/%: %.sh
70         cp $(TOPDIR)/$^ $@
71         chmod +x $@
72
73 obj/%: %.pl
74         cp $(TOPDIR)/$^ $@
75         chmod +x $@
76
77 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
78 # in GNU Make rules with targets in not-yet-existing directories are ignored
79 # when searching for implicit rules and thence targets considered intermediate.
80 .SECONDARY: