8 # features (the more the better)
16 # other configuration flags
27 TARGETS
= yosys
$(EXE
) yosys-config
34 CXXFLAGS
= -Wall
-Wextra
-ggdb
-I
"$(shell pwd)" -MD
-DYOSYS_SRC
='"$(shell pwd)"' -D_YOSYS_
-fPIC
-I
${DESTDIR}/include
35 LDFLAGS
= -L
${DESTDIR}/lib
39 ifeq (Darwin
,$(findstring Darwin
,$(shell uname
)))
40 # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt':
41 CXXFLAGS
+= -I
/opt
/local
/include
42 LDFLAGS
+= -L
/opt
/local
/lib
49 YOSYS_VER
:= 0.3.0+$(shell test -d .git
&& { git log
--author
=clifford@clifford.at
--oneline ca125bf41.. | wc
-l
; })
50 GIT_REV
:= $(shell git rev-parse
--short HEAD
2> /dev
/null || echo UNKNOWN
)
51 OBJS
= kernel
/version_
$(GIT_REV
).o
53 # set 'ABCREV = default' to use abc/ as it is
55 # Note: If you do ABC development, make sure that 'abc' in this directory
56 # is just a symlink to your actual ABC working directory, as 'make mrproper'
57 # will remove the 'abc' directory and you do not want to accidentally
58 # delete your work on ABC..
61 ABCMKARGS
= # CC="$(CXX)" CXX="$(CXX)"
68 ifneq ($(wildcard Makefile.conf
),)
69 $(info $(subst $$--$$,$(newline
),$(shell sed
's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr
-d
'\n' | sed
's,\$$--\$$$$,,')))
73 ifeq ($(CONFIG
),clang
)
75 CXXFLAGS
+= -std
=c
++11 -Os
77 else ifeq ($(CONFIG
),gcc
)
79 CXXFLAGS
+= -std
=gnu
++0x
-Os
81 else ifeq ($(CONFIG
),gcc-4.6
)
83 CXXFLAGS
+= -std
=gnu
++0x
-Os
85 else ifeq ($(CONFIG
),emcc
)
87 CXXFLAGS
+= -std
=c
++11 -Os
-Wno-warn-absolute-paths
88 CXXFLAGS
:= $(filter-out -ggdb
,$(CXXFLAGS
))
91 else ifeq ($(CONFIG
),mxe
)
92 CXX
= /usr
/local
/src
/mxe
/usr
/bin
/i686-pc-mingw32-gcc
93 CXXFLAGS
+= -std
=gnu
++0x
-Os
-D_POSIX_SOURCE
94 CXXFLAGS
:= $(filter-out -fPIC
,$(CXXFLAGS
))
95 LDFLAGS
:= $(filter-out -rdynamic
,$(LDFLAGS
)) -s
96 LDLIBS
:= $(filter-out -lrt
,$(LDLIBS
))
97 ABCMKARGS
+= ARCHFLAGS
="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -x c++ -fpermissive -w"
98 ABCMKARGS
+= LIBS
="lib/x86/pthreadVC2.lib -s" READLINE
=0 CC
="$(CXX)" CXX
="$(CXX)"
101 else ifneq ($(CONFIG
),none
)
102 $(error Invalid CONFIG setting
'$(CONFIG)'. Valid values
: clang
, gcc
, gcc-4.6
, emcc
, none
)
105 ifeq ($(ENABLE_READLINE
),1)
106 CXXFLAGS
+= -DYOSYS_ENABLE_READLINE
113 ifeq ($(ENABLE_PLUGINS
),1)
114 CXXFLAGS
+= -DYOSYS_ENABLE_PLUGINS
$(shell pkg-config
--silence-errors
--cflags libffi
)
115 LDLIBS
+= $(shell pkg-config
--silence-errors
--libs libffi || echo
-lffi
) -ldl
118 ifeq ($(ENABLE_TCL
),1)
119 TCL_VERSION ?
= tcl8.5
120 TCL_INCLUDE ?
= /usr
/include/$(TCL_VERSION
)
121 CXXFLAGS
+= -I
$(TCL_INCLUDE
) -DYOSYS_ENABLE_TCL
122 LDLIBS
+= -l
$(TCL_VERSION
)
125 ifeq ($(ENABLE_GPROF
),1)
130 ifeq ($(ENABLE_ABC
),1)
131 CXXFLAGS
+= -DYOSYS_ENABLE_ABC
132 TARGETS
+= yosys-abc
$(EXE
)
135 ifeq ($(ENABLE_VERIFIC
),1)
136 VERIFIC_DIR ?
= /usr
/local
/src
/verific_lib_eval
137 VERIFIC_COMPONENTS ?
= verilog vhdl database util containers
138 CXXFLAGS
+= $(patsubst %,-I
$(VERIFIC_DIR
)/%,$(VERIFIC_COMPONENTS
)) -DYOSYS_ENABLE_VERIFIC
139 LDLIBS
+= $(patsubst %,$(VERIFIC_DIR
)/%/*-linux.a
,$(VERIFIC_COMPONENTS
))
142 ifeq ($(ENABLE_COVER
),1)
143 CXXFLAGS
+= -DYOSYS_ENABLE_COVER
149 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; }'))
150 P_SHOW
= [$(shell gawk
"BEGIN { N=$(words $(OBJS) yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
151 P
= @echo
"$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
161 OBJS
+= kernel
/driver.o kernel
/register.o kernel
/rtlil.o kernel
/log.o kernel
/calc.o kernel
/yosys.o
163 OBJS
+= libs
/bigint
/BigIntegerAlgorithms.o libs
/bigint
/BigInteger.o libs
/bigint
/BigIntegerUtils.o
164 OBJS
+= libs
/bigint
/BigUnsigned.o libs
/bigint
/BigUnsignedInABase.o
166 OBJS
+= libs
/sha1
/sha1.o
170 OBJS
+= libs
/subcircuit
/subcircuit.o
172 OBJS
+= libs
/ezsat
/ezsat.o
173 OBJS
+= libs
/ezsat
/ezminisat.o
175 OBJS
+= libs
/minisat
/Options.o
176 OBJS
+= libs
/minisat
/SimpSolver.o
177 OBJS
+= libs
/minisat
/Solver.o
178 OBJS
+= libs
/minisat
/System.o
180 include frontends
/*/Makefile.inc
181 include passes
/*/Makefile.inc
182 include backends
/*/Makefile.inc
183 include techlibs
/*/Makefile.inc
187 include frontends
/verilog
/Makefile.inc
188 include frontends
/ilang
/Makefile.inc
189 include frontends
/ast
/Makefile.inc
191 OBJS
+= passes
/hierarchy
/hierarchy.o
192 OBJS
+= passes
/cmds
/select.o
193 OBJS
+= passes
/cmds
/show.o
194 OBJS
+= passes
/cmds
/stat.o
195 OBJS
+= passes
/cmds
/cover.o
196 OBJS
+= passes
/cmds
/design.o
197 OBJS
+= passes
/cmds
/plugin.o
199 include passes
/proc
/Makefile.inc
200 include passes
/opt
/Makefile.inc
201 include passes
/techmap
/Makefile.inc
202 include passes
/abc
/Makefile.inc
204 include backends
/verilog
/Makefile.inc
205 include backends
/ilang
/Makefile.inc
207 include techlibs
/common
/Makefile.inc
211 top-all
: $(TARGETS
) $(EXTRA_TARGETS
)
213 @echo
" Build successful."
217 $(P
) $(CXX
) -o yosys
$(EXE
) $(LDFLAGS
) $(OBJS
) $(LDLIBS
)
220 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
223 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
225 kernel
/version_
$(GIT_REV
).
cc: Makefile
226 $(P
) rm -f kernel
/version_
*.o kernel
/version_
*.d kernel
/version_
*.
cc
227 $(Q
) echo
"namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) ` \
228 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1` $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))\"; }" > kernel
/version_
$(GIT_REV
).
cc
230 yosys-config
: misc
/yosys-config.in
231 $(P
) $(SED
) -e
's,@CXX@,$(CXX),;' -e
's,@CXXFLAGS@,$(CXXFLAGS),;' -e
's,@LDFLAGS@,$(LDFLAGS),;' -e
's,@LDLIBS@,$(LDLIBS),;' \
232 -e
's,@BINDIR@,$(DESTDIR)/bin,;' -e
's,@DATDIR@,$(DESTDIR)/share/yosys,;' < misc
/yosys-config.in
> yosys-config
233 $(Q
) chmod
+x yosys-config
235 abc
/abc-
$(ABCREV
)$(EXE
):
237 ifneq ($(ABCREV
),default
)
238 $(Q
) if
( cd abc
2> /dev
/null
&& hg identify
; ) | grep
-q
+; then \
239 echo
'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr
'A-Za-z' 'N-ZA-Mn-za-m'; false
; \
241 $(Q
) if
test "`cd abc 2> /dev/null && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
242 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; }; \
243 echo
"Pulling ABC from bitbucket.org:"; \
244 test -d abc || hg clone https
://bitbucket.org
/alanmi
/abc abc
; \
245 cd abc
&& hg pull
&& hg update
-r
$(ABCREV
); \
248 $(Q
) rm -f abc
/abc-
[0-9a-f
]*
249 $(Q
) cd abc
&& $(MAKE
) $(S
) $(ABCMKARGS
) PROG
="abc-$(ABCREV)$(EXE)" MSG_PREFIX
="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: "
251 ifeq ($(ABCREV
),default
)
252 .PHONY
: abc
/abc-
$(ABCREV
)$(EXE
)
255 yosys-abc
$(EXE
): abc
/abc-
$(ABCREV
)$(EXE
)
256 $(P
) cp abc
/abc-
$(ABCREV
)$(EXE
) yosys-abc
$(EXE
)
258 test: $(TARGETS
) $(EXTRA_TARGETS
)
259 +cd tests
/simple
&& bash run-test.sh
260 +cd tests
/hana
&& bash run-test.sh
261 +cd tests
/asicworld
&& bash run-test.sh
262 +cd tests
/realmath
&& bash run-test.sh
263 +cd tests
/share
&& bash run-test.sh
264 +cd tests
/fsm
&& bash run-test.sh
265 +cd tests
/techmap
&& bash run-test.sh
266 +cd tests
/memories
&& bash run-test.sh
267 +cd tests
/various
&& bash run-test.sh
268 +cd tests
/sat
&& bash run-test.sh
270 @echo
" Passed \"make test\"."
273 VALGRIND ?
= valgrind
--error-exitcode
=1 --leak-check
=full
--show-reachable
=yes
--errors-for-leak-kinds
=all
275 vgtest
: $(TARGETS
) $(EXTRA_TARGETS
)
276 $(VALGRIND
) .
/yosys
-p
'setattr -mod -unset top; hierarchy; proc; opt; memory -nomap; opt -fine; techmap; opt' $$( ls tests
/simple
/*.v | grep
-v repwhile.v
)
278 @echo
" Passed \"make vgtest\"."
281 vloghtb
: $(TARGETS
) $(EXTRA_TARGETS
)
282 +cd tests
/vloghtb
&& bash run-test.sh
284 @echo
" Passed \"make vloghtb\"."
287 install: $(TARGETS
) $(EXTRA_TARGETS
)
288 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/bin
289 $(INSTALL_SUDO
) install $(TARGETS
) $(DESTDIR
)/bin
/
290 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/share
/yosys
291 $(INSTALL_SUDO
) cp
-r share
/.
$(DESTDIR
)/share
/yosys
/.
293 manual
: $(TARGETS
) $(EXTRA_TARGETS
)
294 cd manual
&& bash appnotes.sh
295 cd manual
&& bash presentation.sh
296 cd manual
&& bash manual.sh
300 cd manual
&& bash
clean.sh
301 rm -f
$(OBJS
) $(GENFILES
) $(TARGETS
) $(EXTRA_TARGETS
) $(EXTRA_OBJS
)
302 rm -f kernel
/version_
*.o kernel
/version_
*.
cc abc
/abc-
[0-9a-f
]*
303 rm -f libs
/*/*.d frontends
/*/*.d passes
/*/*.d backends
/*/*.d kernel
/*.d techlibs
/*/*.d
307 rm -f yosys-abc
$(EXE
) abc
/abc-
[0-9a-f
]*
313 { for file in
$(basename $(OBJS
)); do \
314 for
prefix in
cc y l
; do if
[ -f
$${file}.
$${prefix} ]; then echo
$$file.
$${prefix}; fi
; done \
315 done
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
); } > qtcreator.files
316 { echo .
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
) -printf
'%h\n' |
sort -u
; } > qtcreator.includes
317 touch qtcreator.config qtcreator.creator
320 dist: $(TARGETS
) $(EXTRA_TARGETS
)
321 rm -rf yosys-win32-
{mxebin
,vcxsrc
}-$(YOSYS_VER
){,.zip
}
322 mkdir
-p yosys-win32-mxebin-
$(YOSYS_VER
)
323 cp
-r yosys.exe share
/ yosys-win32-mxebin-
$(YOSYS_VER
)/
324 ifeq ($(ENABLE_ABC
),1)
325 cp
-r yosys-abc.exe abc
/lib
/x86
/pthreadVC2.dll yosys-win32-mxebin-
$(YOSYS_VER
)/
327 echo
-en
'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
328 echo
-en
'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-
$(YOSYS_VER
)/readme.txt
329 sed
-e
's,^[^ ]*:,,; s, ,\n,g; s, *\\,,; s,/[^/]*/\.\./,/,g; s,'"$$PWD/"',,' \
330 $(addsuffix .d
,$(basename $(OBJS
))) |
sort -u | grep
'^[^/]' | grep
-v kernel
/version_
> srcfiles.txt
331 bash misc
/create_vcxsrc.sh yosys-win32-vcxsrc
$(YOSYS_VER
) $(GIT_REV
)
332 echo
"namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel
/version.
cc
333 zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/genfiles.zip
$(GENFILES
) kernel
/version.
cc
334 zip
-r yosys-win32-mxebin-
$(YOSYS_VER
).zip yosys-win32-mxebin-
$(YOSYS_VER
)/
335 zip
-r yosys-win32-vcxsrc-
$(YOSYS_VER
).zip yosys-win32-vcxsrc-
$(YOSYS_VER
)/
336 rm -f srcfiles.txt kernel
/version.
cc
343 echo
'CONFIG := clang' > Makefile.conf
346 echo
'CONFIG := gcc' > Makefile.conf
348 config-gcc-4.6
: clean
349 echo
'CONFIG := gcc-4.6' > Makefile.conf
352 echo
'CONFIG := emcc' > Makefile.conf
353 echo
'ENABLE_TCL := 0' >> Makefile.conf
354 echo
'ENABLE_ABC := 0' >> Makefile.conf
355 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
356 echo
'ENABLE_READLINE := 0' >> Makefile.conf
359 echo
'CONFIG := mxe' > Makefile.conf
360 echo
'ENABLE_TCL := 0' >> Makefile.conf
361 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
362 echo
'ENABLE_READLINE := 0' >> Makefile.conf
365 echo
'CONFIG := gcc' > Makefile.conf
366 echo
'ENABLE_GPROF := 1' >> Makefile.conf
369 echo
"INSTALL_SUDO := sudo" >> Makefile.conf
372 -include frontends
/*/*.d
373 -include passes
/*/*.d
374 -include backends
/*/*.d
376 -include techlibs
/*/*.d
378 .PHONY
: all top-all abc
test install install-abc manual
clean mrproper qtcreator
379 .PHONY
: config-clean config-clang config-gcc config-gcc-4.6 config-gprof config-sudo