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