3 # CONFIGURE SCRIPT FOR CITADEL SERVER
4 # This file is part of "conf-IG-ure"
5 # Copyright (C) 2016-2022 by Art Cancro
7 # This program is open source software. Use, duplication, and/or
8 # disclosure are subject to the GNU General Purpose License version 3.
11 echo Running the configure script to create config.mk
14 ########################################################################
15 # Parse the command line arguments
16 ########################################################################
20 k=`echo $a | awk -F= ' { print $1 } '`
21 v=`echo $a | awk -F= ' { print $2 } '`
25 echo $0 : '--prefix is not supported. you are probably looking for --ctdldir'
32 echo $0 : unknown option $k
34 echo Valid options are:
35 echo ' --ctdldir=DIR Install Citadel server to DIR [/usr/local/citadel]'
43 ########################################################################
44 # Set any missing values
45 ########################################################################
47 # GCC is the default C compiler
48 [ "${CC}" = "" ] && export CC=gcc
50 # Accept PREFIX as a substitute for CTDLDIR, but only if CTDLDIR is not already set
51 [ "$CTDLDIR" = "" ] && [ "$PREFIX" != "" ] && CTDLDIR=$PREFIX
53 # Configure the directory into which Citadel Server will be installed.
54 [ "$CTDLDIR" = "" ] && CTDLDIR=/usr/local/citadel
57 # Permit override of CFLAGS and LDFLAGS using environment variables
58 [ "$CFLAGS" = "" ] && CFLAGS=''
59 [ "$CPPFLAGS" = "" ] && CPPFLAGS=''
60 [ "$LDFLAGS" = "" ] && LDFLAGS=''
63 ########################################################################
65 ########################################################################
66 echo Testing for OpenSSL...
67 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
70 #include <openssl/ssl.h>
71 int main(int argc, char **argv) {
72 SSL_load_error_strings();
76 $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -lssl -lcrypto && $tempfile && {
77 CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
78 LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
80 echo Citadel Server requires OpenSSL which is not present.
85 ########################################################################
87 ########################################################################
88 echo Testing for iconv...
89 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
96 int main(int argc, char **argv) {
97 size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
102 $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile && {
104 echo iconv.h is present and requires no additional libraries
106 echo Trying again with -liconv...
107 $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -liconv && {
109 LDFLAGS=${LDFLAGS}' -liconv'
111 echo Citadel Server requires iconv character set conversion.
117 ########################################################################
119 ########################################################################
120 echo Testing for lresolv...
121 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
128 int main(int argc, char **argv) {
133 $CC $CFLAGS $CPPFLAGS $tempcc -lresolv -o $tempfile && {
140 ########################################################################
142 ########################################################################
143 echo Testing for lintl...
144 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
151 int main(int argc, char **argv) {
156 $CC $CFLAGS $CPPFLAGS $tempcc -lintl -o $tempfile && {
163 ########################################################################
164 # Are we on Linux with -lcrypt and PAMmy stuff?
165 ########################################################################
166 echo Testing for lcrypt...
167 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
174 int main(int argc, char **argv) {
179 $CC $CFLAGS $CPPFLAGS $tempcc -lcrypt -o $tempfile && {
186 ########################################################################
187 # This is needed to link Berkeley DB. We will add more here later.
188 ########################################################################
192 ########################################################################
193 # The build ID can be generated from git or from the date
194 ########################################################################
195 CFLAGS=${CFLAGS}' -DBUILD_ID=\"'$(git describe 2>/dev/null || date +%y%03j)'\"'
196 CFLAGS=${CFLAGS}' -DCTDLDIR=\"'${CTDLDIR}'\"'
199 ########################################################################
200 # Output the config.mk
201 ########################################################################
203 echo '# config.mk is generated by configure'
204 echo "CTDLDIR := ${CTDLDIR}"
206 echo "CFLAGS := ${CFLAGS} ${CPPFLAGS}"
207 echo "LDFLAGS := ${LDFLAGS}"
208 echo "LRESOLV := ${LRESOLV}"
209 echo "LINTL := ${LINTL}"
210 echo "BACKEND_LDFLAGS := ${BACKEND_LDFLAGS}"
211 echo "CHKPW := ${CHKPW}"