]> code.citadel.org Git - citadel.git/blob - citadel/configure
If you can't handle me at my worst, you don't deserve me at my best.
[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 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 echo 
16 echo Running the configure script to create config.mk
17 echo
18
19 ########################################################################
20 # Parse the command line arguments
21 ########################################################################
22 for x in $*
23 do
24         a=$1
25         k=`echo $a | awk -F= ' { print $1 } '`
26         v=`echo $a | awk -F= ' { print $2 } '`
27
28         case $k in
29                 --prefix)
30                         PREFIX=$v
31                 ;;
32                 --ctdldir)
33                         CTDLDIR=$v
34                 ;;
35                 *)
36                         echo $0 : unknown option $k
37                         echo
38                         echo Valid options are:
39                         echo '  --ctdldir=DIR           Install Citadel server to DIR [/usr/local/citadel]'
40                         exit 1
41                 ;;
42         esac
43         shift
44 done
45
46
47 ########################################################################
48 # Set any missing values
49 ########################################################################
50
51 # Accept PREFIX as a substitute for CTDLDIR, but only if CTDLDIR is not already set
52 [ "$CTDLDIR" = "" ] && [ "$PREFIX" != "" ] && CTDLDIR=$PREFIX
53
54 # Configure the directory into which Citadel Server will be installed.
55 [ "$CTDLDIR" = "" ] && CTDLDIR=/usr/local/citadel
56
57 # Permit override of CFLAGS and LDFLAGS using environment variables
58 [ "$CFLAGS" = "" ]      && CFLAGS='-ggdb -Wno-discarded-qualifiers'
59 [ "$LDFLAGS" = "" ]     && LDFLAGS=''
60
61
62 ########################################################################
63 # Test for OpenSSL
64 ########################################################################
65 echo Testing for OpenSSL...
66 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
67 tempcc=${tempfile}.c
68 cat >$tempcc <<!
69 #include <openssl/ssl.h>
70 int main(int argc, char **argv) {
71         SSL_load_error_strings();
72         exit(0);
73 }
74 !
75 cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && {
76         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
77         LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
78 } || {
79         echo Citadel Server requires OpenSSL which is not present.
80         exit 2
81 }
82
83
84 ########################################################################
85 # Test for iconv
86 ########################################################################
87 echo Testing for iconv...
88 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
89 tempcc=${tempfile}.c
90 cat >$tempcc <<!
91 #include <stdlib.h>
92 #include <unistd.h>
93 #include <stdio.h>
94 #include <iconv.h>
95 int main(int argc, char **argv) {
96         size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
97         return(0);
98 }
99 !
100
101 cc $tempcc -o $tempfile && {
102         ICONV='yes'
103         echo iconv.h is present and requires no additional libraries
104 } || {
105         echo Trying again with -liconv...
106         cc $tempcc -liconv -o $tempfile && {
107                 ICONV='yes'
108                 LDFLAGS=${LDFLAGS}' -liconv'
109         } || {
110                 echo Citadel Server requires iconv character set conversion.
111                 exit 1
112         }
113 }
114
115
116 ########################################################################
117 # FIXME do a real build id here
118 ########################################################################
119 CFLAGS=${CFLAGS}' -DBUILD_ID=\"unknown\"'
120
121
122 ########################################################################
123 # Output the config.mk
124 ########################################################################
125 (
126         echo '# config.mk is generated by configure'
127         echo "CTDLDIR := ${CTDLDIR}"
128         echo "CFLAGS := ${CFLAGS}"
129         echo "LDFLAGS := ${LDFLAGS}"
130 ) >config.mk
131
132 cat config.mk
133 echo