d75fd297f8287d89c1eea1e1cce508a92d57f582
[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-2018 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                 --ctdldir)
33                         CTDLDIR=$v
34                 ;;
35                 --with-ssl)
36                         SSL=yes
37                 ;;
38                 --without-ssl)
39                         SSL=no
40                 ;;
41                 *)
42                         echo $0 : unknown option $k
43                         echo
44                         echo Valid options are:
45                         echo '  --prefix=PREFIX         Install files in PREFIX [/usr/local]'
46                         echo '  --bindir=DIR            Install executables in DIR [PREFIX/bin]'
47                         echo '  --ctdldir=DIR           Look for Citadel server in DIR [/usr/local/citadel]'
48                         echo '  --with-ssl              Force build with OpenSSL support [normally autodetected]'
49                         echo '  --without-ssl           Force build without OpenSSL support [normally autodetected]'
50                         exit 1
51                 ;;
52         esac
53         shift
54 done
55
56 # Set any missing values
57
58 [ "$PREFIX" = "" ]      && PREFIX=/usr/local
59 [ "$BINDIR" = "" ]      && BINDIR=${PREFIX}/bin
60 [ "$CTDLDIR" = "" ]     && CTDLDIR=/usr/local/citadel
61 [ "$CFLAGS" = "" ]      && CFLAGS='-ggdb'
62 [ "$LDFLAGS" = "" ]     && LDFLAGS=''
63
64 # Test for OpenSSL
65 [ "$SSL" != "yes" ] && [ "$SSL" != "no" ] && {
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         SSL='no';
77         cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && SSL='yes'
78         rm -f $tempfile 2>/dev/null
79         rm -f $tempcc 2>/dev/null
80 }
81 echo SSL: $SSL
82 [ "$SSL" = "yes" ] && {
83         CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
84         LDFLAGS=${LDFLAGS}' -lssl -lcrypto'
85 }
86
87 # Output the config.mk
88
89 (
90         echo "CFLAGS := ${CFLAGS}"
91         echo "LDFLAGS := ${LDFLAGS}"
92         echo "PREFIX := ${PREFIX}"
93         echo "BINDIR := ${BINDIR}"
94         echo "CTDLDIR := ${CTDLDIR}"
95 ) >config.mk
96
97 cat config.mk
98 echo