-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
40 lines (30 loc) · 878 Bytes
/
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
# The author of this program disclaims copyright.
SHELL := $(shell which bash)
CC := gcc
APP := calc
srcdir = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
lemondir = $(realpath $(srcdir)/../..)
.SUFFIXES:
.SUFFIXES: .c .h
CFLAGS := -Wall -W -O2 -s -pipe -std=c99
LFLAGS := -O2 -s -pipe
all: $(APP)
lemon: $(lemondir)/lemon.c
$(CC) -I$(lemondir) -o $@ $(LFLAGS) $<
# Don't use $(APP).h as a target
# as the header file is not regenerated by
# lemon if there was no change in tokens names.
# Using $(APP).c is sufficient
# becase generating .c will always create the .h as well.
$(APP).c: lemon $(APP).y $(lemondir)/lempar.c
./lemon -T$(lemondir)/lempar.c $(APP).y
$(APP): $(APP).c $(APP).h main.c
cat main.c >> $(APP).c
$(CC) -I. -o $(APP) $(LFLAGS) $<
test: $(APP)
./$(APP)
clean:
rm -f *.o
rm -f *.out
rm -f lemon
rm -f $(APP) $(APP).c $(APP).h