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