7 # features (the more the better)
15 # other configuration flags
24 TARGETS
= yosys yosys-config
31 CXXFLAGS
= -Wall
-Wextra
-ggdb
-I
"$(shell pwd)" -MD
-DYOSYS_SRC
='"$(shell pwd)"' -D_YOSYS_
-fPIC
-I
${DESTDIR}/include
32 LDFLAGS
= -L
${DESTDIR}/lib
37 ifeq (Darwin
,$(findstring Darwin
,$(shell uname
)))
38 # add macports include and library path to search directories, don't use '-rdynamic' and '-lrt':
39 CXXFLAGS
+= -I
/opt
/local
/include
40 LDFLAGS
+= -L
/opt
/local
/lib
49 GIT_REV
:= $(shell git rev-parse
--short HEAD
2> /dev
/null || echo UNKOWN
)
50 OBJS
= kernel
/version_
$(GIT_REV
).o
52 # set 'ABCREV = default' to use abc/ as it is
54 # Note: If you do ABC development, make sure that 'abc' in this directory
55 # is just a symlink to your actual ABC working directory, as 'make mrproper'
56 # will remove the 'abc' directory and you do not want to accidentally
57 # delete your work on ABC..
66 ifneq ($(wildcard Makefile.conf
),)
67 $(info $(subst $$--$$,$(newline
),$(shell sed
's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr
-d
'\n' | sed
's,\$$--\$$$$,,')))
71 ifeq ($(CONFIG
),clang
)
73 CXXFLAGS
+= -std
=c
++11 -Os
75 else ifeq ($(CONFIG
),gcc
)
77 CXXFLAGS
+= -std
=gnu
++0x
-Os
79 else ifeq ($(CONFIG
),gcc-4.6
)
81 CXXFLAGS
+= -std
=gnu
++0x
-Os
83 else ifeq ($(CONFIG
),emcc
)
85 CXXFLAGS
+= -std
=c
++11 -Os
-Wno-warn-absolute-paths
86 CXXFLAGS
:= $(filter-out -ggdb
,$(CXXFLAGS
))
88 else ifneq ($(CONFIG
),none
)
89 $(error Invalid CONFIG setting
'$(CONFIG)'. Valid values
: clang
, gcc
, gcc-4.6
, emcc
, none
)
92 ifeq ($(ENABLE_READLINE
),1)
93 CXXFLAGS
+= -DYOSYS_ENABLE_READLINE
97 ifeq ($(ENABLE_PLUGINS
),1)
98 CXXFLAGS
+= -DYOSYS_ENABLE_PLUGINS
102 ifeq ($(ENABLE_TCL
),1)
103 TCL_VERSION ?
= tcl8.5
104 TCL_INCLUDE ?
= /usr
/include/$(TCL_VERSION
)
105 CXXFLAGS
+= -I
$(TCL_INCLUDE
) -DYOSYS_ENABLE_TCL
106 LDLIBS
+= -l
$(TCL_VERSION
)
109 ifeq ($(ENABLE_GPROF
),1)
114 ifeq ($(ENABLE_QT4
),1)
115 TARGETS
+= yosys-svgviewer
118 ifeq ($(ENABLE_ABC
),1)
122 ifeq ($(ENABLE_VERIFIC
),1)
123 VERIFIC_DIR ?
= /usr
/local
/src
/verific_lib_eval
124 VERIFIC_COMPONENTS ?
= verilog vhdl database util containers
125 CXXFLAGS
+= $(patsubst %,-I
$(VERIFIC_DIR
)/%,$(VERIFIC_COMPONENTS
)) -DYOSYS_ENABLE_VERIFIC
126 LDLIBS
+= $(patsubst %,$(VERIFIC_DIR
)/%/*-linux.a
,$(VERIFIC_COMPONENTS
))
132 P_UPDATE
= $(eval P_STATUS
=$(shell echo
$(OBJS
) yosys | gawk
'BEGIN { RS = " "; I = $(P_STATUS)+0; } $$1 == "$@" && NR > I { I = NR; } END { print I; }'))
133 P_SHOW
= [$(shell gawk
"BEGIN { N=$(words $(OBJS) yosys); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
134 P
= @echo
"$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
144 OBJS
+= kernel
/driver.o kernel
/register.o kernel
/rtlil.o kernel
/log.o kernel
/calc.o kernel
/yosys.o
146 OBJS
+= libs
/bigint
/BigIntegerAlgorithms.o libs
/bigint
/BigInteger.o libs
/bigint
/BigIntegerUtils.o
147 OBJS
+= libs
/bigint
/BigUnsigned.o libs
/bigint
/BigUnsignedInABase.o
149 OBJS
+= libs
/sha1
/sha1.o
153 OBJS
+= libs
/subcircuit
/subcircuit.o
155 OBJS
+= libs
/ezsat
/ezsat.o
156 OBJS
+= libs
/ezsat
/ezminisat.o
158 OBJS
+= libs
/minisat
/Options.o
159 OBJS
+= libs
/minisat
/SimpSolver.o
160 OBJS
+= libs
/minisat
/Solver.o
161 OBJS
+= libs
/minisat
/System.o
163 include frontends
/*/Makefile.inc
164 include passes
/*/Makefile.inc
165 include backends
/*/Makefile.inc
166 include techlibs
/*/Makefile.inc
170 include frontends
/verilog
/Makefile.inc
171 include frontends
/ilang
/Makefile.inc
172 include frontends
/ast
/Makefile.inc
174 OBJS
+= passes
/hierarchy
/hierarchy.o
175 OBJS
+= passes
/cmds
/select.o
176 OBJS
+= passes
/cmds
/show.o
177 OBJS
+= passes
/cmds
/stat.o
178 OBJS
+= passes
/cmds
/cover.o
179 OBJS
+= passes
/cmds
/design.o
180 OBJS
+= passes
/cmds
/plugin.o
182 include passes
/proc
/Makefile.inc
183 include passes
/opt
/Makefile.inc
184 include passes
/techmap
/Makefile.inc
185 include passes
/abc
/Makefile.inc
187 include backends
/verilog
/Makefile.inc
188 include backends
/ilang
/Makefile.inc
190 include techlibs
/common
/Makefile.inc
194 top-all
: $(TARGETS
) $(EXTRA_TARGETS
)
196 @echo
" Build successful."
200 $(P
) $(CXX
) -o yosys
$(LDFLAGS
) $(OBJS
) $(LDLIBS
)
203 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
206 $(P
) $(CXX
) -o
$@
-c
$(CXXFLAGS
) $<
208 kernel
/version_
$(GIT_REV
).
cc: Makefile
209 $(P
) rm -f kernel
/version_
*.o kernel
/version_
*.d kernel
/version_
*.
cc
210 $(Q
) echo
"extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(CXX) ` \
211 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1` $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))\";" > kernel
/version_
$(GIT_REV
).
cc
213 yosys-config
: yosys-config.in
214 $(P
) $(SED
) -e
's,@CXX@,$(CXX),;' -e
's,@CXXFLAGS@,$(CXXFLAGS),;' -e
's,@LDFLAGS@,$(LDFLAGS),;' -e
's,@LDLIBS@,$(LDLIBS),;' \
215 -e
's,@BINDIR@,$(DESTDIR)/bin,;' -e
's,@DATDIR@,$(DESTDIR)/share/yosys,;' < yosys-config.in
> yosys-config
216 $(Q
) chmod
+x yosys-config
218 yosys-svgviewer
: libs
/svgviewer
/*.h libs
/svgviewer
/*.
cpp
219 $(P
) cd libs
/svgviewer
&& $(QMAKE
) && $(MAKE
) $(S
)
220 $(Q
) cp
`find libs/svgviewer -name svgviewer -type f` yosys-svgviewer
224 ifneq ($(ABCREV
),default
)
225 $(Q
) if
( cd abc
2> /dev
/null
&& hg identify
; ) | grep
-q
+; then \
226 echo
'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr
'A-Za-z' 'N-ZA-Mn-za-m'; false
; \
228 $(Q
) if
test "`cd abc 2> /dev/null && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
229 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; }; \
230 echo
"Pulling ABC from bitbucket.org:"; \
231 test -d abc || hg clone https
://bitbucket.org
/alanmi
/abc abc
; \
232 cd abc
&& hg pull
&& hg update
-r
$(ABCREV
); \
235 $(Q
) rm -f abc
/abc-
[0-9a-f
]*
236 $(Q
) cd abc
&& $(MAKE
) $(S
) PROG
="abc-$(ABCREV)" MSG_PREFIX
="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: "
238 ifeq ($(ABCREV
),default
)
239 .PHONY
: abc
/abc-
$(ABCREV
)
242 yosys-abc
: abc
/abc-
$(ABCREV
)
243 $(P
) cp abc
/abc-
$(ABCREV
) yosys-abc
245 test: $(TARGETS
) $(EXTRA_TARGETS
)
246 +cd tests
/simple
&& bash run-test.sh
247 +cd tests
/hana
&& bash run-test.sh
248 +cd tests
/asicworld
&& bash run-test.sh
249 +cd tests
/realmath
&& bash run-test.sh
250 +cd tests
/share
&& bash run-test.sh
251 +cd tests
/fsm
&& bash run-test.sh
252 +cd tests
/techmap
&& bash run-test.sh
253 +cd tests
/memories
&& bash run-test.sh
254 +cd tests
/various
&& bash run-test.sh
255 +cd tests
/sat
&& bash run-test.sh
257 @echo
" Passed \"make test\"."
260 VALGRIND ?
= valgrind
--error-exitcode
=1 --leak-check
=full
--show-reachable
=yes
--errors-for-leak-kinds
=all
262 vgtest
: $(TARGETS
) $(EXTRA_TARGETS
)
263 $(VALGRIND
) .
/yosys
-p
'setattr -mod -unset top; hierarchy; proc; opt; memory -nomap; opt -fine; techmap; opt' $$( ls tests
/simple
/*.v | grep
-v repwhile.v
)
265 @echo
" Passed \"make vgtest\"."
268 vloghtb
: $(TARGETS
) $(EXTRA_TARGETS
)
269 +cd tests
/vloghtb
&& bash run-test.sh
271 @echo
" Passed \"make vloghtb\"."
274 install: $(TARGETS
) $(EXTRA_TARGETS
)
275 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/bin
276 $(INSTALL_SUDO
) install $(TARGETS
) $(DESTDIR
)/bin
/
277 $(INSTALL_SUDO
) mkdir
-p
$(DESTDIR
)/share
/yosys
278 $(INSTALL_SUDO
) cp
-r share
/.
$(DESTDIR
)/share
/yosys
/.
280 manual
: $(TARGETS
) $(EXTRA_TARGETS
)
281 cd manual
&& bash appnotes.sh
282 cd manual
&& bash presentation.sh
283 cd manual
&& bash manual.sh
287 cd manual
&& bash
clean.sh
288 rm -f
$(OBJS
) $(GENFILES
) $(TARGETS
) $(EXTRA_TARGETS
)
289 rm -f kernel
/version_
*.o kernel
/version_
*.
cc abc
/abc-
[0-9a-f
]*
290 rm -f libs
/*/*.d frontends
/*/*.d passes
/*/*.d backends
/*/*.d kernel
/*.d techlibs
/*/*.d
291 test ! -f libs
/svgviewer
/Makefile || make
-C libs
/svgviewer
distclean
295 rm -f yosys-abc abc
/abc-
[0-9a-f
]*
301 { for file in
$(basename $(OBJS
)); do \
302 for
prefix in
cc y l
; do if
[ -f
$${file}.
$${prefix} ]; then echo
$$file.
$${prefix}; fi
; done \
303 done
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
); } > qtcreator.files
304 { echo .
; find backends frontends kernel libs passes
-type f \
( -name
'*.h' -o
-name
'*.hh' \
) -printf
'%h\n' |
sort -u
; } > qtcreator.includes
305 touch qtcreator.config qtcreator.creator
311 echo
'CONFIG := clang' > Makefile.conf
314 echo
'CONFIG := gcc' > Makefile.conf
316 config-gcc-4.6
: clean
317 echo
'CONFIG := gcc-4.6' > Makefile.conf
320 echo
'CONFIG := emcc' > Makefile.conf
321 echo
'ENABLE_TCL := 0' >> Makefile.conf
322 echo
'ENABLE_QT4 := 0' >> Makefile.conf
323 echo
'ENABLE_ABC := 0' >> Makefile.conf
324 echo
'ENABLE_PLUGINS := 0' >> Makefile.conf
325 echo
'ENABLE_READLINE := 0' >> Makefile.conf
328 echo
'CONFIG := gcc' > Makefile.conf
329 echo
'ENABLE_GPROF := 1' >> Makefile.conf
332 echo
"INSTALL_SUDO := sudo" >> Makefile.conf
335 -include frontends
/*/*.d
336 -include passes
/*/*.d
337 -include backends
/*/*.d
339 -include techlibs
/*/*.d
341 .PHONY
: all top-all abc
test install install-abc manual
clean mrproper qtcreator
342 .PHONY
: config-clean config-clang config-gcc config-gcc-4.6 config-gprof config-sudo