-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
104 lines (77 loc) · 3.06 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
101
102
103
104
BENZ_SRCS_C = $(wildcard extlib/benz/*.c)
BENZ_SRCS_M = $(wildcard extlib/benz/*.m)
BENZ_SRCS = $(BENZ_SRCS_C) + $(BENZ_SRCS_M)
BENZ_OBJS = $(BENZ_SRCS_C:.c=.o)
BENZ_OBJS += $(BENZ_SRCS_M:.m=.o)
PICRIN_SRCS = \
src/main.c\
src/load_piclib.c\
src/init_contrib.c
PICRIN_OBJS = \
$(PICRIN_SRCS:.c=.o)
CONTRIB_SRCS =
CONTRIB_OBJS = $(CONTRIB_SRCS:.c=.o)
CONTRIB_LIBS =
CONTRIB_DEFS =
CONTRIB_INITS =
CONTRIB_TESTS =
CONTRIB_DOCS = $(wildcard contrib/*/docs/*.rst)
PICRIN_ISSUE_TESTS = $(wildcard t/issue/*.scm)
REPL_ISSUE_TESTS = $(wildcard t/issue/*.sh)
TEST_RUNNER = bin/picrin
CFLAGS += -I./extlib/benz -I./extlib/benz/include -Wall -Wextra -DSTANDALONE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks -DSCHEME_KIT
LDFLAGS += -lm -framework Foundation -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime
prefix ?= /usr/local
all: CFLAGS += -O2 -DNDEBUG=1
all: bin/picrin
debug: CFLAGS += -O0 -g
debug: bin/picrin
include $(sort $(wildcard contrib/*/nitro.mk))
bin/picrin: CFLAGS += $(CONTRIB_DEFS)
bin/picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) $(BENZ_OBJS)
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) $(BENZ_OBJS) $(LDFLAGS)
src/load_piclib.c: $(CONTRIB_LIBS)
perl etc/mkloader.pl $(CONTRIB_LIBS) > $@
src/init_contrib.c:
perl etc/mkinit.pl $(CONTRIB_INITS) > $@
lib/libbenz.so: $(BENZ_OBJS)
$(CC) -shared $(CFLAGS) -o $@ $(BENZ_OBJS) $(LDFLAGS)
extlib/benz/boot.o: extlib/benz/boot.c
cd extlib/benz; perl boot.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BENZ_OBJS) $(PICRIN_OBJS) $(CONTRIB_OBJS): extlib/benz/include/picrin.h extlib/benz/include/picrin/*.h
doc: docs/*.rst docs/contrib.rst
$(MAKE) -C docs html
mkdir -p doc
cp -uR docs/_build/* -t doc/
docs/contrib.rst: $(CONTRIB_DOCS)
echo "Contrib Libraries \\\(a.k.a nitros\\\)" > $@
echo "================================" >> $@
echo "" >> $@
cat $(CONTRIB_DOCS) >> $@
run: bin/picrin
bin/picrin
test: test-contribs test-nostdlib test-issue
test-contribs: bin/picrin $(CONTRIB_TESTS)
test-nostdlib:
$(CC) -I extlib/benz/include -D'PIC_USE_LIBC=0' -D'PIC_USE_STDIO=0' -D'PIC_USE_WRITE=0' -ffreestanding -nostdlib -Os -fPIC -shared -std=c89 -pedantic -Wall -Wextra -Werror -o lib/libbenz-tiny.so $(BENZ_SRCS) etc/libc_polyfill.c -fno-stack-protector
strip lib/libbenz-tiny.so
ls -lh lib/libbenz-tiny.so
rm -f lib/libbenz-tiny.so
test-issue: test-picrin-issue test-repl-issue
test-picrin-issue: $(TEST_RUNNER) $(PICRIN_ISSUE_TESTS)
for test in $(PICRIN_ISSUE_TESTS); do \
$(TEST_RUNNER) "$$test"; \
done
test-repl-issue: $(REPL_ISSUE_TESTS)
$(REPL_ISSUE_TESTS):
PICRIN=$(TEST_RUNNER) ./$@
install: all
install -c bin/picrin $(prefix)/bin/picrin
clean:
rm -f src/load_piclib.c src/init_contrib.c
rm -f lib/libbenz.so
rm -f $(BENZ_OBJS)
rm -f $(PICRIN_OBJS)
rm -f $(CONTRIB_OBJS)
.PHONY: all install clean run test test-r7rs test-contribs test-issue test-picrin-issue test-repl-issue doc $(CONTRIB_TESTS) $(REPL_ISSUE_TESTS)