Import PicoSAT-965
[cl-satwrap.git] / backends / picosat / configure.sh
bloba82cfe8769f313ba34902fdcec0cd53eec4e1a71
1 #!/bin/sh
3 satcompetition=no
5 log=no
6 debug=no
7 stats=undefined
8 trace=undefined
9 static=yes
10 shared=no
11 thirtytwobit=no
12 static=no
13 rcode=no
15 while [ $# -gt 0 ]
17 case $1 in
18 -g|--debug) debug=yes;;
19 -O|--optimize) debug=no;;
20 -l|--log) log=yes;;
21 -s|--stats) stats=yes;;
22 -t|--trace) trace=yes;;
23 --no-stats) stats=no;;
24 --no-trace) trace=no;;
25 --no-rcode) rcode=no;;
26 --rcode) rcode=yes;;
27 -32|--32|-m32) thirtytwobit=yes;;
28 -static|--static) static=yes;;
29 -shared|--shared) shared=yes;;
30 *) cat <<EOF
31 usage: ./configure.sh [<option> ...]
33 where <option> is one of the following:
35 -g|--debug include debugging code and symbols
36 -O|--optimize optimized compilation (default)
37 -l|--log add low level logging code (default with '-g')
38 -s|--stats more expensive statististcs (default with '-g')
39 -t|--trace trace generation (more memory, default with '-g')
40 --no-stats disable expensive stats
41 --no-trace enable trace generation
42 -32|--32|-m32 compile for 32 bit machine even on 64 bit host
43 -rcode|--no-rcode enable/disable compatibility for used in R exension
44 -static|--static produce static binary
45 -shared|--shared produce shared library
46 EOF
47 exit 1
49 esac
50 shift
51 done
53 echo "version ... `cat VERSION`"
55 if [ $satcompetition = yes ]
56 then
57 debug=no
58 stats=no
59 trace=no
60 thirtytwobit=yes
61 static=yes
62 shared=no
65 echo "debug ... $debug"
66 echo "log ... $log"
68 [ $stats = undefined ] && stats=$debug
69 echo "stats ... $stats"
71 [ $trace = undefined ] && trace=$debug
72 echo "trace ... $trace"
74 echo "static ... $static"
76 echo "shared ... $shared"
78 [ "X$CC" = X ] && CC=gcc
80 if [ X"$CFLAGS" = X ]
81 then
82 case X"$CC" in
83 *wine*|*mingw*) CFLAGS="-DNGETRUSAGE -DNALLSIGNALS";;
84 *);;
85 esac
86 [ $log = yes ] && CFLAGS="$CFLAGS -DLOGGING"
87 [ $stats = yes ] && CFLAGS="$CFLAGS -DSTATS"
88 [ $trace = yes ] && CFLAGS="$CFLAGS -DTRACE"
89 [ $static = yes ] && CFLAGS="$CFLAGS -static"
90 [ $rcode = yes ] && CFLAGS="$CFLAGS -DRCODE"
91 case X"$CC" in
92 X*gcc*)
93 CFLAGS="$CFLAGS -Wall -Wextra"
94 [ $thirtytwobit = yes ] && CFLAGS="$CFLAGS -m32"
95 if [ $debug = yes ]
96 then
97 CFLAGS="$CFLAGS -g3 -ggdb"
98 else
99 CFLAGS="$CFLAGS -DNDEBUG -O3"
103 if [ $debug = yes ]
104 then
105 CFLAGS="$CFLAGS -g"
106 else
107 CFLAGS="$CFLAGS -O"
110 esac
113 if [ $rcode = yes ]
114 then
115 for rdoth in /usr/share/R/include/R.h $RINC undefined
117 [ -f $rdoth ] && break
118 done
119 if [ $rdoth = undefined ]
120 then
121 echo "R.h ... not found (add '-I' manually or 'RHEADER=... ./configure')"
122 else
123 RINC="-I`dirname $rdoth`"
124 CFLAGS="$CFLAGS $RINC"
125 echo "R.h ... added '$RINC' include directive"
127 TARGETS="libpicosat.a"
128 else
129 TARGETS="picosat picomcs picomus picogcnf libpicosat.a"
132 if [ $shared = yes ]
133 then
134 TARGETS="$TARGETS libpicosat.so"
135 CFLAGS="$CFLAGS -fPIC"
137 echo "targets ... $TARGETS"
139 echo "cc ... $CC"
141 echo "cflags ... $CFLAGS"
143 printf "makefile ..."
144 rm -f makefile
145 sed \
146 -e "s,@CC@,$CC," \
147 -e "s,@CFLAGS@,$CFLAGS," \
148 -e "s,@TARGETS@,$TARGETS," \
149 makefile.in > makefile
150 echo " done"