annotate examples/tank/Makefile @ 167:73c4e93d331c

Make makefile more flexible that user can specify dirtories. 1. directory of macro files. (M4MACRODIR) 2. directory of installed include files. (INCDIR) 3. directory of installed libraries. (LIBDIR) You can specify these variables as paramters of make command. For example, "make M4MACRODIR='../../tools'" to change directory of macro files.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 21 Oct 2008 08:32:23 +0800
parents e959ed450b67
children c490796f6c82
rev   line source
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 SVGS = brick.svg bullet.svg bush.svg mud.svg rock.svg \
155
6749f6639924 Fix bug for STAILQ that fail to remove a node.
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2 tank1.svg tank2.svg tank_en.svg bang.svg
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 SVGHS = $(SVGS:C/\.svg/.h/)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 SVGCS = $(SVGS:C/\.svg/.c/)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 SVGOS = $(SVGS:C/\.svg/.o/)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 MBS = $(SVGS:C/\.svg/.mb/)
167
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
7 SVG2CODE= svg2code.py
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
8 MB_C_HEADER= mb_c_header.m4
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
9 MB_C_SOURCE= mb_c_source.m4
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 M4 = m4
167
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
11 M4MACRODIR?= /usr/local/share/mb
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
12 M4FLAGS ?= -I $(M4MACRODIR)
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13 LDFLAGS +=
167
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
14 INCDIR?= /usr/local/include
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
15 LIBDIR?= /usr/local/lib
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
16 LIBS += -lmbfly -lX11 -L$(LIBDIR) `pkg-config --libs cairo` -L../../src
73c4e93d331c Make makefile more flexible that user can specify dirtories.
Thinker K.F. Li <thinker@branda.to>
parents: 165
diff changeset
17 CFLAGS += -I$(INCDIR) `pkg-config --cflags cairo` -I../../src
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 BIN = tank
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 all: tank
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 tank: tank_main.o $(SVGOS)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 $(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 tank_main.o: tank_main.c svgs.h
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 $(CC) $(CFLAGS) -c tank_main.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 svgs.h: $(SVGHS)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 echo "#ifndef __SVGS_H_" > $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 echo "#define __SVGS_H_" >> $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 echo >> $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 for H in $(SVGHS); do \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 echo "#include \"$$H\"" >> $@; \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 done
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 echo >> $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 echo "#endif /* __SVGS_H_ */" >> $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 .for SVG in $(SVGS)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 $(SVG:C/\.svg/.o/): $(SVG:C/.svg/.c/)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 $(CC) $(CFLAGS) -c -o $@ $(.ALLSRC)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42 $(SVG:C/\.svg/.mb/): $(SVG)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 $(SVG2CODE) $(SVG) $@
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 $(SVG:C/\.svg/.h/): $(SVG:C/\.svg/.mb/)
161
0299cdb004a1 * patch for linux, compilation still buggy.
"Mat <MatLinuxer2@gmail.com>"
parents: 155
diff changeset
46 $(M4) $(M4FLAGS) $(MB_C_HEADER) $(.ALLSRC) > $@
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 $(SVG:C/\.svg/.c/): $(SVG:C/\.svg/.mb/)
165
e959ed450b67 * compilation passed
"Mat <MatLinuxer2@gmail.com>"
parents: 164
diff changeset
49 $(M4) $(M4FLAGS) $(MB_C_SOURCE) $(.ALLSRC) > $@
115
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 .endfor
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 clean:
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 @for f in svgs.h $(SVGHS) $(SVGCS) $(SVGOS) $(MBS) \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 *~ *.core tank tank_main.o; do \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 if [ -e $$f ]; then \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 echo "delete $$f"; rm -f $$f; \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 fi; \
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 done