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