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