]> code.citadel.org Git - citadel.git/blobdiff - citadel/configure
Suppress noise during configure
[citadel.git] / citadel / configure
index 4f2304d729307a214e3e706a164053bc73965e15..ad136e3ac1b2ed79061c1688d1e648c2efc7e43b 100755 (executable)
@@ -6,18 +6,14 @@
 #
 # This program is open source software.  Use, duplication, and/or
 # disclosure are subject to the GNU General Purpose License version 3.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
 
-echo 
 echo 
 echo Running the configure script to create config.mk
 echo
 
+########################################################################
 # Parse the command line arguments
+########################################################################
 for x in $*
 do
        a=$1
@@ -26,77 +22,201 @@ do
 
        case $k in
                --prefix)
-                       PREFIX=$v
-               ;;
-               --bindir)
-                       BINDIR=$v
+                       echo $0 : '--prefix is not supported.  you are probably looking for --ctdldir'
+                       exit 1
                ;;
                --ctdldir)
                        CTDLDIR=$v
                ;;
-               --with-ssl)
-                       SSL=yes
-               ;;
-               --without-ssl)
-                       SSL=no
-               ;;
                *)
                        echo $0 : unknown option $k
                        echo
                        echo Valid options are:
-                       echo '  --prefix=PREFIX         Install files in PREFIX [/usr/local]'
-                       echo '  --bindir=DIR            Install executables in DIR [PREFIX/bin]'
-                       echo '  --ctdldir=DIR           Look for Citadel server in DIR [/usr/local/citadel]'
-                       echo '  --with-ssl              Force build with OpenSSL support [normally autodetected]'
-                       echo '  --without-ssl           Force build without OpenSSL support [normally autodetected]'
+                       echo '  --ctdldir=DIR           Install Citadel server to DIR [/usr/local/citadel]'
                        exit 1
                ;;
        esac
        shift
 done
 
-# Set any missing values (FIXME remove the ultra-fatal -W options when finished converting from autotools)
 
-[ "$PREFIX" = "" ]     && PREFIX=/usr/local/citadel
-[ "$BINDIR" = "" ]     && BINDIR=${PREFIX}
-[ "$CTDLDIR" = "" ]    && CTDLDIR=${PREFIX}
-[ "$CFLAGS" = "" ]     && CFLAGS='-ggdb -Werror -Wfatal-errors -Wno-discarded-qualifiers'
+########################################################################
+# Set any missing values
+########################################################################
+
+# GCC is the default C compiler
+[ "${CC}" = "" ]       && export CC=gcc
+
+# Accept PREFIX as a substitute for CTDLDIR, but only if CTDLDIR is not already set
+[ "$CTDLDIR" = "" ] && [ "$PREFIX" != "" ] && CTDLDIR=$PREFIX
+
+# Configure the directory into which Citadel Server will be installed.
+[ "$CTDLDIR" = "" ]    && CTDLDIR=/usr/local/citadel
+
+
+# Permit override of CFLAGS and LDFLAGS using environment variables
+[ "$CFLAGS" = "" ]     && CFLAGS=''
+[ "$CPPFLAGS" = "" ]   && CPPFLAGS=''
 [ "$LDFLAGS" = "" ]    && LDFLAGS=''
 
+
+########################################################################
 # Test for OpenSSL
-[ "$SSL" != "yes" ] && [ "$SSL" != "no" ] && {
-       echo Testing for OpenSSL...
-       tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
-       tempcc=${tempfile}.c
-       cat >$tempcc <<!
+########################################################################
+echo Testing for OpenSSL...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
 #include <openssl/ssl.h>
 int main(int argc, char **argv) {
        SSL_load_error_strings();
        exit(0);
 }
 !
-       SSL='no';
-       cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && SSL='yes'
-       rm -f $tempfile 2>/dev/null
-       rm -f $tempcc 2>/dev/null
-}
-echo SSL: $SSL
-[ "$SSL" = "yes" ] && {
+$CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -lssl -lcrypto && $tempfile >/dev/null 2>&1 && {
        CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
        LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
+} || {
+       echo Citadel Server requires OpenSSL which is not present.
+       rm -f $tempfile $tempcc 2>/dev/null
+       exit 2
 }
 
-# FIXME do a real build id here
-CFLAGS=${CFLAGS}' -DBUILD_ID=\"unknown\"'
 
-# Output the config.mk
+########################################################################
+# Test for iconv
+########################################################################
+echo Testing for iconv...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <iconv.h>
+int main(int argc, char **argv) {
+       size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
+       return(0);
+}
+!
+
+$CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile >/dev/null 2>&1 && {
+       ICONV='yes'
+       echo iconv.h is present and requires no additional libraries
+} || {
+       echo Trying again with -liconv...
+       $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -liconv && {
+               ICONV='yes'
+               LDFLAGS=${LDFLAGS}' -liconv'
+       } || {
+               echo Citadel Server requires iconv character set conversion.
+               rm -f $tempfile $tempcc 2>/dev/null
+               exit 1
+       }
+}
+
+
+########################################################################
+# Test for -lresolv
+########################################################################
+echo Testing for lresolv...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <iconv.h>
+int main(int argc, char **argv) {
+       return(0);
+}
+!
+
+$CC $CFLAGS $CPPFLAGS $tempcc -lresolv -o $tempfile >/dev/null 2>&1 && {
+       LRESOLV='-lresolv'
+} || {
+       LRESOLV=''
+}
 
+rm -f $tempfile $tempcc 2>/dev/null
+
+
+########################################################################
+# Test for -lintl
+########################################################################
+echo Testing for lintl...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <iconv.h>
+int main(int argc, char **argv) {
+       return(0);
+}
+!
+
+$CC $CFLAGS $CPPFLAGS $tempcc -lintl -o $tempfile >/dev/null 2>&1 && {
+       LINTL='-lintl'
+} || {
+       LINTL=''
+}
+
+rm -f $tempfile $tempcc 2>/dev/null
+
+
+########################################################################
+# Are we on Linux with -lcrypt and PAMmy stuff?
+########################################################################
+echo Testing for lcrypt...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <crypt.h>
+int main(int argc, char **argv) {
+       return(0);
+}
+!
+
+$CC $CFLAGS $CPPFLAGS $tempcc -lcrypt -o $tempfile >/dev/null 2>&1 && {
+       CHKPW='chkpw chkpwd'
+} || {
+       CHKPW=''
+}
+
+rm -f $tempfile $tempcc 2>/dev/null
+
+
+########################################################################
+# This is needed to link Berkeley DB.  We will add more here later.
+########################################################################
+BACKEND_LDFLAGS=-ldb
+
+
+########################################################################
+# The build ID can be generated from git or from the date
+########################################################################
+CFLAGS=${CFLAGS}' -DBUILD_ID=\"'$(git describe 2>/dev/null || date +%y%03j)'\"'
+CFLAGS=${CFLAGS}' -DCTDLDIR=\"'${CTDLDIR}'\"'
+
+
+########################################################################
+# Output the config.mk
+########################################################################
 (
-       echo "CFLAGS := ${CFLAGS}"
-       echo "LDFLAGS := ${LDFLAGS}"
-       echo "PREFIX := ${PREFIX}"
-       echo "BINDIR := ${BINDIR}"
+       echo '# config.mk is generated by configure'
        echo "CTDLDIR := ${CTDLDIR}"
+       echo "CC := ${CC}"
+       echo "CFLAGS := ${CFLAGS} ${CPPFLAGS}"
+       echo "LDFLAGS := ${LDFLAGS}"
+       echo "LRESOLV := ${LRESOLV}"
+       echo "LINTL := ${LINTL}"
+       echo "BACKEND_LDFLAGS := ${BACKEND_LDFLAGS}"
+       echo "CHKPW := ${CHKPW}"
 ) >config.mk
 
 cat config.mk