This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
68 lines (51 loc) · 1.37 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
PREFIX?=/usr/local
INCLUDE_DIR=$(PREFIX)/include
LIB_DIR=$(PREFIX)/lib
LIB = libjzon.a
HEADER = jzon.h
CFLAGS = -g -Wall -std=gnu11 -fPIC
LDFLAGS =
LDLIBS =
YACC = ./lemon
YFLAGS = -q
LEX = flex
LFLAGS = --header-file=lexer.h
SOURCES = parser.c lexer.c jzon.c object.c array.c
OBJECTS = $(patsubst %.c, %.o, $(SOURCES))
.PHONY: all release install uninstall test valgrind style clean dist-clean
all: $(LIB)
$(LIB): $(OBJECTS)
ar -rcs $@ $^
parser.c: lemon parser.y
$(YACC) $(YFLAGS) parser.y
lexer.c: lexer.l parser.c
$(LEX) $(LFLAGS) -o $@ $<
release: CFLAGS = -std=gnu11 -Os -march=native -flto -Wall -Wextra -Wpedantic -Wstrict-overflow -fno-strict-aliasing
release: $(LIB)
install: release
mkdir -p $(INCLUDE_DIR)
mkdir -p $(LIB_DIR)
install -m 644 $(LIB) $(LIB_DIR)/$(LIB)
install -m 644 $(HEADER) $(INCLUDE_DIR)/$(HEADER)
uninstall:
rm -f $(LIB_DIR)/$(LIB)
rm -f $(INCLUDE_DIR)/$(HEADER)
SPECK_CFLAGS = -I.
SPECK_LDFLAGS = -L.
SPECK_LIBS = -ljzon
-include speck/speck.mk
test: $(SPECK) $(LIB) $(SUITES)
@$(SPECK)
lemon: lemon.c
$(CC) -std=gnu11 -Os -Wall -o $@ $<
valgrind: $(SPECK) $(LIB) $(SUITES)
@valgrind --leak-check=full --error-exitcode=1 $(SPECK)
style:
astyle -A3s4SpHk3jn jzon.c jzon.h object.c array.c spec/*.c
clean:
rm -f $(LIB) $(OBJECTS) parser.c parser.h lexer.c lexer.h
rm -rf *.dSYM spec/*.dSYM
rm -f spec/*.so
dist-clean:
@make clean
rm -f lemon