-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (43 loc) · 1.19 KB
/
Makefile
File metadata and controls
58 lines (43 loc) · 1.19 KB
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
.PHONY: main install clean test
PREFIX?=/usr
LIBS:=ncurses readline
CFLAGS += $(if $(SAN),-fsanitize=${SAN}) -Wno-unused-result
CPPFLAGS:=-include source/global.h -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}))
# PREFIX is old GNU automake convention and DESTDIR is Gentoo/ebuild convention
DESTDIR ?= $(or ${PREFIX},/usr/)
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}
install -d ${DESTDIR}/bin/
install ${OUTPUT} ${DESTDIR}/bin/
clean:
-${RM} ${GENLEX}
-${RM} ${GENYACC}
-${RM} ${object}
-${RM} ${OUTPUT}
test:
cmdtest --fast