-
Notifications
You must be signed in to change notification settings - Fork 153
/
makefile
63 lines (57 loc) · 1.64 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
# sophia makefile
#
CC ?= cc
ifdef ENABLE_COVERAGE
CFLAGS_COVERAGE = --coverage
else
CFLAGS_COVERAGE =
endif
CFLAGS_DEBUG = -DSS_INJECTION_ENABLE -g
CFLAGS_OPT = -O2
CFLAGS_STRICT = -std=c99 -pedantic -Wextra -Wall
CFLAGS_MISC = -Wno-unused-function -fPIC -fno-stack-protector -fvisibility=hidden
SOPHIA_CFLAGS = $(CFLAGS_DEBUG) \
$(CFLAGS_OPT) \
$(CFLAGS_STRICT) \
$(CFLAGS_COVERAGE) \
$(CFLAGS_MISC) \
$(CFLAGS)
SOPHIA_LDFLAGS = -shared $(LDFLAGS)
SOPHIA_DEP = $(wildcard sophia/*/*) makefile
SOPHIA_VMAJOR = 2
SOPHIA_VMINOR = 2
SOPHIA_BUILD = `git rev-parse --short HEAD`
all: banner static dynamic
banner:
@echo "SOPHIA $(SOPHIA_VMAJOR).$(SOPHIA_VMINOR) (git: $(SOPHIA_BUILD))"
@echo
sophia.c: $(SOPHIA_DEP)
@echo sophia/build
@sh sophia/build sophia $@
sophia.h: sophia/sophia/sophia.h
@cp $< .
sophia.o: sophia.c sophia.h
@echo "$(CC) sophia.c -c $(CFLAGS_DEBUG) $(CFLAGS_COVERAGE)$(CFLAGS_OPT) $(CFLAGS_STRICT)"
@$(CC) $(SOPHIA_CFLAGS) -c sophia.c -o sophia.o
@echo
libsophia.a: sophia.o
@ar crs libsophia.a sophia.o
libsophia.so: sophia.o
@$(CC) sophia.o $(SOPHIA_LDFLAGS) -o libsophia.so.2.2.0
@ln -sf libsophia.so.2.2.0 libsophia.so.2.2
@ln -sf libsophia.so.2.2.0 libsophia.so
ifeq ($(shell uname), Linux)
@strip --strip-unneeded libsophia.so.2.2.0
endif
ifeq ($(shell uname), Darwin)
@strip -u -r -x libsophia.so.2.2.0
endif
static: libsophia.a
dynamic: libsophia.so
clean:
@rm -f sophia.c sophia.h sophia.o
@rm -f libsophia.a
@rm -f libsophia.so
@rm -f libsophia.so.2.2
@rm -f libsophia.so.2.2.0
.PHONY: all banner static dynamic clean