]> code.citadel.org Git - citadel.git/blob - citadel/configure
configure (in Citadel Server) - don't accept "--prefix" anymore.
[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                         echo $0 : '--prefix is not supported.  you are probably looking for --ctdldir'
31                         exit 1
32                 ;;
33                 --ctdldir)
34                         CTDLDIR=$v
35                 ;;
36                 *)
37                         echo $0 : unknown option $k
38                         echo
39                         echo Valid options are:
40                         echo '  --ctdldir=DIR           Install Citadel server to DIR [/usr/local/citadel]'
41                         exit 1
42                 ;;
43         esac
44         shift
45 done
46
47
48 ########################################################################
49 # Set any missing values
50 ########################################################################
51
52 # Accept PREFIX as a substitute for CTDLDIR, but only if CTDLDIR is not already set
53 [ "$CTDLDIR" = "" ] && [ "$PREFIX" != "" ] && CTDLDIR=$PREFIX
54
55 # Configure the directory into which Citadel Server will be installed.
56 [ "$CTDLDIR" = "" ] && CTDLDIR=/usr/local/citadel
57
58 # Permit override of CFLAGS and LDFLAGS using environment variables
59 [ "$CFLAGS" = "" ]      && CFLAGS='-ggdb'
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 $tempcc -lssl -lcrypto -o $tempfile && $tempfile && {
77         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
78         LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
79 } || {
80         echo Citadel Server requires OpenSSL which is not present.
81         exit 2
82 }
83
84
85 ########################################################################
86 # Test for iconv
87 ########################################################################
88 echo Testing for iconv...
89 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
90 tempcc=${tempfile}.c
91 cat >$tempcc <<!
92 #include <stdlib.h>
93 #include <unistd.h>
94 #include <stdio.h>
95 #include <iconv.h>
96 int main(int argc, char **argv) {
97         size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
98         return(0);
99 }
100 !
101
102 cc $tempcc -o $tempfile && {
103         ICONV='yes'
104         echo iconv.h is present and requires no additional libraries
105 } || {
106         echo Trying again with -liconv...
107         cc $tempcc -liconv -o $tempfile && {
108                 ICONV='yes'
109                 LDFLAGS=${LDFLAGS}' -liconv'
110         } || {
111                 echo Citadel Server requires iconv character set conversion.
112                 exit 1
113         }
114 }
115
116
117 ########################################################################
118 # FIXME do a real build id here
119 ########################################################################
120 CFLAGS=${CFLAGS}' -DBUILD_ID=\"unknown\"'
121 CFLAGS=${CFLAGS}' -DCTDLDIR=\"'${CTDLDIR}'\"'
122
123
124 ########################################################################
125 # Output the config.mk
126 ########################################################################
127 (
128         echo '# config.mk is generated by configure'
129         echo "CTDLDIR := ${CTDLDIR}"
130         echo "CFLAGS := ${CFLAGS}"
131         echo "LDFLAGS := ${LDFLAGS}"
132 ) >config.mk
133
134 cat config.mk
135 echo