-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
165 lines (137 loc) · 6.31 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Makefile for Linux, Darwin
# Requirements: GNU Make, llvm-10
# Options: DESTDIR, PREFIX, DATAMODEL(ILP32/LP64)
PROG = ypsilon
PREFIX = /usr/local
CPPFLAGS = -DNDEBUG -DSYSTEM_SHARE_PATH='"$(DESTDIR)$(PREFIX)/share/$(PROG)"' -DSYSTEM_EXTENSION_PATH='"$(DESTDIR)$(PREFIX)/lib/$(PROG)"'
CXX = clang++
CXXFLAGS = `llvm-config --cxxflags` -fcxx-exceptions
SRCS = file.cpp main.cpp object_heap_compact.cpp subr_flonum.cpp vm0.cpp vm1.cpp vm2.cpp vm3.cpp object_set.cpp \
object_slab.cpp subr_list.cpp serialize.cpp vm3.cpp port.cpp subr_others.cpp arith.cpp printer.cpp \
subr_port.cpp subr_r5rs_arith.cpp equiv.cpp reader.cpp subr_base.cpp uuid.cpp subr_socket.cpp subr_hash.cpp \
subr_unicode.cpp hash.cpp subr_base_arith.cpp ucs4.cpp ioerror.cpp subr_bitwise.cpp utf8.cpp subr_bvector.cpp \
violation.cpp object_factory.cpp subr_file.cpp subr_process.cpp object_heap.cpp subr_fixnum.cpp bit.cpp \
list.cpp fasl.cpp socket.cpp subr_c_ffi.cpp subr_codegen.cpp digamma.cpp subr_linmath.cpp
VPATH = src
UNAME = $(shell uname -a)
ifndef DATAMODEL
ifeq (,$(shell echo | $(CXX) -E -dM - | grep '__LP64__'))
DATAMODEL = ILP32
else
DATAMODEL = LP64
endif
endif
ifneq (,$(findstring Linux, $(UNAME)))
ifneq (,$(findstring aarch64, $(UNAME)))
CPPFLAGS += -DDEFAULT_HEAP_LIMIT=2048
endif
ifneq (,$(findstring x86, $(UNAME)))
ifeq ($(DATAMODEL), ILP32)
CXXFLAGS += -march=x86
CPPFLAGS += -DDEFAULT_HEAP_LIMIT=512
else
CXXFLAGS += -march=x86-64
CPPFLAGS += -DDEFAULT_HEAP_LIMIT=2048
endif
endif
CXXFLAGS += -O3 -pthread -fomit-frame-pointer -momit-leaf-frame-pointer
LDFLAGS = -fuse-ld=lld
LDLIBS = -Wl,--as-needed $(shell llvm-config --ldflags --system-libs --libs all) -pthread -Wl,--no-as-needed -ldl
endif
ifneq (,$(findstring Darwin, $(UNAME)))
CXXFLAGS += -O3 -momit-leaf-frame-pointer
CPPFLAGS += -DDEFAULT_HEAP_LIMIT=2048
LDLIBS = $(shell llvm-config --ldflags --system-libs --libs all)
endif
OBJS = $(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS))) $(patsubst %.s, %.o, $(filter %.s, $(SRCS)))
DEPS = $(patsubst %.cpp, %.d, $(filter %.cpp, $(SRCS)))
.PHONY: all install uninstall sitelib stdlib extension check bench clean distclean
all: $(PROG) $(EXTS)
@mkdir -p -m755 $(HOME)/.ypsilon
$(PROG): $(OBJS)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
install: all sitelib
mkdir -p -m755 $(DESTDIR)$(PREFIX)/bin
cp $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG)
chmod 755 $(DESTDIR)$(PREFIX)/bin/$(PROG)
uninstall:
-rm -rf $(DESTDIR)$(PREFIX)/share/$(PROG)/stdlib
-rm -rf $(DESTDIR)$(PREFIX)/share/$(PROG)/sitelib
-rm -rf $(DESTDIR)$(PREFIX)/lib/$(PROG)
-rm -f $(DESTDIR)$(PREFIX)/bin/$(PROG)
-rmdir $(DESTDIR)$(PREFIX)/share/$(PROG)
stdlib:
mkdir -p -m755 $(DESTDIR)$(PREFIX)/share/$(PROG)/stdlib
find stdlib -type f -name '*.scm' | cpio -pdu $(DESTDIR)$(PREFIX)/share/$(PROG)
find $(DESTDIR)$(PREFIX)/share/$(PROG)/stdlib -type d -exec chmod 755 {} \;
find $(DESTDIR)$(PREFIX)/share/$(PROG)/stdlib -type f -exec chmod 644 {} \;
sitelib:
mkdir -p -m755 $(DESTDIR)$(PREFIX)/share/$(PROG)/sitelib
find sitelib -type f -name '*.scm' | cpio -pdu $(DESTDIR)$(PREFIX)/share/$(PROG)
find $(DESTDIR)$(PREFIX)/share/$(PROG)/sitelib -type d -exec chmod 755 {} \;
find $(DESTDIR)$(PREFIX)/share/$(PROG)/sitelib -type f -exec chmod 644 {} \;
extension:
mkdir -p -m755 $(DESTDIR)$(PREFIX)/lib/$(PROG)
find . -type f -name '*.dylib' | cpio -pdu $(DESTDIR)$(PREFIX)/lib/$(PROG)
find $(DESTDIR)$(PREFIX)/lib/$(PROG) -type d -exec chmod 755 {} \;
find $(DESTDIR)$(PREFIX)/lib/$(PROG) -type f -exec chmod 755 {} \;
check: all
@echo '----------------------------------------'
@echo 'r4rstest.scm:'
@./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r4rstest.scm
@echo '----------------------------------------'
@echo 'tspl.scm:'
@./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/tspl.scm
@echo '----------------------------------------'
@echo 'arith.scm:'
@./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/arith.scm
@echo '----------------------------------------'
@echo 'r5rs_pitfall.scm:'
@./$(PROG) --r6rs --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r5rs-pitfall.scm
@echo '----------------------------------------'
@echo 'r6rs.scm:'
@./$(PROG) --r6rs --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r6rs.scm
@echo '----------------------------------------'
@echo 'r6rs-lib.scm:'
@./$(PROG) --r6rs --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r6rs-lib.scm
@echo '----------------------------------------'
@echo 'r6rs-more.scm:'
@./$(PROG) --r6rs --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r6rs-more.scm
@echo '----------------------------------------'
@echo 'r7rs-test.scm:'
@./$(PROG) --r7rs --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/r7rs-test.scm
@echo '----------------------------------------'
@echo 'c-ffi-test.scm:'
@./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/c-ffi-test.scm
@echo '----------------------------------------'
@echo 'syntax-rule-stress-test.scm:'
@./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib ./test/syntax-rule-stress-test.scm
@echo '----------------------------------------'
@echo 'Passed all tests'
@rm -f ./test/tmp*
eval: all
./$(PROG) --verbose --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./sitelib
bench: all
./$(PROG) --heap-limit=128 --acc=/tmp --clean-acc --sitelib=./test:./sitelib --loadpath=bench/gambit-benchmarks -- bench/run-ypsilon.scm
clean:
rm -f *.o *.d *.dylib
rm -f $(HOME)/.ypsilon/*.cache
rm -f $(HOME)/.ypsilon/*.time
distclean: clean
rm -f *.out
rm -f tmp1 tmp2 tmp3 spheres.pgm
rm -f ./test/tmp*
rm -f ./bench/gambit-benchmarks/tmp*
rm -f ./bench/gambit-benchmarks/spheres.pgm
rm -f ./heap/debug-*.vmi
rm -f $(PROG)
moreclean: distclean
find . -type f -name .DS_Store -print0 | xargs -0 rm -f
find . -type f -name '*~' -print0 | xargs -0 rm -f
%.d: %.cpp
$(SHELL) -ec '$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; [ -s $@ ] || rm -f $@'
ifeq ($(findstring clean, $(MAKECMDGOALS)), )
ifeq ($(findstring uninstall, $(MAKECMDGOALS)), )
-include $(DEPS)
endif
endif