#!/bin/sh # CONFIGURE SCRIPT FOR CITADEL SERVER # This file is part of "conf-IG-ure" # Copyright (C) 2016-2022 by Art Cancro # # 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 Running the configure script to create config.mk echo ######################################################################## # Parse the command line arguments ######################################################################## for x in $* do a=$1 k=`echo $a | awk -F= ' { print $1 } '` v=`echo $a | awk -F= ' { print $2 } '` case $k in --prefix) PREFIX=$v ;; --ctdldir) CTDLDIR=$v ;; *) echo $0 : unknown option $k echo echo Valid options are: echo ' --ctdldir=DIR Install Citadel server to DIR [/usr/local/citadel]' exit 1 ;; esac shift done ######################################################################## # Set any missing values ######################################################################## # 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 -Wno-discarded-qualifiers' [ "$LDFLAGS" = "" ] && LDFLAGS='' ######################################################################## # Test for OpenSSL ######################################################################## echo Testing for OpenSSL... tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$ tempcc=${tempfile}.c cat >$tempcc < int main(int argc, char **argv) { SSL_load_error_strings(); exit(0); } ! 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 #include #include 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\"' CFLAGS=${CFLAGS}' -DCTDLDIR=\"'${CTDLDIR}'\"' ######################################################################## # Output the config.mk ######################################################################## ( echo '# config.mk is generated by configure' echo "CTDLDIR := ${CTDLDIR}" echo "CFLAGS := ${CFLAGS}" echo "LDFLAGS := ${LDFLAGS}" ) >config.mk cat config.mk echo