1#!/bin/sh 2######################################################################### 3# 4# mairix - message index builder and finder for maildir folders. 5# 6# Copyright (C) Richard P. Curnow 2003,2004,2005 7# Copyright (C) Paramjit Oberoi 2005 8# 9# This program is free software; you can redistribute it and/or modify 10# it under the terms of version 2 of the GNU General Public License as 11# published by the Free Software Foundation. 12# 13# This program is distributed in the hope that it will be useful, but 14# WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16# General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License along 19# with this program; if not, write to the Free Software Foundation, Inc., 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21# 22# ======================================================================= 23 24if [ -f config.log ]; then rm -f config.log ; fi 25exec 5>config.log 26 27MYCC=${CC:-gcc} 28MYCFLAGS=${CFLAGS:--O2 -Wall} 29MYCPPFLAGS=${CPPFLAGS:-} 30MYLDFLAGS=${LDFLAGS:-} 31 32# ======================================================================= 33# Functions 34 35#{{{ cleanup 36cleanup () { 37 if [ -f docheck.c ]; then rm -f docheck.c ; fi 38 if [ -f docheck.o ]; then rm -f docheck.o ; fi 39 if [ -f docheck ]; then rm -f docheck ; fi 40 rm -rf docheck.c docheck.o docheck 41} 42#}}} 43 44#{{{ test_cc : basic compiler sanity check 45test_cc () { 46 printf "Testing whether your compiler \"$MYCC $MYCFLAGS\" works : " 47 cat >docheck.c <<EOF; 48#include <stdio.h> 49int main (int argc, char **argv) 50{ 51 return 0; 52} 53EOF 54 ${MYCC} ${MYCFLAGS} -o docheck docheck.c 1>&5 2>&5 55 if [ $? -eq 0 ] 56 then 57 printf "it works\n" 58 else 59 printf "it doesn't work\n" 60 printf "Failed program was\n" 1>&5 61 cat docheck.c 1>&5 62 rm -f docheck.c docheck 63 exit 1 64 fi 65 cleanup 66} 67#}}} 68 69#{{{ test_for_stdint_h 70test_for_stdint_h () { 71 cat >docheck.c <<EOF; 72#include <stdint.h> 73int main(int argc, char **argv) { 74 return 0; 75} 76EOF 77 78 ${MYCC} ${MYCFLAGS} -c -o docheck.o docheck.c >/dev/null 2>&1 79 if [ $? -eq 0 ] 80 then 81 result=0 82 else 83 result=1 84 fi 85 86 rm -f docheck.c docheck.o 87 echo $result 88} 89#}}} 90#{{{ test_for_inttypes_h 91test_for_inttypes_h () { 92 cat >docheck.c <<EOF; 93#include <inttypes.h> 94int main(int argc, char **argv) { 95 return 0; 96} 97EOF 98 99 ${MYCC} ${MYCFLAGS} -c -o docheck.o docheck.c >/dev/null 2>&1 100 if [ $? -eq 0 ] 101 then 102 result=0 103 else 104 result=1 105 fi 106 107 rm -f docheck.c docheck.o 108 echo $result 109} 110#}}} 111#{{{ test_for_zlib 112test_for_zlib () { 113 cat > docheck.c <<EOF; 114#include <zlib.h> 115int main () { 116 const char *foo; 117 foo = zlibVersion(); 118 return 0; 119} 120EOF 121 echo "Test program is" 1>&5 122 cat docheck.c 1>&5 123 ${MYCC} ${MYCPPFLAGS} ${MYCFLAGS} ${MYLDFLAGS} -o docheck docheck.c -lz 1>&5 2>&1 124 if [ $? -eq 0 ] 125 then 126 result=0 127 else 128 result=1 129 fi 130 rm -f docheck.c docheck 131 echo $result 132} 133#}}} 134#{{{ test_for_bzlib 135test_for_bzlib () { 136 cat > docheck.c <<EOF; 137#include <bzlib.h> 138int main () { 139 const char *foo; 140 foo = BZ2_bzlibVersion(); 141 return 0; 142} 143EOF 144 echo "Test program is" 1>&5 145 cat docheck.c 1>&5 146 ${MYCC} ${MYCPPFLAGS} ${MYCFLAGS} ${MYLDFLAGS} -o docheck docheck.c -lbz2 1>&5 2>&1 147 if [ $? -eq 0 ] 148 then 149 result=0 150 else 151 result=1 152 fi 153 rm -f docheck.c docheck 154 echo $result 155} 156#}}} 157 158#{{{ test_for_bison 159test_for_bison () { 160 bison --help > /dev/null 161 if [ $? -eq 0 ] 162 then 163 result=0 164 else 165 result=1 166 fi 167 echo $result 168} 169#}}} 170 171#{{{ test_for_flex 172test_for_flex () { 173 flex --help > /dev/null 174 if [ $? -eq 0 ] 175 then 176 result=0 177 else 178 result=1 179 fi 180 echo $result 181} 182#}}} 183 184#{{{ test_for_openssl 185test_for_openssl () { 186 cat > docheck.c <<EOF; 187#include <openssl/ssl.h> 188int main () { 189 SSL_load_error_strings(); 190 SSL_library_init(); 191 return 0; 192} 193EOF 194 echo "Test program is" 1>&5 195 cat docheck.c 1>&5 196 ${MYCC} ${MYCPPFLAGS} ${MYCFLAGS} ${MYLDFLAGS} -o docheck docheck.c -lssl -lcrypto 1>&5 2>&1 197 if [ $? -eq 0 ] 198 then 199 result=0 200 else 201 result=1 202 fi 203 rm -f docheck.c docheck 204 echo $result 205} 206#}}} 207 208#{{{ usage 209usage () { 210 cat <<EOF; 211\`configure' configures tdl to adapt to many kinds of systems. 212 213Usage: ./configure [OPTION]... 214 215Defaults for the options are specified in brackets. 216 217Configuration: 218 -h, --help display this help and exit 219 220Installation directories: 221 --prefix=PREFIX install architecture-independent files in PREFIX 222 [/usr/local] 223 224By default, \`make install' will install all the files in 225\`/usr/local/bin', \`/usr/local/lib' etc. You can specify 226an installation prefix other than \`/usr/local' using \`--prefix', 227for instance \`--prefix=$HOME'. 228 229Fine tuning of the installation directories: 230 --bindir=DIR user executables [EPREFIX/bin] 231 --infodir=DIR info documentation [PREFIX/info] 232 --mandir=DIR man documentation [PREFIX/man] 233 --docdir=DIR other documentation [PREFIX/doc/mairix-\$version] 234 235Other options: 236 --enable-gzip-mbox attempt to support gzipped mboxes (requires zlib) 237 --disable-gzip-mbox don't attempt to support gzipped mboxes 238 --enable-bzip-mbox attempt to support bzip2ed mboxes (requires bzlib) 239 --disable-bzip-mbox don't attempt to support bzip2ed mboxes 240 241Some influential environment variables: 242 CC C compiler command 243 CFLAGS C compiler flags 244 CPPFLAGS Extra C preprocessor flags, e.g. -I<include dir> if you 245 have header files in a nonstandard directory <include dir> 246 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a 247 nonstandard directory <lib dir> 248 249Use these variables to override the choices made by \`configure' or to help 250it to find libraries and programs with nonstandard names/locations. 251 252Report bugs to <rc@rc0.org.uk>. 253EOF 254} 255#}}} 256# ======================================================================= 257 258# Defaults for variables 259PREFIX=/usr/local 260 261use_readline=yes 262bad_options=no 263use_gzip_mbox=yes 264use_bzip_mbox=yes 265 266# Parse options to configure 267for option 268do 269 case "$option" in 270 271 --prefix=* | --install-prefix=* ) 272 PREFIX=`echo $option | sed -e 's/[^=]*=//;'` 273 ;; 274 --bindir=* ) 275 BINDIR=`echo $option | sed -e 's/[^=]*=//;'` 276 ;; 277 --mandir=* ) 278 MANDIR=`echo $option | sed -e 's/[^=]*=//;'` 279 ;; 280 --infodir=* ) 281 INFODIR=`echo $option | sed -e 's/[^=]*=//;'` 282 ;; 283 --docdir=* ) 284 DOCDIR=`echo $option | sed -e 's/[^=]*=//;'` 285 ;; 286 --enable-gzip-mbox ) 287 use_gzip_mbox=yes 288 ;; 289 --disable-gzip-mbox ) 290 use_gzip_mbox=no 291 ;; 292 --enable-bzip-mbox ) 293 use_bzip_mbox=yes 294 ;; 295 --disable-bzip-mbox ) 296 use_bzip_mbox=no 297 ;; 298 -h | --help ) 299 usage 300 exit 1 301 ;; 302 * ) 303 printf "Unrecognized option : $option\n" 304 bad_options=yes 305 ;; 306 esac 307done 308 309if [ ${bad_options} = yes ]; then 310 exit 1 311fi 312 313DEFS="" 314test_cc 315 316printf "Checking for <stdint.h> : " 317if [ `test_for_stdint_h` -eq 0 ]; then 318 printf "Yes\n" 319 DEFS="${DEFS} -DHAS_STDINT_H" 320else 321 printf "No\n" 322fi 323 324printf "Checking for <inttypes.h> : " 325if [ `test_for_inttypes_h` -eq 0 ]; then 326 printf "Yes\n" 327 DEFS="${DEFS} -DHAS_INTTYPES_H" 328else 329 printf "No\n" 330fi 331 332if [ $use_gzip_mbox = "yes" ]; then 333 printf "Checking for zlib : " 334 if [ `test_for_zlib` -eq 0 ]; then 335 printf "Yes\n"; 336 DEFS="${DEFS} -DUSE_GZIP_MBOX" 337 LIBS="-lz" 338 else 339 printf "No (disabled gzipped mbox support)\n"; 340 fi 341fi 342 343if [ $use_bzip_mbox = "yes" ]; then 344 printf "Checking for bzlib : " 345 if [ `test_for_bzlib` -eq 0 ]; then 346 printf "Yes\n"; 347 DEFS="${DEFS} -DUSE_BZIP_MBOX" 348 LIBS="${LIBS} -lbz2" 349 else 350 printf "No (disabled bzip2ed mbox support)\n"; 351 fi 352fi 353 354printf "Checking for bison : " 355if [ `test_for_bison` -eq 0 ]; then 356 printf "Yes\n"; 357else 358 printf "No\n"; 359 exit 1; 360fi 361 362printf "Checking for flex : " 363if [ `test_for_flex` -eq 0 ]; then 364 printf "Yes\n"; 365else 366 printf "No\n"; 367 exit 1; 368fi 369 370printf "Checking for OpenSSL : " 371if [ `test_for_openssl` -eq 0 ]; then 372 printf "Yes\n"; 373 DEFS="${DEFS} -DUSE_OPENSSL" 374 LIBS="${LIBS} -lssl -lcrypto" 375else 376 printf "No (disabled IMAP STARTTLS support)\n"; 377fi 378 379#{{{ Determine version number of the program. 380if [ -f version.txt ]; then 381 revision=`cat version.txt` 382else 383 revision="DEVELOPMENT" 384fi 385 386#}}} 387if [ "x" = "x${BINDIR}" ]; then BINDIR=${PREFIX}/bin ; fi 388if [ "x" = "x${MANDIR}" ]; then MANDIR=${PREFIX}/man ; fi 389if [ "x" = "x${INFODIR}" ]; then INFODIR=${PREFIX}/info ; fi 390if [ "x" = "x${DOCDIR}" ]; then DOCDIR=${PREFIX}/doc/mairix-${revision} ; fi 391 392echo "Generating Makefile" 393 394rm -f Makefile 395sed -e "s%@cc@%${MYCC}%; \ 396 s%@defs@%${DEFS}%; \ 397 s%@cflags@%${MYCFLAGS}%; \ 398 s%@prefix@%${PREFIX}%; \ 399 s%@bindir@%${BINDIR}%; \ 400 s%@mandir@%${MANDIR}%; \ 401 s%@infodir@%${INFODIR}%; \ 402 s%@docdir@%${DOCDIR}%; \ 403 s%@LIBS@%${LIBS}%; \ 404 s%@CPPFLAGS@%${MYCPPFLAGS}%; \ 405 s%@LDFLAGS@%${MYLDFLAGS}%; \ 406 " < Makefile.in > Makefile 407 408# Avoid editing Makefile instead of Makefile.in 409chmod ugo-w Makefile 410 411# ======================================================================= 412# vim:et:sw=2:ht=2:sts=2:fdm=marker:cms=#%s 413 414