broke build into three parts - config, build, and install
[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 "Install prefix [$PREFIX] ";
50         read X;
51         if [ ! -z "$X" ]; then PREFIX="$X"; fi;
52
53         prompt "Temporary files directory [$TMP] "
54         read X;
55         if [ ! -z "$X" ]; then TMP="$X"; fi;
56
57         prompt "Apache2 apxs binary [$APXS2] "
58         read X;
59         if [ ! -z "$X" ]; then APXS2="$X"; fi;
60
61         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
62         read X;
63         if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
64
65         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
66         read X;
67         if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
68
69         prompt "Build targets [${TARGETS[@]:0}] "
70         read X;
71         if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
72
73
74         cat <<-WORDS
75
76         -----------------------------------------------------------------------
77         Verify the following install directories are sane.
78         Note: * indicates that you must have write privelages for the location
79         -----------------------------------------------------------------------
80
81         -----------------------------------------------------------------------
82         Install prefix             [$PREFIX]*
83         Temporary files directory  [$TMP]*
84         Apache2 apxs binary        [$APXS2]
85         Apache2 headers directory  [$APACHE2_HEADERS]
86         Libxml2 headers directory  [$LIBXML2_HEADERS]
87         Build targets              [${TARGETS[@]:0}]
88         -----------------------------------------------------------------------
89
90         If these are not OK, use control-c to break out rerun this script.
91         Otherwise, type enter.
92
93         WORDS
94
95         read OK;
96
97         writeConfig;
98 }
99
100 function prompt { echo ""; echo -n "$*"; }
101
102 function writeConfig {
103
104         rm -f "$CONFIG_FILE";
105         echo "Writing config to $CONFIG_FILE...";
106
107         _write "PREFIX=\"$PREFIX\"";
108         _write "TMP=\"$TMP\"";
109         _write "APXS2=\"$APXS2\"";
110         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
111         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
112
113         # print out the targets
114         STR="TARGETS=(";
115         for target in ${TARGETS[@]:0}; do
116                 STR="$STR \"$target\"";
117         done;
118         STR="$STR)";
119         _write "$STR";
120
121         _write "OPENSRF_DIR=\"OpenSRF/src/\"";
122         _write "OPENILS_DIR=\"Open-ILS/src/\"";
123         _write "EVERGREEN_DIR=\"Evergreen/\"";
124
125 }
126
127 function _write {
128         echo "$*" >> "$CONFIG_FILE";
129 }
130
131
132
133 buildConfig;