-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
93 lines (66 loc) · 1.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS) -Isrc
OFLAGS = -O3 -DNDEBUG
#OFLAGS = -pg
OBJS = tree.o compile.o
all : peg leg
peg : peg.o $(OBJS)
$(CC) $(CFLAGS) -o $@-new peg.o $(OBJS)
mv $@-new $@
leg : leg.o $(OBJS)
$(CC) $(CFLAGS) -o $@-new leg.o $(OBJS)
mv $@-new $@
testleg : .FORCE
./leg -o [email protected] src/leg.leg
$(CC) $(CFLAGS) -Wno-unused -Wno-array-bounds -o $@ leg.c src/compile.c src/tree.c
./$@ -o [email protected] src/leg.leg
ROOT =
PREFIX = /usr/local
BINDIR = $(ROOT)$(PREFIX)/bin
MANDIR = $(ROOT)$(PREFIX)/man/man1
install : $(BINDIR) $(BINDIR)/peg $(BINDIR)/leg $(MANDIR) $(MANDIR)/peg.1
$(BINDIR) :
mkdir -p $(BINDIR)
$(BINDIR)/% : %
cp -p $< $@
strip $@
$(MANDIR) :
mkdir -p $(MANDIR)
$(MANDIR)/% : src/%
cp -p $< $@
uninstall : .FORCE
rm -f $(BINDIR)/peg
rm -f $(BINDIR)/leg
rm -f $(MANDIR)/peg.1
%.o : src/%.c
$(CC) $(CFLAGS) -c -o $@ $<
peg.o : src/peg.c src/peg.peg-c
leg.o : src/leg.c
check : check-peg check-leg
check-peg : peg.peg-c .FORCE
diff src/peg.peg-c peg.peg-c
check-leg : leg.c .FORCE
diff src/leg.c leg.c
peg.peg-c : src/peg.peg peg
./peg -o $@ $<
leg.c : src/leg.leg leg
./leg -o $@ $<
new : newpeg newleg
newpeg : peg.peg-c
mv src/peg.peg-c src/peg.peg-c-
mv peg.peg-c src/.
newleg : leg.c
mv src/leg.c src/leg.c-
mv leg.c src/.
test examples : peg leg .FORCE
$(SHELL) -ec '(cd examples; $(MAKE))'
clean : .FORCE
rm -f src/*~ *~ *.o *.peg.[cd] *.leg.[cd] peg.peg-c leg.c
$(SHELL) -ec '(cd examples; $(MAKE) $@)'
spotless : clean .FORCE
rm -f src/*-
rm -rf build
rm -f peg
rm -f leg
$(SHELL) -ec '(cd examples; $(MAKE) $@)'
.FORCE :