Added test cases for sat command
[yosys.git] / Makefile
1
2 CONFIG := clang-debug
3 # CONFIG := gcc-debug
4 # CONFIG := release
5
6 # features (the more the better)
7 ENABLE_TCL := 1
8 ENABLE_QT4 := 1
9 ENABLE_MINISAT := 1
10 ENABLE_ABC := 1
11
12 # other configuration flags
13 ENABLE_GPROF := 0
14
15 DESTDIR := /usr/local
16 INSTALL_SUDO :=
17
18 OBJS =
19 GENFILES =
20 EXTRA_TARGETS =
21 TARGETS = yosys yosys-config
22
23 all: top-all
24
25 CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -MD -D_YOSYS_ -fPIC
26 LDFLAGS = -rdynamic
27 LDLIBS = -lstdc++ -lreadline -lm -ldl -lrt
28 QMAKE = qmake-qt4
29
30 YOSYS_VER := 0.1.0+
31 GIT_REV := $(shell git rev-parse --short HEAD || echo UNKOWN)
32 OBJS = kernel/version_$(GIT_REV).o
33
34 # set 'ABCREV = default' to use abc/ as it is
35 #
36 # Note: If you do ABC development, make sure that 'abc' in this directory
37 # is just a symlink to your actual ABC working directory, as 'make mrproper'
38 # will remove the 'abc' directory and you do not want to accidentally
39 # delete your work on ABC..
40 ABCREV = e6b09e1
41 ABCPULL = 1
42
43 -include Makefile.conf
44
45 ifeq ($(CONFIG),clang-debug)
46 CXX = clang
47 CXXFLAGS += -std=c++11 -Os
48 endif
49
50 ifeq ($(CONFIG),gcc-debug)
51 CXX = gcc
52 CXXFLAGS += -std=gnu++0x -Os
53 endif
54
55 ifeq ($(CONFIG),release)
56 CXX = gcc
57 CXXFLAGS += -std=gnu++0x -march=native -O3 -DNDEBUG
58 endif
59
60 ifeq ($(ENABLE_TCL),1)
61 CXXFLAGS += -I/usr/include/tcl8.5 -DYOSYS_ENABLE_TCL
62 LDLIBS += -ltcl8.5
63 endif
64
65 ifeq ($(ENABLE_GPROF),1)
66 CXXFLAGS += -pg -fno-inline
67 LDFLAGS += -pg
68 endif
69
70 ifeq ($(ENABLE_QT4),1)
71 TARGETS += yosys-svgviewer
72 endif
73
74 ifeq ($(ENABLE_ABC),1)
75 TARGETS += yosys-abc
76 endif
77
78 OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o
79
80 OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
81 OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
82
83 OBJS += libs/sha1/sha1.o
84 OBJS += libs/subcircuit/subcircuit.o
85 OBJS += libs/ezsat/ezsat.o
86
87 ifeq ($(ENABLE_MINISAT),1)
88 CXXFLAGS += -DYOSYS_ENABLE_MINISAT
89 OBJS += libs/ezsat/ezminisat.o
90 LDLIBS += -lminisat
91 endif
92
93 include frontends/*/Makefile.inc
94 include passes/*/Makefile.inc
95 include backends/*/Makefile.inc
96 include techlibs/*/Makefile.inc
97
98 top-all: $(TARGETS) $(EXTRA_TARGETS)
99
100 yosys: $(OBJS)
101 $(CXX) -o yosys $(LDFLAGS) $(OBJS) $(LDLIBS)
102
103 kernel/version_$(GIT_REV).cc: Makefile
104 rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
105 echo "extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV))\";" > kernel/version_$(GIT_REV).cc
106
107 yosys-config: yosys-config.in
108 sed -e 's,@CXX@,$(CXX),;' -e 's,@CXXFLAGS@,$(CXXFLAGS),;' -e 's,@LDFLAGS@,$(LDFLAGS),;' -e 's,@LDLIBS@,$(LDLIBS),;' \
109 -e 's,@BINDIR@,$(DESTDIR)/bin,;' -e 's,@DATDIR@,$(DESTDIR)/share/yosys,;' < yosys-config.in > yosys-config
110 chmod +x yosys-config
111
112 yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp
113 cd libs/svgviewer && $(QMAKE) && make
114 cp libs/svgviewer/svgviewer yosys-svgviewer
115
116 abc/abc-$(ABCREV):
117 ifneq ($(ABCREV),default)
118 if test "`cd abc && hg identify | cut -f1 -d' '`" != "$(ABCREV)"; then \
119 test $(ABCPULL) -ne 0 || { echo; echo "!!! ABC not up to date and ABCPULL set to 0 in Makefile !!!"; echo; exit 1; }; \
120 test -d abc || hg clone https://bitbucket.org/alanmi/abc abc; \
121 cd abc && hg pull && hg update -r $(ABCREV); \
122 fi
123 endif
124 rm -f abc/abc-[0-9a-f]*
125 cd abc && $(MAKE) PROG="abc-$(ABCREV)" MSG_PREFIX="YOSYS-ABC: "
126
127 ifeq ($(ABCREV),default)
128 .PHONY: abc/abc-$(ABCREV)
129 endif
130
131 yosys-abc: abc/abc-$(ABCREV)
132 cp abc/abc-$(ABCREV) yosys-abc
133
134 test: yosys
135 cd tests/simple && bash run-test.sh
136 cd tests/hana && bash run-test.sh
137 cd tests/asicworld && bash run-test.sh
138 cd tests/sat && bash run-test.sh
139
140 install: $(TARGETS) $(EXTRA_TARGETS)
141 $(INSTALL_SUDO) mkdir -p $(DESTDIR)/bin
142 $(INSTALL_SUDO) install $(TARGETS) $(DESTDIR)/bin/
143 $(INSTALL_SUDO) mkdir -p $(DESTDIR)/share/yosys
144 $(INSTALL_SUDO) cp -r share/. $(DESTDIR)/share/yosys/.
145
146 manual:
147 cd manual && bash manual.sh
148
149 clean:
150 rm -rf share
151 rm -f $(OBJS) $(GENFILES) $(TARGETS)
152 rm -f kernel/version_*.o kernel/version_*.cc abc/abc-[0-9a-f]*
153 rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d
154 cd manual && rm -f *.aux *.bbl *.blg *.idx *.log *.out *.pdf *.toc *.ok
155 test ! -f libs/svgviewer/Makefile || make -C libs/svgviewer distclean
156
157 mrproper: clean
158 git clean -xdf
159
160 qtcreator:
161 { for file in $(basename $(OBJS)); do \
162 for prefix in cc y l; do if [ -f $${file}.$${prefix} ]; then echo $$file.$${prefix}; fi; done \
163 done; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \); } > qtcreator.files
164 { echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
165 touch qtcreator.config qtcreator.creator
166
167 config-clean: clean
168 rm -f Makefile.conf
169
170 config-clang-debug: clean
171 echo 'CONFIG := clang-debug' > Makefile.conf
172
173 config-gcc-debug: clean
174 echo 'CONFIG := gcc-debug' > Makefile.conf
175
176 config-release: clean
177 echo 'CONFIG := release' > Makefile.conf
178
179 config-gprof: clean
180 echo 'CONFIG := gcc-debug' > Makefile.conf
181 echo 'ENABLE_GPROF := 1' >> Makefile.conf
182
183 config-sudo:
184 echo "INSTALL_SUDO := sudo" >> Makefile.conf
185
186 -include libs/*/*.d
187 -include frontends/*/*.d
188 -include passes/*/*.d
189 -include backends/*/*.d
190 -include kernel/*.d
191
192 .PHONY: all top-all abc test install install-abc manual clean mrproper qtcreator
193 .PHONY: config-clean config-clang-debug config-gcc-debug config-release
194