8 # features (the more the better)
16 # other configuration flags
28 TARGETS
= yosys
$(EXE
) yosys-config
35 CXXFLAGS
= -Wall
-Wextra
-ggdb
-I
"$(shell pwd)" -MD
-DYOSYS_SRC
='"$(shell pwd)"' -D_YOSYS_
-fPIC
-I
$(DESTDIR
)/include
36 LDFLAGS
= -L
$(DESTDIR
)/lib
41 ifeq (Darwin
,$(findstring Darwin
,$(shell uname
)))
42 # add macports/homebrew include and library path to search directories, don't use '-rdynamic' and '-lrt':
43 CXXFLAGS
+= -I
/opt
/local
/include -I
/usr
/local
/opt
/readline
/include
44 LDFLAGS
+= -L
/opt
/local
/lib
-L
/usr
/local
/opt
/readline
/lib
45 # add homebrew's libffi include and library path
46 CXXFLAGS
+= $(shell PKG_CONFIG_PATH
=$$(brew list libffi | grep pkgconfig | xargs dirname
) pkg-config
--silence-errors
--cflags libffi
)
47 LDFLAGS
+= $(shell PKG_CONFIG_PATH
=$$(brew list libffi | grep pkgconfig | xargs dirname
) pkg-config
--silence-errors
--libs libffi
)
48 # use bison installed by homebrew if available
49 BISON
= $(shell (brew list bison | grep
-m1
"bin/bison") || echo bison
)
56 YOSYS_VER
:= 0.4+$(shell test -d .git
&& { git log
--author
=clifford@clifford.at
--oneline d5aa0ee158b41.. | wc
-l
; })
57 GIT_REV
:= $(shell git rev-parse
--short HEAD
2> /dev
/null || echo UNKNOWN
)
58 OBJS
= kernel
/version_
$(GIT_REV
).o
60 # set 'ABCREV = default' to use abc/ as it is
62 # Note: If you do ABC development, make sure that 'abc' in this directory
63 # is just a symlink to your actual ABC working directory, as 'make mrproper'
64 # will remove the 'abc' directory and you do not want to accidentally
65 # delete your work on ABC..
68 ABCMKARGS
= # CC="$(CXX)" CXX="$(CXX)"
75 ifneq ($(wildcard Makefile.conf
),)
76 $(info $(subst $$--$$,$(newline
),$(shell sed
's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr
-d
'\n' | sed
's,\$$--\$$$$,,')))
80 ifeq ($(CONFIG
),clang
)
82 CXXFLAGS
+= -std
=c
++11 -Os
84 else ifeq ($(CONFIG
),gcc
)
86 CXXFLAGS
+= -std
=gnu
++0x
-Os
88 else ifeq ($(CONFIG
),gcc-4.6
)
90 CXXFLAGS
+= -std
=gnu
++0x
-Os
92 else ifeq ($(CONFIG
),emcc
)
94 CXXFLAGS
+= -std
=c
++11 -Os
-Wno-warn-absolute-paths
95 CXXFLAGS
:= $(filter-out -ggdb
,$(CXXFLAGS
))
98 else ifeq ($(CONFIG
),mxe
)
99 CXX
= /usr
/local
/src
/mxe
/usr
/bin
/i686-pc-mingw32-gcc
100 CXXFLAGS
+= -std
=gnu
++0x
-Os
-D_POSIX_SOURCE
101 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
102 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -s
103 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
104 ABCMKARGS
+= ARCHFLAGS
="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -x c++ -fpermissive -w"
105 ABCMKARGS
+= LIBS
="lib/x86/pthreadVC2.lib -s" READLINE
=0 CC
="$(CXX)" CXX
="$(CXX)"
108 else ifneq ($(CONFIG
),none
)
109 $(error Invalid CONFIG setting
'$(CONFIG)'. Valid values
: clang
, gcc
, gcc-4.6
, emcc
, none
)
112 ifeq ($(ENABLE_READLINE
),1)
113 CXXFLAGS
+= -DYOSYS_ENABLE_READLINE
120 ifeq ($(ENABLE_PLUGINS
),1)
121 CXXFLAGS
+= -DYOSYS_ENABLE_PLUGINS
$(shell pkg-config
--silence-errors
--cflags libffi
)
122 LDLIBS
+= $(shell pkg-config
--silence-errors
--libs libffi || echo
-lffi
) -ldl
125 ifeq ($(ENABLE_TCL
),1)
126 TCL_VERSION ?
= tcl8.5
127 TCL_INCLUDE ?
= /usr
/include/$(TCL_VERSION
)
128 CXXFLAGS
+= -I
$(TCL_INCLUDE
) -DYOSYS_ENABLE_TCL
129 LDLIBS
+= -l
$(TCL_VERSION
)
132 ifeq ($(ENABLE_GPROF
),1)
137 ifeq ($(ENABLE_NDEBUG
),1)
138 CXXFLAGS
:= -O3
-DNDEBUG
$(filter-out -Os
,$(CXXFLAGS
))
141 ifeq ($(ENABLE_ABC
),1)
142 CXXFLAGS
+= -DYOSYS_ENABLE_ABC
143 TARGETS
+= yosys-abc
$(EXE
)
146 ifeq ($(ENABLE_VERIFIC
),1)
147 VERIFIC_DIR ?
= /usr
/local
/src
/verific_lib_eval
148 VERIFIC_COMPONENTS ?
= verilog vhdl database util containers
149 CXXFLAGS
+= $(patsubst %,-I
$(VERIFIC_DIR
)/%,$(VERIFIC_COMPONENTS
)) -DYOSYS_ENABLE_VERIFIC
150 LDLIBS
+= $(patsubst %,$(VERIFIC_DIR
)/%/*-linux.a
,$(VERIFIC_COMPONENTS
))
153 ifeq ($(ENABLE_COVER
),1)
154 CXXFLAGS
+= -DYOSYS_ENABLE_COVER
157 define add_share_file
158 EXTRA_TARGETS
+= $(1)/$(notdir $(2))
159 $(1)/$(notdir $(2)): $(2)
161 $$(Q
) cp
$(2) $(1)/$(notdir $(2))
167 P_UPDATE
= $(eval P_STATUS
=$(shell echo
$(OBJS
) yosys
$(EXE
) | gawk
'BEGIN { RS = " "; I = $(P_STATUS)+0; } $$1 == "$@" && NR > I { I = NR; } END { print I; }'))
168 P_SHOW
= [$(shell gawk
"BEGIN { N=$(words $(OBJS) yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
169 P
= @echo
"$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
179 OBJS
+= kernel
/driver.o kernel
/register.o kernel
/rtlil.o kernel
/log.o kernel
/calc.o kernel
/yosys.o
181 OBJS
+= libs
/bigint
/BigIntegerAlgorithms.o libs
/bigint
/BigInteger.o libs
/bigint
/BigIntegerUtils.o
182 OBJS
+= libs
/bigint
/BigUnsigned.o libs
/bigint
/BigUnsignedInABase.o
184 OBJS
+= libs
/sha1
/sha1.o
188 OBJS
+= libs
/subcircuit
/subcircuit.o
190 OBJS
+= libs
/ezsat
/ezsat.o
191 OBJS
+= libs
/ezsat
/ezminisat.o
193 OBJS
+= libs
/minisat
/Options.o
194 OBJS
+= libs
/minisat
/SimpSolver.o
195 OBJS
+= libs
/minisat
/Solver.o
196 OBJS
+= libs
/minisat
/System.o
198 include frontends
/*/Makefile.inc
199 include passes
/*/Makefile.inc
200 include backends
/*/Makefile.inc
201 include techlibs
/*/Makefile.inc
205 include frontends
/verilog
/Makefile.inc
206 include frontends
/ilang
/Makefile.inc
207 include frontends
/ast
/Makefile.inc
209 OBJS
+= passes
/hierarchy
/hierarchy.o
210 OBJS
+= passes
/cmds
/select.o
211 OBJS
+= passes
/cmds
/show.o
212 OBJS
+= passes
/cmds
/stat.o
213 OBJS
+= passes
/cmds
/cover.o
214 OBJS
+= passes
/cmds
/design.o
215 OBJS
+= passes
/cmds
/plugin.o
217 include passes
/proc
/Makefile.inc
218 include passes
/opt
/Makefile.inc
219 include passes
/techmap
/Makefile.inc
220 include passes
/abc
/Makefile.inc
222 include backends
/verilog
/Makefile.inc
223 include backends
/ilang
/Makefile.inc
225 include techlibs
/common
/Makefile.inc
229 top-all
: $(TARGETS
) $(EXTRA_TARGETS
)
231 @echo
" Build successful."
235 $(P
) $(CXX
) -o yosys
$(EXE
) $(LDFLAGS
) $(OBJS
) $(LDLIBS
)
238 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
241 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
243 kernel
/version_
$(GIT_REV
).
cc: Makefile
244 $(P
) rm -f kernel
/version_
*.o kernel
/version_
*.d kernel
/version_
*.
cc
245 $(Q
) echo
"namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) ` \
246 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1` $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))\"; }" > kernel
/version_
$(GIT_REV
).
cc
248 yosys-config
: misc
/yosys-config.in
249 $(P
) $(SED
) -e
's,@CXX@,$(CXX),;' -e
's,@CXXFLAGS@,$(CXXFLAGS),;' -e
's,@LDFLAGS@,$(LDFLAGS),;' -e
's,@LDLIBS@,$(LDLIBS),;' \
250 -e
's,@BINDIR@,$(DESTDIR)/bin,;' -e
's,@DATDIR@,$(DESTDIR)/share/yosys,;' < misc
/yosys-config.in
> yosys-config
251 $(Q
) chmod
+x yosys-config
253 abc
/abc-
$(ABCREV
)$(EXE
):
255 ifneq ($(ABCREV
),default
)
256 $(Q
) if
( cd abc
2> /dev
/null
&& hg identify
; ) | grep
-q
+; then \
257 echo
'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr
'A-Za-z' 'N-ZA-Mn-za-m'; false
; \
259 $(Q
) if
test "`cd abc 2> /dev/null && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
260 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; }; \
261 echo
"Pulling ABC from bitbucket.org:"; set
-x
; \
262 test -d abc || hg clone https
://bitbucket.org
/alanmi
/abc abc
; \
263 cd abc
&& $(MAKE
) DEP
= clean && hg pull
&& hg update
-r
$(ABCREV
); \
266 $(Q
) rm -f abc
/abc-
[0-9a-f
]*
267 $(Q
) cd abc
&& $(MAKE
) $(S
) $(ABCMKARGS
) PROG
="abc-$(ABCREV)$(EXE)" MSG_PREFIX
="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: "
269 ifeq ($(ABCREV
),default
)
270 .PHONY
: abc
/abc-
$(ABCREV
)$(EXE
)
273 yosys-abc
$(EXE
): abc
/abc-
$(ABCREV
)$(EXE
)
274 $(P
) cp abc
/abc-
$(ABCREV
)$(EXE
) yosys-abc
$(EXE
)
276 test: $(TARGETS
) $(EXTRA_TARGETS
)
277 +cd tests
/simple
&& bash run-test.sh
278 +cd tests
/hana
&& bash run-test.sh
279 +cd tests
/asicworld
&& bash run-test.sh
280 +cd tests
/realmath
&& bash run-test.sh
281 +cd tests
/share
&& bash run-test.sh
282 +cd tests
/fsm
&& bash run-test.sh
283 +cd tests
/techmap
&& bash run-test.sh
284 +cd tests
/memories
&& bash run-test.sh
285 +cd tests
/bram
&& bash run-test.sh
286 +cd tests
/various
&& bash run-test.sh
287 +cd tests
/sat
&& bash run-test.sh
289 @echo
" Passed \"make test\"."
292 VALGRIND ?
= valgrind
--error-exitcode
=1 --leak-check
=full
--show-reachable
=yes
--errors-for-leak-kinds
=all
294 vgtest
: $(TARGETS
) $(EXTRA_TARGETS
)
295 $(VALGRIND
) .
/yosys
-p
'setattr -mod -unset top; hierarchy; proc; opt; memory -nomap; opt -fine; techmap; opt' $$( ls tests
/simple
/*.v | grep
-v repwhile.v
)
297 @echo
" Passed \"make vgtest\"."
300 vloghtb
: $(TARGETS
) $(EXTRA_TARGETS
)
301 +cd tests
/vloghtb
&& bash run-test.sh
303 @echo
" Passed \"make vloghtb\"."
306 install: $(TARGETS
) $(EXTRA_TARGETS
)
307 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/bin
308 $(INSTALL_SUDO
) install $(TARGETS
) $(DESTDIR
)/bin
/
309 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/share
/yosys
310 $(INSTALL_SUDO
) cp
-r share
/.
$(DESTDIR
)/share
/yosys
/.
312 manual
: $(TARGETS
) $(EXTRA_TARGETS
)
313 cd manual
&& bash appnotes.sh
314 cd manual
&& bash presentation.sh
315 cd manual
&& bash manual.sh
319 cd manual
&& bash
clean.sh
320 rm -f
$(OBJS
) $(GENFILES
) $(TARGETS
) $(EXTRA_TARGETS
) $(EXTRA_OBJS
)
321 rm -f kernel
/version_
*.o kernel
/version_
*.
cc abc
/abc-
[0-9a-f
]*
322 rm -f libs
/*/*.d frontends
/*/*.d passes
/*/*.d backends
/*/*.d kernel
/*.d techlibs
/*/*.d
325 $(MAKE
) -C abc DEP
= clean
326 rm -f yosys-abc
$(EXE
) abc
/abc-
[0-9a-f
]*
332 { for file in
$(basename $(OBJS
)); do \
333 for
prefix in
cc y l
; do if
[ -f
$${file}.
$${prefix} ]; then echo
$$file.
$${prefix}; fi
; done \
334 done
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
); } > qtcreator.files
335 { echo .
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
) -printf
'%h\n' |
sort -u
; } > qtcreator.includes
336 touch qtcreator.config qtcreator.creator
338 vcxsrc
: $(GENFILES
) $(EXTRA_TARGETS
)
339 rm -rf yosys-win32-vcxsrc-
$(YOSYS_VER
){,.zip
}
340 set
-e
; for f in
$(wildcard $(filter %.
cc %.
cpp,$(GENFILES
)) $(addsuffix .
cc,$(basename $(OBJS
))) $(addsuffix .
cpp,$(basename $(OBJS
))) 2>/dev
/null
); do \
341 echo
"Analyse: $$f" >&2; cpp -std
=gnu
++0x
-MM
-I.
-D_YOSYS_
$$f; done | sed
's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep
'^[^/]' |
sort -u | grep
-v kernel
/version_
> srcfiles.txt
342 bash misc
/create_vcxsrc.sh yosys-win32-vcxsrc
$(YOSYS_VER
) $(GIT_REV
)
343 echo
"namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel
/version.
cc
344 zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/genfiles.zip
$(GENFILES
) kernel
/version.
cc
345 zip
-r yosys-win32-vcxsrc-
$(YOSYS_VER
).zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/
346 rm -f srcfiles.txt kernel
/version.
cc
349 mxebin
: $(TARGETS
) $(EXTRA_TARGETS
)
350 rm -rf yosys-win32-mxebin-
$(YOSYS_VER
){,.zip
}
351 mkdir
-p yosys-win32-mxebin-
$(YOSYS_VER
)
352 cp
-r yosys.exe share
/ yosys-win32-mxebin-
$(YOSYS_VER
)/
353 ifeq ($(ENABLE_ABC
),1)
354 cp
-r yosys-abc.exe abc
/lib
/x86
/pthreadVC2.dll yosys-win32-mxebin-
$(YOSYS_VER
)/
356 echo
-en
'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
357 echo
-en
'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
358 zip
-r yosys-win32-mxebin-
$(YOSYS_VER
).zip yosys-win32-mxebin-
$(YOSYS_VER
)/
365 echo
'CONFIG := clang' > Makefile.conf
368 echo
'CONFIG := gcc' > Makefile.conf
370 config-gcc-4.6
: clean
371 echo
'CONFIG := gcc-4.6' > Makefile.conf
374 echo
'CONFIG := emcc' > Makefile.conf
375 echo
'ENABLE_TCL := 0' >> Makefile.conf
376 echo
'ENABLE_ABC := 0' >> Makefile.conf
377 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
378 echo
'ENABLE_READLINE := 0' >> Makefile.conf
381 echo
'CONFIG := mxe' > Makefile.conf
382 echo
'ENABLE_TCL := 0' >> Makefile.conf
383 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
384 echo
'ENABLE_READLINE := 0' >> Makefile.conf
387 echo
'CONFIG := gcc' > Makefile.conf
388 echo
'ENABLE_GPROF := 1' >> Makefile.conf
391 echo
"INSTALL_SUDO := sudo" >> Makefile.conf
400 -include frontends
/*/*.d
401 -include passes
/*/*.d
402 -include backends
/*/*.d
404 -include techlibs
/*/*.d
406 .PHONY
: all top-all abc
test install install-abc manual
clean mrproper qtcreator
407 .PHONY
: config-clean config-clang config-gcc config-gcc-4.6 config-gprof config-sudo