forked from clasp-developers/clasp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
299 lines (238 loc) · 11 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# -*- mode: GNUmakefile; indent-tabs-mode: t -*-
# Cleaned up by Shinmera October 13, 2015
export CLASP_HOME ?= $(shell pwd)
include $(wildcard $(CLASP_HOME)/local.config)
export PJOBS ?= 1
export PREFIX := $(or $(PREFIX), \
/usr/local/clasp )
export TARGET_OS ?= $(shell uname)
export TARGET_OS := $(or $(filter $(TARGET_OS), Linux),\
$(filter $(TARGET_OS), Darwin),\
$(error Invalid TARGET_OS: $(TARGET_OS)))
export ADDRESS-MODEL ?= 64
export ADDRESS-MODEL := $(or $(filter $(ADDRESS-MODEL), 64),\
$(error Invalid ADDRESS-MODEL: $(ADDRESS-MODEL)))
# From the GNU Make manual; portably search PATH for a program. We can't rely on `which` existing...
# Use $(call pathsearch,foo) instead of $(shell which foo)
pathsearch = $(firstword $(wildcard $(addsuffix /$(strip $(1)),$(subst :, ,$(PATH)))))
export CLASP_SBCL := $(or $(CLASP_SBCL),\
$(call pathsearch, sbcl),\
$(error Could not find sbcl - it needs to be installed and in your path.))
export PYTHON2 := $(or $(PYTHON2),\
$(call pathsearch, python2.7),\
$(call pathsearch, python2),\
$(call pathsearch, python),\
$(warning Could not find python.))
export EXECUTABLE_DIR ?= $(or $(and $(filter $(TARGET_OS),Linux), bin),\
$(and $(filter $(TARGET_OS),Darwin), MacOS))
export DEVEMACS ?= $(or $(and $(filter $(TARGET_OS),Linux), emacs -nw ./),\
$(and $(filter $(TARGET_OS),Darwin), open -n -a /Applications/Emacs.app ./))
ifneq ($(EXTERNALS_CLASP_DIR),)
export LLVM_CONFIG := $(or $(LLVM_CONFIG),\
$(wildcard $(EXTERNALS_CLASP_DIR)/build/release/bin/llvm-config),\
$(error Could not find llvm-config (release build) in externals-clasp.))
export LLVM_CONFIG_DEBUG := $(or $(LLVM_CONFIG_DEBUG),\
$(wildcard $(EXTERNALS_CLASP_DIR)/build/debug/bin/llvm-config),\
$(warning Could not find llvm-config (debug build) in externals-clasp.),\
$(LLVM_CONFIG))
else
# XXX: confirm the necessity of llvm-config* pathsearch!
export LLVM_CONFIG ?= $(or $(call pathsearch, llvm-config-4.0),\
$(call pathsearch, llvm-config),\
$(call pathsearch, llvm-config*),\
$(error Could not find llvm-config.))
endif
export GIT_COMMIT ?= $(shell git rev-parse --short HEAD || echo "unknown-commit")
export CLASP_VERSION ?= $(shell git describe --always || echo "unknown-version")
export LLVM_CONFIG_RELEASE ?= $(LLVM_CONFIG)
export LLVM_CONFIG_DEBUG ?= $(LLVM_CONFIG)
export LLVM_BIN_DIR ?= $(shell $(LLVM_CONFIG_RELEASE) --bindir)
# Not always the same as LLVM_BIN_DIR!
export LLVM_VERSION := $(shell $(LLVM_CONFIG) --version)
export LLVM_MAJOR_MINOR_VERSION := $(shell echo $(LLVM_VERSION) | sed 's/^\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)/\1.\2/')
export LLVM_VERSION_X100 := $(shell echo $(LLVM_VERSION) | sed 's/[.]//g' )
#$(info llvm-version is $(LLVM_VERSION))
#$(info llvm-major-minor-version is $(LLVM_MAJOR_MINOR_VERSION))
export CLASP_CLANG_PATH := $(or $(CLASP_CLANG_PATH),\
$(wildcard $(LLVM_BIN_DIR)/clang-$(LLVM_MAJOR_MINOR_VERSION)),\
$(wildcard $(LLVM_BIN_DIR)/clang),\
$(call pathsearch, clang-$(LLVM_MAJOR_MINOR_VERSION)),\
$(call pathsearch, clang),\
$(error Could not find clang - it needs to be installed and in your path.))
export CLASP_CLANGXX_PATH := $(or $(CLASP_CLANGXX_PATH),\
$(wildcard $(LLVM_BIN_DIR)/clang++-$(LLVM_MAJOR_MINOR_VERSION)),\
$(wildcard $(LLVM_BIN_DIR)/clang++),\
$(call pathsearch, clang++-$(LLVM_MAJOR_MINOR_VERSION)),\
$(call pathsearch, clang++),\
$(error Could not find clang - it needs to be installed and in your path.))
export BUILD ?= $(CLASP_HOME)/src/common/build
export CLASP_DEBUG_LLVM_LIB_DIR ?= $(shell $(LLVM_CONFIG_DEBUG) --libdir | tr -d '\n')
export CLASP_RELEASE_LLVM_LIB_DIR ?= $(shell $(LLVM_CONFIG_RELEASE) --libdir | tr -d '\n')
export CLASP_LIB_EXTENSION ?= so
export CLASP_LIB_EXTENSION := $(or $(and $(filter $(TARGET_OS), Linux ), so), \
$(and $(filter $(TARGET_OS), Darwin ), dylib), \
$(error Invalid TARGET_OS: $(TARGET_OS)))
export CLASP_DEBUG_CXXFLAGS += -I$(shell $(LLVM_CONFIG_DEBUG) --includedir)
#export CLASP_DEBUG_LINKFLAGS += -L$(CLASP_DEBUG_LLVM_LIB_DIR)
#export CLASP_DEBUG_LINKFLAGS += $(shell $(LLVM_CONFIG_DEBUG) --libs)
#export CLASP_DEBUG_LINKFLAGS += $(shell $(LLVM_CONFIG_DEBUG) --system-libs)
export CLASP_RELEASE_CXXFLAGS += -I$(shell $(LLVM_CONFIG_RELEASE) --includedir)
#export CLASP_RELEASE_LINKFLAGS += -L$(CLASP_RELEASE_LLVM_LIB_DIR)
#export CLASP_RELEASE_LINKFLAGS += $(shell $(LLVM_CONFIG_RELEASE) --libs)
#export CLASP_RELEASE_LINKFLAGS += $(shell $(LLVM_CONFIG_RELEASE) --system-libs)
ifneq ($(EXTERNALS_CLASP_DIR),)
export CLASP_DEBUG_CXXFLAGS += -I$(EXTERNALS_CLASP_DIR)/build/common/include
# export CLASP_DEBUG_LINKFLAGS += -L$(EXTERNALS_CLASP_DIR)/build/common/lib -lgmp -lgmpxx -lreadline -lexpat
export CLASP_RELEASE_CXXFLAGS += -I$(EXTERNALS_CLASP_DIR)/build/common/include
# export CLASP_RELEASE_LINKFLAGS += -L$(EXTERNALS_CLASP_DIR)/build/common/lib -lgmp -lgmpxx -lreadline -lexpat
endif
ifeq ($(TARGET_OS),Darwin)
export INCLUDE_DIRS += /usr/local/Cellar/gmp/6.0.0a/include
export INCLUDE_DIRS += /opt/local/include
export LIB_DIRS += /usr/local/Cellar/gmp/6.0.0a/lib
export LIB_DIRS += /opt/local/lib
endif
include_flags := $(foreach dir,$(INCLUDE_DIRS),$(and $(wildcard $(dir)),-I$(dir)))
lib_flags := $(foreach dir,$(LIB_DIRS),$(and $(wildcard $(dir)),-L$(dir)))
export CLASP_DEBUG_CXXFLAGS += $(include_flags)
#export CLASP_DEBUG_LINKFLAGS += $(lib_flags)
export CLASP_RELEASE_CXXFLAGS += $(include_flags)
#export CLASP_RELEASE_LINKFLAGS += $(lib_flags)
export PATH := $(LLVM_BIN_DIR):$(PATH)
export PATH := $(CLASP_HOME)/src/common:$(PATH)
export PATH := $(BINDIR):$(PATH)
ifneq ($(CXXFLAGS),)
export USE_CXXFLAGS := cxxflags=$(CXXFLAGS)
endif
ifeq ($(NO_COLOR),)
TPUT = $(call pathsearch,tput)
ifneq ($(TPUT),)
COLOR_GREEN = $(shell $(TPUT) setaf 2 2>/dev/null)
COLOR_RESET = $(shell $(TPUT) sgr0 2>/dev/null)
endif
endif
define varprint
@echo -e "$(COLOR_GREEN)$(strip $(1))$(COLOR_RESET): $($(strip $(1)))"
endef
all:
make configure
make build_cboehm
configure:
make submodules
make asdf
./waf configure --prefix=$(PREFIX)
build_cboehm:
./waf -j $(PJOBS) build_cboehm
build_cboehmdc:
./waf -j $(PJOBS) build_cboehmdc
redeye-clean:
./waf -j $(PJOBS) clean_impsprep
redeye-prep:
./waf -j $(PJOBS) build_impsprep build_cboehmdc
redeye-run:
(./build/boehmdc/iclasp-boehmdc -i ./build/boehmdc/cclasp-boehmdc-image.fasl -f ignore-extensions \
-e "(require :clasp-analyzer)" \
-e "(defparameter *compile-commands* \"`pwd`/build/mpsprep/compile_commands.json\")" \
-e "(time (clasp-analyzer:search/generate-code (clasp-analyzer:setup-clasp-analyzer-compilation-tool-database (pathname *compile-commands*))))" \
-e "(quit)")
redeye:
make redeye-prep
make redeye-run
./waf build_cboehm
pump:
(cd src/core; make pump)
(cd src/clbind; make pump)
submodules:
$(MAKE) submodules-other
$(MAKE) submodules-mps
submodules-other:
-git submodule update --init src/lisp/kernel/contrib/sicl
-git submodule update --init src/lisp/modules/asdf
-git submodule update --init src/lisp/kernel/contrib/Acclimation
# -(cd src/lisp/modules/asdf; git checkout master; git pull origin master)
submodules-mps:
-git submodule update --init src/mps
asdf:
(cd src/lisp/modules/asdf; make)
#
# Tell ASDF where to find the SICL/Code/Cleavir systems - the final // means search subdirs
#
#export CL_SOURCE_REGISTRY = $(shell echo `pwd`/src/lisp/kernel/contrib/sicl/Code/Cleavir//):$(shell echo `pwd`/src/lisp/kernel/contrib/slime//)
#
# When developing, set the CLASP_LISP_SOURCE_DIR environment variable
# to tell clasp to use the development source directly rather than the
# stuff in the clasp build target directory. This saves us the trouble of
# constantly having to copy the lisp sources to the target directory.
export DEV_CLASP_LISP_SOURCE_DIR := $(shell pwd)/src/lisp
export CLASP_LISP_SOURCE_DIR ?= $(DEV_CLASP_LISP_SOURCE_DIR)
devemacs:
@echo This shell sets up environment variables
@echo as they are defined when commands execute within the makefile
(CLASP_LISP_SOURCE_DIR=$(DEV_CLASP_LISP_SOURCE_DIR) $(DEVEMACS))
devemacs_no_clasp_lisp_source_dir:
@echo This shell sets up environment variables
@echo as they are defined when commands execute within the makefile
$(DEVEMACS)
devshell:
@echo This shell sets up environment variables
@echo as they are defined when commands execute within the makefile
(CLASP_LISP_SOURCE_DIR=$(DEV_CLASP_LISP_SOURCE_DIR) bash -l)
devshell-telemetry:
@echo This shell sets up environment variables
@echo as they are defined when commands execute within the makefile
(CLASP_LISP_SOURCE_DIR=$(DEV_CLASP_LISP_SOURCE_DIR); export CLASP_MPS_CONFIG="32 32 16 80 32 80"; export CLASP_TELEMETRY_FILE=/tmp/clasp.tel; export CLASP_TELEMETRY_MASK=3; bash)
cloc-files:
find src/ -name '*.cc' -print >/tmp/files.cloc
find include/ -name '*.h' -print >>/tmp/files.cloc
clean:
git submodule sync
./waf distclean
pull-sicl-master:
(cd src/lisp/kernel/contrib/sicl; git pull origin master)
make setup-cleavir
mps-submodule:
git submodule add -b dev/2014-08-18/non-incremental https://github.com/Ravenbrook/mps-temporary ./src/mps
asdf-submodule:
git submodule add --name updatedAsdf https://github.com/drmeister/asdf.git ./src/lisp/kernel/asdf
dump-local-config:
cat $(CLASP_HOME)/local.config
print-config:
$(info >> Makefile Configuration:)
$(call varprint, CLASP_HOME)
$(call varprint, EXTERNALS_CLASP_DIR)
$(call varprint, LLVM_CONFIG)
$(call varprint, TARGET_OS)
$(call varprint, ADDRESS-MODEL)
$(call varprint, PJOBS)
$(call varprint, LLVM_CONFIG_DEBUG)
$(call varprint, LLVM_CONFIG_RELEASE)
$(call varprint, LLVM_BIN_DIR)
$(call varprint, CLASP_CLANG_PATH)
$(call varprint, CLASP_CLANGXX_PATH)
$(call varprint, GIT_COMMIT)
$(call varprint, CLASP_VERSION)
$(call varprint, LIBATOMIC_OPS_SOURCE_DIR)
$(call varprint, CLASP_APP_EXECS)
$(call varprint, CLASP_APP_RESOURCES_DIR)
$(call varprint, CLASP_APP_RESOURCES_LIB_COMMON_DIR)
$(call varprint, CLASP_DEBUG_LLVM_LIB_DIR)
$(call varprint, CLASP_RELEASE_LLVM_LIB_DIR)
$(call varprint, CLASP_DEBUG_CXXFLAGS)
$(call varprint, CLASP_DEBUG_LINKFLAGS)
$(call varprint, CLASP_RELEASE_CXXFLAGS)
$(call varprint, CLASP_RELEASE_LINKFLAGS)
$(call varprint, DEVEMACS)
$(call varprint, PYTHON2)
$(call varprint, EXECUTABLE_DIR)
$(call varprint, BINDIR)
$(call varprint, EXECS)
$(call varprint, PATH)
$(call varprint, USE_CXXFLAGS)
clang-format:
git ls-files src/ include/ \
| perl -ne 'chomp;print "$$_\n" if -f $$_ and (/\.[hc][hcp]?p?$$/) and !-l and !m#^include/.+/generated#;' \
| xargs -P$(PJOBS) -n1 --verbose clang-format -i
docker:
docker-compose run clasp-build
docker-compose build clasp
docker-compose build cando