adding more build targets and build variables
[Evergreen.git] / config.sh
1 #!/bin/bash
2 # --------------------------------------------------------------------
3 # Copyright (C) 2005  Georgia Public Library Service 
4 # Bill Erickson <highfalutin@gmail.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 # --------------------------------------------------------------------
16
17
18 # --------------------------------------------------------------------
19 # Prompts the user for config settings and writes a custom config
20 # file based on these settings
21 # --------------------------------------------------------------------
22
23
24 CONFIG_FILE="install.conf";
25 DEFAULT_CONFIG_FILE="install.conf.default";
26
27 function buildConfig {
28
29 #       if [ -f "$CONFIG_FILE" ]; then
30 #               echo "";
31 #               echo "Using existing config file \"$CONFIG_FILE\""; 
32 #               echo "To generate a new config, remove \"$CONFIG_FILE\"";
33 #               echo "";
34 #               sleep 3;        
35 #               exit 0;
36 #       fi
37
38
39         if [ -f "$DEFAULT_CONFIG_FILE" ]; then
40                 source "$DEFAULT_CONFIG_FILE";
41         fi;
42
43
44         echo "";
45         echo "-----------------------------------------------------------------------";
46         echo "Type Enter to select the default"
47         echo "-----------------------------------------------------------------------";
48
49         prompt "Temporary files directory [$TMP] "
50         read X; if [ ! -z "$X" ]; then TMP="$X"; fi;
51
52         prompt "Install prefix [$PREFIX] ";
53         read X;
54         if [ ! -z "$X" ]; then 
55                 PREFIX="$X"; 
56                 BINDIR="$PREFIX/bin/";
57                 LIBDIR="$PREFIX/lib/";
58                 PERLDIR="$LIBDIR/perl5/";
59                 INCLUDEDIR="$PREFIX/include/";
60         fi
61
62         prompt "Executables directory [$BINDIR] "
63         read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
64
65         prompt "Lib directory [$LIBDIR] "
66         read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
67
68         prompt "Perl directory [$PERLDIR] "
69         read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
70
71         prompt "Include files directory [$INCLUDEDIR] "
72         read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
73
74         prompt "Config files directory [$ETCDIR] "
75         read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
76
77         prompt "Web Root Directory [$WEBDIR] "
78         read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
79
80         prompt "Templates directory [$TEMPLATEDIR] "
81         read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
82
83         prompt "Apache2 apxs binary [$APXS2] "
84         read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
85
86         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
87         read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
88
89         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
90         read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
91
92         prompt "Build targets [${TARGETS[@]:0}] "
93         read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
94
95         writeConfig;
96 }
97
98 function prompt { echo ""; echo -n "$*"; }
99
100 function writeConfig {
101
102         rm -f "$CONFIG_FILE";
103         echo "Writing config to $CONFIG_FILE...";
104
105         _write "PREFIX=\"$PREFIX\"";
106         _write "BINDIR=\"$BINDIR\"";
107         _write "LIBDIR=\"$LIBDIR\"";
108         _write "PERLDIR=\"$PERLDIR\"";
109         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
110
111         _write "TMP=\"$TMP\"";
112         _write "APXS2=\"$APXS2\"";
113         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
114         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
115
116         _write "WEBDIR=\"$WEBDIR\"";
117         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
118
119         # print out the targets
120         STR="TARGETS=(";
121         for target in ${TARGETS[@]:0}; do
122                 STR="$STR \"$target\"";
123         done;
124         STR="$STR)";
125         _write "$STR";
126
127         _write "OPENSRF_DIR=\"OpenSRF/src/\"";
128         _write "OPENILS_DIR=\"Open-ILS/src/\"";
129         _write "EVERGREEN_DIR=\"Evergreen/\"";
130
131         prompt "To write a new config, run 'make config'";
132         sleep 2;
133
134 }
135
136 function _write {
137         echo "$*" >> "$CONFIG_FILE";
138 }
139
140
141
142 buildConfig;