This is an omnibus commit which moves the Citadel Server from crusty old GNU Autotool...
[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 
17 echo Running the configure script to create config.mk
18 echo
19
20 # Parse the command line arguments
21 for x in $*
22 do
23         a=$1
24         k=`echo $a | awk -F= ' { print $1 } '`
25         v=`echo $a | awk -F= ' { print $2 } '`
26
27         case $k in
28                 --prefix)
29                         PREFIX=$v
30                 ;;
31                 --bindir)
32                         BINDIR=$v
33                 ;;
34                 --ctdldir)
35                         CTDLDIR=$v
36                 ;;
37                 --with-ssl)
38                         SSL=yes
39                 ;;
40                 --without-ssl)
41                         SSL=no
42                 ;;
43                 *)
44                         echo $0 : unknown option $k
45                         echo
46                         echo Valid options are:
47                         echo '  --prefix=PREFIX         Install files in PREFIX [/usr/local]'
48                         echo '  --bindir=DIR            Install executables in DIR [PREFIX/bin]'
49                         echo '  --ctdldir=DIR           Look for Citadel server in DIR [/usr/local/citadel]'
50                         echo '  --with-ssl              Force build with OpenSSL support [normally autodetected]'
51                         echo '  --without-ssl           Force build without OpenSSL support [normally autodetected]'
52                         exit 1
53                 ;;
54         esac
55         shift
56 done
57
58 # Set any missing values (FIXME remove the ultra-fatal -W options when finished converting from autotools)
59
60 [ "$PREFIX" = "" ]      && PREFIX=/usr/local/citadel
61 [ "$BINDIR" = "" ]      && BINDIR=${PREFIX}
62 [ "$CTDLDIR" = "" ]     && CTDLDIR=${PREFIX}
63 [ "$CFLAGS" = "" ]      && CFLAGS='-ggdb -Werror -Wfatal-errors -Wno-discarded-qualifiers'
64 [ "$LDFLAGS" = "" ]     && LDFLAGS=''
65
66 # Test for OpenSSL
67 [ "$SSL" != "yes" ] && [ "$SSL" != "no" ] && {
68         echo Testing for OpenSSL...
69         tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
70         tempcc=${tempfile}.c
71         cat >$tempcc <<!
72 #include <openssl/ssl.h>
73 int main(int argc, char **argv) {
74         SSL_load_error_strings();
75         exit(0);
76 }
77 !
78         SSL='no';
79         cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && SSL='yes'
80         rm -f $tempfile 2>/dev/null
81         rm -f $tempcc 2>/dev/null
82 }
83 echo SSL: $SSL
84 [ "$SSL" = "yes" ] && {
85         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
86         LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
87 }
88
89 # FIXME do a real build id here
90 CFLAGS=${CFLAGS}' -DBUILD_ID=\"unknown\"'
91
92 # Output the config.mk
93
94 (
95         echo "CFLAGS := ${CFLAGS}"
96         echo "LDFLAGS := ${LDFLAGS}"
97         echo "PREFIX := ${PREFIX}"
98         echo "BINDIR := ${BINDIR}"
99         echo "CTDLDIR := ${CTDLDIR}"
100 ) >config.mk
101
102 cat config.mk
103 echo