annotate examples/calculator/Makefile @ 90:bd29780bf266

Reduce redundant code
author Thinker K.F. Li <thinker@branda.to>
date Sat, 23 Aug 2008 22:23:44 +0800
parents dd813dcc232c
children 565b55508c8d
rev   line source
88
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 SVG=calculator_scr.svg
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 TOOLSDIR=../../tools
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 INCS=-I../../src
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 CFLAGS+=`pkg-config --cflags cairo` $(INCS) -Wall
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 LDFLAGS=-L../../src/ `pkg-config --libs cairo`
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 LIBS=-lmbfly
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 BINS= calc
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 all: $(BINS)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 calc: main.o $(SVG:C/.svg/.o/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 $(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 main.o: main.c $(SVG:C/.svg/.h/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 $(CC) $(CFLAGS) -c -o $@ main.c
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 $(SVG:C/.svg/.o/): $(SVG:C/.svg/.c/) $(SVG:C/.svg/.h/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 $(CC) -c $(CFLAGS) -o $@ $(SVG:C/.svg/.c/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 $(SVG:C/.svg/.mb/): $(SVG)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 $(TOOLSDIR)/svg2code.py $(.ALLSRC) $@
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 $(SVG:C/.svg/.c/): $(SVG:C/.svg/.mb/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 m4 -I $(TOOLSDIR) mb_c_source.m4 $(.ALLSRC) > $@
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 $(SVG:C/.svg/.h/): $(SVG:C/.svg/.mb/)
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 m4 -I $(TOOLSDIR) mb_c_header.m4 $(.ALLSRC) > $@
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 clean:
90
bd29780bf266 Reduce redundant code
Thinker K.F. Li <thinker@branda.to>
parents: 88
diff changeset
30 for i in *.mb *.o *.core *~ $(SVG:C/.svg/.c/) $(SVG:C/.svg/.h/) $(BINS); do \
88
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 if [ -e "$$i" ]; then \
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 echo "delete $$i"; \
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 rm -f "$$i"; \
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 fi; \
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 done