Merge pull request #2455 from gsomlo/gls-fedpkg-fixes
[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+3715
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 ifeq ($(ENABLE_ABC),1)
612 ifneq ($(ABCEXTERNAL),)
613 kernel/yosys.o: CXXFLAGS += -DABCEXTERNAL='"$(ABCEXTERNAL)"'
614 endif
615 endif
616 OBJS += kernel/cellaigs.o kernel/celledges.o kernel/satgen.o kernel/mem.o
617
618 kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
619 kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"' -DYOSYS_PROGRAM_PREFIX='"$(PROGRAM_PREFIX)"'
620
621 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
622 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
623
624 OBJS += libs/sha1/sha1.o
625
626 ifneq ($(SMALL),1)
627
628 OBJS += libs/json11/json11.o
629
630 OBJS += libs/subcircuit/subcircuit.o
631
632 OBJS += libs/ezsat/ezsat.o
633 OBJS += libs/ezsat/ezminisat.o
634
635 OBJS += libs/minisat/Options.o
636 OBJS += libs/minisat/SimpSolver.o
637 OBJS += libs/minisat/Solver.o
638 OBJS += libs/minisat/System.o
639
640 include $(YOSYS_SRC)/frontends/*/Makefile.inc
641 include $(YOSYS_SRC)/passes/*/Makefile.inc
642 include $(YOSYS_SRC)/backends/*/Makefile.inc
643 include $(YOSYS_SRC)/techlibs/*/Makefile.inc
644
645 else
646
647 include $(YOSYS_SRC)/frontends/verilog/Makefile.inc
648 include $(YOSYS_SRC)/frontends/rtlil/Makefile.inc
649 include $(YOSYS_SRC)/frontends/ast/Makefile.inc
650 include $(YOSYS_SRC)/frontends/blif/Makefile.inc
651
652 OBJS += passes/hierarchy/hierarchy.o
653 OBJS += passes/cmds/select.o
654 OBJS += passes/cmds/show.o
655 OBJS += passes/cmds/stat.o
656 OBJS += passes/cmds/cover.o
657 OBJS += passes/cmds/design.o
658 OBJS += passes/cmds/plugin.o
659
660 include $(YOSYS_SRC)/passes/proc/Makefile.inc
661 include $(YOSYS_SRC)/passes/opt/Makefile.inc
662 include $(YOSYS_SRC)/passes/techmap/Makefile.inc
663
664 include $(YOSYS_SRC)/backends/verilog/Makefile.inc
665 include $(YOSYS_SRC)/backends/rtlil/Makefile.inc
666
667 include $(YOSYS_SRC)/techlibs/common/Makefile.inc
668
669 endif
670
671 ifeq ($(LINK_ABC),1)
672 OBJS += $(PROGRAM_PREFIX)yosys-libabc.a
673 endif
674
675 # prevent the CXXFLAGS set by this Makefile from reaching abc/Makefile,
676 # especially the -MD flag which will break the build when CXX is clang
677 unexport CXXFLAGS
678
679 top-all: $(TARGETS) $(EXTRA_TARGETS)
680 @echo ""
681 @echo " Build successful."
682 @echo ""
683
684 ifeq ($(CONFIG),emcc)
685 yosys.js: $(filter-out yosysjs-$(YOSYS_VER).zip,$(EXTRA_TARGETS))
686 endif
687
688 $(PROGRAM_PREFIX)yosys$(EXE): $(OBJS)
689 $(P) $(LD) -o $(PROGRAM_PREFIX)yosys$(EXE) $(LDFLAGS) $(OBJS) $(LDLIBS)
690
691 libyosys.so: $(filter-out kernel/driver.o,$(OBJS))
692 ifeq ($(OS), Darwin)
693 $(P) $(LD) -o libyosys.so -shared -Wl,-install_name,$(DESTDIR)$(LIBDIR)/libyosys.so $(LDFLAGS) $^ $(LDLIBS)
694 else
695 $(P) $(LD) -o libyosys.so -shared -Wl,-soname,$(DESTDIR)$(LIBDIR)/libyosys.so $(LDFLAGS) $^ $(LDLIBS)
696 endif
697
698 %.o: %.cc
699 $(Q) mkdir -p $(dir $@)
700 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
701
702 %.pyh: %.h
703 $(Q) mkdir -p $(dir $@)
704 $(P) cat $< | grep -E -v "#[ ]*(include|error)" | $(LD) $(CXXFLAGS) -x c++ -o $@ -E -P -
705
706 ifeq ($(ENABLE_PYOSYS),1)
707 $(PY_WRAPPER_FILE).cc: misc/$(PY_GEN_SCRIPT).py $(PY_WRAP_INCLUDES)
708 $(Q) mkdir -p $(dir $@)
709 $(P) python$(PYTHON_VERSION) -c "from misc import $(PY_GEN_SCRIPT); $(PY_GEN_SCRIPT).gen_wrappers(\"$(PY_WRAPPER_FILE).cc\")"
710 endif
711
712 %.o: %.cpp
713 $(Q) mkdir -p $(dir $@)
714 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
715
716 YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) $(shell \
717 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))
718
719 kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
720 $(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
721 $(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
722
723 ifeq ($(ENABLE_VERIFIC),1)
724 CXXFLAGS_NOVERIFIC = $(foreach v,$(CXXFLAGS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
725 LDLIBS_NOVERIFIC = $(foreach v,$(LDLIBS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
726 else
727 CXXFLAGS_NOVERIFIC = $(CXXFLAGS)
728 LDLIBS_NOVERIFIC = $(LDLIBS)
729 endif
730
731 $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in
732 $(P) $(SED) -e 's#@CXXFLAGS@#$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(strip $(CXXFLAGS_NOVERIFIC)))#;' \
733 -e 's#@CXX@#$(strip $(CXX))#;' -e 's#@LDFLAGS@#$(strip $(LDFLAGS) $(PLUGIN_LDFLAGS))#;' -e 's#@LDLIBS@#$(strip $(LDLIBS_NOVERIFIC))#;' \
734 -e 's#@BINDIR@#$(strip $(BINDIR))#;' -e 's#@DATDIR@#$(strip $(DATDIR))#;' < $< > $(PROGRAM_PREFIX)yosys-config
735 $(Q) chmod +x $(PROGRAM_PREFIX)yosys-config
736
737 abc/abc-$(ABCREV)$(EXE) abc/libabc-$(ABCREV).a:
738 $(P)
739 ifneq ($(ABCREV),default)
740 $(Q) if test -d abc/.hg; then \
741 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; \
742 fi
743 $(Q) if ( cd abc 2> /dev/null && ! git diff-index --quiet HEAD; ); then \
744 echo 'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \
745 fi
746 # set a variable so the test fails if git fails to run - when comparing outputs directly, empty string would match empty string
747 $(Q) if ! (cd abc 2> /dev/null && rev="`git rev-parse $(ABCREV)`" && test "`git rev-parse HEAD`" == "$$rev"); then \
748 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; }; \
749 echo "Pulling ABC from $(ABCURL):"; set -x; \
750 test -d abc || git clone $(ABCURL) abc; \
751 cd abc && $(MAKE) DEP= clean && git fetch $(ABCURL) && git checkout $(ABCREV); \
752 fi
753 endif
754 $(Q) rm -f abc/abc-[0-9a-f]*
755 $(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)
756
757 ifeq ($(ABCREV),default)
758 .PHONY: abc/abc-$(ABCREV)$(EXE)
759 .PHONY: abc/libabc-$(ABCREV).a
760 endif
761
762 $(PROGRAM_PREFIX)yosys-abc$(EXE): abc/abc-$(ABCREV)$(EXE)
763 $(P) cp abc/abc-$(ABCREV)$(EXE) $(PROGRAM_PREFIX)yosys-abc$(EXE)
764
765 $(PROGRAM_PREFIX)yosys-libabc.a: abc/libabc-$(ABCREV).a
766 $(P) cp abc/libabc-$(ABCREV).a $(PROGRAM_PREFIX)yosys-libabc.a
767
768 ifneq ($(SEED),)
769 SEEDOPT="-S $(SEED)"
770 else
771 SEEDOPT=""
772 endif
773
774 ifneq ($(ABCEXTERNAL),)
775 ABCOPT="-A $(ABCEXTERNAL)"
776 else
777 ABCOPT=""
778 endif
779
780 test: $(TARGETS) $(EXTRA_TARGETS)
781 +cd tests/simple && bash run-test.sh $(SEEDOPT)
782 +cd tests/simple_abc9 && bash run-test.sh $(SEEDOPT)
783 +cd tests/hana && bash run-test.sh $(SEEDOPT)
784 +cd tests/asicworld && bash run-test.sh $(SEEDOPT)
785 # +cd tests/realmath && bash run-test.sh $(SEEDOPT)
786 +cd tests/share && bash run-test.sh $(SEEDOPT)
787 +cd tests/opt_share && bash run-test.sh $(SEEDOPT)
788 +cd tests/fsm && bash run-test.sh $(SEEDOPT)
789 +cd tests/techmap && bash run-test.sh
790 +cd tests/memories && bash run-test.sh $(ABCOPT) $(SEEDOPT)
791 +cd tests/bram && bash run-test.sh $(SEEDOPT)
792 +cd tests/various && bash run-test.sh
793 +cd tests/select && bash run-test.sh
794 +cd tests/sat && bash run-test.sh
795 +cd tests/svinterfaces && bash run-test.sh $(SEEDOPT)
796 +cd tests/svtypes && bash run-test.sh $(SEEDOPT)
797 +cd tests/proc && bash run-test.sh
798 +cd tests/opt && bash run-test.sh
799 +cd tests/aiger && bash run-test.sh $(ABCOPT)
800 +cd tests/arch && bash run-test.sh
801 +cd tests/arch/ice40 && bash run-test.sh $(SEEDOPT)
802 +cd tests/arch/xilinx && bash run-test.sh $(SEEDOPT)
803 +cd tests/arch/ecp5 && bash run-test.sh $(SEEDOPT)
804 +cd tests/arch/efinix && bash run-test.sh $(SEEDOPT)
805 +cd tests/arch/anlogic && bash run-test.sh $(SEEDOPT)
806 +cd tests/arch/gowin && bash run-test.sh $(SEEDOPT)
807 +cd tests/arch/intel_alm && bash run-test.sh $(SEEDOPT)
808 +cd tests/arch/nexus && bash run-test.sh $(SEEDOPT)
809 +cd tests/rpc && bash run-test.sh
810 +cd tests/memfile && bash run-test.sh
811 +cd tests/verilog && bash run-test.sh
812 @echo ""
813 @echo " Passed \"make test\"."
814 @echo ""
815
816 VALGRIND ?= valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
817
818 vgtest: $(TARGETS) $(EXTRA_TARGETS)
819 $(VALGRIND) ./yosys -p 'setattr -mod -unset top; synth' $$( ls tests/simple/*.v | grep -v repwhile.v )
820 @echo ""
821 @echo " Passed \"make vgtest\"."
822 @echo ""
823
824 vloghtb: $(TARGETS) $(EXTRA_TARGETS)
825 +cd tests/vloghtb && bash run-test.sh
826 @echo ""
827 @echo " Passed \"make vloghtb\"."
828 @echo ""
829
830 ystests: $(TARGETS) $(EXTRA_TARGETS)
831 rm -rf tests/ystests
832 git clone https://github.com/YosysHQ/yosys-tests.git tests/ystests
833 +$(MAKE) PATH="$$PWD:$$PATH" -C tests/ystests
834 @echo ""
835 @echo " Finished \"make ystests\"."
836 @echo ""
837
838 # Unit test
839 unit-test: libyosys.so
840 @$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
841 CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
842
843 clean-unit-test:
844 @$(MAKE) -C $(UNITESTPATH) clean
845
846 install: $(TARGETS) $(EXTRA_TARGETS)
847 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(BINDIR)
848 $(INSTALL_SUDO) cp $(filter-out libyosys.so,$(TARGETS)) $(DESTDIR)$(BINDIR)
849 ifneq ($(filter $(PROGRAM_PREFIX)yosys,$(TARGETS)),)
850 $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys
851 endif
852 ifneq ($(filter $(PROGRAM_PREFIX)yosys-abc,$(TARGETS)),)
853 $(INSTALL_SUDO) $(STRIP) $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys-abc
854 endif
855 ifneq ($(filter $(PROGRAM_PREFIX)yosys-filterlib,$(TARGETS)),)
856 $(INSTALL_SUDO) $(STRIP) $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys-filterlib
857 endif
858 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(DATDIR)
859 $(INSTALL_SUDO) cp -r share/. $(DESTDIR)$(DATDIR)/.
860 ifeq ($(ENABLE_LIBYOSYS),1)
861 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(LIBDIR)
862 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(LIBDIR)/
863 $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(LIBDIR)/libyosys.so
864 ifeq ($(ENABLE_PYOSYS),1)
865 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
866 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
867 $(INSTALL_SUDO) cp misc/__init__.py $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/
868 endif
869 endif
870
871 uninstall:
872 $(INSTALL_SUDO) rm -vf $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(TARGETS)))
873 $(INSTALL_SUDO) rm -rvf $(DESTDIR)$(DATDIR)
874 ifeq ($(ENABLE_LIBYOSYS),1)
875 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.so
876 ifeq ($(ENABLE_PYOSYS),1)
877 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
878 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/__init__.py
879 $(INSTALL_SUDO) rmdir $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
880 endif
881 endif
882
883 update-manual: $(TARGETS) $(EXTRA_TARGETS)
884 cd manual && ../$(PROGRAM_PREFIX)yosys -p 'help -write-tex-command-reference-manual'
885
886 manual: $(TARGETS) $(EXTRA_TARGETS)
887 cd manual && bash appnotes.sh
888 cd manual && bash presentation.sh
889 cd manual && bash manual.sh
890
891 clean:
892 rm -rf share
893 rm -rf kernel/*.pyh
894 if test -d manual; then cd manual && sh clean.sh; fi
895 rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS) $(PY_WRAP_INCLUDES) $(PY_WRAPPER_FILE).cc
896 rm -f kernel/version_*.o kernel/version_*.cc
897 rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d
898 rm -rf tests/asicworld/*.out tests/asicworld/*.log
899 rm -rf tests/hana/*.out tests/hana/*.log
900 rm -rf tests/simple/*.out tests/simple/*.log
901 rm -rf tests/memories/*.out tests/memories/*.log tests/memories/*.dmp
902 rm -rf tests/sat/*.log tests/techmap/*.log tests/various/*.log
903 rm -rf tests/bram/temp tests/fsm/temp tests/realmath/temp tests/share/temp tests/smv/temp
904 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_*
905 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
906 rm -f tests/tools/cmp_tbdata
907
908 clean-abc:
909 $(MAKE) -C abc DEP= clean
910 rm -f $(PROGRAM_PREFIX)yosys-abc$(EXE) $(PROGRAM_PREFIX)yosys-libabc.a abc/abc-[0-9a-f]* abc/libabc-[0-9a-f]*.a
911
912 mrproper: clean
913 git clean -xdf
914
915 coverage:
916 ./$(PROGRAM_PREFIX)yosys -qp 'help; help -all'
917 rm -rf coverage.info coverage_html
918 lcov --capture -d . --no-external -o coverage.info
919 genhtml coverage.info --output-directory coverage_html
920
921 qtcreator:
922 { for file in $(basename $(OBJS)); do \
923 for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
924 done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
925 { echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
926 touch qtcreator.config qtcreator.creator
927
928 vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
929 rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
930 set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
931 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
932 bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
933 echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
934 zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
935 zip -r yosys-win32-vcxsrc-$(YOSYS_VER).zip yosys-win32-vcxsrc-$(YOSYS_VER)/
936 rm -f srcfiles.txt kernel/version.cc
937
938 ifeq ($(CONFIG),mxe)
939 mxebin: $(TARGETS) $(EXTRA_TARGETS)
940 rm -rf yosys-win32-mxebin-$(YOSYS_VER){,.zip}
941 mkdir -p yosys-win32-mxebin-$(YOSYS_VER)
942 cp -r $(PROGRAM_PREFIX)yosys.exe share/ yosys-win32-mxebin-$(YOSYS_VER)/
943 ifeq ($(ENABLE_ABC),1)
944 cp -r $(PROGRAM_PREFIX)yosys-abc.exe abc/lib/x86/pthreadVC2.dll yosys-win32-mxebin-$(YOSYS_VER)/
945 endif
946 echo -en 'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
947 echo -en 'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
948 zip -r yosys-win32-mxebin-$(YOSYS_VER).zip yosys-win32-mxebin-$(YOSYS_VER)/
949 endif
950
951 config-clean: clean
952 rm -f Makefile.conf
953
954 config-clang: clean
955 echo 'CONFIG := clang' > Makefile.conf
956
957 config-gcc: clean
958 echo 'CONFIG := gcc' > Makefile.conf
959
960 config-gcc-static: clean
961 echo 'CONFIG := gcc-static' > Makefile.conf
962 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
963 echo 'ENABLE_READLINE := 0' >> Makefile.conf
964 echo 'ENABLE_TCL := 0' >> Makefile.conf
965
966 config-gcc-4.8: clean
967 echo 'CONFIG := gcc-4.8' > Makefile.conf
968
969 config-afl-gcc: clean
970 echo 'CONFIG := afl-gcc' > Makefile.conf
971
972 config-emcc: clean
973 echo 'CONFIG := emcc' > Makefile.conf
974 echo 'ENABLE_TCL := 0' >> Makefile.conf
975 echo 'ENABLE_ABC := 0' >> Makefile.conf
976 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
977 echo 'ENABLE_READLINE := 0' >> Makefile.conf
978 echo 'ENABLE_ZLIB := 0' >> Makefile.conf
979
980 config-wasi: clean
981 echo 'CONFIG := wasi' > Makefile.conf
982 echo 'ENABLE_TCL := 0' >> Makefile.conf
983 echo 'ENABLE_ABC := 0' >> Makefile.conf
984 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
985 echo 'ENABLE_READLINE := 0' >> Makefile.conf
986 echo 'ENABLE_ZLIB := 0' >> Makefile.conf
987
988 config-mxe: clean
989 echo 'CONFIG := mxe' > Makefile.conf
990 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
991
992 config-msys2: clean
993 echo 'CONFIG := msys2' > Makefile.conf
994 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
995
996 config-msys2-64: clean
997 echo 'CONFIG := msys2-64' > Makefile.conf
998 echo 'ENABLE_PLUGINS := 0' >> 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