Mercurial > MadButterfly
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 | 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 | 3 SVGHS = $(SVGS:C/\.svg/.h/) |
4 SVGCS = $(SVGS:C/\.svg/.c/) | |
5 SVGOS = $(SVGS:C/\.svg/.o/) | |
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 | 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 | 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 | 18 BIN = tank |
19 | |
20 all: tank | |
21 | |
22 tank: tank_main.o $(SVGOS) | |
23 $(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS) | |
24 | |
25 tank_main.o: tank_main.c svgs.h | |
26 $(CC) $(CFLAGS) -c tank_main.c | |
27 | |
28 svgs.h: $(SVGHS) | |
29 echo "#ifndef __SVGS_H_" > $@ | |
30 echo "#define __SVGS_H_" >> $@ | |
31 echo >> $@ | |
32 for H in $(SVGHS); do \ | |
33 echo "#include \"$$H\"" >> $@; \ | |
34 done | |
35 echo >> $@ | |
36 echo "#endif /* __SVGS_H_ */" >> $@ | |
37 | |
38 .for SVG in $(SVGS) | |
39 $(SVG:C/\.svg/.o/): $(SVG:C/.svg/.c/) | |
40 $(CC) $(CFLAGS) -c -o $@ $(.ALLSRC) | |
41 | |
42 $(SVG:C/\.svg/.mb/): $(SVG) | |
43 $(SVG2CODE) $(SVG) $@ | |
44 | |
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 | 47 |
48 $(SVG:C/\.svg/.c/): $(SVG:C/\.svg/.mb/) | |
165 | 49 $(M4) $(M4FLAGS) $(MB_C_SOURCE) $(.ALLSRC) > $@ |
115 | 50 |
51 .endfor | |
52 | |
53 clean: | |
54 @for f in svgs.h $(SVGHS) $(SVGCS) $(SVGOS) $(MBS) \ | |
55 *~ *.core tank tank_main.o; do \ | |
56 if [ -e $$f ]; then \ | |
57 echo "delete $$f"; rm -f $$f; \ | |
58 fi; \ | |
59 done |