10 # features (the more the better)
24 PYTHON_VERSION_TESTCODE
:= "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));print(t)"
25 PYTHON_EXECUTABLE
:= $(shell if python3
-c
""; then echo
"python3"; else echo
"python"; fi
)
26 PYTHON_VERSION
:= $(shell $(PYTHON_EXECUTABLE
) -c
""$(PYTHON_VERSION_TESTCODE
)"")
27 PYTHON_MAJOR_VERSION
:= $(shell echo
$(PYTHON_VERSION
) | cut
-f1
-d.
)
28 PYTHON_DESTDIR
:= `$(PYTHON_EXECUTABLE)-config --prefix`/lib
/python
$(PYTHON_VERSION
)/dist-packages
30 # other configuration flags
38 # Needed for environments that don't have proper thread support (i.e. emscripten)
39 DISABLE_ABC_THREADS
:= 0
45 # SANITIZER = undefined
49 OS
:= $(shell uname
-s
)
53 BINDIR
:= $(PREFIX
)/bin
54 LIBDIR
:= $(PREFIX
)/lib
55 DATDIR
:= $(PREFIX
)/share
/yosys
62 TARGETS
= yosys
$(EXE
) yosys-config
68 UNITESTPATH
:= tests
/unit
72 YOSYS_SRC
:= $(dir $(firstword $(MAKEFILE_LIST
)))
75 CXXFLAGS
:= $(CXXFLAGS
) -Wall
-Wextra
-ggdb
-I.
-I
"$(YOSYS_SRC)" -MD
-D_YOSYS_
-fPIC
-I
$(PREFIX
)/include
76 LDFLAGS
:= $(LDFLAGS
) -L
$(LIBDIR
)
77 LDLIBS
:= $(LDLIBS
) -lstdc
++ -lm
80 PKG_CONFIG ?
= pkg-config
87 PLUGIN_LDFLAGS
+= -undefined dynamic_lookup
89 # homebrew search paths
90 ifneq ($(shell which brew
),)
91 BREW_PREFIX
:= $(shell brew
--prefix)/opt
92 CXXFLAGS
+= -I
$(BREW_PREFIX
)/readline
/include
93 LDFLAGS
+= -L
$(BREW_PREFIX
)/readline
/lib
94 PKG_CONFIG_PATH
:= $(BREW_PREFIX
)/libffi
/lib
/pkgconfig
:$(PKG_CONFIG_PATH
)
95 PKG_CONFIG_PATH
:= $(BREW_PREFIX
)/tcl-tk
/lib
/pkgconfig
:$(PKG_CONFIG_PATH
)
96 export PATH
:= $(BREW_PREFIX
)/bison
/bin
:$(BREW_PREFIX
)/gettext
/bin
:$(BREW_PREFIX
)/flex
/bin
:$(PATH
)
98 # macports search paths
99 else ifneq ($(shell which port
),)
100 PORT_PREFIX
:= $(patsubst %/bin
/port
,%,$(shell which port
))
101 CXXFLAGS
+= -I
$(PORT_PREFIX
)/include
102 LDFLAGS
+= -L
$(PORT_PREFIX
)/lib
103 PKG_CONFIG_PATH
:= $(PORT_PREFIX
)/lib
/pkgconfig
:$(PKG_CONFIG_PATH
)
104 export PATH
:= $(PORT_PREFIX
)/bin
:$(PATH
)
112 YOSYS_VER
:= 0.8+$(shell cd
$(YOSYS_SRC
) && test -e .git
&& { git log
--author
=clifford@clifford.at
--oneline
4d4665b..
2> /dev
/null | wc
-l
; })
113 GIT_REV
:= $(shell cd
$(YOSYS_SRC
) && git rev-parse
--short HEAD
2> /dev
/null || echo UNKNOWN
)
114 OBJS
= kernel
/version_
$(GIT_REV
).o
116 # set 'ABCREV = default' to use abc/ as it is
118 # Note: If you do ABC development, make sure that 'abc' in this directory
119 # is just a symlink to your actual ABC working directory, as 'make mrproper'
120 # will remove the 'abc' directory and you do not want to accidentally
121 # delete your work on ABC..
124 ABCURL ?
= https
://github.com
/berkeley-abc
/abc
125 ABCMKARGS
= CC
="$(CXX)" CXX
="$(CXX)" ABC_USE_LIBSTDCXX
=1
127 # set ABCEXTERNAL = <abc-command> to use an external ABC instance
128 # Note: The in-tree ABC (yosys-abc) will not be installed when ABCEXTERNAL is set.
136 ifneq ($(wildcard Makefile.conf
),)
137 $(info $(subst $$--$$,$(newline
),$(shell sed
's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr
-d
'\n' | sed
's,\$$--\$$$$,,')))
138 include Makefile.conf
141 ifeq ($(CONFIG
),clang
)
144 CXXFLAGS
+= -std
=c
++11 -Os
145 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H"
147 ifneq ($(SANITIZER
),)
148 $(info [Clang Sanitizer
] $(SANITIZER
))
149 CXXFLAGS
+= -g
-O1
-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize
=$(SANITIZER
)
150 LDFLAGS
+= -g
-fsanitize
=$(SANITIZER
)
151 ifeq ($(SANITIZER
),address
)
154 ifeq ($(SANITIZER
),memory
)
155 CXXFLAGS
+= -fPIE
-fsanitize-memory-track-origins
156 LDFLAGS
+= -fPIE
-fsanitize-memory-track-origins
158 ifeq ($(SANITIZER
),cfi
)
164 else ifeq ($(CONFIG
),gcc
)
167 CXXFLAGS
+= -std
=c
++11 -Os
168 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H"
170 else ifeq ($(CONFIG
),gcc-static
)
172 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -static
173 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
174 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
175 CXXFLAGS
+= -std
=c
++11 -Os
176 ABCMKARGS
= CC
="$(CC)" CXX
="$(CXX)" LD
="$(LD)" ABC_USE_LIBSTDCXX
=1 LIBS
="-lm -lpthread -static" OPTFLAGS
="-O" \
177 ARCHFLAGS
="-DABC_USE_STDINT_H -DABC_NO_DYNAMIC_LINKING=1 -Wno-unused-but-set-variable $(ARCHFLAGS)" ABC_USE_NO_READLINE
=1
178 ifeq ($(DISABLE_ABC_THREADS
),1)
179 ABCMKARGS
+= "ABC_USE_NO_PTHREADS=1"
182 else ifeq ($(CONFIG
),gcc-4.8
)
185 CXXFLAGS
+= -std
=c
++11 -Os
186 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H"
188 else ifeq ($(CONFIG
),cygwin
)
191 CXXFLAGS
+= -std
=gnu
++11 -Os
192 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H"
194 else ifeq ($(CONFIG
),emcc
)
197 CXXFLAGS
:= -std
=c
++11 $(filter-out -fPIC
-ggdb
,$(CXXFLAGS
))
198 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H -DABC_MEMALIGN=8"
199 EMCCFLAGS
:= -Os
-Wno-warn-absolute-paths
200 EMCCFLAGS
+= --memory-init-file
0 --embed-file share
-s NO_EXIT_RUNTIME
=1
201 EMCCFLAGS
+= -s EXPORTED_FUNCTIONS
="['_main','_run','_prompt','_errmsg']"
202 EMCCFLAGS
+= -s TOTAL_MEMORY
=128*1024*1024
203 # https://github.com/kripken/emscripten/blob/master/src/settings.js
204 CXXFLAGS
+= $(EMCCFLAGS
)
205 LDFLAGS
+= $(EMCCFLAGS
)
209 TARGETS
:= $(filter-out yosys-config
,$(TARGETS
))
210 EXTRA_TARGETS
+= yosysjs-
$(YOSYS_VER
).zip
212 ifeq ($(ENABLE_ABC
),1)
214 DISABLE_ABC_THREADS
:= 1
218 wget
-O viz.js.part https
://github.com
/mdaines
/viz.js
/releases
/download
/0.0.3/viz.js
219 mv viz.js.part viz.js
221 yosysjs-
$(YOSYS_VER
).zip
: yosys.js viz.js misc
/yosysjs
/*
222 rm -rf yosysjs-
$(YOSYS_VER
) yosysjs-
$(YOSYS_VER
).zip
223 mkdir
-p yosysjs-
$(YOSYS_VER
)
224 cp viz.js misc
/yosysjs
/* yosys.js yosysjs-
$(YOSYS_VER
)/
225 zip
-r yosysjs-
$(YOSYS_VER
).zip yosysjs-
$(YOSYS_VER
)
227 yosys.html
: misc
/yosys.html
228 $(P
) cp misc
/yosys.html yosys.html
230 else ifeq ($(CONFIG
),mxe
)
231 PKG_CONFIG
= /usr
/local
/src
/mxe
/usr
/bin
/i686-w64-mingw32.static-pkg-config
232 CXX
= /usr
/local
/src
/mxe
/usr
/bin
/i686-w64-mingw32.static-g
++
233 LD
= /usr
/local
/src
/mxe
/usr
/bin
/i686-w64-mingw32.static-g
++
234 CXXFLAGS
+= -std
=c
++11 -Os
-D_POSIX_SOURCE
-DYOSYS_MXE_HACKS
-Wno-attributes
235 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
236 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -s
237 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
238 ABCMKARGS
+= ARCHFLAGS
="-DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
239 ABCMKARGS
+= LIBS
="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE
=1 CC
="/usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc"
242 else ifeq ($(CONFIG
),msys2
)
243 CXX
= i686-w64-mingw32-g
++
244 LD
= i686-w64-mingw32-g
++
245 CXXFLAGS
+= -std
=c
++11 -Os
-D_POSIX_SOURCE
-DYOSYS_WIN32_UNIX_DIR
246 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
247 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -s
248 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
249 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
250 ABCMKARGS
+= LIBS
="-lpthread -s" ABC_USE_NO_READLINE
=0 CC
="i686-w64-mingw32-gcc" CXX
="$(CXX)"
253 else ifeq ($(CONFIG
),msys2-64
)
254 CXX
= x86_64-w64-mingw32-g
++
255 LD
= x86_64-w64-mingw32-g
++
256 CXXFLAGS
+= -std
=c
++11 -Os
-D_POSIX_SOURCE
-DYOSYS_WIN32_UNIX_DIR
257 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
258 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -s
259 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
260 ABCMKARGS
+= ARCHFLAGS
="-DABC_USE_STDINT_H -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
261 ABCMKARGS
+= LIBS
="-lpthread -s" ABC_USE_NO_READLINE
=0 CC
="x86_64-w64-mingw32-gcc" CXX
="$(CXX)"
264 else ifneq ($(CONFIG
),none
)
265 $(error Invalid CONFIG setting
'$(CONFIG)'. Valid values
: clang
, gcc
, gcc-4.8
, emcc
, mxe
, msys2
, msys2-64
)
268 ifeq ($(ENABLE_LIBYOSYS
),1)
269 TARGETS
+= libyosys.so
272 ifeq ($(ENABLE_PYOSYS
),1)
274 #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
275 BOOST_PYTHON_LIB ?
= $(shell \
276 if echo
"int main(int argc, char ** argv) {return 0;}" |
$(CXX
) -xc
-o
/dev
/null
`$(PYTHON_EXECUTABLE)-config --libs` -lboost_python-py
$(subst .
,,$(PYTHON_VERSION
)) - > /dev
/null
2>&1; then echo
"-lboost_python-py$(subst .,,$(PYTHON_VERSION))"; else \
277 if echo
"int main(int argc, char ** argv) {return 0;}" |
$(CXX
) -xc
-o
/dev
/null
`$(PYTHON_EXECUTABLE)-config --libs` -lboost_python-py
$(subst .
,,$(PYTHON_MAJOR_VERSION
)) - > /dev
/null
2>&1; then echo
"-lboost_python-py$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
278 if echo
"int main(int argc, char ** argv) {return 0;}" |
$(CXX
) -xc
-o
/dev
/null
`$(PYTHON_EXECUTABLE)-config --libs` -lboost_python
$(subst .
,,$(PYTHON_VERSION
)) - > /dev
/null
2>&1; then echo
"-lboost_python$(subst .,,$(PYTHON_VERSION))"; else \
279 if echo
"int main(int argc, char ** argv) {return 0;}" |
$(CXX
) -xc
-o
/dev
/null
`$(PYTHON_EXECUTABLE)-config --libs` -lboost_python
$(subst .
,,$(PYTHON_MAJOR_VERSION
)) - > /dev
/null
2>&1; then echo
"-lboost_python$(subst .,,$(PYTHON_MAJOR_VERSION))"; else \
280 echo
""; fi
; fi
; fi
; fi
;)
282 ifeq ($(BOOST_PYTHON_LIB
),)
283 $(error BOOST_PYTHON_LIB could not be detected. Please
define manualy
)
286 ifeq ($(PYTHON_MAJOR_VERSION
),3)
287 LDLIBS
+= `$(PYTHON_EXECUTABLE)-config --libs` $(BOOST_PYTHON_LIB
) -lboost_system
-lboost_filesystem
288 CXXFLAGS
+= `$(PYTHON_EXECUTABLE)-config --includes` -D WITH_PYTHON
290 LDLIBS
+= `$(PYTHON_EXECUTABLE)-config --libs` $(BOOST_PYTHON_LIB
) -lboost_system
-lboost_filesystem
291 CXXFLAGS
+= `$(PYTHON_EXECUTABLE)-config --includes` -D WITH_PYTHON
294 PY_WRAPPER_FILE
= kernel
/python_wrappers
295 OBJS
+= $(PY_WRAPPER_FILE
).o
296 PY_GEN_SCRIPT
= py_wrap_generator
297 PY_WRAP_INCLUDES
:= $(shell python
$(PYTHON_VERSION
) -c
"import $(PY_GEN_SCRIPT); $(PY_GEN_SCRIPT).print_includes()")
300 ifeq ($(ENABLE_READLINE
),1)
301 CXXFLAGS
+= -DYOSYS_ENABLE_READLINE
302 ifeq ($(OS
), FreeBSD
)
303 CXXFLAGS
+= -I
/usr
/local
/include
306 ifeq ($(LINK_CURSES
),1)
308 ABCMKARGS
+= "ABC_READLINE_LIBRARIES=-lcurses -lreadline"
310 ifeq ($(LINK_TERMCAP
),1)
312 ABCMKARGS
+= "ABC_READLINE_LIBRARIES=-lreadline -ltermcap"
318 ifeq ($(ENABLE_EDITLINE
),1)
319 CXXFLAGS
+= -DYOSYS_ENABLE_EDITLINE
320 LDLIBS
+= -ledit
-ltinfo
-lbsd
322 ABCMKARGS
+= "ABC_USE_NO_READLINE=1"
326 ifeq ($(DISABLE_ABC_THREADS
),1)
327 ABCMKARGS
+= "ABC_USE_NO_PTHREADS=1"
330 ifeq ($(ENABLE_PLUGINS
),1)
331 CXXFLAGS
+= $(shell PKG_CONFIG_PATH
=$(PKG_CONFIG_PATH
) $(PKG_CONFIG
) --silence-errors
--cflags libffi
) -DYOSYS_ENABLE_PLUGINS
332 LDLIBS
+= $(shell PKG_CONFIG_PATH
=$(PKG_CONFIG_PATH
) $(PKG_CONFIG
) --silence-errors
--libs libffi || echo
-lffi
)
333 ifneq ($(OS
), FreeBSD
)
338 ifeq ($(ENABLE_GLOB
),1)
339 CXXFLAGS
+= -DYOSYS_ENABLE_GLOB
342 ifeq ($(ENABLE_TCL
),1)
343 TCL_VERSION ?
= tcl
$(shell bash
-c
"tclsh <(echo 'puts [info tclversion]')")
344 ifeq ($(OS
), FreeBSD
)
345 TCL_INCLUDE ?
= /usr
/local
/include/$(TCL_VERSION
)
347 TCL_INCLUDE ?
= /usr
/include/$(TCL_VERSION
)
351 CXXFLAGS
+= -DYOSYS_ENABLE_TCL
352 LDLIBS
+= -ltcl86
-lwsock32
-lws2_32
-lnetapi32
-lz
354 CXXFLAGS
+= $(shell PKG_CONFIG_PATH
=$(PKG_CONFIG_PATH
) $(PKG_CONFIG
) --silence-errors
--cflags tcl || echo
-I
$(TCL_INCLUDE
)) -DYOSYS_ENABLE_TCL
355 ifeq ($(OS
), FreeBSD
)
356 # FreeBSD uses tcl8.6, but lib is named "libtcl86"
357 LDLIBS
+= $(shell PKG_CONFIG_PATH
=$(PKG_CONFIG_PATH
) $(PKG_CONFIG
) --silence-errors
--libs tcl || echo
-l
$(TCL_VERSION
) | tr
-d
'.')
359 LDLIBS
+= $(shell PKG_CONFIG_PATH
=$(PKG_CONFIG_PATH
) $(PKG_CONFIG
) --silence-errors
--libs tcl || echo
-l
$(TCL_VERSION
))
364 ifeq ($(ENABLE_GCOV
),1)
365 CXXFLAGS
+= --coverage
366 LDFLAGS
+= --coverage
369 ifeq ($(ENABLE_GPROF
),1)
374 ifeq ($(ENABLE_NDEBUG
),1)
375 CXXFLAGS
:= -O3
-DNDEBUG
$(filter-out -Os
-ggdb
,$(CXXFLAGS
))
378 ifeq ($(ENABLE_DEBUG
),1)
379 ifeq ($(CONFIG
),clang
)
380 CXXFLAGS
:= -O0
-DDEBUG
$(filter-out -Os
,$(CXXFLAGS
))
382 CXXFLAGS
:= -Og
-DDEBUG
$(filter-out -Os
,$(CXXFLAGS
))
386 ifeq ($(ENABLE_ABC
),1)
387 CXXFLAGS
+= -DYOSYS_ENABLE_ABC
389 CXXFLAGS
+= -DYOSYS_LINK_ABC
390 ifeq ($(DISABLE_ABC_THREADS
),0)
394 ifeq ($(ABCEXTERNAL
),)
395 TARGETS
+= yosys-abc
$(EXE
)
400 ifeq ($(ENABLE_VERIFIC
),1)
401 VERIFIC_DIR ?
= /usr
/local
/src
/verific_lib
402 VERIFIC_COMPONENTS ?
= verilog vhdl database util containers hier_tree
403 CXXFLAGS
+= $(patsubst %,-I
$(VERIFIC_DIR
)/%,$(VERIFIC_COMPONENTS
)) -DYOSYS_ENABLE_VERIFIC
405 LDLIBS
+= $(patsubst %,$(VERIFIC_DIR
)/%/*-mac.a
,$(VERIFIC_COMPONENTS
)) -lz
407 LDLIBS
+= $(patsubst %,$(VERIFIC_DIR
)/%/*-linux.a
,$(VERIFIC_COMPONENTS
)) -lz
411 ifeq ($(ENABLE_PROTOBUF
),1)
412 LDLIBS
+= $(shell pkg-config
--cflags --libs protobuf
)
415 ifeq ($(ENABLE_COVER
),1)
416 CXXFLAGS
+= -DYOSYS_ENABLE_COVER
419 define add_share_file
420 EXTRA_TARGETS
+= $(subst //,/,$(1)/$(notdir $(2)))
421 $(subst //,/,$(1)/$(notdir $(2))): $(2)
423 $$(Q
) cp
"$(YOSYS_SRC)"/$(2) $(subst //,/,$(1)/$(notdir $(2)))
426 define add_gen_share_file
427 EXTRA_TARGETS
+= $(subst //,/,$(1)/$(notdir $(2)))
428 $(subst //,/,$(1)/$(notdir $(2))): $(2)
430 $$(Q
) cp
$(2) $(subst //,/,$(1)/$(notdir $(2)))
433 define add_include_file
434 $(eval
$(call add_share_file
,$(dir share
/include/$(1)),$(1)))
440 P_UPDATE
= $(eval P_STATUS
=$(shell echo
$(OBJS
) yosys
$(EXE
) |
$(AWK
) 'BEGIN { RS = " "; I = $(P_STATUS)+0; } $$1 == "$@" && NR > I { I = NR; } END { print I; }'))
441 P_SHOW
= [$(shell $(AWK
) "BEGIN { N=$(words $(OBJS) yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
442 P
= @echo
"$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
452 $(eval
$(call add_include_file
,kernel
/yosys.h
))
453 $(eval
$(call add_include_file
,kernel
/hashlib.h
))
454 $(eval
$(call add_include_file
,kernel
/log.h
))
455 $(eval
$(call add_include_file
,kernel
/rtlil.h
))
456 $(eval
$(call add_include_file
,kernel
/register.h
))
457 $(eval
$(call add_include_file
,kernel
/celltypes.h
))
458 $(eval
$(call add_include_file
,kernel
/celledges.h
))
459 $(eval
$(call add_include_file
,kernel
/consteval.h
))
460 $(eval
$(call add_include_file
,kernel
/sigtools.h
))
461 $(eval
$(call add_include_file
,kernel
/modtools.h
))
462 $(eval
$(call add_include_file
,kernel
/macc.h
))
463 $(eval
$(call add_include_file
,kernel
/utils.h
))
464 $(eval
$(call add_include_file
,kernel
/satgen.h
))
465 $(eval
$(call add_include_file
,libs
/ezsat
/ezsat.h
))
466 $(eval
$(call add_include_file
,libs
/ezsat
/ezminisat.h
))
467 $(eval
$(call add_include_file
,libs
/sha1
/sha1.h
))
468 $(eval
$(call add_include_file
,passes
/fsm
/fsmdata.h
))
469 $(eval
$(call add_include_file
,frontends
/ast
/ast.h
))
470 $(eval
$(call add_include_file
,backends
/ilang
/ilang_backend.h
))
472 OBJS
+= kernel
/driver.o kernel
/register.o kernel
/rtlil.o kernel
/log.o kernel
/calc.o kernel
/yosys.o
473 OBJS
+= kernel
/cellaigs.o kernel
/celledges.o
475 kernel
/log.o
: CXXFLAGS
+= -DYOSYS_SRC
='"$(YOSYS_SRC)"'
476 kernel
/yosys.o
: CXXFLAGS
+= -DYOSYS_DATDIR
='"$(DATDIR)"'
478 OBJS
+= libs
/bigint
/BigIntegerAlgorithms.o libs
/bigint
/BigInteger.o libs
/bigint
/BigIntegerUtils.o
479 OBJS
+= libs
/bigint
/BigUnsigned.o libs
/bigint
/BigUnsignedInABase.o
481 OBJS
+= libs
/sha1
/sha1.o
485 OBJS
+= libs
/subcircuit
/subcircuit.o
487 OBJS
+= libs
/ezsat
/ezsat.o
488 OBJS
+= libs
/ezsat
/ezminisat.o
490 OBJS
+= libs
/minisat
/Options.o
491 OBJS
+= libs
/minisat
/SimpSolver.o
492 OBJS
+= libs
/minisat
/Solver.o
493 OBJS
+= libs
/minisat
/System.o
495 include $(YOSYS_SRC
)/frontends
/*/Makefile.inc
496 include $(YOSYS_SRC
)/passes
/*/Makefile.inc
497 include $(YOSYS_SRC
)/backends
/*/Makefile.inc
498 include $(YOSYS_SRC
)/techlibs
/*/Makefile.inc
502 include frontends
/verilog
/Makefile.inc
503 include frontends
/ilang
/Makefile.inc
504 include frontends
/ast
/Makefile.inc
505 include frontends
/blif
/Makefile.inc
507 OBJS
+= passes
/hierarchy
/hierarchy.o
508 OBJS
+= passes
/cmds
/select.o
509 OBJS
+= passes
/cmds
/show.o
510 OBJS
+= passes
/cmds
/stat.o
511 OBJS
+= passes
/cmds
/cover.o
512 OBJS
+= passes
/cmds
/design.o
513 OBJS
+= passes
/cmds
/plugin.o
515 include passes
/proc
/Makefile.inc
516 include passes
/opt
/Makefile.inc
517 include passes
/techmap
/Makefile.inc
519 include backends
/verilog
/Makefile.inc
520 include backends
/ilang
/Makefile.inc
522 include techlibs
/common
/Makefile.inc
527 OBJS
+= yosys-libabc.a
530 top-all
: $(TARGETS
) $(EXTRA_TARGETS
)
532 @echo
" Build successful."
535 ifeq ($(CONFIG
),emcc
)
536 yosys.js
: $(filter-out yosysjs-
$(YOSYS_VER
).zip
,$(EXTRA_TARGETS
))
540 $(P
) $(LD
) -o yosys
$(EXE
) $(LDFLAGS
) $(OBJS
) $(LDLIBS
)
542 libyosys.so
: $(filter-out kernel
/driver.o
,$(OBJS
))
543 $(P
) $(LD
) -o libyosys.so
-shared
-Wl
,-soname
,libyosys.so
$(LDFLAGS
) $^
$(LDLIBS
)
546 $(Q
) mkdir
-p
$(dir $@
)
547 $(P
) $(CXX
) -o
$@
-c
$(CPPFLAGS
) $(CXXFLAGS
) $<
550 $(Q
) mkdir
-p
$(dir $@
)
551 $(P
) cat
$< | grep
-E
-v
"#[ ]*(include|error)" |
$(LD
) -x c
++ -o
$@
-E
-P
-
553 $(PY_WRAPPER_FILE
).
cc: $(PY_GEN_SCRIPT
).py
$(PY_WRAP_INCLUDES
)
554 $(Q
) mkdir
-p
$(dir $@
)
555 $(P
) python
$(PYTHON_VERSION
) -c
"import $(PY_GEN_SCRIPT); $(PY_GEN_SCRIPT).gen_wrappers(\"$(PY_WRAPPER_FILE).cc\")"
558 $(Q
) mkdir
-p
$(dir $@
)
559 $(P
) $(CXX
) -o
$@
-c
$(CPPFLAGS
) $(CXXFLAGS
) $<
561 YOSYS_VER_STR
:= Yosys
$(YOSYS_VER
) (git sha1
$(GIT_REV
), $(notdir $(CXX
)) $(shell \
562 $(CXX
) --version | tr
' ()' '\n' | grep
'^[0-9]' | head
-n1
) $(filter -f
% -m
% -O
% -DNDEBUG
,$(CXXFLAGS
)))
564 kernel
/version_
$(GIT_REV
).
cc: $(YOSYS_SRC
)/Makefile
565 $(P
) rm -f kernel
/version_
*.o kernel
/version_
*.d kernel
/version_
*.
cc
566 $(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
568 ifeq ($(ENABLE_VERIFIC
),1)
569 CXXFLAGS_NOVERIFIC
= $(foreach v
,$(CXXFLAGS
),$(if
$(findstring $(VERIFIC_DIR
),$(v
)),,$(v
)))
570 LDLIBS_NOVERIFIC
= $(foreach v
,$(LDLIBS
),$(if
$(findstring $(VERIFIC_DIR
),$(v
)),,$(v
)))
572 CXXFLAGS_NOVERIFIC
= $(CXXFLAGS
)
573 LDLIBS_NOVERIFIC
= $(LDLIBS
)
576 yosys-config
: misc
/yosys-config.in
577 $(P
) $(SED
) -e
's#@CXXFLAGS@#$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(strip $(CXXFLAGS_NOVERIFIC)))#;' \
578 -e
's#@CXX@#$(strip $(CXX))#;' -e
's#@LDFLAGS@#$(strip $(LDFLAGS) $(PLUGIN_LDFLAGS))#;' -e
's#@LDLIBS@#$(strip $(LDLIBS_NOVERIFIC))#;' \
579 -e
's#@BINDIR@#$(strip $(BINDIR))#;' -e
's#@DATDIR@#$(strip $(DATDIR))#;' < $< > yosys-config
580 $(Q
) chmod
+x yosys-config
582 abc
/abc-
$(ABCREV
)$(EXE
) abc
/libabc-
$(ABCREV
).a
:
584 ifneq ($(ABCREV
),default
)
585 $(Q
) if
test -d abc
/.hg
; then \
586 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
; \
588 $(Q
) if
( cd abc
2> /dev
/null
&& ! git diff-index
--quiet HEAD
; ); then \
589 echo
'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr
'A-Za-z' 'N-ZA-Mn-za-m'; false
; \
591 $(Q
) if
test "`cd abc 2> /dev/null && git rev-parse --short HEAD`" != "$(ABCREV)"; then \
592 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; }; \
593 echo
"Pulling ABC from $(ABCURL):"; set
-x
; \
594 test -d abc || git clone
$(ABCURL
) abc
; \
595 cd abc
&& $(MAKE
) DEP
= clean && git fetch
origin master
&& git checkout
$(ABCREV
); \
598 $(Q
) rm -f abc
/abc-
[0-9a-f
]*
599 $(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
)
601 ifeq ($(ABCREV
),default
)
602 .PHONY
: abc
/abc-
$(ABCREV
)$(EXE
)
603 .PHONY
: abc
/libabc-
$(ABCREV
).a
606 yosys-abc
$(EXE
): abc
/abc-
$(ABCREV
)$(EXE
)
607 $(P
) cp abc
/abc-
$(ABCREV
)$(EXE
) yosys-abc
$(EXE
)
609 yosys-libabc.a
: abc
/libabc-
$(ABCREV
).a
610 $(P
) cp abc
/libabc-
$(ABCREV
).a yosys-libabc.a
618 test: $(TARGETS
) $(EXTRA_TARGETS
)
619 +cd tests
/simple
&& bash run-test.sh
$(SEEDOPT
)
620 +cd tests
/hana
&& bash run-test.sh
$(SEEDOPT
)
621 +cd tests
/asicworld
&& bash run-test.sh
$(SEEDOPT
)
622 # +cd tests/realmath && bash run-test.sh $(SEEDOPT)
623 +cd tests
/share
&& bash run-test.sh
$(SEEDOPT
)
624 +cd tests
/fsm
&& bash run-test.sh
$(SEEDOPT
)
625 +cd tests
/techmap
&& bash run-test.sh
626 +cd tests
/memories
&& bash run-test.sh
$(SEEDOPT
)
627 +cd tests
/bram
&& bash run-test.sh
$(SEEDOPT
)
628 +cd tests
/various
&& bash run-test.sh
629 +cd tests
/sat
&& bash run-test.sh
630 +cd tests
/svinterfaces
&& bash run-test.sh
$(SEEDOPT
)
631 +cd tests
/opt
&& bash run-test.sh
632 +cd tests
/aiger
&& bash run-test.sh
634 @echo
" Passed \"make test\"."
637 VALGRIND ?
= valgrind
--error-exitcode
=1 --leak-check
=full
--show-reachable
=yes
--errors-for-leak-kinds
=all
639 vgtest
: $(TARGETS
) $(EXTRA_TARGETS
)
640 $(VALGRIND
) .
/yosys
-p
'setattr -mod -unset top; synth' $$( ls tests
/simple
/*.v | grep
-v repwhile.v
)
642 @echo
" Passed \"make vgtest\"."
645 vloghtb
: $(TARGETS
) $(EXTRA_TARGETS
)
646 +cd tests
/vloghtb
&& bash run-test.sh
648 @echo
" Passed \"make vloghtb\"."
651 ystests
: $(TARGETS
) $(EXTRA_TARGETS
)
653 git clone https
://github.com
/YosysHQ
/yosys-tests.git tests
/ystests
654 +$(MAKE
) PATH
="$$PWD:$$PATH" -C tests
/ystests
656 @echo
" Finished \"make ystests\"."
660 unit-test
: libyosys.so
661 @
$(MAKE
) -C
$(UNITESTPATH
) CXX
="$(CXX)" CPPFLAGS
="$(CPPFLAGS)" \
662 CXXFLAGS
="$(CXXFLAGS)" LDLIBS
="$(LDLIBS)" ROOTPATH
="$(CURDIR)"
665 @
$(MAKE
) -C
$(UNITESTPATH
) clean
667 install: $(TARGETS
) $(EXTRA_TARGETS
)
668 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)$(BINDIR
)
669 $(INSTALL_SUDO
) cp
$(TARGETS
) $(DESTDIR
)$(BINDIR
)
670 ifneq ($(filter yosys
,$(TARGETS
)),)
671 $(INSTALL_SUDO
) $(STRIP
) -S
$(DESTDIR
)$(BINDIR
)/yosys
673 ifneq ($(filter yosys-abc
,$(TARGETS
)),)
674 $(INSTALL_SUDO
) $(STRIP
) $(DESTDIR
)$(BINDIR
)/yosys-abc
676 ifneq ($(filter yosys-filterlib
,$(TARGETS
)),)
677 $(INSTALL_SUDO
) $(STRIP
) $(DESTDIR
)$(BINDIR
)/yosys-filterlib
679 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)$(DATDIR
)
680 $(INSTALL_SUDO
) cp
-r share
/.
$(DESTDIR
)$(DATDIR
)/.
681 ifeq ($(ENABLE_LIBYOSYS
),1)
682 $(INSTALL_SUDO
) cp libyosys.so
$(DESTDIR
)$(LIBDIR
)
683 $(INSTALL_SUDO
) $(STRIP
) -S
$(DESTDIR
)$(LIBDIR
)/libyosys.so
684 $(INSTALL_SUDO
) ldconfig
685 ifeq ($(ENABLE_PYOSYS
),1)
686 $(INSTALL_SUDO
) mkdir
-p
$(PYTHON_DESTDIR
)/pyosys
687 $(INSTALL_SUDO
) cp libyosys.so
$(PYTHON_DESTDIR
)/pyosys
688 $(INSTALL_SUDO
) cp __init__.py
$(PYTHON_DESTDIR
)/pyosys
693 $(INSTALL_SUDO
) rm -vf
$(addprefix $(DESTDIR
)$(BINDIR
)/,$(notdir $(TARGETS
)))
694 $(INSTALL_SUDO
) rm -rvf
$(DESTDIR
)$(DATDIR
)
695 ifeq ($(ENABLE_LIBYOSYS
),1)
696 $(INSTALL_SUDO
) rm -vf
$(DESTDIR
)$(LIBDIR
)/libyosys.so
697 ifeq ($(ENABLE_PYOSYS
),1)
698 $(INSTALL_SUDO
) rm -vf
$(PYTHON_DESTDIR
)/pyosys
/libyosys.so
699 $(INSTALL_SUDO
) rm -vf
$(PYTHON_DESTDIR
)/pyosys
/__init__.py
700 $(INSTALL_SUDO
) rmdir
$(PYTHON_DESTDIR
)/pyosys
704 update-manual
: $(TARGETS
) $(EXTRA_TARGETS
)
705 cd manual
&& ..
/yosys
-p
'help -write-tex-command-reference-manual'
707 manual
: $(TARGETS
) $(EXTRA_TARGETS
)
708 cd manual
&& bash appnotes.sh
709 cd manual
&& bash presentation.sh
710 cd manual
&& bash manual.sh
715 if
test -d manual
; then cd manual
&& sh
clean.sh
; fi
716 rm -f
$(OBJS
) $(GENFILES
) $(TARGETS
) $(EXTRA_TARGETS
) $(EXTRA_OBJS
) $(PY_WRAP_INCLUDES
) $(PY_WRAPPER_FILE
).
cc
717 rm -f kernel
/version_
*.o kernel
/version_
*.
cc abc
/abc-
[0-9a-f
]* abc
/libabc-
[0-9a-f
]*.a
718 rm -f libs
/*/*.d frontends
/*/*.d passes
/*/*.d backends
/*/*.d kernel
/*.d techlibs
/*/*.d
719 rm -rf tests
/asicworld
/*.out tests
/asicworld
/*.log
720 rm -rf tests
/hana
/*.out tests
/hana
/*.log
721 rm -rf tests
/simple
/*.out tests
/simple
/*.log
722 rm -rf tests
/memories
/*.out tests
/memories
/*.log tests
/memories
/*.dmp
723 rm -rf tests
/sat
/*.log tests
/techmap
/*.log tests
/various
/*.log
724 rm -rf tests
/bram
/temp tests
/fsm
/temp tests
/realmath
/temp tests
/share
/temp tests
/smv
/temp
725 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_
*
726 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
727 rm -f tests
/tools
/cmp_tbdata
730 $(MAKE
) -C abc DEP
= clean
731 rm -f yosys-abc
$(EXE
) yosys-libabc.a abc
/abc-
[0-9a-f
]* abc
/libabc-
[0-9a-f
]*.a
737 .
/yosys
-qp
'help; help -all'
738 rm -rf coverage.
info coverage_html
739 lcov
--capture
-d .
--no-external
-o coverage.
info
740 genhtml coverage.
info --output-directory coverage_html
743 { for file in
$(basename $(OBJS
)); do \
744 for
prefix in
cc y l
; do if
[ -f
$${file}.
$${prefix} ]; then echo
$$file.
$${prefix}; fi
; done \
745 done
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
); } > qtcreator.files
746 { echo .
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
) -printf
'%h\n' |
sort -u
; } > qtcreator.includes
747 touch qtcreator.config qtcreator.creator
749 vcxsrc
: $(GENFILES
) $(EXTRA_TARGETS
)
750 rm -rf yosys-win32-vcxsrc-
$(YOSYS_VER
){,.zip
}
751 set
-e
; for f in
`ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
752 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
753 bash misc
/create_vcxsrc.sh yosys-win32-vcxsrc
$(YOSYS_VER
) $(GIT_REV
)
754 echo
"namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel
/version.
cc
755 zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/genfiles.zip
$(GENFILES
) kernel
/version.
cc
756 zip
-r yosys-win32-vcxsrc-
$(YOSYS_VER
).zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/
757 rm -f srcfiles.txt kernel
/version.
cc
760 mxebin
: $(TARGETS
) $(EXTRA_TARGETS
)
761 rm -rf yosys-win32-mxebin-
$(YOSYS_VER
){,.zip
}
762 mkdir
-p yosys-win32-mxebin-
$(YOSYS_VER
)
763 cp
-r yosys.exe share
/ yosys-win32-mxebin-
$(YOSYS_VER
)/
764 ifeq ($(ENABLE_ABC
),1)
765 cp
-r yosys-abc.exe abc
/lib
/x86
/pthreadVC2.dll yosys-win32-mxebin-
$(YOSYS_VER
)/
767 echo
-en
'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
768 echo
-en
'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
769 zip
-r yosys-win32-mxebin-
$(YOSYS_VER
).zip yosys-win32-mxebin-
$(YOSYS_VER
)/
776 echo
'CONFIG := clang' > Makefile.conf
779 echo
'CONFIG := gcc' > Makefile.conf
781 config-gcc-static
: clean
782 echo
'CONFIG := gcc-static' > Makefile.conf
783 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
784 echo
'ENABLE_READLINE := 0' >> Makefile.conf
785 echo
'ENABLE_TCL := 0' >> Makefile.conf
787 config-gcc-4.8
: clean
788 echo
'CONFIG := gcc-4.8' > Makefile.conf
791 echo
'CONFIG := emcc' > Makefile.conf
792 echo
'ENABLE_TCL := 0' >> Makefile.conf
793 echo
'ENABLE_ABC := 0' >> Makefile.conf
794 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
795 echo
'ENABLE_READLINE := 0' >> Makefile.conf
798 echo
'CONFIG := mxe' > Makefile.conf
799 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
802 echo
'CONFIG := msys2' > Makefile.conf
804 config-msys2-64
: clean
805 echo
'CONFIG := msys2-64' > Makefile.conf
808 echo
'CONFIG := cygwin' > Makefile.conf
811 echo
'CONFIG := gcc' > Makefile.conf
812 echo
'ENABLE_GCOV := 1' >> Makefile.conf
813 echo
'ENABLE_DEBUG := 1' >> Makefile.conf
816 echo
'CONFIG := gcc' > Makefile.conf
817 echo
'ENABLE_GPROF := 1' >> Makefile.conf
820 echo
"INSTALL_SUDO := sudo" >> Makefile.conf
829 -include frontends
/*/*.d
830 -include passes
/*/*.d
831 -include backends
/*/*.d
833 -include techlibs
/*/*.d
835 .PHONY
: all top-all abc
test install install-abc manual
clean mrproper qtcreator coverage vcxsrc mxebin
836 .PHONY
: config-clean config-clang config-gcc config-gcc-static config-gcc-4.8 config-gprof config-sudo