-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
100 lines (75 loc) · 1.76 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
prefix = /opt/local
exec_prefix= ${prefix}
libdir = $(exec_prefix)/lib
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = $(INSTALL)
ifeq ($(patsubst gcc%,gcc,$(notdir $(basename $(CC)))),gcc)
GCCFLAGS=-ggdb3
endif
LIBJSONSL_DIR+=$(shell pwd)
LDFLAGS+=-L$(LIBJSONSL_DIR) -Wl,-rpath $(LIBJSONSL_DIR)
CFLAGS+=\
-Wall -std=gnu89 -pedantic \
-O3 $(GCCFLAGS) \
-I$(LIBJSONSL_DIR) -DJSONSL_STATE_GENERIC \
CXXFLAGS+=\
-Wall -std=c++03 -pedantic -O3 -I$(LIBJSONSL_DIR)
export CFLAGS
export LDFLAGS
export CXXFLAGS
DYLIBPREFIX=lib
ifeq ($(shell uname -s),Darwin)
DYLIBSUFFIX=.dylib
DYLIBFLAGS=-fPIC -fno-common -dynamiclib -Wl,-install_name,$(libdir)/$(LIB_FQNAME)
else
DYLIBSUFFIX=.so
DYLIBFLAGS=-shared -fPIC
endif
LIB_BASENAME=jsonsl
LIB_PREFIX?=$(DYLIBPREFIX)
LIB_SUFFIX?=$(DYLIBSUFFIX)
LIB_FQNAME = $(LIB_PREFIX)$(LIB_BASENAME)$(LIB_SUFFIX)
ifdef STATIC_LIB
LDFLAGS+=$(shell pwd)/$(LIB_FQNAME)
LIBFLAGS=-c
else
LDFLAGS+=-l$(LIB_BASENAME)
LIBFLAGS=$(DYLIBFLAGS)
endif
ifdef JSONSL_PARSE_NAN
CFLAGS+="-DJSONSL_PARSE_NAN"
endif
all: $(LIB_FQNAME)
install: all
$(INSTALL) $(LIB_FQNAME) $(DESTDIR)$(libdir)
.PHONY: examples
examples:
$(MAKE) -C $@
share: json_samples.tgz
tar xzf $^
json_examples_tarball:
rm -f json_samples.tgz
tar -czf json_samples.tgz share
check: $(LIB_FQNAME) share jsonsl.c
JSONSL_QUIET_TESTS=1 $(MAKE) -C tests
bench: share
$(MAKE) -C perf run-benchmarks
$(LIB_FQNAME): jsonsl.c
$(CC) $(CFLAGS) $(LIBFLAGS) -o $@ $^
.PHONY: doc
doc: Doxyfile
doxygen -s $^
.PHONY: clean
clean:
rm -f *.o *.so *.a
rm -f $(LIB_FQNAME)
rm -f -r share
rm -f -r *.dSYM
$(MAKE) -C examples clean
$(MAKE) -C tests clean
$(MAKE) -C perf clean
distclean: clean
rm -rf share doc *.out
dist:
-rm -f jsonsl.tar.gz
xargs < MANIFEST tar czf jsonsl.tar.gz