Integrated the DKIM signer into serv_smtpclient, but disabled it
[citadel.git] / citadel / configure
1 #!/bin/sh
2
3 # CONFIGURE SCRIPT FOR CITADEL SERVER
4 # This file is part of "conf-IG-ure"
5 # Copyright (C) 2016-2022 by Art Cancro
6 #
7 # This program is open source software.  Use, duplication, and/or
8 # disclosure are subject to the GNU General Purpose License version 3.
9
10 echo 
11 echo Running the configure script to create config.mk
12 echo
13
14 ########################################################################
15 # Parse the command line arguments
16 ########################################################################
17 for x in $*
18 do
19         a=$1
20         k=`echo $a | awk -F= ' { print $1 } '`
21         v=`echo $a | awk -F= ' { print $2 } '`
22
23         case $k in
24                 --prefix)
25                         echo $0 : '--prefix is not supported.  you are probably looking for --ctdldir'
26                         exit 1
27                 ;;
28                 --ctdldir)
29                         CTDLDIR=$v
30                 ;;
31                 *)
32                         echo $0 : unknown option $k
33                         echo
34                         echo Valid options are:
35                         echo '  --ctdldir=DIR           Install Citadel server to DIR [/usr/local/citadel]'
36                         exit 1
37                 ;;
38         esac
39         shift
40 done
41
42
43 ########################################################################
44 # Set any missing values
45 ########################################################################
46
47 # GCC is the default C compiler
48 [ "${CC}" = "" ]        && export CC=gcc
49
50 # Accept PREFIX as a substitute for CTDLDIR, but only if CTDLDIR is not already set
51 [ "$CTDLDIR" = "" ] && [ "$PREFIX" != "" ] && CTDLDIR=$PREFIX
52
53 # Configure the directory into which Citadel Server will be installed.
54 [ "$CTDLDIR" = "" ]     && CTDLDIR=/usr/local/citadel
55
56
57 # Permit override of CFLAGS and LDFLAGS using environment variables
58 [ "$CFLAGS" = "" ]      && CFLAGS=''
59 [ "$CPPFLAGS" = "" ]    && CPPFLAGS=''
60 [ "$LDFLAGS" = "" ]     && LDFLAGS=''
61
62
63 ########################################################################
64 # Test for OpenSSL
65 ########################################################################
66 echo Testing for OpenSSL...
67 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
68 tempcc=${tempfile}.c
69 cat >$tempcc <<!
70 #include <openssl/ssl.h>
71 int main(int argc, char **argv) {
72         SSL_load_error_strings();
73         exit(0);
74 }
75 !
76 $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -lssl -lcrypto && $tempfile >/dev/null 2>&1 && {
77         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
78         LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
79 } || {
80         echo Citadel Server requires OpenSSL which is not present.
81         rm -f $tempfile $tempcc 2>/dev/null
82         exit 2
83 }
84
85
86 ########################################################################
87 # Test for iconv
88 ########################################################################
89 echo Testing for iconv...
90 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
91 tempcc=${tempfile}.c
92 cat >$tempcc <<!
93 #include <stdlib.h>
94 #include <unistd.h>
95 #include <stdio.h>
96 #include <iconv.h>
97 int main(int argc, char **argv) {
98         size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
99         return(0);
100 }
101 !
102
103 $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile >/dev/null 2>&1 && {
104         ICONV='yes'
105         echo iconv.h is present and requires no additional libraries
106 } || {
107         echo Trying again with -liconv...
108         $CC $CFLAGS $CPPFLAGS $tempcc -o $tempfile $LDFLAGS -liconv && {
109                 ICONV='yes'
110                 LDFLAGS=${LDFLAGS}' -liconv'
111         } || {
112                 echo Citadel Server requires iconv character set conversion.
113                 rm -f $tempfile $tempcc 2>/dev/null
114                 exit 1
115         }
116 }
117
118
119 ########################################################################
120 # Test for -lresolv
121 ########################################################################
122 echo Testing for lresolv...
123 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
124 tempcc=${tempfile}.c
125 cat >$tempcc <<!
126 #include <stdlib.h>
127 #include <unistd.h>
128 #include <stdio.h>
129 #include <iconv.h>
130 int main(int argc, char **argv) {
131         return(0);
132 }
133 !
134
135 $CC $CFLAGS $CPPFLAGS $tempcc -lresolv -o $tempfile >/dev/null 2>&1 && {
136         LRESOLV='-lresolv'
137 } || {
138         LRESOLV=''
139 }
140
141 rm -f $tempfile $tempcc 2>/dev/null
142
143
144 ########################################################################
145 # Test for -lintl
146 ########################################################################
147 echo Testing for lintl...
148 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
149 tempcc=${tempfile}.c
150 cat >$tempcc <<!
151 #include <stdlib.h>
152 #include <unistd.h>
153 #include <stdio.h>
154 #include <iconv.h>
155 int main(int argc, char **argv) {
156         return(0);
157 }
158 !
159
160 $CC $CFLAGS $CPPFLAGS $tempcc -lintl -o $tempfile >/dev/null 2>&1 && {
161         LINTL='-lintl'
162 } || {
163         LINTL=''
164 }
165
166 rm -f $tempfile $tempcc 2>/dev/null
167
168
169 ########################################################################
170 # Are we on Linux with -lcrypt and PAMmy stuff?
171 ########################################################################
172 echo Testing for lcrypt...
173 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
174 tempcc=${tempfile}.c
175 cat >$tempcc <<!
176 #include <stdlib.h>
177 #include <unistd.h>
178 #include <stdio.h>
179 #include <crypt.h>
180 int main(int argc, char **argv) {
181         return(0);
182 }
183 !
184
185 $CC $CFLAGS $CPPFLAGS $tempcc -lcrypt -o $tempfile >/dev/null 2>&1 && {
186         CHKPW='chkpw chkpwd'
187 } || {
188         CHKPW=''
189 }
190
191 rm -f $tempfile $tempcc 2>/dev/null
192
193
194 ########################################################################
195 # This is needed to link Berkeley DB.  We will add more here later.
196 ########################################################################
197 BACKEND_LDFLAGS=-ldb
198
199
200 ########################################################################
201 # The build ID can be generated from git or from the date
202 ########################################################################
203 CFLAGS=${CFLAGS}' -DBUILD_ID=\"'$(git describe 2>/dev/null || date +%y%03j)'\"'
204 CFLAGS=${CFLAGS}' -DCTDLDIR=\"'${CTDLDIR}'\"'
205
206
207 ########################################################################
208 # Output the config.mk
209 ########################################################################
210 (
211         echo '# config.mk is generated by configure'
212         echo "CTDLDIR := ${CTDLDIR}"
213         echo "CC := ${CC}"
214         echo "CFLAGS := ${CFLAGS} ${CPPFLAGS}"
215         echo "LDFLAGS := ${LDFLAGS}"
216         echo "LRESOLV := ${LRESOLV}"
217         echo "LINTL := ${LINTL}"
218         echo "BACKEND_LDFLAGS := ${BACKEND_LDFLAGS}"
219         echo "CHKPW := ${CHKPW}"
220 ) >config.mk
221
222 cat config.mk
223 echo