forked from quil-lang/quilc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
185 lines (151 loc) · 5.93 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
COMMIT_HASH=$(shell git rev-parse --short HEAD)
LISP_CACHE ?= $(HOME)/.cache/common-lisp
RIGETTI_LISP_LIBRARY_HOME=../
SBCL_BIN=sbcl
SBCL=$(SBCL_BIN) --noinform --no-userinit --no-sysinit --non-interactive
QUICKLISP_HOME=$(HOME)/quicklisp
QUICKLISP_SETUP=$(QUICKLISP_HOME)/setup.lisp
QUICKLISP=$(SBCL) --load $(QUICKLISP_HOME)/setup.lisp \
--eval '(push (truename ".") asdf:*central-registry*)' \
--eval '(push :hunchentoot-no-ssl *features*)' \
--eval '(push :drakma-no-ssl *features*)' \
--eval "(push (truename \"$(RIGETTI_LISP_LIBRARY_HOME)\") ql:*local-project-directories*)"
QUICKLISP_BOOTSTRAP_URL=https://beta.quicklisp.org/quicklisp.lisp
UNAME_S=$(shell uname -s)
ZMQ_REPO=https://download.opensuse.org/repositories/network:/messaging:/zeromq:/release-stable/xUbuntu_16.04/
PREFIX ?= /usr/local
all: quilc
###############################################################################
# SETUP
###############################################################################
$(QUICKLISP_SETUP):
mkdir -p $(QUICKLISP_HOME)
curl -o $(QUICKLISP_HOME)/quicklisp-bootstrap.lisp \
$(QUICKLISP_BOOTSTRAP_URL)
$(SBCL) --load $(QUICKLISP_HOME)/quicklisp-bootstrap \
--eval "(quicklisp-quickstart:install :path \"$(QUICKLISP_HOME)\")"
system-index.txt: $(QUICKLISP_SETUP)
$(QUICKLISP) \
$(FOREST_SDK_FEATURE) \
--eval '(ql:quickload "quilc")' \
--eval '(ql:write-asdf-manifest-file "system-index.txt")'
###############################################################################
# DEPENDENCIES
###############################################################################
dump-version-info:
$(QUICKLISP) \
--eval '(format t "~A ~A" (lisp-implementation-type) (lisp-implementation-version))' \
--eval '(print (ql-dist:find-system "alexa"))' \
--eval '(print (ql-dist:find-system "magicl"))' \
--eval '(print (ql-dist:find-system "rpcq"))' \
--eval '(terpri)' --quit
install-test-deps:
ifeq ($(UNAME_S),Linux)
ifeq ($(shell sed -n "s/^ID=//p" /etc/os-release),debian)
echo "deb http://http.us.debian.org/debian/ testing non-free contrib main" >> /etc/apt/sources.list
apt update
echo "deb $(ZMQ_REPO) ./" >> /etc/apt/sources.list
curl $(ZMQ_REPO)/Release.key | apt-key add -
apt-get install -y git libblas-dev libffi-dev liblapack-dev libzmq3-dev clang-7
else
echo "Centos-based platforms unsupported"
endif
else
echo "Non-Linux-based platforms unsupported"
endif
ifeq ($(UNAME_S),Darwin)
LIBTWEEDLEDUM := libtweedledum.dylib
else
LIBTWEEDLEDUM := libtweedledum.so
endif
.PHONY: install-tweedledum
install-tweedledum:
install src/contrib/tweedledum/$(LIBTWEEDLEDUM) /usr/local/lib
###############################################################################
# BUILD
###############################################################################
.PHONY: quilc
quilc: system-index.txt
$(SBCL) $(FOREST_SDK_FEATURE) \
--eval "(setf sb-ext:\*on-package-variance\* '(:warn (:swank :swank-backend :swank-repl) :error t))" \
--eval '(push :hunchentoot-no-ssl *features*)' \
--eval '(push :drakma-no-ssl *features*)' \
--load "build-app.lisp" \
$(FOREST_SDK_OPTION) \
$(QUILC_UNSAFE_OPTION)
quilc-sdk-base: FOREST_SDK_FEATURE=--eval '(pushnew :forest-sdk *features*)'
quilc-sdk-base: clean clean-cache quilc
# By default, relocate shared libraries on SDK builds
quilc-sdk: FOREST_SDK_OPTION=--quilc-sdk
quilc-sdk: quilc-sdk-base
# Don't relocate shared libraries on barebones SDK builds
quilc-sdk-barebones: quilc-sdk-base
quilc-unsafe: QUILC_UNSAFE_OPTION=--unsafe
quilc-unsafe: quilc
DOCKER_BUILD_TARGET=all
DOCKER_TAG=rigetti/quilc:$(COMMIT_HASH)
.PHONY: docker
docker: Dockerfile
docker build --build-arg build_target=$(DOCKER_BUILD_TARGET) \
-t $(DOCKER_TAG) .
docker-sdk: DOCKER_BUILD_TARGET=quilc-sdk
docker-sdk: DOCKER_TAG=quilc-sdk
docker-sdk: docker
docker-sdk-barebones: DOCKER_BUILD_TARGET=quilc-sdk-barebones
docker-sdk-barebones: DOCKER_TAG=quilc-sdk-barebones
docker-sdk-barebones: docker
###############################################################################
# INSTALL/UNINSTALL
###############################################################################
.PHONY: install
install: quilc
install quilc $(DESTDIR)$(PREFIX)/bin
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/quilc
###############################################################################
# TEST
###############################################################################
test:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-tests)" \
--eval "(asdf:test-system :cl-quil)" \
--eval "(ql:quickload :quilc-tests)" \
--eval "(asdf:test-system :quilc)"
test-cl-quil:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-tests)" \
--eval "(asdf:test-system :cl-quil)"
test-quilc:
$(QUICKLISP) \
--eval "(ql:quickload :quilc-tests)" \
--eval "(asdf:test-system :quilc)"
# You can specify a different c++17-compatible compiler via the CXX
# variable. For example: make CXX=/usr/bin/clang++ test-tweedledum
test-tweedledum:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil/tweedledum-tests)" \
--eval "(asdf:test-system :cl-quil/tweedledum-tests)"
test-ccl:
ccl -n --batch --load $(QUICKLISP_HOME)/setup.lisp \
--eval '(push (truename ".") asdf:*central-registry*)' \
--eval "(push (truename \"$(RIGETTI_LISP_LIBRARY_HOME)\") ql:*local-project-directories*)" \
--eval "(ql:quickload :quilc)" \
--eval '(quit)'
###############################################################################
# CLEAN
###############################################################################
.PHONY: clean clean-quicklisp clean-cache cleanall
clean:
rm -f quilc system-index.txt build-output.log
rm -f coverage-report/*.html
rm -f src/contrib/**/*.so src/contrib/**/*.dylib
clean-quicklisp:
@echo "Cleaning up old projects in Quicklisp"
$(QUICKLISP) \
--eval '(ql-dist:clean (ql-dist:dist "quicklisp"))'
clean-cache:
@echo "Deleting $(LISP_CACHE)"
rm -rf "$(LISP_CACHE)"
cleanall: clean clean-cache clean-quicklisp
@echo "All cleaned and reindexed."