-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
53 lines (39 loc) · 1010 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
41
42
43
44
45
46
47
48
49
50
51
52
53
.PHONY: test
LIBS:=ncurses readline
CFLAGS += $(if $(SAN),-fsanitize=${SAN}) -Wno-unused-result
CPPFLAGS:=-I config/ ${shell pkg-config --cflags ${LIBS}}
LDLIBS=${shell pkg-config --libs ${LIBS}}
LEX:=flex
ifeq (${DEBUG}, 1)
CFLAGS += -O0 -ggdb -Wall -Wpedantic
else
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
endif
LEXD:=source/
LEXF:=$(shell find ${LEXD} -iname '*.l')
GENLEX:=$(subst .l,.c,${LEXF})
YACCD:=source/
YACCF:=$(shell find ${YACCD} -iname '*.y')
GENYACC:=$(subst .y,.c,${YACCF})
SRCD:=source/
OBJD:=object/
source:=$(shell find ${SRCD} -iname '*.c') ${GENLEX} ${GENYACC}
object:=$(subst .c,.o,$(subst ${SRCD},${OBJD},${source}))
OUTPUT:=csope
main: ${object}
${LINK.c} ${object} -o ${OUTPUT} ${LDLIBS}
object/%.o: source/%.c
${COMPILE.c} $< -o $@
source/%.c: source/%.l
${LEX} -o $@ $<
source/%.c: source/%.y
${YACC} -o $@ $<
install: ${OUTPUT}
cp ${OUTPUT} /usr/bin/
clean:
-${RM} ${GENLEX}
-${RM} ${GENYACC}
-${RM} ${object}
-${RM} ${OUTPUT}
test:
cmdtest --fast