/[meta-cvs]/meta-cvs/F-4948435BE08AA37BF07EE55E790D14D9
ViewVC logotype

Contents of /meta-cvs/F-4948435BE08AA37BF07EE55E790D14D9

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Tue Jan 2 07:51:19 2007 UTC (7 years, 3 months ago) by kaz
Branch: MAIN
CVS Tags: mcvs-1-1-98
Changes since 1.1: +23 -8 lines
* configure: Parse version number from CVS keyword, show in banner.
1 #!/bin/sh
2
3 #
4 # Save command line in a way that can be re-run.
5 # This takes care of spaces, but if there are shell-meta characters
6 # in the arguments, oops.
7 #
8
9 cmdline=
10 for arg in "$0" "$@" ; do
11 [ -n "$cmdline" ] && cmdline="$cmdline "
12 case $arg in
13 *" "* | " "* | *" " )
14 cmdline=$cmdline$(printf "\"%s\"" "$arg")
15 ;;
16 * )
17 cmdline=$cmdline$arg
18 ;;
19 esac
20 done
21
22 #
23 # Default variables
24 #
25
26 prefix=/usr/local
27
28 #
29 # Parse configuration variables
30 #
31 while [ $# -gt 0 ] ; do
32 case $1 in
33 --no-* )
34 var=${1#--no-}
35 val=
36 ;;
37 --*=* )
38 var=${1%=*}
39 var=${var#--}
40 val=${1#*=}
41 ;;
42 --*= )
43 var=${1%=*}
44 var=${var#--}
45 val=
46 ;; --* )
47 var=${1#--}
48 val=y
49 ;;
50 *=* )
51 var=${1%=*}
52 val=${1#*=}
53 ;;
54 *= )
55 var=${1%=*}
56 val=
57 ;;
58 * )
59 printf "$0: '$1' doesn't look like a configuration variable assignment\n"
60 printf "$0: use --help to get help\n"
61 exit 1
62 esac
63
64 if ! printf $var | grep -q -E '^[[:alpha:]][[:alnum:]]*$' ; then
65 printf "$0: '$var' isn't a proper configuration variable name\n"
66 exit 1;
67 fi
68
69 eval "$var=\"$val\""
70 shift
71 done
72
73 #
74 # If --help was given (or --help=<nonempty> or help=<nonempty>) then
75 # print help and exit. The termination status is failed, to indicate
76 # that configuration was not done.
77 #
78
79 if [ -n "$help" ] ; then
80 cat <<!
81
82 usage: $0 { variable=value }*\n"
83
84 The configure script prepares Meta-CVS for building and installation.
85 To configure a program means to establish the values of kakefile variables
86 which influence how the software is built, where it is installed.
87 These variables can also influence what features are present in the
88 software, and can determine various defaults for those behaviors which are
89 dynamically configurable when the software is run.
90
91 Configuration variables are recorded in a file called config.make. This is a
92 GNU makefile, and consequently uses the GNU make syntax. It is included in the
93 main Makefile by an include statement.
94
95 The configure script is flexible. It allows variables to be entered in any
96 of these forms:
97
98 Canonical:
99
100 variable=value Defines the given variable as having the given value.
101 variable= Defines the variable as having an empty value.
102 An empty value serves as boolean false.
103
104 Long-option style:
105
106 --variable=value Same as 'variable=value', but resembles a GNU-style
107 long option.
108 --variable Same as 'variable=y'.
109 --no-variable Same as 'variable='.
110
111 No variables are required. The configure script establishes default values
112 for any variables which are needed by the build, but which are not specified
113 on the command line.
114
115 After running $0, check that the config.make contents are sane.
116
117 !
118 exit 1
119 fi
120
121 #
122 # Variables are read, --help wasn't given, so let's configure!
123 #
124
125 #
126 # Grok software version from CVS varaible
127 #
128
129 name_key="$Name: $"
130 save_ifs=$IFS ; IFS=":-$ " ; set -- $name_key ; IFS=$save_ifs
131 mcvs_ver_major=$3
132 mcvs_ver_minor=$4
133 mcvs_ver_patch=$5
134
135 #
136 # The all important banner.
137 #
138
139 if [ $3 ] ; then
140 banner_text=$(printf " Configuring Meta-CVS %d.%d.%d \n" $3 $4 $5)
141 else
142 banner_text=" Configuring Meta-CVS (unknown version) "
143 fi
144 banner_box=$(printf "%.*s\n" ${#banner_text} \
145 "-------------------------------------------")
146 printf "+%s+\n|%s|\n+%s+\n" $banner_box "$banner_text" $banner_box
147
148 #
149 # From here on in, we bail if any command fails.
150 #
151
152 set -e
153
154 #
155 # Verify sanity of --prefix
156 #
157
158 printf "Checking prefix %s ... " "$prefix"
159 case $prefix in
160 "" )
161 ;;
162 " "* | *" "* | *" " )
163 printf "incorrect (contains spaces)\n"
164 exit 1
165 ;;
166 -* )
167 printf "incorrect (resembles a command option)\n"
168 exit 1
169 ;;
170 /* )
171 ;;
172 * )
173 printf "incorrect (must be absolute path)\n"
174 exit 1
175 ;;
176 esac
177
178 test_prefix=$prefix
179
180 while true ; do
181 if [ -e $test_prefix ] ; then
182 if [ ! -d $test_prefix ] ; then
183 printf "incorrect ('%s' is not a directory)!\n" $test_prefix
184 exit 1
185 fi
186 if [ ! -w $test_prefix ] ; then
187 printf "okay (but no write access to '%s')\n" \
188 "$test_prefix"
189 else
190 printf "okay\n"
191 fi
192 break
193 fi
194 test_prefix=$(dirname $test_prefix)
195 done
196
197 #
198 # Check for lndir
199 #
200
201 printf "Checking for lndir ... "
202
203 mkdir conf1.$$
204 touch conf1.$$/f
205 mkdir conf2
206 mkdir conf3
207 lndir -silent ../conf1.$$ conf2 > /dev/null 2>&1 && [ -h conf2/f ]
208 lndir_silent=$?
209 rm -rf conf2
210 lndir ../conf1.$$ conf3 > /dev/null 2>&1 && [ -h conf3/f ]
211 lndir_verbose=$?
212 rm -rf conf3
213 rm -rf conf1.$$
214
215 if [ $lndir_silent -eq 0 ] ; then
216 printf "yes (supports -silent)\n"
217 lndir_silent_flag=-silent
218 elif [ $lndir_verbose -eq 0 ] ; then
219 printf "yes (no -silent)\n"
220 lndir_silent_flag=
221 else
222 printf "nonworking/missing\n"
223 exit 1
224 fi
225
226 #
227 # Check for GNU make
228 #
229
230 printf "Checking for GNU Make ... "
231
232 output=$(make --version 2>&1)
233 set -- $output
234
235 if [ $1 != "GNU" -o $2 != "Make" ] ; then
236 printf "missing\n"
237 exit 1
238 fi
239
240 make_version=$3
241
242 save_ifs=$IFS ; IFS=. ; set -- $make_version ; IFS=$save_ifs
243
244 if [ $1 -lt 3 -o \( $1 -eq 3 -a $2 -lt 80 \) ] ; then
245 printf "too old (%s found, 3.80 or newer needed)\n" $make_version
246 exit 1
247 else
248 printf "yes (%s found)\n" $make_version
249 fi
250
251 #
252 # Check for CLISP
253 #
254
255 printf "Checking for CLISP ... "
256
257 output=$(clisp --version 2>&1)
258 set -- $output
259
260 if [ $1 != "GNU" -o $2 != "CLISP" ] ; then
261 printf "missing\n"
262 exit 1
263 fi
264
265 clisp_version=$3
266
267 save_ifs=$IFS ; IFS=. ; set -- $clisp_version ; IFS=$save_ifs
268
269 if [ $1 -lt 2 -o \( $1 -eq 2 -a $2 -lt 38 \) ] ; then
270 printf "too old (%s found, 2.38 or newer needed)\n" $clisp_version
271 exit 1
272 else
273 printf "yes (%s found)\n" $clisp_version
274 fi
275
276 #
277 # First, we have to figure out whether we are configured straight
278 # in the source directory, or whether we are in a separate build directory.
279 # In the latter case, we set up a symbolic link to the Makefile.
280 #
281 source_dir=$(dirname $0)
282
283 #
284 # Compute an absolute path to the source directory.
285 #
286 top_srcdir="$(cd "$source_dir" ; pwd -P)"
287
288 if [ "$source_dir" != "." ] ; then
289 printf "symlinking Makefile -> $source_dir/Makefile\n"
290 ln -sf "$source_dir/Makefile" .
291
292 printf "symlinking code directory ...\n"
293 mkdir -p code
294 lndir $lndir_silent_flag $top_srcdir/code code
295 else
296 printf "warning: its recommended to build in a separate directory\n"
297 fi
298
299 #
300 # Establish default values for any variables that are not specified
301 # on the command line.
302 #
303 prefix=${prefix-/usr/local}
304
305 #
306 # Save configuration in config.log
307 #
308 cat > config.log <<!
309
310 Configured on $(date) using
311
312 $cmdline
313
314 !
315
316 #
317 # Finally, we generate config.make
318 #
319 printf "generating config.make\n"
320
321 cat > config.make <<!
322 # absolute path to source code directory
323 top_srcdir := $top_srcdir
324
325 # installation prefix
326 prefix := $prefix
327 !

  ViewVC Help
Powered by ViewVC 1.1.5