Adding support for reading wrong assumptions
[satlib.git] / lingeling / code / configure.sh
1 #!/bin/sh
2
3 check=undefined
4 chksol=undefined
5 coverage=undefined
6 debug=no
7 log=undefined
8 lto=no
9 olevel=none
10 other=none
11 picosat=no
12 druplig=no
13 profile=undefined
14 static=no
15 aiger=undefined
16 double=no
17 yalsat=undefined
18
19 ##########################################################################
20
21 die () {
22   echo "*** configure.sh: $*" 1>&2
23   exit 1
24 }
25
26 ##########################################################################
27
28 while [ $# -gt 0 ]
29 do
30   case $1 in
31     -h|--help) 
32        echo "usage: configure.sh [<option> ...]"
33        echo
34        echo "where <option> is one of the following"
35        echo
36        echo "-h | --help"
37        echo "-g | --debug    include debugging code and symbols"
38        echo "-l | --log      include logging code (default with '-g')"
39        echo "-c | --check    include checking code (default with '-g')"
40        echo "-p | --profile  compile with '-pg' for profiling"
41        echo "--coverage      compile with coverage options"
42        echo "--no-check      no checking code (overwrite default for '-g')"
43        echo "--chksol        always check solution (default for '-c')"
44        echo "--no-chksol     do not check solution"
45        echo "--softfloats    use software floats"
46        echo "--double        use hardware floats (of 'double' type)"
47        echo "--no-log        no logging code (overwrite default for '-g')"
48        echo "-O[0-4]         set optimization level unless '-g' specified"
49        echo "-flto           enable link time optimization"
50        echo "--picosat       add checking code depending on PicoSAT"
51        echo "--druplig       add checking code depending on Druplig"
52        echo "-f...|-m...     add other compiler options"
53        echo "--aiger=<dir>   specify AIGER directory (default '../aiger')"
54        echo "--no-aiger      no targets requiring AIGER library"
55        echo "--yalsat=<dir>  specify YalSAT directory (default '../yalsat')"
56        echo "--no-yalsat     do not include YalSAT code"
57        exit 0
58        ;;
59     -g|--debug) debug=yes;;
60     -l|--log) log=yes;;
61     -c|--check) check=yes;;
62     --chksol) chksol=yes;;
63     --no-chksol|--nchksol) chksol=no;;
64     --no-check) check=no;;
65     --no-log) log=no;;
66     -p|--profile) profile=yes;;
67     --softfloats) double=no;;
68     --double) double=yes;;
69     --coverage) coverage=yes;;
70     --picosat) picosat=yes;;
71     --druplig) druplig=yes;;
72     -O) debug=no;;
73     -O0|-O1|-O2|-O3|-O4) olevel=$1;;
74     -lto|-flto|--lto|--flto) lto=yes;;
75     -static) static=yes;;
76     --aiger=*) aiger=`echo "$1"|sed -e 's,^--aiger=,,' `;;
77     --no-aiger) aiger=no;;
78     --yalsat=*) yalsat=`echo "$1"|sed -e 's,^--yalsat=,,' `;;
79     --no-yalsat) yalsat=no;;
80     -f*|-m*) if [ $other = none ]; then other=$1; else other="$other $1"; fi;;
81     *) echo "*** configure.sh: invalid command line option '$1'"; exit 1;;
82   esac
83   shift
84 done
85
86 ##########################################################################
87
88 if [ x"$aiger" = xundefined ]
89 then
90   if [ -d ../aiger ]
91   then
92     aiger="../aiger"
93   fi
94 fi
95
96 if [ x"$aiger" = xundefined ]
97 then
98   aiger=no
99 elif [ ! x"$aiger" = xno ]
100 then
101   if [ ! -d "$aiger" ]
102   then
103     die "'$aiger' not a directory (use '--aiger' or '--no-aiger')"
104   elif [ ! -f "$aiger/aiger.h" ]
105   then
106     die "can not find '$aiger/aiger.h'"
107   elif [ ! -f "$aiger/aiger.o" ]
108   then
109     die "can not find '$aiger/aiger.o'"
110   fi
111 fi
112
113 ##########################################################################
114
115 if [ x"$yalsat" = xundefined ]
116 then
117   if [ -d ../yalsat ]
118   then
119     yalsat="../yalsat"
120     echo "using $yalsat"
121   fi
122 fi
123
124 if [ x"$yalsat" = xundefined ]
125 then
126   yalsat=no
127 elif [ ! x"$yalsat" = xno ]
128 then
129   if [ ! -d "$yalsat" ]
130   then
131     die "'$yalsat' not a directory (use '--yalsat' or '--no-yalsat')"
132   elif [ ! -f "$yalsat/yals.h" ]
133   then
134     die "can not find '$yalssat/yals.h'"
135   elif [ ! -f "$yalsat/libyals.a" ]
136   then
137     die "can not find '$yalsat/libyals.a'"
138   fi
139 fi
140
141 ##########################################################################
142
143 [ $log = undefined ] && log=$debug
144 [ $check = undefined ] && check=$debug
145
146 for CNF in profile.cnf.gz \
147            /data/cnf/sc2009/applications/simon-s03-fifo8-300.cnf \
148            /data/cnf/cmu/longmult12.dimacs \
149            log/prime65537.in \
150            none
151 do
152   [ -f $CNF ] && break;
153 done
154
155 ##########################################################################
156
157 [ x"$CC" = x ] && CC=gcc
158
159 CFLAGS="-Wall"
160 if [ $debug = yes ]
161 then
162   CFLAGS="$CFLAGS -g3"
163   [ $olevel = none ] || CFLAGS="$CFLAGS $olevel"
164 else
165   [ $olevel = none ] && olevel=-O3
166   CFLAGS="$CFLAGS $olevel"
167   [ $lto = yes ] && CFLAGS="$CFLAGS -flto -fwhole-program"
168 fi
169
170 [ $double = no ] && CFLAGS="$CFLAGS -DNDBLSCR"
171
172 LIBS="-lm"
173 if [ $picosat = yes ]
174 then
175   if [ ! -d ../picosat ]
176   then
177     echo "*** configure.sh: can not find '../picosat'"
178     exit 1;
179   elif [ ! -f ../picosat/picosat.h ]
180   then
181     echo "*** configure.sh: can not find '../picosat/picosat.h'"
182     exit 1;
183   elif [ ! -f ../picosat/libpicosat.a ]
184   then
185     echo "*** configure.sh: can not find '../picosat/libpicosat.a'"
186     exit 1;
187   else
188     HDEPS="../picosat/picosat.h"
189     LDEPS="../picosat/libpicosat.a"
190     LIBS="$LIBS -L../picosat -lpicosat"
191     CFLAGS="$CFLAGS -I../picosat"
192   fi
193 else
194   HDEPS=""
195   LDEPS=""
196 fi
197
198 if [ $druplig = yes ]
199 then
200   if [ ! -d ../druplig ]
201   then
202     echo "*** configure.sh: can not find '../druplig'"
203     exit 1;
204   elif [ ! -f ../druplig/druplig.h ]
205   then
206     echo "*** configure.sh: can not find '../druplig/druplig.h'"
207     exit 1;
208   elif [ ! -f ../druplig/libdruplig.a ]
209   then
210     echo "*** configure.sh: can not find '../druplig/libdruplig.a'"
211     exit 1;
212   else
213     HDEPS="../druplig/druplig.h"
214     LDEPS="../druplig/libdruplig.a"
215     LIBS="$LIBS -L../druplig -ldruplig"
216     CFLAGS="$CFLAGS -I../druplig"
217   fi
218 else
219   HDEPS=""
220   LDEPS=""
221 fi
222
223 if [ "$aiger" = no ]
224 then
225   AIGERTARGETS=""
226   AIGER=""
227 else
228   AIGERTARGETS="blimc"
229   AIGER="$aiger"
230 fi
231
232 if [ ! "$yalsat" = no ]
233 then
234   [ x"$HDEPS" = x ] || HDEPS="${HDEPS} "
235   HDEPS="${HDEPS}$yalsat/yals.h"
236   [ x"$LDEPS" = x ] || LDEPS="${LDEPS} "
237   LDEPS="${LDEPS}$yalsat/libyals.a"
238   [ x"$LIBS" = x ] || LIBS="${LIBS} "
239   LIBS="${LIBS} -L$yalsat -lyals"
240   [ x"$CFLAGS" = x ] || CFLAGS="${CFLAGS} "
241   CFLAGS="${CFLAGS} -I$yalsat"
242 fi
243
244 [ $chksol = undefined ] && chksol=$check
245 [ $static = yes ] && CFLAGS="$CFLAGS -static"
246 [ $profile = yes ] && CFLAGS="$CFLAGS -pg"
247 [ $coverage = yes ] && CFLAGS="$CFLAGS -ftest-coverage -fprofile-arcs"
248 [ $other = none ] || CFLAGS="$CFLAGS $other"
249 [ $log = no ] && CFLAGS="$CFLAGS -DNLGLOG"
250 [ $check = no ] && CFLAGS="$CFLAGS -DNDEBUG"
251 [ $chksol = no ] && CFLAGS="$CFLAGS -DNCHKSOL"
252 [ $picosat = no ] && CFLAGS="$CFLAGS -DNLGLPICOSAT"
253 [ $druplig = no ] && CFLAGS="$CFLAGS -DNLGLDRUPLIG"
254 [ $yalsat = no ] && CFLAGS="$CFLAGS -DNLGLYALSAT"
255
256 echo "$CC $CFLAGS"
257
258 ##########################################################################
259
260 rm -f makefile
261 sed \
262   -e "s,@CC@,$CC," \
263   -e "s,@CFLAGS@,$CFLAGS," \
264   -e "s,@HDEPS@,$HDEPS," \
265   -e "s,@LDEPS@,$LDEPS," \
266   -e "s,@AIGERTARGETS@,$AIGERTARGETS," \
267   -e "s,@AIGER@,$AIGER," \
268   -e "s,@CNF@,$CNF," \
269   -e "s,@LIBS@,$LIBS," \
270   makefile.in > makefile