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