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