# 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
--prefix)
PREFIX=$v
;;
- --bindir)
- BINDIR=$v
- ;;
--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
# 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}
+# 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='-ggdb -Werror -Wfatal-errors -Wno-discarded-qualifiers'
[ "$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 $tempcc -lssl -lcrypto -o $tempfile && $tempfile && {
CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
+} || {
+ echo Citadel Server requires OpenSSL which is not present.
+ exit 2
}
+
+########################################################################
+# 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 $tempcc -o $tempfile && {
+ ICONV='yes'
+ echo iconv.h is present and requires no additional libraries
+} || {
+ echo Trying again with -liconv...
+ cc $tempcc -liconv -o $tempfile && {
+ ICONV='yes'
+ LDFLAGS=${LDFLAGS}' -liconv'
+ } || {
+ echo Citadel Server requires iconv character set conversion.
+ exit 1
+ }
+}
+
+
# FIXME do a real build id here
CFLAGS=${CFLAGS}' -DBUILD_ID=\"unknown\"'
# Output the config.mk
(
+ echo # config.mk is generated by configure
+ echo "CTDLDIR := ${CTDLDIR}"
echo "CFLAGS := ${CFLAGS}"
echo "LDFLAGS := ${LDFLAGS}"
- echo "PREFIX := ${PREFIX}"
- echo "BINDIR := ${BINDIR}"
- echo "CTDLDIR := ${CTDLDIR}"
) >config.mk
cat config.mk