Merge https://github.com/cliffordwolf/yosys
[yosys.git] / Makefile
1
2 CONFIG := clang
3 # CONFIG := gcc
4 # CONFIG := gcc-4.8
5 # CONFIG := emcc
6 # CONFIG := mxe
7 # CONFIG := msys2
8
9 # features (the more the better)
10 ENABLE_TCL := 1
11 ENABLE_ABC := 1
12 ENABLE_PLUGINS := 1
13 ENABLE_READLINE := 1
14 ENABLE_EDITLINE := 0
15 ENABLE_VERIFIC := 0
16 ENABLE_COVER := 1
17 ENABLE_LIBYOSYS := 0
18
19 # other configuration flags
20 ENABLE_GPROF := 0
21 ENABLE_DEBUG := 0
22 ENABLE_NDEBUG := 0
23 LINK_CURSES := 0
24 LINK_TERMCAP := 0
25
26 # clang sanitizers
27 SANITIZER =
28 # SANITIZER = address
29 # SANITIZER = memory
30 # SANITIZER = undefined
31 # SANITIZER = cfi
32
33
34 PREFIX ?= /usr/local
35 INSTALL_SUDO :=
36
37 BINDIR := $(PREFIX)/bin
38 LIBDIR := $(PREFIX)/lib
39 DATDIR := $(PREFIX)/share/yosys
40
41 EXE =
42 OBJS =
43 GENFILES =
44 EXTRA_OBJS =
45 EXTRA_TARGETS =
46 TARGETS = yosys$(EXE) yosys-config
47
48 PRETTY = 1
49 SMALL = 0
50
51 # Unit test
52 UNITESTPATH := tests/unit
53
54 all: top-all
55
56 YOSYS_SRC := $(dir $(firstword $(MAKEFILE_LIST)))
57 VPATH := $(YOSYS_SRC)
58
59 CXXFLAGS := $(CXXFLAGS) -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -D_YOSYS_ -fPIC -I$(PREFIX)/include
60 LDFLAGS := $(LDFLAGS) -L$(LIBDIR)
61 LDLIBS := $(LDLIBS) -lstdc++ -lm
62 PLUGIN_LDFLAGS :=
63
64 PKG_CONFIG ?= pkg-config
65 SED ?= sed
66 BISON ?= bison
67
68 ifeq (Darwin,$(findstring Darwin,$(shell uname)))
69 PLUGIN_LDFLAGS += -undefined dynamic_lookup
70
71 # homebrew search paths
72 ifneq ($(shell which brew),)
73 BREW_PREFIX := $(shell brew --prefix)/opt
74 CXXFLAGS += -I$(BREW_PREFIX)/readline/include
75 LDFLAGS += -L$(BREW_PREFIX)/readline/lib
76 PKG_CONFIG_PATH := $(BREW_PREFIX)/libffi/lib/pkgconfig:$(PKG_CONFIG_PATH)
77 PKG_CONFIG_PATH := $(BREW_PREFIX)/tcl-tk/lib/pkgconfig:$(PKG_CONFIG_PATH)
78 export PATH := $(BREW_PREFIX)/bison/bin:$(BREW_PREFIX)/gettext/bin:$(BREW_PREFIX)/flex/bin:$(PATH)
79
80 # macports search paths
81 else ifneq ($(shell which port),)
82 PORT_PREFIX := $(patsubst %/bin/port,%,$(shell which port))
83 CXXFLAGS += -I$(PORT_PREFIX)/include
84 LDFLAGS += -L$(PORT_PREFIX)/lib
85 PKG_CONFIG_PATH := $(PORT_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
86 export PATH := $(PORT_PREFIX)/bin:$(PATH)
87 endif
88
89 else
90 LDFLAGS += -rdynamic
91 LDLIBS += -lrt
92 endif
93
94 YOSYS_VER := 0.7+$(shell cd $(YOSYS_SRC) && test -e .git && { git log --author=clifford@clifford.at --oneline 61f6811.. | wc -l; })
95 GIT_REV := $(shell cd $(YOSYS_SRC) && git rev-parse --short HEAD 2> /dev/null || echo UNKNOWN)
96 OBJS = kernel/version_$(GIT_REV).o
97
98 # set 'ABCREV = default' to use abc/ as it is
99 #
100 # Note: If you do ABC development, make sure that 'abc' in this directory
101 # is just a symlink to your actual ABC working directory, as 'make mrproper'
102 # will remove the 'abc' directory and you do not want to accidentally
103 # delete your work on ABC..
104 ABCREV = f6838749f234
105 ABCPULL = 1
106 ABCURL ?= https://bitbucket.org/alanmi/abc
107 ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1
108
109 # set ABCEXTERNAL = <abc-command> to use an external ABC instance
110 # Note: The in-tree ABC (yosys-abc) will not be installed when ABCEXTERNAL is set.
111 ABCEXTERNAL ?=
112
113 define newline
114
115
116 endef
117
118 ifneq ($(wildcard Makefile.conf),)
119 $(info $(subst $$--$$,$(newline),$(shell sed 's,^,[Makefile.conf] ,; s,$$,$$--$$,;' < Makefile.conf | tr -d '\n' | sed 's,\$$--\$$$$,,')))
120 include Makefile.conf
121 endif
122
123 ifeq ($(CONFIG),clang)
124 CXX = clang
125 LD = clang++
126 CXXFLAGS += -std=c++11 -Os
127
128 ifneq ($(SANITIZER),)
129 $(info [Clang Sanitizer] $(SANITIZER))
130 CXXFLAGS += -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=$(SANITIZER)
131 LDFLAGS += -g -fsanitize=$(SANITIZER)
132 ifeq ($(SANITIZER),address)
133 ENABLE_COVER := 0
134 endif
135 ifeq ($(SANITIZER),memory)
136 CXXFLAGS += -fPIE -fsanitize-memory-track-origins
137 LDFLAGS += -fPIE -fsanitize-memory-track-origins
138 endif
139 ifeq ($(SANITIZER),cfi)
140 CXXFLAGS += -flto
141 LDFLAGS += -flto
142 endif
143 endif
144
145 else ifeq ($(CONFIG),gcc)
146 CXX = gcc
147 LD = gcc
148 CXXFLAGS += -std=c++11 -Os
149
150 else ifeq ($(CONFIG),gcc-4.8)
151 CXX = gcc-4.8
152 LD = gcc-4.8
153 CXXFLAGS += -std=c++11 -Os
154
155 else ifeq ($(CONFIG),emcc)
156 CXX = emcc
157 LD = emcc
158 CXXFLAGS := -std=c++11 $(filter-out -fPIC -ggdb,$(CXXFLAGS))
159 EMCCFLAGS := -Os -Wno-warn-absolute-paths
160 EMCCFLAGS += --memory-init-file 0 --embed-file share -s NO_EXIT_RUNTIME=1
161 EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt','_errmsg']"
162 EMCCFLAGS += -s TOTAL_MEMORY=128*1024*1024
163 # https://github.com/kripken/emscripten/blob/master/src/settings.js
164 CXXFLAGS += $(EMCCFLAGS)
165 LDFLAGS += $(EMCCFLAGS)
166 LDLIBS =
167 EXE = .js
168
169 TARGETS := $(filter-out yosys-config,$(TARGETS))
170 EXTRA_TARGETS += yosysjs-$(YOSYS_VER).zip
171
172 viz.js:
173 wget -O viz.js.part https://github.com/mdaines/viz.js/releases/download/0.0.3/viz.js
174 mv viz.js.part viz.js
175
176 yosysjs-$(YOSYS_VER).zip: yosys.js viz.js misc/yosysjs/*
177 rm -rf yosysjs-$(YOSYS_VER) yosysjs-$(YOSYS_VER).zip
178 mkdir -p yosysjs-$(YOSYS_VER)
179 cp viz.js misc/yosysjs/* yosys.js yosysjs-$(YOSYS_VER)/
180 zip -r yosysjs-$(YOSYS_VER).zip yosysjs-$(YOSYS_VER)
181
182 yosys.html: misc/yosys.html
183 $(P) cp misc/yosys.html yosys.html
184
185 else ifeq ($(CONFIG),mxe)
186 PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config
187 CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc
188 LD = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc
189 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_MXE_HACKS -Wno-attributes
190 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
191 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
192 LDLIBS := $(filter-out -lrt,$(LDLIBS))
193 ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
194 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE=1 CC="$(CXX)" CXX="$(CXX)"
195 EXE = .exe
196
197 else ifeq ($(CONFIG),msys2)
198 CXX = i686-w64-mingw32-gcc
199 LD = i686-w64-mingw32-gcc
200 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
201 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
202 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
203 LDLIBS := $(filter-out -lrt,$(LDLIBS))
204 ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
205 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE=0 CC="$(CXX)" CXX="$(CXX)"
206 EXE = .exe
207
208 else ifneq ($(CONFIG),none)
209 $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.8, emcc, mxe, msys2)
210 endif
211
212 ifeq ($(ENABLE_LIBYOSYS),1)
213 TARGETS += libyosys.so
214 endif
215
216 ifeq ($(ENABLE_READLINE),1)
217 CXXFLAGS += -DYOSYS_ENABLE_READLINE
218 LDLIBS += -lreadline
219 ifeq ($(LINK_CURSES),1)
220 LDLIBS += -lcurses
221 ABCMKARGS += "ABC_READLINE_LIBRARIES=-lcurses -lreadline"
222 endif
223 ifeq ($(LINK_TERMCAP),1)
224 LDLIBS += -ltermcap
225 ABCMKARGS += "ABC_READLINE_LIBRARIES=-lreadline -ltermcap"
226 endif
227 ifeq ($(CONFIG),mxe)
228 LDLIBS += -ltermcap
229 endif
230 else
231 ifeq ($(ENABLE_EDITLINE),1)
232 CXXFLAGS += -DYOSYS_ENABLE_EDITLINE
233 LDLIBS += -ledit -ltinfo -lbsd
234 endif
235 endif
236
237 ifeq ($(ENABLE_PLUGINS),1)
238 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS
239 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ldl
240 endif
241
242 ifeq ($(ENABLE_TCL),1)
243 TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')")
244 TCL_INCLUDE ?= /usr/include/$(TCL_VERSION)
245
246 ifeq ($(CONFIG),mxe)
247 CXXFLAGS += -DYOSYS_ENABLE_TCL
248 LDLIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32
249 else
250 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL
251 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION))
252 endif
253 endif
254
255 ifeq ($(ENABLE_GPROF),1)
256 CXXFLAGS += -pg
257 LDFLAGS += -pg
258 endif
259
260 ifeq ($(ENABLE_NDEBUG),1)
261 CXXFLAGS := -O3 -DNDEBUG $(filter-out -Os -ggdb,$(CXXFLAGS))
262 endif
263
264 ifeq ($(ENABLE_DEBUG),1)
265 ifeq ($(CONFIG),clang)
266 CXXFLAGS := -O0 $(filter-out -Os,$(CXXFLAGS))
267 else
268 CXXFLAGS := -Og $(filter-out -Os,$(CXXFLAGS))
269 endif
270 endif
271
272 ifeq ($(ENABLE_ABC),1)
273 CXXFLAGS += -DYOSYS_ENABLE_ABC
274 ifeq ($(ABCEXTERNAL),)
275 TARGETS += yosys-abc$(EXE)
276 endif
277 endif
278
279 ifeq ($(ENABLE_VERIFIC),1)
280 VERIFIC_DIR ?= /usr/local/src/verific_lib_eval
281 VERIFIC_COMPONENTS ?= verilog vhdl database util containers sdf
282 CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -DYOSYS_ENABLE_VERIFIC
283 LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS))
284 endif
285
286 ifeq ($(ENABLE_COVER),1)
287 CXXFLAGS += -DYOSYS_ENABLE_COVER
288 endif
289
290 define add_share_file
291 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
292 $(subst //,/,$(1)/$(notdir $(2))): $(2)
293 $$(P) mkdir -p $(1)
294 $$(Q) cp "$(YOSYS_SRC)"/$(2) $(subst //,/,$(1)/$(notdir $(2)))
295 endef
296
297 define add_gen_share_file
298 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
299 $(subst //,/,$(1)/$(notdir $(2))): $(2)
300 $$(P) mkdir -p $(1)
301 $$(Q) cp $(2) $(subst //,/,$(1)/$(notdir $(2)))
302 endef
303
304 define add_include_file
305 $(eval $(call add_share_file,$(dir share/include/$(1)),$(1)))
306 endef
307
308 ifeq ($(PRETTY), 1)
309 P_STATUS = 0
310 P_OFFSET = 0
311 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; }'))
312 P_SHOW = [$(shell gawk "BEGIN { N=$(words $(OBJS) yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
313 P = @echo "$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
314 Q = @
315 S = -s
316 else
317 P_SHOW = ->
318 P =
319 Q =
320 S =
321 endif
322
323 $(eval $(call add_include_file,kernel/yosys.h))
324 $(eval $(call add_include_file,kernel/hashlib.h))
325 $(eval $(call add_include_file,kernel/log.h))
326 $(eval $(call add_include_file,kernel/rtlil.h))
327 $(eval $(call add_include_file,kernel/register.h))
328 $(eval $(call add_include_file,kernel/celltypes.h))
329 $(eval $(call add_include_file,kernel/celledges.h))
330 $(eval $(call add_include_file,kernel/consteval.h))
331 $(eval $(call add_include_file,kernel/sigtools.h))
332 $(eval $(call add_include_file,kernel/modtools.h))
333 $(eval $(call add_include_file,kernel/macc.h))
334 $(eval $(call add_include_file,kernel/utils.h))
335 $(eval $(call add_include_file,kernel/satgen.h))
336 $(eval $(call add_include_file,libs/ezsat/ezsat.h))
337 $(eval $(call add_include_file,libs/ezsat/ezminisat.h))
338 $(eval $(call add_include_file,libs/sha1/sha1.h))
339 $(eval $(call add_include_file,passes/fsm/fsmdata.h))
340 $(eval $(call add_include_file,frontends/ast/ast.h))
341 $(eval $(call add_include_file,backends/ilang/ilang_backend.h))
342
343 OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/yosys.o
344 OBJS += kernel/cellaigs.o kernel/celledges.o
345
346 kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
347 kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"'
348
349 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
350 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
351
352 OBJS += libs/sha1/sha1.o
353
354 ifneq ($(SMALL),1)
355
356 OBJS += libs/subcircuit/subcircuit.o
357
358 OBJS += libs/ezsat/ezsat.o
359 OBJS += libs/ezsat/ezminisat.o
360
361 OBJS += libs/minisat/Options.o
362 OBJS += libs/minisat/SimpSolver.o
363 OBJS += libs/minisat/Solver.o
364 OBJS += libs/minisat/System.o
365
366 include $(YOSYS_SRC)/frontends/*/Makefile.inc
367 include $(YOSYS_SRC)/passes/*/Makefile.inc
368 include $(YOSYS_SRC)/backends/*/Makefile.inc
369 include $(YOSYS_SRC)/techlibs/*/Makefile.inc
370
371 else
372
373 include frontends/verilog/Makefile.inc
374 include frontends/ilang/Makefile.inc
375 include frontends/ast/Makefile.inc
376 include frontends/blif/Makefile.inc
377
378 OBJS += passes/hierarchy/hierarchy.o
379 OBJS += passes/cmds/select.o
380 OBJS += passes/cmds/show.o
381 OBJS += passes/cmds/stat.o
382 OBJS += passes/cmds/cover.o
383 OBJS += passes/cmds/design.o
384 OBJS += passes/cmds/plugin.o
385
386 include passes/proc/Makefile.inc
387 include passes/opt/Makefile.inc
388 include passes/techmap/Makefile.inc
389
390 include backends/verilog/Makefile.inc
391 include backends/ilang/Makefile.inc
392
393 include techlibs/common/Makefile.inc
394
395 endif
396
397 top-all: $(TARGETS) $(EXTRA_TARGETS)
398 @echo ""
399 @echo " Build successful."
400 @echo ""
401
402 ifeq ($(CONFIG),emcc)
403 yosys.js: $(filter-out yosysjs-$(YOSYS_VER).zip,$(EXTRA_TARGETS))
404 endif
405
406 yosys$(EXE): $(OBJS)
407 $(P) $(LD) -o yosys$(EXE) $(LDFLAGS) $(OBJS) $(LDLIBS)
408
409 libyosys.so: $(filter-out kernel/driver.o,$(OBJS))
410 $(P) $(LD) -o libyosys.so -shared -Wl,-soname,libyosys.so $(LDFLAGS) $^ $(LDLIBS)
411
412 %.o: %.cc
413 $(Q) mkdir -p $(dir $@)
414 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
415
416 %.o: %.cpp
417 $(Q) mkdir -p $(dir $@)
418 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
419
420 YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) $(shell \
421 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))
422
423 kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
424 $(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
425 $(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
426
427 yosys-config: misc/yosys-config.in
428 $(P) $(SED) -e 's#@CXXFLAGS@#$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(CXXFLAGS))#;' \
429 -e 's#@CXX@#$(CXX)#;' -e 's#@LDFLAGS@#$(LDFLAGS) $(PLUGIN_LDFLAGS)#;' -e 's#@LDLIBS@#$(LDLIBS)#;' \
430 -e 's#@BINDIR@#$(BINDIR)#;' -e 's#@DATDIR@#$(DATDIR)#;' < $< > yosys-config
431 $(Q) chmod +x yosys-config
432
433 abc/abc-$(ABCREV)$(EXE):
434 $(P)
435 ifneq ($(ABCREV),default)
436 $(Q) if ( cd abc 2> /dev/null && hg identify; ) | grep -q +; then \
437 echo 'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \
438 fi
439 $(Q) if test "`cd abc 2> /dev/null && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
440 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; }; \
441 echo "Pulling ABC from $(ABCURL):"; set -x; \
442 test -d abc || hg clone $(ABCURL) abc; \
443 cd abc && $(MAKE) DEP= clean && hg pull && hg update -r $(ABCREV); \
444 fi
445 endif
446 $(Q) rm -f abc/abc-[0-9a-f]*
447 $(Q) cd abc && $(MAKE) $(S) $(ABCMKARGS) PROG="abc-$(ABCREV)$(EXE)" MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: "
448
449 ifeq ($(ABCREV),default)
450 .PHONY: abc/abc-$(ABCREV)$(EXE)
451 endif
452
453 yosys-abc$(EXE): abc/abc-$(ABCREV)$(EXE)
454 $(P) cp abc/abc-$(ABCREV)$(EXE) yosys-abc$(EXE)
455
456 ifneq ($(SEED),)
457 SEEDOPT="-S $(SEED)"
458 else
459 SEEDOPT=""
460 endif
461
462 test: $(TARGETS) $(EXTRA_TARGETS)
463 +cd tests/simple && bash run-test.sh $(SEEDOPT)
464 +cd tests/hana && bash run-test.sh $(SEEDOPT)
465 +cd tests/asicworld && bash run-test.sh $(SEEDOPT)
466 +cd tests/realmath && bash run-test.sh $(SEEDOPT)
467 +cd tests/share && bash run-test.sh $(SEEDOPT)
468 +cd tests/fsm && bash run-test.sh $(SEEDOPT)
469 +cd tests/techmap && bash run-test.sh
470 +cd tests/memories && bash run-test.sh $(SEEDOPT)
471 +cd tests/bram && bash run-test.sh $(SEEDOPT)
472 +cd tests/various && bash run-test.sh
473 +cd tests/sat && bash run-test.sh
474 @echo ""
475 @echo " Passed \"make test\"."
476 @echo ""
477
478 VALGRIND ?= valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
479
480 vgtest: $(TARGETS) $(EXTRA_TARGETS)
481 $(VALGRIND) ./yosys -p 'setattr -mod -unset top; synth' $$( ls tests/simple/*.v | grep -v repwhile.v )
482 @echo ""
483 @echo " Passed \"make vgtest\"."
484 @echo ""
485
486 vloghtb: $(TARGETS) $(EXTRA_TARGETS)
487 +cd tests/vloghtb && bash run-test.sh
488 @echo ""
489 @echo " Passed \"make vloghtb\"."
490 @echo ""
491
492 # Unit test
493 unit-test: libyosys.so
494 @$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
495 CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
496
497 clean-unit-test:
498 @$(MAKE) -C $(UNITESTPATH) clean
499
500 install: $(TARGETS) $(EXTRA_TARGETS)
501 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(BINDIR)
502 $(INSTALL_SUDO) install $(TARGETS) $(DESTDIR)$(BINDIR)
503 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(DATDIR)
504 $(INSTALL_SUDO) cp -r share/. $(DESTDIR)$(DATDIR)/.
505 ifeq ($(ENABLE_LIBYOSYS),1)
506 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(LIBDIR)
507 $(INSTALL_SUDO) ldconfig
508 endif
509
510 uninstall:
511 $(INSTALL_SUDO) rm -vf $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(TARGETS)))
512 $(INSTALL_SUDO) rm -rvf $(DESTDIR)$(DATDIR)
513 ifeq ($(ENABLE_LIBYOSYS),1)
514 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.so
515 endif
516
517 update-manual: $(TARGETS) $(EXTRA_TARGETS)
518 cd manual && ../yosys -p 'help -write-tex-command-reference-manual'
519
520 manual: $(TARGETS) $(EXTRA_TARGETS)
521 cd manual && bash appnotes.sh
522 cd manual && bash presentation.sh
523 cd manual && bash manual.sh
524
525 clean:
526 rm -rf share
527 if test -d manual; then cd manual && sh clean.sh; fi
528 rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS)
529 rm -f kernel/version_*.o kernel/version_*.cc abc/abc-[0-9a-f]*
530 rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d
531 rm -rf tests/asicworld/*.out tests/asicworld/*.log
532 rm -rf tests/hana/*.out tests/hana/*.log
533 rm -rf tests/simple/*.out tests/simple/*.log
534 rm -rf tests/memories/*.out tests/memories/*.log tests/memories/*.dmp
535 rm -rf tests/sat/*.log tests/techmap/*.log tests/various/*.log
536 rm -rf tests/bram/temp tests/fsm/temp tests/realmath/temp tests/share/temp tests/smv/temp
537 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_*
538 rm -f tests/tools/cmp_tbdata
539
540 clean-abc:
541 $(MAKE) -C abc DEP= clean
542 rm -f yosys-abc$(EXE) abc/abc-[0-9a-f]*
543
544 mrproper: clean
545 git clean -xdf
546
547 qtcreator:
548 { for file in $(basename $(OBJS)); do \
549 for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
550 done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
551 { echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
552 touch qtcreator.config qtcreator.creator
553
554 vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
555 rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
556 set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
557 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
558 bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
559 echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
560 zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
561 zip -r yosys-win32-vcxsrc-$(YOSYS_VER).zip yosys-win32-vcxsrc-$(YOSYS_VER)/
562 rm -f srcfiles.txt kernel/version.cc
563
564 ifeq ($(CONFIG),mxe)
565 mxebin: $(TARGETS) $(EXTRA_TARGETS)
566 rm -rf yosys-win32-mxebin-$(YOSYS_VER){,.zip}
567 mkdir -p yosys-win32-mxebin-$(YOSYS_VER)
568 cp -r yosys.exe share/ yosys-win32-mxebin-$(YOSYS_VER)/
569 ifeq ($(ENABLE_ABC),1)
570 cp -r yosys-abc.exe abc/lib/x86/pthreadVC2.dll yosys-win32-mxebin-$(YOSYS_VER)/
571 endif
572 echo -en 'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
573 echo -en 'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
574 zip -r yosys-win32-mxebin-$(YOSYS_VER).zip yosys-win32-mxebin-$(YOSYS_VER)/
575 endif
576
577 config-clean: clean
578 rm -f Makefile.conf
579
580 config-clang: clean
581 echo 'CONFIG := clang' > Makefile.conf
582
583 config-gcc: clean
584 echo 'CONFIG := gcc' > Makefile.conf
585
586 config-gcc-4.8: clean
587 echo 'CONFIG := gcc-4.8' > Makefile.conf
588
589 config-emcc: clean
590 echo 'CONFIG := emcc' > Makefile.conf
591 echo 'ENABLE_TCL := 0' >> Makefile.conf
592 echo 'ENABLE_ABC := 0' >> Makefile.conf
593 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
594 echo 'ENABLE_READLINE := 0' >> Makefile.conf
595
596 config-mxe: clean
597 echo 'CONFIG := mxe' > Makefile.conf
598 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
599
600 config-msys2: clean
601 echo 'CONFIG := msys2' > Makefile.conf
602
603 config-gprof: clean
604 echo 'CONFIG := gcc' > Makefile.conf
605 echo 'ENABLE_GPROF := 1' >> Makefile.conf
606
607 config-sudo:
608 echo "INSTALL_SUDO := sudo" >> Makefile.conf
609
610 echo-yosys-ver:
611 @echo "$(YOSYS_VER)"
612
613 echo-git-rev:
614 @echo "$(GIT_REV)"
615
616 -include libs/*/*.d
617 -include frontends/*/*.d
618 -include passes/*/*.d
619 -include backends/*/*.d
620 -include kernel/*.d
621 -include techlibs/*/*.d
622
623 .PHONY: all top-all abc test install install-abc manual clean mrproper qtcreator
624 .PHONY: config-clean config-clang config-gcc config-gcc-4.8 config-gprof config-sudo
625