04821c612471752fca075d37dafae2c69b558679
[citadel.git] / textclient / configure
1 #!/bin/sh
2
3 # CONFIGURE SCRIPT FOR CITADEL TEXT CLIENT
4 # This file is part of "conf-IG-ure"
5 # Copyright (C) 2016-2019 by Art Cancro
6 # Distributed under the terms of the GNU General Public License v3 with the following special exceptions:
7 # 1. By using this software you agree that it's called "Linux", not "GNU/Linux"
8 # 2. By using this software you agree that it's called "open source", not "free software"
9 # 3. By using this software you agree that GNU Autotools are crap, which is why conf-IG-ure exists
10 # 4. By using this software you agree that Richard Stallman is a communist.
11 # 5. By reading these special exceptions you have already agreed to them.
12
13 echo 
14 echo 
15 echo Running the configure script to create config.mk
16 echo
17
18 # Parse the command line arguments
19 for x in $*
20 do
21         a=$1
22         k=`echo $a | awk -F= ' { print $1 } '`
23         v=`echo $a | awk -F= ' { print $2 } '`
24
25         case $k in
26                 --prefix)
27                         PREFIX=$v
28                 ;;
29                 --bindir)
30                         BINDIR=$v
31                 ;;
32                 --etcdir)
33                         ETCDIR=$v
34                 ;;
35                 --ctdldir)
36                         CTDLDIR=$v
37                 ;;
38                 --with-ssl)
39                         SSL=yes
40                 ;;
41                 --without-ssl)
42                         SSL=no
43                 ;;
44                 *)
45                         echo $0 : unknown option $k
46                         echo
47                         echo Valid options are:
48                         echo '  --prefix=PREFIX         Install files in PREFIX [/usr/local]'
49                         echo '  --bindir=DIR            Install executables in DIR [PREFIX/bin]'
50                         echo '  --etcdir=DIR            Install citadel.rc in DIR [PREFIX/etc]'
51                         echo '  --ctdldir=DIR           Look for Citadel server in DIR [/usr/local/citadel]'
52                         echo '  --with-ssl              Force build with OpenSSL support [normally autodetected]'
53                         echo '  --without-ssl           Force build without OpenSSL support [normally autodetected]'
54                         exit 1
55                 ;;
56         esac
57         shift
58 done
59
60 # Set any missing values
61
62 [ "$PREFIX" = "" ]      && PREFIX=/usr/local
63 [ "$BINDIR" = "" ]      && BINDIR=${PREFIX}/bin
64 [ "$CTDLDIR" = "" ]     && CTDLDIR=/usr/local/citadel
65 [ "$CFLAGS" = "" ]      && CFLAGS='-ggdb'
66 [ "$LDFLAGS" = "" ]     && LDFLAGS=''
67
68 # Test for OpenSSL
69 [ "$SSL" != "yes" ] && [ "$SSL" != "no" ] && {
70         echo Testing for OpenSSL...
71         tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
72         tempcc=${tempfile}.c
73         cat >$tempcc <<!
74 #include <openssl/ssl.h>
75 int main(int argc, char **argv) {
76         SSL_load_error_strings();
77         exit(0);
78 }
79 !
80         SSL='no';
81         cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && SSL='yes'
82         rm -f $tempfile 2>/dev/null
83         rm -f $tempcc 2>/dev/null
84 }
85 echo SSL: $SSL
86 [ "$SSL" = "yes" ] && {
87         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
88         LDFLAGS=${LDFLAGS}' -lssl -lcrypto'
89 }
90
91 # Output the config.mk
92
93 (
94         echo "CFLAGS := ${CFLAGS}"
95         echo "LDFLAGS := ${LDFLAGS}"
96         echo "PREFIX := ${PREFIX}"
97         echo "BINDIR := ${BINDIR}"
98         echo "CTDLDIR := ${CTDLDIR}"
99 ) >config.mk
100
101 cat config.mk
102 echo