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