1#!/bin/sh 2 3satcompetition=no 4 5log=no 6debug=no 7stats=undefined 8trace=undefined 9static=yes 10shared=no 11thirtytwobit=no 12static=no 13rcode=no 14 15while [ $# -gt 0 ] 16do 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 31usage: ./configure.sh [<option> ...] 32 33where <option> is one of the following: 34 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 46EOF 47exit 1 48;; 49 esac 50shift 51done 52 53echo "version ... `cat VERSION`" 54 55if [ $satcompetition = yes ] 56then 57 debug=no 58 stats=no 59 trace=no 60 thirtytwobit=yes 61 static=yes 62 shared=no 63fi 64 65echo "debug ... $debug" 66echo "log ... $log" 67 68[ $stats = undefined ] && stats=$debug 69echo "stats ... $stats" 70 71[ $trace = undefined ] && trace=$debug 72echo "trace ... $trace" 73 74echo "static ... $static" 75 76echo "shared ... $shared" 77 78[ "X$CC" = X ] && CC=gcc 79 80if [ X"$CFLAGS" = X ] 81then 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" 100 fi 101 ;; 102 *) 103 if [ $debug = yes ] 104 then 105 CFLAGS="$CFLAGS -g" 106 else 107 CFLAGS="$CFLAGS -O" 108 fi 109 ;; 110 esac 111fi 112 113if [ $rcode = yes ] 114then 115 for rdoth in /usr/share/R/include/R.h $RINC undefined 116 do 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" 126 fi 127 TARGETS="libpicosat.a" 128else 129 TARGETS="picosat picomcs picomus picogcnf libpicosat.a" 130fi 131 132if [ $shared = yes ] 133then 134 TARGETS="$TARGETS libpicosat.so" 135 CFLAGS="$CFLAGS -fPIC" 136fi 137echo "targets ... $TARGETS" 138 139echo "cc ... $CC" 140 141echo "cflags ... $CFLAGS" 142 143printf "makefile ..." 144rm -f makefile 145sed \ 146 -e "s,@CC@,$CC," \ 147 -e "s,@CFLAGS@,$CFLAGS," \ 148 -e "s,@TARGETS@,$TARGETS," \ 149makefile.in > makefile 150echo " done" 151