43c3a7af4d9e4d8e8c92fb6263b4c25c0fc9f95d
[yosys.git] / Makefile
1
2 CONFIG := clang
3 # CONFIG := gcc
4 # CONFIG := gcc-4.8
5 # CONFIG := afl-gcc
6 # CONFIG := emcc
7 # CONFIG := wasi
8 # CONFIG := mxe
9 # CONFIG := msys2
10 # CONFIG := msys2-64
11
12 # features (the more the better)
13 ENABLE_TCL := 1
14 ENABLE_ABC := 1
15 ENABLE_GLOB := 1
16 ENABLE_PLUGINS := 1
17 ENABLE_READLINE := 1
18 ENABLE_EDITLINE := 0
19 ENABLE_VERIFIC := 0
20 ENABLE_COVER := 1
21 ENABLE_LIBYOSYS := 0
22 ENABLE_PROTOBUF := 0
23 ENABLE_ZLIB := 1
24
25 # python wrappers
26 ENABLE_PYOSYS := 0
27
28 # other configuration flags
29 ENABLE_GCOV := 0
30 ENABLE_GPROF := 0
31 ENABLE_DEBUG := 0
32 ENABLE_NDEBUG := 0
33 ENABLE_CCACHE := 0
34 # sccache is not always a drop-in replacement for ccache in practice
35 ENABLE_SCCACHE := 0
36 LINK_CURSES := 0
37 LINK_TERMCAP := 0
38 LINK_ABC := 0
39 # Needed for environments that can't run executables (i.e. emscripten, wasm)
40 DISABLE_SPAWN := 0
41 # Needed for environments that don't have proper thread support (i.e. emscripten, wasm--for now)
42 DISABLE_ABC_THREADS := 0
43
44 # clang sanitizers
45 SANITIZER =
46 # SANITIZER = address
47 # SANITIZER = memory
48 # SANITIZER = undefined
49 # SANITIZER = cfi
50
51 PROGRAM_PREFIX :=
52
53 OS := $(shell uname -s)
54 PREFIX ?= /usr/local
55 INSTALL_SUDO :=
56
57 ifneq ($(wildcard Makefile.conf),)
58 include Makefile.conf
59 endif
60
61 ifeq ($(ENABLE_PYOSYS),1)
62 ENABLE_LIBYOSYS := 1
63 endif
64
65 BINDIR := $(PREFIX)/bin
66 LIBDIR := $(PREFIX)/lib/$(PROGRAM_PREFIX)yosys
67 DATDIR := $(PREFIX)/share/$(PROGRAM_PREFIX)yosys
68
69 EXE =
70 OBJS =
71 GENFILES =
72 EXTRA_OBJS =
73 EXTRA_TARGETS =
74 TARGETS = $(PROGRAM_PREFIX)yosys$(EXE) $(PROGRAM_PREFIX)yosys-config
75
76 PRETTY = 1
77 SMALL = 0
78
79 # Unit test
80 UNITESTPATH := tests/unit
81
82 all: top-all
83
84 YOSYS_SRC := $(dir $(firstword $(MAKEFILE_LIST)))
85 VPATH := $(YOSYS_SRC)
86
87 CXXFLAGS := $(CXXFLAGS) -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -MP -D_YOSYS_ -fPIC -I$(PREFIX)/include
88 LDLIBS := $(LDLIBS) -lstdc++ -lm
89 PLUGIN_LDFLAGS :=
90
91 PKG_CONFIG ?= pkg-config
92 SED ?= sed
93 BISON ?= bison
94 STRIP ?= strip
95 AWK ?= awk
96
97 ifeq ($(OS), Darwin)
98 PLUGIN_LDFLAGS += -undefined dynamic_lookup
99
100 # homebrew search paths
101 ifneq ($(shell :; command -v brew),)
102 BREW_PREFIX := $(shell brew --prefix)/opt
103 $(info $$BREW_PREFIX is [${BREW_PREFIX}])
104 ifeq ($(ENABLE_PYOSYS),1)
105 CXXFLAGS += -I$(BREW_PREFIX)/boost/include/boost
106 LDFLAGS += -L$(BREW_PREFIX)/boost/lib
107 endif
108 CXXFLAGS += -I$(BREW_PREFIX)/readline/include
109 LDFLAGS += -L$(BREW_PREFIX)/readline/lib
110 PKG_CONFIG_PATH := $(BREW_PREFIX)/libffi/lib/pkgconfig:$(PKG_CONFIG_PATH)
111 PKG_CONFIG_PATH := $(BREW_PREFIX)/tcl-tk/lib/pkgconfig:$(PKG_CONFIG_PATH)
112 export PATH := $(BREW_PREFIX)/bison/bin:$(BREW_PREFIX)/gettext/bin:$(BREW_PREFIX)/flex/bin:$(PATH)
113
114 # macports search paths
115 else ifneq ($(shell :; command -v port),)
116 PORT_PREFIX := $(patsubst %/bin/port,%,$(shell :; command -v port))
117 CXXFLAGS += -I$(PORT_PREFIX)/include
118 LDFLAGS += -L$(PORT_PREFIX)/lib
119 PKG_CONFIG_PATH := $(PORT_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
120 export PATH := $(PORT_PREFIX)/bin:$(PATH)
121 endif
122
123 else
124 LDFLAGS += -rdynamic
125 LDLIBS += -lrt
126 endif
127
128 YOSYS_VER := 0.9+3696
129 GIT_REV := $(shell cd $(YOSYS_SRC) && git rev-parse --short HEAD 2> /dev/null || echo UNKNOWN)
130 OBJS = kernel/version_$(GIT_REV).o
131
132 bumpversion:
133 sed -i "/^YOSYS_VER := / s/+[0-9][0-9]*$$/+`git log --oneline 8a4c6e6.. | wc -l`/;" Makefile
134
135 # set 'ABCREV = default' to use abc/ as it is
136 #
137 # Note: If you do ABC development, make sure that 'abc' in this directory
138 # is just a symlink to your actual ABC working directory, as 'make mrproper'
139 # will remove the 'abc' directory and you do not want to accidentally
140 # delete your work on ABC..
141 ABCREV = 4f5f73d
142 ABCPULL = 1
143 ABCURL ?= https://github.com/YosysHQ/abc
144 ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1
145
146 # set ABCEXTERNAL = <abc-command> to use an external ABC instance
147 # Note: The in-tree ABC (yosys-abc) will not be installed when ABCEXTERNAL is set.
148 ABCEXTERNAL ?=
149
150 define newline
151
152
153 endef
154
155 ifneq ($(wildcard Makefile.conf),)
156 # don't echo Makefile.conf contents when invoked to print source versions
157 ifeq ($(findstring echo-,$(MAKECMDGOALS)),)
158 $(info $(subst $$--$$,$(newline),$(shell sed 's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr -d '\n' | sed 's,\$$--\$$$$,,')))
159 endif
160 include Makefile.conf
161 endif
162
163 PYTHON_EXECUTABLE := $(shell if python3 -c ""; then echo "python3"; else echo "python"; fi)
164 ifeq ($(ENABLE_PYOSYS),1)
165 PYTHON_VERSION_TESTCODE := "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));print(t)"
166 PYTHON_VERSION := $(shell $(PYTHON_EXECUTABLE) -c ""$(PYTHON_VERSION_TESTCODE)"")
167 PYTHON_MAJOR_VERSION := $(shell echo $(PYTHON_VERSION) | cut -f1 -d.)
168
169 ENABLE_PYTHON_CONFIG_EMBED ?= $(shell $(PYTHON_EXECUTABLE)-config --embed --libs > /dev/null && echo 1)
170 ifeq ($(ENABLE_PYTHON_CONFIG_EMBED),1)
171 PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config --embed
172 else
173 PYTHON_CONFIG := $(PYTHON_EXECUTABLE)-config
174 endif
175
176 PYTHON_DESTDIR := $(shell $(PYTHON_EXECUTABLE) -c "import site; print(site.getsitepackages()[-1]);")
177
178 # Reload Makefile.conf to override python specific variables if defined
179 ifneq ($(wildcard Makefile.conf),)
180 include Makefile.conf
181 endif
182
183 endif
184
185 ifeq ($(CONFIG),clang)
186 CXX = clang
187 LD = clang++
188 CXXFLAGS += -std=c++11 -Os
189 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
190
191 ifneq ($(SANITIZER),)
192 $(info [Clang Sanitizer] $(SANITIZER))
193 CXXFLAGS += -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=$(SANITIZER)
194 LDFLAGS += -g -fsanitize=$(SANITIZER)
195 ifeq ($(SANITIZER),address)
196 ENABLE_COVER := 0
197 endif
198 ifeq ($(SANITIZER),memory)
199 CXXFLAGS += -fPIE -fsanitize-memory-track-origins
200 LDFLAGS += -fPIE -fsanitize-memory-track-origins
201 endif
202 ifeq ($(SANITIZER),cfi)
203 CXXFLAGS += -flto
204 LDFLAGS += -flto
205 endif
206 endif
207
208 else ifeq ($(CONFIG),gcc)
209 CXX = gcc
210 LD = gcc
211 CXXFLAGS += -std=c++11 -Os
212 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
213
214 else ifeq ($(CONFIG),gcc-static)
215 LD = $(CXX)
216 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -static
217 LDLIBS := $(filter-out -lrt,$(LDLIBS))
218 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
219 CXXFLAGS += -std=c++11 -Os
220 ABCMKARGS = CC="$(CC)" CXX="$(CXX)" LD="$(LD)" ABC_USE_LIBSTDCXX=1 LIBS="-lm -lpthread -static" OPTFLAGS="-O" \
221 ARCHFLAGS="-DABC_USE_STDINT_H -DABC_NO_DYNAMIC_LINKING=1 -Wno-unused-but-set-variable $(ARCHFLAGS)" ABC_USE_NO_READLINE=1
222 ifeq ($(DISABLE_ABC_THREADS),1)
223 ABCMKARGS += "ABC_USE_NO_PTHREADS=1"
224 endif
225
226 else ifeq ($(CONFIG),gcc-4.8)
227 CXX = gcc-4.8
228 LD = gcc-4.8
229 CXXFLAGS += -std=c++11 -Os
230 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
231
232 else ifeq ($(CONFIG),afl-gcc)
233 CXX = AFL_QUIET=1 AFL_HARDEN=1 afl-gcc
234 LD = AFL_QUIET=1 AFL_HARDEN=1 afl-gcc
235 CXXFLAGS += -std=c++11 -Os
236 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
237
238 else ifeq ($(CONFIG),cygwin)
239 CXX = gcc
240 LD = gcc
241 CXXFLAGS += -std=gnu++11 -Os
242 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
243
244 else ifeq ($(CONFIG),emcc)
245 CXX = emcc
246 LD = emcc
247 CXXFLAGS := -std=c++11 $(filter-out -fPIC -ggdb,$(CXXFLAGS))
248 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H -DABC_MEMALIGN=8"
249 EMCCFLAGS := -Os -Wno-warn-absolute-paths
250 EMCCFLAGS += --memory-init-file 0 --embed-file share -s NO_EXIT_RUNTIME=1
251 EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt','_errmsg','_memset']"
252 EMCCFLAGS += -s TOTAL_MEMORY=134217728
253 EMCCFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]'
254 # https://github.com/kripken/emscripten/blob/master/src/settings.js
255 CXXFLAGS += $(EMCCFLAGS)
256 LDFLAGS += $(EMCCFLAGS)
257 LDLIBS =
258 EXE = .js
259
260 DISABLE_SPAWN := 1
261
262 TARGETS := $(filter-out $(PROGRAM_PREFIX)yosys-config,$(TARGETS))
263 EXTRA_TARGETS += yosysjs-$(YOSYS_VER).zip
264
265 ifeq ($(ENABLE_ABC),1)
266 LINK_ABC := 1
267 DISABLE_ABC_THREADS := 1
268 endif
269
270 viz.js:
271 wget -O viz.js.part https://github.com/mdaines/viz.js/releases/download/0.0.3/viz.js
272 mv viz.js.part viz.js
273
274 yosysjs-$(YOSYS_VER).zip: yosys.js yosys.wasm viz.js misc/yosysjs/*
275 rm -rf yosysjs-$(YOSYS_VER) yosysjs-$(YOSYS_VER).zip
276 mkdir -p yosysjs-$(YOSYS_VER)
277 cp viz.js misc/yosysjs/* yosys.js yosys.wasm yosysjs-$(YOSYS_VER)/
278 zip -r yosysjs-$(YOSYS_VER).zip yosysjs-$(YOSYS_VER)
279
280 yosys.html: misc/yosys.html
281 $(P) cp misc/yosys.html yosys.html
282
283 else ifeq ($(CONFIG),wasi)
284 ifeq ($(WASI_SDK),)
285 CXX = clang
286 LD = clang++
287 AR = llvm-ar
288 RANLIB = llvm-ranlib
289 WASIFLAGS := -target wasm32-wasi --sysroot $(WASI_SYSROOT) $(WASIFLAGS)
290 else
291 CXX = $(WASI_SDK)/bin/clang
292 LD = $(WASI_SDK)/bin/clang++
293 AR = $(WASI_SDK)/bin/ar
294 RANLIB = $(WASI_SDK)/bin/ranlib
295 WASIFLAGS := --sysroot $(WASI_SDK)/share/wasi-sysroot $(WASIFLAGS)
296 endif
297 CXXFLAGS := $(WASIFLAGS) -std=c++11 -Os $(filter-out -fPIC,$(CXXFLAGS))
298 LDFLAGS := $(WASIFLAGS) -Wl,-z,stack-size=1048576 $(filter-out -rdynamic,$(LDFLAGS))
299 LDLIBS := $(filter-out -lrt,$(LDLIBS))
300 ABCMKARGS += AR="$(AR)" RANLIB="$(RANLIB)"
301 ABCMKARGS += ARCHFLAGS="$(WASIFLAGS) -DABC_USE_STDINT_H -DABC_NO_DYNAMIC_LINKING"
302 ABCMKARGS += OPTFLAGS="-Os"
303 EXE = .wasm
304
305 DISABLE_SPAWN := 1
306
307 ifeq ($(ENABLE_ABC),1)
308 LINK_ABC := 1
309 DISABLE_ABC_THREADS := 1
310 endif
311
312 else ifeq ($(CONFIG),mxe)
313 PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config
314 CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-g++
315 LD = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-g++
316 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_MXE_HACKS -Wno-attributes
317 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
318 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
319 LDLIBS := $(filter-out -lrt,$(LDLIBS))
320 ABCMKARGS += ARCHFLAGS="-DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
321 # TODO: Try to solve pthread linking issue in more appropriate way
322 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" LDFLAGS="-Wl,--allow-multiple-definition" ABC_USE_NO_READLINE=1 CC="/usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc"
323 EXE = .exe
324
325 else ifeq ($(CONFIG),msys2)
326 CXX = i686-w64-mingw32-g++
327 LD = i686-w64-mingw32-g++
328 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
329 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
330 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
331 LDLIBS := $(filter-out -lrt,$(LDLIBS))
332 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
333 ABCMKARGS += LIBS="-lpthread -s" ABC_USE_NO_READLINE=0 CC="i686-w64-mingw32-gcc" CXX="$(CXX)"
334 EXE = .exe
335
336 else ifeq ($(CONFIG),msys2-64)
337 CXX = x86_64-w64-mingw32-g++
338 LD = x86_64-w64-mingw32-g++
339 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
340 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
341 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
342 LDLIBS := $(filter-out -lrt,$(LDLIBS))
343 ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
344 ABCMKARGS += LIBS="-lpthread -s" ABC_USE_NO_READLINE=0 CC="x86_64-w64-mingw32-gcc" CXX="$(CXX)"
345 EXE = .exe
346
347 else ifneq ($(CONFIG),none)
348 $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.8, emcc, mxe, msys2, msys2-64)
349 endif
350
351 ifeq ($(ENABLE_LIBYOSYS),1)
352 TARGETS += libyosys.so
353 endif
354
355 ifeq ($(ENABLE_PYOSYS),1)
356
357 #Detect name of boost_python library. Some distros usbe boost_python-py<version>, other boost_python<version>, some only use the major version number, some a concatenation of major and minor version numbers
358 ifeq ($(OS), Darwin)
359 BOOST_PYTHON_LIB ?= $(shell \
360 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null $(shell $(PYTHON_CONFIG) --ldflags) -lboost_python-py$(subst .,,$(PYTHON_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python-py$(subst .,,$(PYTHON_VERSION))"; else \
361 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null $(shell $(PYTHON_CONFIG) --ldflags) -lboost_python-py$(subst .,,$(PYTHON_MAJOR_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python-py$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
362 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null $(shell $(PYTHON_CONFIG) --ldflags) -lboost_python$(subst .,,$(PYTHON_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python$(subst .,,$(PYTHON_VERSION))"; else \
363 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null $(shell $(PYTHON_CONFIG) --ldflags) -lboost_python$(subst .,,$(PYTHON_MAJOR_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
364 echo ""; fi; fi; fi; fi;)
365 else
366 BOOST_PYTHON_LIB ?= $(shell \
367 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null `$(PYTHON_CONFIG) --libs` -lboost_python-py$(subst .,,$(PYTHON_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python-py$(subst .,,$(PYTHON_VERSION))"; else \
368 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null `$(PYTHON_CONFIG) --libs` -lboost_python-py$(subst .,,$(PYTHON_MAJOR_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python-py$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
369 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null `$(PYTHON_CONFIG) --libs` -lboost_python$(subst .,,$(PYTHON_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python$(subst .,,$(PYTHON_VERSION))"; else \
370 if echo "int main(int argc, char ** argv) {return 0;}" | $(CXX) -xc -o /dev/null `$(PYTHON_CONFIG) --libs` -lboost_python$(subst .,,$(PYTHON_MAJOR_VERSION)) - > /dev/null 2>&1; then echo "-lboost_python$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
371 echo ""; fi; fi; fi; fi;)
372 endif
373
374 ifeq ($(BOOST_PYTHON_LIB),)
375 $(error BOOST_PYTHON_LIB could not be detected. Please define manually)
376 endif
377
378 ifeq ($(OS), Darwin)
379 ifeq ($(PYTHON_MAJOR_VERSION),3)
380 LDLIBS += $(shell $(PYTHON_CONFIG) --ldflags) $(BOOST_PYTHON_LIB) -lboost_system -lboost_filesystem
381 CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DWITH_PYTHON
382 else
383 LDLIBS += $(shell $(PYTHON_CONFIG) --ldflags) $(BOOST_PYTHON_LIB) -lboost_system -lboost_filesystem
384 CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DWITH_PYTHON
385 endif
386 else
387 ifeq ($(PYTHON_MAJOR_VERSION),3)
388 LDLIBS += $(shell $(PYTHON_CONFIG) --libs) $(BOOST_PYTHON_LIB) -lboost_system -lboost_filesystem
389 CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DWITH_PYTHON
390 else
391 LDLIBS += $(shell $(PYTHON_CONFIG) --libs) $(BOOST_PYTHON_LIB) -lboost_system -lboost_filesystem
392 CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DWITH_PYTHON
393 endif
394 endif
395
396 ifeq ($(ENABLE_PYOSYS),1)
397 PY_WRAPPER_FILE = kernel/python_wrappers
398 OBJS += $(PY_WRAPPER_FILE).o
399 PY_GEN_SCRIPT= py_wrap_generator
400 PY_WRAP_INCLUDES := $(shell python$(PYTHON_VERSION) -c "from misc import $(PY_GEN_SCRIPT); $(PY_GEN_SCRIPT).print_includes()")
401 endif
402 endif
403
404 ifeq ($(ENABLE_READLINE),1)
405 CXXFLAGS += -DYOSYS_ENABLE_READLINE
406 ifeq ($(OS), FreeBSD)
407 CXXFLAGS += -I/usr/local/include
408 endif
409 LDLIBS += -lreadline
410 ifeq ($(LINK_CURSES),1)
411 LDLIBS += -lcurses
412 ABCMKARGS += "ABC_READLINE_LIBRARIES=-lcurses -lreadline"
413 endif
414 ifeq ($(LINK_TERMCAP),1)
415 LDLIBS += -ltermcap
416 ABCMKARGS += "ABC_READLINE_LIBRARIES=-lreadline -ltermcap"
417 endif
418 ifeq ($(CONFIG),mxe)
419 LDLIBS += -ltermcap
420 endif
421 else
422 ifeq ($(ENABLE_EDITLINE),1)
423 CXXFLAGS += -DYOSYS_ENABLE_EDITLINE
424 LDLIBS += -ledit -ltinfo -lbsd
425 else
426 ABCMKARGS += "ABC_USE_NO_READLINE=1"
427 endif
428 endif
429
430 ifeq ($(DISABLE_ABC_THREADS),1)
431 ABCMKARGS += "ABC_USE_NO_PTHREADS=1"
432 endif
433
434 ifeq ($(DISABLE_SPAWN),1)
435 CXXFLAGS += -DYOSYS_DISABLE_SPAWN
436 endif
437
438 ifeq ($(ENABLE_PLUGINS),1)
439 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS
440 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi)
441 ifneq ($(OS), FreeBSD)
442 LDLIBS += -ldl
443 endif
444 endif
445
446 ifeq ($(ENABLE_GLOB),1)
447 CXXFLAGS += -DYOSYS_ENABLE_GLOB
448 endif
449
450 ifeq ($(ENABLE_ZLIB),1)
451 CXXFLAGS += -DYOSYS_ENABLE_ZLIB
452 LDLIBS += -lz
453 endif
454
455
456 ifeq ($(ENABLE_TCL),1)
457 TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')")
458 ifeq ($(OS), FreeBSD)
459 TCL_INCLUDE ?= /usr/local/include/$(TCL_VERSION)
460 else
461 TCL_INCLUDE ?= /usr/include/$(TCL_VERSION)
462 endif
463
464 ifeq ($(CONFIG),mxe)
465 CXXFLAGS += -DYOSYS_ENABLE_TCL
466 LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv
467 else
468 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL
469 ifeq ($(OS), FreeBSD)
470 # FreeBSD uses tcl8.6, but lib is named "libtcl86"
471 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION) | tr -d '.')
472 else
473 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION))
474 endif
475 endif
476 endif
477
478 ifeq ($(ENABLE_GCOV),1)
479 CXXFLAGS += --coverage
480 LDFLAGS += --coverage
481 endif
482
483 ifeq ($(ENABLE_GPROF),1)
484 CXXFLAGS += -pg
485 LDFLAGS += -pg
486 endif
487
488 ifeq ($(ENABLE_NDEBUG),1)
489 CXXFLAGS := -O3 -DNDEBUG $(filter-out -Os -ggdb,$(CXXFLAGS))
490 endif
491
492 ifeq ($(ENABLE_DEBUG),1)
493 ifeq ($(CONFIG),clang)
494 CXXFLAGS := -O0 -DDEBUG $(filter-out -Os,$(CXXFLAGS))
495 else
496 CXXFLAGS := -Og -DDEBUG $(filter-out -Os,$(CXXFLAGS))
497 endif
498 endif
499
500 ifeq ($(ENABLE_ABC),1)
501 CXXFLAGS += -DYOSYS_ENABLE_ABC
502 ifeq ($(LINK_ABC),1)
503 CXXFLAGS += -DYOSYS_LINK_ABC
504 ifeq ($(DISABLE_ABC_THREADS),0)
505 LDLIBS += -lpthread
506 endif
507 else
508 ifeq ($(ABCEXTERNAL),)
509 TARGETS += $(PROGRAM_PREFIX)yosys-abc$(EXE)
510 endif
511 endif
512 endif
513
514 ifeq ($(ENABLE_VERIFIC),1)
515 VERIFIC_DIR ?= /usr/local/src/verific_lib
516 VERIFIC_COMPONENTS ?= verilog vhdl database util containers hier_tree
517 CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -DYOSYS_ENABLE_VERIFIC
518 ifeq ($(OS), Darwin)
519 LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-mac.a,$(VERIFIC_COMPONENTS)) -lz
520 else
521 LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS)) -lz
522 endif
523 endif
524
525 ifeq ($(ENABLE_PROTOBUF),1)
526 LDLIBS += $(shell pkg-config --cflags --libs protobuf)
527 endif
528
529 ifeq ($(ENABLE_COVER),1)
530 CXXFLAGS += -DYOSYS_ENABLE_COVER
531 endif
532
533 ifeq ($(ENABLE_CCACHE),1)
534 CXX := ccache $(CXX)
535 else
536 ifeq ($(ENABLE_SCCACHE),1)
537 CXX := sccache $(CXX)
538 endif
539 endif
540
541 define add_share_file
542 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
543 $(subst //,/,$(1)/$(notdir $(2))): $(2)
544 $$(P) mkdir -p $(1)
545 $$(Q) cp "$(YOSYS_SRC)"/$(2) $(subst //,/,$(1)/$(notdir $(2)))
546 endef
547
548 define add_gen_share_file
549 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
550 $(subst //,/,$(1)/$(notdir $(2))): $(2)
551 $$(P) mkdir -p $(1)
552 $$(Q) cp $(2) $(subst //,/,$(1)/$(notdir $(2)))
553 endef
554
555 define add_include_file
556 $(eval $(call add_share_file,$(dir share/include/$(1)),$(1)))
557 endef
558
559 define add_extra_objs
560 EXTRA_OBJS += $(1)
561 .SECONDARY: $(1)
562 endef
563
564 ifeq ($(PRETTY), 1)
565 P_STATUS = 0
566 P_OFFSET = 0
567 P_UPDATE = $(eval P_STATUS=$(shell echo $(OBJS) $(PROGRAM_PREFIX)yosys$(EXE) | $(AWK) 'BEGIN { RS = " "; I = $(P_STATUS)+0; } $$1 == "$@" && NR > I { I = NR; } END { print I; }'))
568 P_SHOW = [$(shell $(AWK) "BEGIN { N=$(words $(OBJS) $(PROGRAM_PREFIX)yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
569 P = @echo "$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
570 Q = @
571 S = -s
572 else
573 P_SHOW = ->
574 P =
575 Q =
576 S =
577 endif
578
579 $(eval $(call add_include_file,kernel/yosys.h))
580 $(eval $(call add_include_file,kernel/hashlib.h))
581 $(eval $(call add_include_file,kernel/log.h))
582 $(eval $(call add_include_file,kernel/rtlil.h))
583 $(eval $(call add_include_file,kernel/register.h))
584 $(eval $(call add_include_file,kernel/celltypes.h))
585 $(eval $(call add_include_file,kernel/celledges.h))
586 $(eval $(call add_include_file,kernel/consteval.h))
587 $(eval $(call add_include_file,kernel/constids.inc))
588 $(eval $(call add_include_file,kernel/sigtools.h))
589 $(eval $(call add_include_file,kernel/modtools.h))
590 $(eval $(call add_include_file,kernel/macc.h))
591 $(eval $(call add_include_file,kernel/utils.h))
592 $(eval $(call add_include_file,kernel/satgen.h))
593 $(eval $(call add_include_file,kernel/ff.h))
594 $(eval $(call add_include_file,kernel/ffinit.h))
595 $(eval $(call add_include_file,kernel/mem.h))
596 $(eval $(call add_include_file,libs/ezsat/ezsat.h))
597 $(eval $(call add_include_file,libs/ezsat/ezminisat.h))
598 $(eval $(call add_include_file,libs/sha1/sha1.h))
599 $(eval $(call add_include_file,libs/json11/json11.hpp))
600 $(eval $(call add_include_file,passes/fsm/fsmdata.h))
601 $(eval $(call add_include_file,frontends/ast/ast.h))
602 $(eval $(call add_include_file,backends/rtlil/rtlil_backend.h))
603 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl.h))
604 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl_vcd.h))
605 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl_capi.cc))
606 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl_capi.h))
607 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl_vcd_capi.cc))
608 $(eval $(call add_include_file,backends/cxxrtl/cxxrtl_vcd_capi.h))
609
610 OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/yosys.o
611 OBJS += kernel/cellaigs.o kernel/celledges.o kernel/satgen.o kernel/mem.o
612
613 kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
614 kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"' -DYOSYS_PROGRAM_PREFIX='"$(PROGRAM_PREFIX)"'
615
616 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
617 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
618
619 OBJS += libs/sha1/sha1.o
620
621 ifneq ($(SMALL),1)
622
623 OBJS += libs/json11/json11.o
624
625 OBJS += libs/subcircuit/subcircuit.o
626
627 OBJS += libs/ezsat/ezsat.o
628 OBJS += libs/ezsat/ezminisat.o
629
630 OBJS += libs/minisat/Options.o
631 OBJS += libs/minisat/SimpSolver.o
632 OBJS += libs/minisat/Solver.o
633 OBJS += libs/minisat/System.o
634
635 include $(YOSYS_SRC)/frontends/*/Makefile.inc
636 include $(YOSYS_SRC)/passes/*/Makefile.inc
637 include $(YOSYS_SRC)/backends/*/Makefile.inc
638 include $(YOSYS_SRC)/techlibs/*/Makefile.inc
639
640 else
641
642 include $(YOSYS_SRC)/frontends/verilog/Makefile.inc
643 include $(YOSYS_SRC)/frontends/rtlil/Makefile.inc
644 include $(YOSYS_SRC)/frontends/ast/Makefile.inc
645 include $(YOSYS_SRC)/frontends/blif/Makefile.inc
646
647 OBJS += passes/hierarchy/hierarchy.o
648 OBJS += passes/cmds/select.o
649 OBJS += passes/cmds/show.o
650 OBJS += passes/cmds/stat.o
651 OBJS += passes/cmds/cover.o
652 OBJS += passes/cmds/design.o
653 OBJS += passes/cmds/plugin.o
654
655 include $(YOSYS_SRC)/passes/proc/Makefile.inc
656 include $(YOSYS_SRC)/passes/opt/Makefile.inc
657 include $(YOSYS_SRC)/passes/techmap/Makefile.inc
658
659 include $(YOSYS_SRC)/backends/verilog/Makefile.inc
660 include $(YOSYS_SRC)/backends/rtlil/Makefile.inc
661
662 include $(YOSYS_SRC)/techlibs/common/Makefile.inc
663
664 endif
665
666 ifeq ($(LINK_ABC),1)
667 OBJS += $(PROGRAM_PREFIX)yosys-libabc.a
668 endif
669
670 # prevent the CXXFLAGS set by this Makefile from reaching abc/Makefile,
671 # especially the -MD flag which will break the build when CXX is clang
672 unexport CXXFLAGS
673
674 top-all: $(TARGETS) $(EXTRA_TARGETS)
675 @echo ""
676 @echo " Build successful."
677 @echo ""
678
679 ifeq ($(CONFIG),emcc)
680 yosys.js: $(filter-out yosysjs-$(YOSYS_VER).zip,$(EXTRA_TARGETS))
681 endif
682
683 $(PROGRAM_PREFIX)yosys$(EXE): $(OBJS)
684 $(P) $(LD) -o $(PROGRAM_PREFIX)yosys$(EXE) $(LDFLAGS) $(OBJS) $(LDLIBS)
685
686 libyosys.so: $(filter-out kernel/driver.o,$(OBJS))
687 ifeq ($(OS), Darwin)
688 $(P) $(LD) -o libyosys.so -shared -Wl,-install_name,$(DESTDIR)$(LIBDIR)/libyosys.so $(LDFLAGS) $^ $(LDLIBS)
689 else
690 $(P) $(LD) -o libyosys.so -shared -Wl,-soname,$(DESTDIR)$(LIBDIR)/libyosys.so $(LDFLAGS) $^ $(LDLIBS)
691 endif
692
693 %.o: %.cc
694 $(Q) mkdir -p $(dir $@)
695 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
696
697 %.pyh: %.h
698 $(Q) mkdir -p $(dir $@)
699 $(P) cat $< | grep -E -v "#[ ]*(include|error)" | $(LD) $(CXXFLAGS) -x c++ -o $@ -E -P -
700
701 ifeq ($(ENABLE_PYOSYS),1)
702 $(PY_WRAPPER_FILE).cc: misc/$(PY_GEN_SCRIPT).py $(PY_WRAP_INCLUDES)
703 $(Q) mkdir -p $(dir $@)
704 $(P) python$(PYTHON_VERSION) -c "from misc import $(PY_GEN_SCRIPT); $(PY_GEN_SCRIPT).gen_wrappers(\"$(PY_WRAPPER_FILE).cc\")"
705 endif
706
707 %.o: %.cpp
708 $(Q) mkdir -p $(dir $@)
709 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
710
711 YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) $(shell \
712 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))
713
714 kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
715 $(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
716 $(Q) mkdir -p kernel && echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"$(YOSYS_VER_STR)\"; }" > kernel/version_$(GIT_REV).cc
717
718 ifeq ($(ENABLE_VERIFIC),1)
719 CXXFLAGS_NOVERIFIC = $(foreach v,$(CXXFLAGS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
720 LDLIBS_NOVERIFIC = $(foreach v,$(LDLIBS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
721 else
722 CXXFLAGS_NOVERIFIC = $(CXXFLAGS)
723 LDLIBS_NOVERIFIC = $(LDLIBS)
724 endif
725
726 $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in
727 $(P) $(SED) -e 's#@CXXFLAGS@#$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(strip $(CXXFLAGS_NOVERIFIC)))#;' \
728 -e 's#@CXX@#$(strip $(CXX))#;' -e 's#@LDFLAGS@#$(strip $(LDFLAGS) $(PLUGIN_LDFLAGS))#;' -e 's#@LDLIBS@#$(strip $(LDLIBS_NOVERIFIC))#;' \
729 -e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config
730 $(Q) chmod +x $(PROGRAM_PREFIX)yosys-config
731
732 abc/abc-$(ABCREV)$(EXE) abc/libabc-$(ABCREV).a:
733 $(P)
734 ifneq ($(ABCREV),default)
735 $(Q) if test -d abc/.hg; then \
736 echo 'REEBE: NOP qverpgbel vf n ut jbexvat pbcl! Erzbir nop/ naq er-eha "znxr".' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \
737 fi
738 $(Q) if ( cd abc 2> /dev/null && ! git diff-index --quiet HEAD; ); then \
739 echo 'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \
740 fi
741 # set a variable so the test fails if git fails to run - when comparing outputs directly, empty string would match empty string
742 $(Q) if ! (cd abc 2> /dev/null && rev="`git rev-parse $(ABCREV)`" && test "`git rev-parse HEAD`" == "$$rev"); then \
743 test $(ABCPULL) -ne 0 || { echo 'REEBE: NOP abg hc gb qngr naq NOPCHYY frg gb 0 va Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; exit 1; }; \
744 echo "Pulling ABC from $(ABCURL):"; set -x; \
745 test -d abc || git clone $(ABCURL) abc; \
746 cd abc && $(MAKE) DEP= clean && git fetch $(ABCURL) && git checkout $(ABCREV); \
747 fi
748 endif
749 $(Q) rm -f abc/abc-[0-9a-f]*
750 $(Q) cd abc && $(MAKE) $(S) $(ABCMKARGS) $(if $(filter %.a,$@),PROG="abc-$(ABCREV)",PROG="abc-$(ABCREV)$(EXE)") MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: " $(if $(filter %.a,$@),libabc-$(ABCREV).a)
751
752 ifeq ($(ABCREV),default)
753 .PHONY: abc/abc-$(ABCREV)$(EXE)
754 .PHONY: abc/libabc-$(ABCREV).a
755 endif
756
757 $(PROGRAM_PREFIX)yosys-abc$(EXE): abc/abc-$(ABCREV)$(EXE)
758 $(P) cp abc/abc-$(ABCREV)$(EXE) $(PROGRAM_PREFIX)yosys-abc$(EXE)
759
760 $(PROGRAM_PREFIX)yosys-libabc.a: abc/libabc-$(ABCREV).a
761 $(P) cp abc/libabc-$(ABCREV).a $(PROGRAM_PREFIX)yosys-libabc.a
762
763 ifneq ($(SEED),)
764 SEEDOPT="-S $(SEED)"
765 else
766 SEEDOPT=""
767 endif
768
769 ifneq ($(ABCEXTERNAL),)
770 ABCOPT="-A $(ABCEXTERNAL)"
771 else
772 ABCOPT=""
773 endif
774
775 test: $(TARGETS) $(EXTRA_TARGETS)
776 +cd tests/simple && bash run-test.sh $(SEEDOPT)
777 +cd tests/simple_abc9 && bash run-test.sh $(SEEDOPT)
778 +cd tests/hana && bash run-test.sh $(SEEDOPT)
779 +cd tests/asicworld && bash run-test.sh $(SEEDOPT)
780 # +cd tests/realmath && bash run-test.sh $(SEEDOPT)
781 +cd tests/share && bash run-test.sh $(SEEDOPT)
782 +cd tests/opt_share && bash run-test.sh $(SEEDOPT)
783 +cd tests/fsm && bash run-test.sh $(SEEDOPT)
784 +cd tests/techmap && bash run-test.sh
785 +cd tests/memories && bash run-test.sh $(ABCOPT) $(SEEDOPT)
786 +cd tests/bram && bash run-test.sh $(SEEDOPT)
787 +cd tests/various && bash run-test.sh
788 +cd tests/select && bash run-test.sh
789 +cd tests/sat && bash run-test.sh
790 +cd tests/svinterfaces && bash run-test.sh $(SEEDOPT)
791 +cd tests/svtypes && bash run-test.sh $(SEEDOPT)
792 +cd tests/proc && bash run-test.sh
793 +cd tests/opt && bash run-test.sh
794 +cd tests/aiger && bash run-test.sh $(ABCOPT)
795 +cd tests/arch && bash run-test.sh
796 +cd tests/arch/ice40 && bash run-test.sh $(SEEDOPT)
797 +cd tests/arch/xilinx && bash run-test.sh $(SEEDOPT)
798 +cd tests/arch/ecp5 && bash run-test.sh $(SEEDOPT)
799 +cd tests/arch/efinix && bash run-test.sh $(SEEDOPT)
800 +cd tests/arch/anlogic && bash run-test.sh $(SEEDOPT)
801 +cd tests/arch/gowin && bash run-test.sh $(SEEDOPT)
802 +cd tests/arch/intel_alm && bash run-test.sh $(SEEDOPT)
803 +cd tests/arch/nexus && bash run-test.sh $(SEEDOPT)
804 +cd tests/rpc && bash run-test.sh
805 +cd tests/memfile && bash run-test.sh
806 +cd tests/verilog && bash run-test.sh
807 @echo ""
808 @echo " Passed \"make test\"."
809 @echo ""
810
811 VALGRIND ?= valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
812
813 vgtest: $(TARGETS) $(EXTRA_TARGETS)
814 $(VALGRIND) ./yosys -p 'setattr -mod -unset top; synth' $$( ls tests/simple/*.v | grep -v repwhile.v )
815 @echo ""
816 @echo " Passed \"make vgtest\"."
817 @echo ""
818
819 vloghtb: $(TARGETS) $(EXTRA_TARGETS)
820 +cd tests/vloghtb && bash run-test.sh
821 @echo ""
822 @echo " Passed \"make vloghtb\"."
823 @echo ""
824
825 ystests: $(TARGETS) $(EXTRA_TARGETS)
826 rm -rf tests/ystests
827 git clone https://github.com/YosysHQ/yosys-tests.git tests/ystests
828 +$(MAKE) PATH="$$PWD:$$PATH" -C tests/ystests
829 @echo ""
830 @echo " Finished \"make ystests\"."
831 @echo ""
832
833 # Unit test
834 unit-test: libyosys.so
835 @$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
836 CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
837
838 clean-unit-test:
839 @$(MAKE) -C $(UNITESTPATH) clean
840
841 install: $(TARGETS) $(EXTRA_TARGETS)
842 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(BINDIR)
843 $(INSTALL_SUDO) cp $(filter-out libyosys.so,$(TARGETS)) $(DESTDIR)$(BINDIR)
844 ifneq ($(filter $(PROGRAM_PREFIX)yosys,$(TARGETS)),)
845 $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys
846 endif
847 ifneq ($(filter $(PROGRAM_PREFIX)yosys-abc,$(TARGETS)),)
848 $(INSTALL_SUDO) $(STRIP) $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys-abc
849 endif
850 ifneq ($(filter $(PROGRAM_PREFIX)yosys-filterlib,$(TARGETS)),)
851 $(INSTALL_SUDO) $(STRIP) $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys-filterlib
852 endif
853 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(DATDIR)
854 $(INSTALL_SUDO) cp -r share/. $(DESTDIR)$(DATDIR)/.
855 ifeq ($(ENABLE_LIBYOSYS),1)
856 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(LIBDIR)
857 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(LIBDIR)/
858 $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(LIBDIR)/libyosys.so
859 ifeq ($(ENABLE_PYOSYS),1)
860 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
861 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
862 $(INSTALL_SUDO) cp misc/__init__.py $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/
863 endif
864 endif
865
866 uninstall:
867 $(INSTALL_SUDO) rm -vf $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(TARGETS)))
868 $(INSTALL_SUDO) rm -rvf $(DESTDIR)$(DATDIR)
869 ifeq ($(ENABLE_LIBYOSYS),1)
870 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.so
871 ifeq ($(ENABLE_PYOSYS),1)
872 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
873 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/__init__.py
874 $(INSTALL_SUDO) rmdir $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
875 endif
876 endif
877
878 update-manual: $(TARGETS) $(EXTRA_TARGETS)
879 cd manual && ../$(PROGRAM_PREFIX)yosys -p 'help -write-tex-command-reference-manual'
880
881 manual: $(TARGETS) $(EXTRA_TARGETS)
882 cd manual && bash appnotes.sh
883 cd manual && bash presentation.sh
884 cd manual && bash manual.sh
885
886 clean:
887 rm -rf share
888 rm -rf kernel/*.pyh
889 if test -d manual; then cd manual && sh clean.sh; fi
890 rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS) $(PY_WRAP_INCLUDES) $(PY_WRAPPER_FILE).cc
891 rm -f kernel/version_*.o kernel/version_*.cc
892 rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d
893 rm -rf tests/asicworld/*.out tests/asicworld/*.log
894 rm -rf tests/hana/*.out tests/hana/*.log
895 rm -rf tests/simple/*.out tests/simple/*.log
896 rm -rf tests/memories/*.out tests/memories/*.log tests/memories/*.dmp
897 rm -rf tests/sat/*.log tests/techmap/*.log tests/various/*.log
898 rm -rf tests/bram/temp tests/fsm/temp tests/realmath/temp tests/share/temp tests/smv/temp
899 rm -rf vloghtb/Makefile vloghtb/refdat vloghtb/rtl vloghtb/scripts vloghtb/spec vloghtb/check_yosys vloghtb/vloghammer_tb.tar.bz2 vloghtb/temp vloghtb/log_test_*
900 rm -f tests/svinterfaces/*.log_stdout tests/svinterfaces/*.log_stderr tests/svinterfaces/dut_result.txt tests/svinterfaces/reference_result.txt tests/svinterfaces/a.out tests/svinterfaces/*_syn.v tests/svinterfaces/*.diff
901 rm -f tests/tools/cmp_tbdata
902
903 clean-abc:
904 $(MAKE) -C abc DEP= clean
905 rm -f $(PROGRAM_PREFIX)yosys-abc$(EXE) $(PROGRAM_PREFIX)yosys-libabc.a abc/abc-[0-9a-f]* abc/libabc-[0-9a-f]*.a
906
907 mrproper: clean
908 git clean -xdf
909
910 coverage:
911 ./$(PROGRAM_PREFIX)yosys -qp 'help; help -all'
912 rm -rf coverage.info coverage_html
913 lcov --capture -d . --no-external -o coverage.info
914 genhtml coverage.info --output-directory coverage_html
915
916 qtcreator:
917 { for file in $(basename $(OBJS)); do \
918 for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
919 done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
920 { echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
921 touch qtcreator.config qtcreator.creator
922
923 vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
924 rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
925 set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
926 echo "Analyse: $$f" >&2; cpp -std=c++11 -MM -I. -D_YOSYS_ $$f; done | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep '^[^/]' | sort -u | grep -v kernel/version_ > srcfiles.txt
927 bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
928 echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
929 zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
930 zip -r yosys-win32-vcxsrc-$(YOSYS_VER).zip yosys-win32-vcxsrc-$(YOSYS_VER)/
931 rm -f srcfiles.txt kernel/version.cc
932
933 ifeq ($(CONFIG),mxe)
934 mxebin: $(TARGETS) $(EXTRA_TARGETS)
935 rm -rf yosys-win32-mxebin-$(YOSYS_VER){,.zip}
936 mkdir -p yosys-win32-mxebin-$(YOSYS_VER)
937 cp -r $(PROGRAM_PREFIX)yosys.exe share/ yosys-win32-mxebin-$(YOSYS_VER)/
938 ifeq ($(ENABLE_ABC),1)
939 cp -r $(PROGRAM_PREFIX)yosys-abc.exe abc/lib/x86/pthreadVC2.dll yosys-win32-mxebin-$(YOSYS_VER)/
940 endif
941 echo -en 'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
942 echo -en 'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
943 zip -r yosys-win32-mxebin-$(YOSYS_VER).zip yosys-win32-mxebin-$(YOSYS_VER)/
944 endif
945
946 config-clean: clean
947 rm -f Makefile.conf
948
949 config-clang: clean
950 echo 'CONFIG := clang' > Makefile.conf
951
952 config-gcc: clean
953 echo 'CONFIG := gcc' > Makefile.conf
954
955 config-gcc-static: clean
956 echo 'CONFIG := gcc-static' > Makefile.conf
957 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
958 echo 'ENABLE_READLINE := 0' >> Makefile.conf
959 echo 'ENABLE_TCL := 0' >> Makefile.conf
960
961 config-gcc-4.8: clean
962 echo 'CONFIG := gcc-4.8' > Makefile.conf
963
964 config-afl-gcc: clean
965 echo 'CONFIG := afl-gcc' > Makefile.conf
966
967 config-emcc: clean
968 echo 'CONFIG := emcc' > Makefile.conf
969 echo 'ENABLE_TCL := 0' >> Makefile.conf
970 echo 'ENABLE_ABC := 0' >> Makefile.conf
971 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
972 echo 'ENABLE_READLINE := 0' >> Makefile.conf
973 echo 'ENABLE_ZLIB := 0' >> Makefile.conf
974
975 config-wasi: clean
976 echo 'CONFIG := wasi' > Makefile.conf
977 echo 'ENABLE_TCL := 0' >> Makefile.conf
978 echo 'ENABLE_ABC := 0' >> Makefile.conf
979 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
980 echo 'ENABLE_READLINE := 0' >> Makefile.conf
981 echo 'ENABLE_ZLIB := 0' >> Makefile.conf
982
983 config-mxe: clean
984 echo 'CONFIG := mxe' > Makefile.conf
985 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
986
987 config-msys2: clean
988 echo 'CONFIG := msys2' > Makefile.conf
989 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
990
991 config-msys2-64: clean
992 echo 'CONFIG := msys2-64' > Makefile.conf
993 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
994
995 config-cygwin: clean
996 echo 'CONFIG := cygwin' > Makefile.conf
997
998 config-gcov: clean
999 echo 'CONFIG := gcc' > Makefile.conf
1000 echo 'ENABLE_GCOV := 1' >> Makefile.conf
1001 echo 'ENABLE_DEBUG := 1' >> Makefile.conf
1002
1003 config-gprof: clean
1004 echo 'CONFIG := gcc' > Makefile.conf
1005 echo 'ENABLE_GPROF := 1' >> Makefile.conf
1006
1007 config-sudo:
1008 echo "INSTALL_SUDO := sudo" >> Makefile.conf
1009
1010 echo-yosys-ver:
1011 @echo "$(YOSYS_VER)"
1012
1013 echo-git-rev:
1014 @echo "$(GIT_REV)"
1015
1016 echo-abc-rev:
1017 @echo "$(ABCREV)"
1018
1019 -include libs/*/*.d
1020 -include frontends/*/*.d
1021 -include passes/*/*.d
1022 -include backends/*/*.d
1023 -include kernel/*.d
1024 -include techlibs/*/*.d
1025
1026 .PHONY: all top-all abc test install install-abc manual clean mrproper qtcreator coverage vcxsrc mxebin
1027 .PHONY: config-clean config-clang config-gcc config-gcc-static config-gcc-4.8 config-afl-gcc config-gprof config-sudo