blob: 6364f1d7bdfc76708617dba2e981a40ba1268b89 (
plain)
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
|
--- Makefile
+++ Makefile
@@ -1,28 +1,36 @@
-CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS)
-OFLAGS = -O3 -DNDEBUG
-#OFLAGS = -pg
+CC ?= gcc
+CFLAGS += -Wall
+
+DEBUG ?= 0
+
+ifeq ($(DEBUG), 1)
+CFLAGS += -g -DDEBUG
+else
+CFLAGS += -DNDEBUG
+endif
OBJS = tree.o compile.o
all : peg leg
peg : peg.o $(OBJS)
- $(CC) $(CFLAGS) -o $@-new peg.o $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@-new peg.o $(OBJS)
mv $@-new $@
leg : leg.o $(OBJS)
- $(CC) $(CFLAGS) -o $@-new leg.o $(OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@-new leg.o $(OBJS)
mv $@-new $@
-ROOT =
-PREFIX = /usr/local
-BINDIR = $(ROOT)$(PREFIX)/bin
-
-install : $(BINDIR)/peg $(BINDIR)/leg
-
-$(BINDIR)/% : %
- cp -p $< $@
- strip $@
+PREFIX ?= /usr/local
+BINDIR ?= $(PREFIX)/bin
+
+INSTALL ?= install
+INSTALL_PROG ?= $(INSTALL) -m755
+
+install : all
+ $(INSTALL) -d $(BINDIR)
+ $(INSTALL_PROG) peg $(BINDIR)/peg
+ $(INSTALL_PROG) leg $(BINDIR)/leg
uninstall : .FORCE
rm -f $(BINDIR)/peg
|