Merge branch 'stv0g-master'
[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 += -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -D_YOSYS_ -fPIC -I$(PREFIX)/include
57 LDFLAGS += -L$(LIBDIR)
58 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 = a2fcd1cc61a6
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 CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc
180 LD = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc
181 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE
182 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
183 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
184 LDLIBS := $(filter-out -lrt,$(LDLIBS))
185 ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
186 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE=1 CC="$(CXX)" CXX="$(CXX)"
187 EXE = .exe
188
189 else ifeq ($(CONFIG),msys2)
190 CXX = i686-w64-mingw32-gcc
191 LD = i686-w64-mingw32-gcc
192 CXXFLAGS += -std=c++11 -Os -D_POSIX_SOURCE -DYOSYS_WIN32_UNIX_DIR
193 CXXFLAGS := $(filter-out -fPIC,$(CXXFLAGS))
194 LDFLAGS := $(filter-out -rdynamic,$(LDFLAGS)) -s
195 LDLIBS := $(filter-out -lrt,$(LDLIBS))
196 ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -fpermissive -w"
197 ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" ABC_USE_NO_READLINE=0 CC="$(CXX)" CXX="$(CXX)"
198 EXE = .exe
199
200 else ifneq ($(CONFIG),none)
201 $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.8, emcc, mxe, msys2)
202 endif
203
204 ifeq ($(ENABLE_LIBYOSYS),1)
205 TARGETS += libyosys.so
206 endif
207
208 ifeq ($(ENABLE_READLINE),1)
209 CXXFLAGS += -DYOSYS_ENABLE_READLINE
210 LDLIBS += -lreadline
211 ifeq ($(LINK_CURSES),1)
212 LDLIBS += -lcurses
213 ABCMKARGS += "ABC_READLINE_LIBRARIES=-lcurses -lreadline"
214 endif
215 ifeq ($(CONFIG),mxe)
216 LDLIBS += -lpdcurses
217 endif
218 endif
219
220 ifeq ($(ENABLE_PLUGINS),1)
221 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags libffi) -DYOSYS_ENABLE_PLUGINS
222 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libffi || echo -lffi) -ldl
223 endif
224
225 ifeq ($(ENABLE_TCL),1)
226 TCL_VERSION ?= tcl$(shell bash -c "tclsh <(echo 'puts [info tclversion]')")
227 TCL_INCLUDE ?= /usr/include/$(TCL_VERSION)
228
229 CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL
230 LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo -l$(TCL_VERSION))
231 endif
232
233 ifeq ($(ENABLE_GPROF),1)
234 CXXFLAGS += -pg
235 LDFLAGS += -pg
236 endif
237
238 ifeq ($(ENABLE_NDEBUG),1)
239 CXXFLAGS := -O3 -DNDEBUG $(filter-out -Os,$(CXXFLAGS))
240 endif
241
242 ifeq ($(ENABLE_ABC),1)
243 CXXFLAGS += -DYOSYS_ENABLE_ABC
244 ifeq ($(ABCEXTERNAL),)
245 TARGETS += yosys-abc$(EXE)
246 endif
247 endif
248
249 ifeq ($(ENABLE_VERIFIC),1)
250 VERIFIC_DIR ?= /usr/local/src/verific_lib_eval
251 VERIFIC_COMPONENTS ?= verilog vhdl database util containers sdf
252 CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -DYOSYS_ENABLE_VERIFIC
253 LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS))
254 endif
255
256 ifeq ($(ENABLE_COVER),1)
257 CXXFLAGS += -DYOSYS_ENABLE_COVER
258 endif
259
260 define add_share_file
261 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
262 $(subst //,/,$(1)/$(notdir $(2))): $(2)
263 $$(P) mkdir -p $(1)
264 $$(Q) cp "$(YOSYS_SRC)"/$(2) $(subst //,/,$(1)/$(notdir $(2)))
265 endef
266
267 define add_gen_share_file
268 EXTRA_TARGETS += $(subst //,/,$(1)/$(notdir $(2)))
269 $(subst //,/,$(1)/$(notdir $(2))): $(2)
270 $$(P) mkdir -p $(1)
271 $$(Q) cp $(2) $(subst //,/,$(1)/$(notdir $(2)))
272 endef
273
274 define add_include_file
275 $(eval $(call add_share_file,$(dir share/include/$(1)),$(1)))
276 endef
277
278 ifeq ($(PRETTY), 1)
279 P_STATUS = 0
280 P_OFFSET = 0
281 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; }'))
282 P_SHOW = [$(shell gawk "BEGIN { N=$(words $(OBJS) yosys$(EXE)); printf \"%3d\", $(P_OFFSET)+90*$(P_STATUS)/N; exit; }")%]
283 P = @echo "$(if $(findstring $@,$(TARGETS) $(EXTRA_TARGETS)),$(eval P_OFFSET = 10))$(call P_UPDATE)$(call P_SHOW) Building $@";
284 Q = @
285 S = -s
286 else
287 P_SHOW = ->
288 P =
289 Q =
290 S =
291 endif
292
293 $(eval $(call add_include_file,kernel/yosys.h))
294 $(eval $(call add_include_file,kernel/hashlib.h))
295 $(eval $(call add_include_file,kernel/log.h))
296 $(eval $(call add_include_file,kernel/rtlil.h))
297 $(eval $(call add_include_file,kernel/register.h))
298 $(eval $(call add_include_file,kernel/celltypes.h))
299 $(eval $(call add_include_file,kernel/celledges.h))
300 $(eval $(call add_include_file,kernel/consteval.h))
301 $(eval $(call add_include_file,kernel/sigtools.h))
302 $(eval $(call add_include_file,kernel/modtools.h))
303 $(eval $(call add_include_file,kernel/macc.h))
304 $(eval $(call add_include_file,kernel/utils.h))
305 $(eval $(call add_include_file,kernel/satgen.h))
306 $(eval $(call add_include_file,libs/ezsat/ezsat.h))
307 $(eval $(call add_include_file,libs/ezsat/ezminisat.h))
308 $(eval $(call add_include_file,libs/sha1/sha1.h))
309 $(eval $(call add_include_file,passes/fsm/fsmdata.h))
310 $(eval $(call add_include_file,frontends/ast/ast.h))
311 $(eval $(call add_include_file,backends/ilang/ilang_backend.h))
312
313 OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/yosys.o
314 OBJS += kernel/cellaigs.o kernel/celledges.o
315
316 kernel/log.o: CXXFLAGS += -DYOSYS_SRC='"$(YOSYS_SRC)"'
317 kernel/yosys.o: CXXFLAGS += -DYOSYS_DATDIR='"$(DATDIR)"'
318
319 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
320 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
321
322 OBJS += libs/sha1/sha1.o
323
324 ifneq ($(SMALL),1)
325
326 OBJS += libs/subcircuit/subcircuit.o
327
328 OBJS += libs/ezsat/ezsat.o
329 OBJS += libs/ezsat/ezminisat.o
330
331 OBJS += libs/minisat/Options.o
332 OBJS += libs/minisat/SimpSolver.o
333 OBJS += libs/minisat/Solver.o
334 OBJS += libs/minisat/System.o
335
336 include $(YOSYS_SRC)/frontends/*/Makefile.inc
337 include $(YOSYS_SRC)/passes/*/Makefile.inc
338 include $(YOSYS_SRC)/backends/*/Makefile.inc
339 include $(YOSYS_SRC)/techlibs/*/Makefile.inc
340
341 else
342
343 include frontends/verilog/Makefile.inc
344 include frontends/ilang/Makefile.inc
345 include frontends/ast/Makefile.inc
346 include frontends/blif/Makefile.inc
347
348 OBJS += passes/hierarchy/hierarchy.o
349 OBJS += passes/cmds/select.o
350 OBJS += passes/cmds/show.o
351 OBJS += passes/cmds/stat.o
352 OBJS += passes/cmds/cover.o
353 OBJS += passes/cmds/design.o
354 OBJS += passes/cmds/plugin.o
355
356 include passes/proc/Makefile.inc
357 include passes/opt/Makefile.inc
358 include passes/techmap/Makefile.inc
359
360 include backends/verilog/Makefile.inc
361 include backends/ilang/Makefile.inc
362
363 include techlibs/common/Makefile.inc
364
365 endif
366
367 top-all: $(TARGETS) $(EXTRA_TARGETS)
368 @echo ""
369 @echo " Build successful."
370 @echo ""
371
372 ifeq ($(CONFIG),emcc)
373 yosys.js: $(filter-out yosysjs-$(YOSYS_VER).zip,$(EXTRA_TARGETS))
374 endif
375
376 yosys$(EXE): $(OBJS)
377 $(P) $(LD) -o yosys$(EXE) $(LDFLAGS) $(OBJS) $(LDLIBS)
378
379 libyosys.so: $(filter-out kernel/driver.o,$(OBJS))
380 $(P) $(LD) -o libyosys.so -shared -Wl,-soname,libyosys.so $(LDFLAGS) $^ $(LDLIBS)
381
382 %.o: %.cc
383 $(Q) mkdir -p $(dir $@)
384 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
385
386 %.o: %.cpp
387 $(Q) mkdir -p $(dir $@)
388 $(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
389
390 YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) $(shell \
391 $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))
392
393 kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
394 $(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
395 $(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
396
397 yosys-config: misc/yosys-config.in
398 $(P) $(SED) -e 's#@CXXFLAGS@#$(subst -I. -I"$(YOSYS_SRC)",-I"$(DATDIR)/include",$(CXXFLAGS))#;' \
399 -e 's#@CXX@#$(CXX)#;' -e 's#@LDFLAGS@#$(LDFLAGS)#;' -e 's#@LDLIBS@#$(LDLIBS)#;' \
400 -e 's#@BINDIR@#$(BINDIR)#;' -e 's#@DATDIR@#$(DATDIR)#;' < $< > yosys-config
401 $(Q) chmod +x yosys-config
402
403 abc/abc-$(ABCREV)$(EXE):
404 $(P)
405 ifneq ($(ABCREV),default)
406 $(Q) if ( cd abc 2> /dev/null && hg identify; ) | grep -q +; then \
407 echo 'REEBE: NOP pbagnvaf ybpny zbqvsvpngvbaf! Frg NOPERI=qrsnhyg va Lbflf Znxrsvyr!' | tr 'A-Za-z' 'N-ZA-Mn-za-m'; false; \
408 fi
409 $(Q) if test "`cd abc 2> /dev/null && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
410 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; }; \
411 echo "Pulling ABC from $(ABCURL):"; set -x; \
412 test -d abc || hg clone $(ABCURL) abc; \
413 cd abc && $(MAKE) DEP= clean && hg pull && hg update -r $(ABCREV); \
414 fi
415 endif
416 $(Q) rm -f abc/abc-[0-9a-f]*
417 $(Q) cd abc && $(MAKE) $(S) $(ABCMKARGS) PROG="abc-$(ABCREV)$(EXE)" MSG_PREFIX="$(eval P_OFFSET = 5)$(call P_SHOW)$(eval P_OFFSET = 10) ABC: "
418
419 ifeq ($(ABCREV),default)
420 .PHONY: abc/abc-$(ABCREV)$(EXE)
421 endif
422
423 yosys-abc$(EXE): abc/abc-$(ABCREV)$(EXE)
424 $(P) cp abc/abc-$(ABCREV)$(EXE) yosys-abc$(EXE)
425
426 ifneq ($(SEED),)
427 SEEDOPT="-S $(SEED)"
428 else
429 SEEDOPT=""
430 endif
431
432 test: $(TARGETS) $(EXTRA_TARGETS)
433 +cd tests/simple && bash run-test.sh $(SEEDOPT)
434 +cd tests/hana && bash run-test.sh $(SEEDOPT)
435 +cd tests/asicworld && bash run-test.sh $(SEEDOPT)
436 +cd tests/realmath && bash run-test.sh $(SEEDOPT)
437 +cd tests/share && bash run-test.sh $(SEEDOPT)
438 +cd tests/fsm && bash run-test.sh $(SEEDOPT)
439 +cd tests/techmap && bash run-test.sh
440 +cd tests/memories && bash run-test.sh $(SEEDOPT)
441 +cd tests/bram && bash run-test.sh $(SEEDOPT)
442 +cd tests/various && bash run-test.sh
443 +cd tests/sat && bash run-test.sh
444 @echo ""
445 @echo " Passed \"make test\"."
446 @echo ""
447
448 VALGRIND ?= valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
449
450 vgtest: $(TARGETS) $(EXTRA_TARGETS)
451 $(VALGRIND) ./yosys -p 'setattr -mod -unset top; synth' $$( ls tests/simple/*.v | grep -v repwhile.v )
452 @echo ""
453 @echo " Passed \"make vgtest\"."
454 @echo ""
455
456 vloghtb: $(TARGETS) $(EXTRA_TARGETS)
457 +cd tests/vloghtb && bash run-test.sh
458 @echo ""
459 @echo " Passed \"make vloghtb\"."
460 @echo ""
461
462 # Unit test
463 unit-test: libyosys.so
464 @$(MAKE) -C $(UNITESTPATH) CXX="$(CXX)" CPPFLAGS="$(CPPFLAGS)" \
465 CXXFLAGS="$(CXXFLAGS)" LDLIBS="$(LDLIBS)" ROOTPATH="$(CURDIR)"
466
467 clean-unit-test:
468 @$(MAKE) -C $(UNITESTPATH) clean
469
470 install: $(TARGETS) $(EXTRA_TARGETS)
471 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(BINDIR)
472 $(INSTALL_SUDO) install $(TARGETS) $(DESTDIR)$(BINDIR)
473 $(INSTALL_SUDO) mkdir -p $(DESTDIR)$(DATDIR)
474 $(INSTALL_SUDO) cp -r share/. $(DESTDIR)$(DATDIR)/.
475 ifeq ($(ENABLE_LIBYOSYS),1)
476 $(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(LIBDIR)
477 $(INSTALL_SUDO) ldconfig
478 endif
479
480 uninstall:
481 $(INSTALL_SUDO) rm -vf $(addprefix $(DESTDIR)$(BINDIR),$(notdir $(TARGETS)))
482 $(INSTALL_SUDO) rm -rvf $(DESTDIR)$(DATDIR)
483 ifeq ($(ENABLE_LIBYOSYS),1)
484 $(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.so
485 endif
486
487 update-manual: $(TARGETS) $(EXTRA_TARGETS)
488 cd manual && ../yosys -p 'help -write-tex-command-reference-manual'
489
490 manual: $(TARGETS) $(EXTRA_TARGETS)
491 cd manual && bash appnotes.sh
492 cd manual && bash presentation.sh
493 cd manual && bash manual.sh
494
495 clean:
496 rm -rf share
497 if test -d manual; then cd manual && sh clean.sh; fi
498 rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS)
499 rm -f kernel/version_*.o kernel/version_*.cc abc/abc-[0-9a-f]*
500 rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d
501
502 clean-abc:
503 $(MAKE) -C abc DEP= clean
504 rm -f yosys-abc$(EXE) abc/abc-[0-9a-f]*
505
506 mrproper: clean
507 git clean -xdf
508
509 qtcreator:
510 { for file in $(basename $(OBJS)); do \
511 for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
512 done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
513 { echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
514 touch qtcreator.config qtcreator.creator
515
516 vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
517 rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
518 set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
519 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
520 bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
521 echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
522 zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
523 zip -r yosys-win32-vcxsrc-$(YOSYS_VER).zip yosys-win32-vcxsrc-$(YOSYS_VER)/
524 rm -f srcfiles.txt kernel/version.cc
525
526 ifeq ($(CONFIG),mxe)
527 mxebin: $(TARGETS) $(EXTRA_TARGETS)
528 rm -rf yosys-win32-mxebin-$(YOSYS_VER){,.zip}
529 mkdir -p yosys-win32-mxebin-$(YOSYS_VER)
530 cp -r yosys.exe share/ yosys-win32-mxebin-$(YOSYS_VER)/
531 ifeq ($(ENABLE_ABC),1)
532 cp -r yosys-abc.exe abc/lib/x86/pthreadVC2.dll yosys-win32-mxebin-$(YOSYS_VER)/
533 endif
534 echo -en 'This is Yosys $(YOSYS_VER) for Win32.\r\n' > yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
535 echo -en 'Documentation at http://www.clifford.at/yosys/.\r\n' >> yosys-win32-mxebin-$(YOSYS_VER)/readme.txt
536 zip -r yosys-win32-mxebin-$(YOSYS_VER).zip yosys-win32-mxebin-$(YOSYS_VER)/
537 endif
538
539 config-clean: clean
540 rm -f Makefile.conf
541
542 config-clang: clean
543 echo 'CONFIG := clang' > Makefile.conf
544
545 config-gcc: clean
546 echo 'CONFIG := gcc' > Makefile.conf
547
548 config-gcc-4.8: clean
549 echo 'CONFIG := gcc-4.8' > Makefile.conf
550
551 config-emcc: clean
552 echo 'CONFIG := emcc' > Makefile.conf
553 echo 'ENABLE_TCL := 0' >> Makefile.conf
554 echo 'ENABLE_ABC := 0' >> Makefile.conf
555 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
556 echo 'ENABLE_READLINE := 0' >> Makefile.conf
557
558 config-mxe: clean
559 echo 'CONFIG := mxe' > Makefile.conf
560 echo 'ENABLE_TCL := 0' >> Makefile.conf
561 echo 'ENABLE_PLUGINS := 0' >> Makefile.conf
562 echo 'ENABLE_READLINE := 0' >> Makefile.conf
563
564 config-msys2: clean
565 echo 'CONFIG := msys2' > Makefile.conf
566
567 config-gprof: clean
568 echo 'CONFIG := gcc' > Makefile.conf
569 echo 'ENABLE_GPROF := 1' >> Makefile.conf
570
571 config-sudo:
572 echo "INSTALL_SUDO := sudo" >> Makefile.conf
573
574 echo-yosys-ver:
575 @echo "$(YOSYS_VER)"
576
577 echo-git-rev:
578 @echo "$(GIT_REV)"
579
580 -include libs/*/*.d
581 -include frontends/*/*.d
582 -include passes/*/*.d
583 -include backends/*/*.d
584 -include kernel/*.d
585 -include techlibs/*/*.d
586
587 .PHONY: all top-all abc test install install-abc manual clean mrproper qtcreator
588 .PHONY: config-clean config-clang config-gcc config-gcc-4.8 config-gprof config-sudo
589