]> code.delx.au - gnu-emacs/blob - configure1.in
*** empty log message ***
[gnu-emacs] / configure1.in
1 #!/bin/sh
2 # Configuration script for GNU Emacs
3 # Copyright (C) 1992 Free Software Foundation, Inc.
4
5 #This file is part of GNU Emacs.
6
7 #GNU Emacs is free software; you can redistribute it and/or modify
8 #it under the terms of the GNU General Public License as published by
9 #the Free Software Foundation; either version 1, or (at your option)
10 #any later version.
11
12 #GNU Emacs is distributed in the hope that it will be useful,
13 #but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 #GNU General Public License for more details.
16
17 #You should have received a copy of the GNU General Public License
18 #along with GNU Emacs; see the file COPYING. If not, write to
19 #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 # Shell script to edit files and make symlinks in preparation for
22 # compiling Emacs.
23 #
24 # Usage: configure machine
25 #
26 # If configure succeeds, it leaves its status in config.status.
27 # If configure fails after disturbing the status quo,
28 # config.status is removed.
29 #
30
31 progname=$0
32
33 short_usage="Type \`${progname} -usage' for more information about options."
34
35 usage_message="Usage: ${progname} MACHINENAME [-OPTION[=VALUE] ...]
36 Set compilation and installation parameters for GNU Emacs, and report.
37 MACHINENAME is the machine to build for. See \`etc/MACHINES'.
38 Options are:
39 -opsystem=SYSTEM - operating system to build for; see \`etc/MACHINES'.
40 -libroot=DIR - where to install Emacs's library files
41 These options have reasonable defaults (in []s), and may not be needed:
42 -g, -O - Passed to the compiler. If omitted, use -O only.
43 -cc=COMPILER - Which compiler to use. Defaults to gcc if available.
44 -libdir=DIR - where to look for arch-dependent library files
45 -datadir=DIR - where to look for architecture-independent library files
46 -bindir=DIR - where to install the Emacs executable, and some friends
47 -lisppath=PATH - colon-separated list of Elisp directories
48 -lockdir=DIR - where Emacs should do its file-locking stuff
49 -window_system=none or [x11, if it is installed] - what window system to use
50 -have_x_menu=yes or [no] - include menu support under X11
51 -gnu_malloc=[yes] or no - use the GNU memory allocator
52 -rel_alloc=[yes] or no - use compacting allocator for buffers
53 -highpri=N - run at N points higher-than-normal priority
54 -lisp_float_type=[yes] or no - Support native floating point in Elisp
55 If successful, ${progname} leaves its status in config.status. If
56 unsuccessful after disturbing the status quo, config.status is removed."
57
58 if [ ! -r ./src/lisp.h ]; then
59 echo "${progname}: Can't find Emacs sources in \`./src'.
60 Run this config script in the top directory of the Emacs source tree." 1>&2
61 exit 1
62 fi
63
64 options=":\
65 usage:help:\
66 machine:opsystem:\
67 g:O:cc:\
68 libroot:datadir:libdir:bindir:lisppath:lockdir:\
69 gnu_malloc:rel_alloc:highpri:lisp_float_type:\
70 window_system:have_x_menu:\
71 "
72
73 boolean_opts=":\
74 g:O:\
75 gnu_malloc:rel_alloc:lisp_float_type:have_x_menu:\
76 "
77
78 config_h_opts=":\
79 highpri:gnu_malloc:rel_alloc:lisp_float_type:\
80 have_x_windows:have_x11:have_x_menu:\
81 c_switch_site:sigtype:\
82 "
83
84 libroot=
85 bindir=/usr/local/bin
86 gnu_malloc=yes
87 lisp_float_type=yes
88
89 # The default values for the following options are guessed at after other
90 # options have been checked and given values, so we set them to null here.
91 lisppath=""
92 datadir=""
93 libdir=""
94 lockdir=""
95 window_system=""
96 have_x_menu=""
97
98 # This must be the only option on the line, and it can't be abbreviated.
99 # This keeps it from interfering with the other, documented options.
100 if [ "$*" = "+distribute" ]; then
101 libroot=/usr/local/lib/emacs
102 machine=hp300bsd
103 opsystem=bsd4-3
104 shift
105 fi
106
107 echo "Examining options..."
108 for arg in $*; do
109 case "${arg}" in
110 -*)
111 # Separate the switch name from the value it's being given.
112 case "${arg}" in
113 -*=* )
114 opt=`echo ${arg} | sed 's:^-\([^=]*\)=.*$:\1:'`
115 val=`echo ${arg} | sed 's:^-[^=]*=\(.*\)$:\1:'`
116 valomitted=no
117 ;;
118 -* )
119 # If FOO is a boolean argument, -FOO is equivalent to -FOO=yes.
120 opt=`echo ${arg} | sed 's:^-\(.*\)$:\1:'`
121 val="yes"
122 valomitted=yes
123 ;;
124 esac
125
126 # Make sure the argument is valid and unambiguous.
127 case ${options} in
128 *:${opt}:* ) # Exact match.
129 optvar=${opt}
130 ;;
131 *:${opt}*:${opt}*:* ) # Ambiguous prefix.
132 echo "\`-${opt}' is an ambiguous switch; it could be any of the following:"
133 echo `echo ${options} | tr ':' '\012' | grep '^'${opt}`
134 echo ${short_usage}
135 exit 1
136 ;;
137 *:${opt}*:* ) # Unambigous prefix.
138 optvar=`echo ${options} | sed 's/^.*:\('${opt}'[^:]*\):.*$/\1/'`
139 ;;
140 * )
141 (echo "\`-${opt}' is not a valid option."
142 echo "${short_usage}") | more
143 exit 1
144 ;;
145 esac
146
147 case "${optvar}" in
148 usage | help)
149 echo "${usage_message}" | more
150 exit 1
151 ;;
152 esac
153
154 # If the variable is supposed to be boolean, make sure the value
155 # given is either "yes" or "no". If not, make sure some value
156 # was given.
157 case "${boolean_opts}" in
158 *:${optvar}:* )
159 case "${val}" in
160 y | ye | yes ) val=yes ;;
161 n | no ) val=no ;;
162 * )
163 echo "The \`-${optvar}' option (\`-${opt}') is supposed to have a boolean
164 value - set it to either \`yes' or \`no'." 1>&2
165 exit 1
166 ;;
167 esac
168 ;;
169 *)
170 if [ "${valomitted}" = "yes" ]; then
171 (echo "${progname}: You must give a value for the \`-${opt}' option, as in
172 \`-${opt}=FOO'."
173 echo "${short_usage}") | more
174 exit 1
175 fi
176 ;;
177 esac
178
179 eval "${optvar}=\"${val}\""
180 ;;
181 *)
182 machine=${arg}
183 ;;
184 esac
185 done
186
187 if [ "${machine}" = "" ]; then
188 (echo "You must specify a machine name as an argument to ${progname}."
189 echo "${short_usage}") | more
190 exit 1
191 fi
192
193 echo "Checking machine..."
194 machfile="m/${machine}.h"
195 if [ ! -r src/${machfile} ]; then
196 echo "${progname}: Emacs has no configuration info for the machine called
197 \`${machine}'. Look at etc/MACHINES for the names of machines
198 that Emacs has been ported to." 1>&2
199 exit 1
200 fi
201
202 echo "Checking operating system..."
203 if [ "${opsystem}" = "" ]; then
204
205 echo " No operating system explicitly specified."
206 echo " Guessing, based on machine..."
207 # Get the default operating system to go with the specified machine.
208 opsystem=`grep 'USUAL-OPSYS="' src/${machfile} \
209 | sed 's/^.*USUAL-OPSYS="\([^"]*\)".*$/\1/'`
210
211 if [ "${opsystem}" = "" ]; then
212 echo "${progname}: Emacs's configuration files don't suggest what operating
213 system a \`${machine}' machine might run. Try specifying the
214 operating system explicitly by passing ${progname} an
215 \`-opsystem=SYSTEM-NAME' flag. Look at etc/MACHINES for the
216 names of operating systems that Emacs has been ported to." 1>&2
217 exit 1
218 fi
219
220 if [ "${opsystem}" = "note" ]; then
221 echo "The \`${machine}' machine can be used with more than one operating
222 system, and Emacs's configuration info isn't clever enough to figure
223 out which one you're running. Run ${progname} with -machine and
224 -opsystem arguments as specified below for the appropriate system.
225 (This information comes from the file \`etc/MACHINES' - see that
226 file for more detail.)
227
228 " 1>&2
229 sed < src/${machfile} -e '1,/NOTE-START/d' -e '/NOTE-END/,$d' | more
230 echo
231 exit 1
232 fi
233
234 opsysfile="s/${opsystem}.h"
235 if [ ! -r src/${opsysfile} ]; then
236 echo "${progname}: Emacs's configuration files say that the default
237 operating system for the machine \`${machine}' is \`${opsystem}',
238 but there is no configuration file for \`${opsystem}', so Emacs's
239 default info is screwed up. Try specifying the operating system
240 explicitly by passing ${progname} an \`-opsystem=SYSTEM-NAME' flag." 1>&2
241 exit 1
242 fi
243 else
244 opsysfile="s/${opsystem}.h"
245 if [ ! -r src/${opsysfile} ]; then
246 echo "${progname}: Emacs has no configuration info for the operating system
247 \`${opsystem}'. Look at etc/MACHINES for the names of operating
248 systems that Emacs has been ported to." 1>&2
249 exit 1
250 fi
251 fi
252
253 if [ "${libroot}" = "" ]; then
254 echo "Guessing library directory..."
255 libroot=`/bin/pwd`
256 fi
257
258 echo "Checking window system..."
259 window_system="`echo ${window_system} | tr A-Z a-z`"
260 case "${window_system}" in
261 "none" | "x11" | "x10" ) ;;
262 "x" ) window_system=x11 ;;
263 "" )
264 echo " No window system specifed. Looking for X Windows."
265 window_system=none
266 if [ -r /usr/lib/libX11.a -a -d /usr/include/X11 ]; then
267 window_system=x11
268 fi
269 ;;
270 * )
271 echo "The \`-window_system' option must be set to \`none' or \`X11'." 1>&2
272 exit 1
273 ;;
274 esac
275
276 case "${window_system}" in
277 x11 )
278 have_x_windows=yes
279 have_x11=yes
280 ;;
281 x10 )
282 have_x_windows=yes
283 have_x11=no
284 ;;
285 none )
286 have_x_windows=no
287 have_x11=no
288 ;;
289 esac
290
291 # What is the return type of a signal handler? We grep
292 # /usr/include/signal.h for the declaration of the signal function.
293 # Yuck.
294 echo "Looking for return type of signal handler functions..."
295 if [ -r /usr/include/signal.h ]; then
296 sigpattern='[ ]*([ ]*\*[ ]*signal[ ]*('
297 sigtype=void
298 if grep -s "int${sigpattern}" /usr/include/signal.h; then
299 sigtype=int
300 fi
301 fi
302
303
304 # Do the opsystem or machine files prohibit the use of the GNU malloc?
305 echo "Checking to see if the GNU malloc routines are permissible..."
306 if (cd ./src;grep SYSTEM_MALLOC ${opsysfile} ${machfile} > /dev/null); then
307 gnu_malloc=no
308 gnu_malloc_reason="
309 (The GNU allocators don't work with this machine and/or operating system.)"
310 fi
311
312 rel_alloc=${gnu_malloc}
313
314 if [ "${have_x_menu}" = "" ]; then
315 have_x_menu=no
316 fi
317
318 if [ "${lisppath}" = "" ]; then
319 lisppath=${libroot}/local-lisp:${libroot}/lisp
320 fi
321
322 if [ "${datadir}" = "" ]; then
323 datadir=${libroot}/etc
324 fi
325
326 if [ "${libdir}" = "" ]; then
327 libdir=${libroot}/arch-lib
328 fi
329
330 if [ "${lockdir}" = "" ]; then
331 lockdir=${libroot}/lock
332 fi
333
334 echo "Checking for GCC..."
335 case "${cc}" in
336 "" )
337 temppath=`echo $PATH | sed 's/^:/.:/
338 s/::/:.:/g
339 s/:$/:./
340 s/:/ /g'`
341 cc=`(
342 for dir in ${temppath}; do
343 if [ -f ${dir}/gcc ]; then echo gcc; exit 0; fi
344 done
345 echo cc
346 )`
347 ;;
348 esac
349
350 case "${O},${g},${cc}" in
351 ,,gcc ) O=yes; g=yes ;;
352 ,,* ) O=yes; g=no ;;
353 esac
354
355 echo "Guessing which libraries the lib-src programs will want,"
356 echo " based on the machine- and system-dependent files..."
357 echo '#include "src/'${machfile}'"
358 #include "src/'${opsysfile}'"
359 #ifndef LIBS_MACHINE
360 #define LIBS_MACHINE
361 #endif
362 #ifndef LIBS_SYSTEM
363 #define LIBS_SYSTEM
364 #endif
365 libsrc_libs=LIBS_MACHINE LIBS_SYSTEM
366 ' > config-tmp-$$.c
367 eval `${cc} -E config-tmp-$$.c | grep 'libsrc_libs='`
368 rm config-tmp-$$.c
369
370 rm -f config.status
371 set -e
372
373 # Make the proper settings in the config file.
374 echo "Making src/config.h from src/config.h-dist"
375 if [ "${highpri}" != "" ]; then
376 highpri="(-${highpri})"
377 fi
378 case "${g}" in
379 "yes" ) c_switch_site="${c_switch_site} -g" ;;
380 esac
381 case "${O}" in
382 "yes" ) c_switch_site="${c_switch_site} -O" ;;
383 esac
384 sed_flags="-e 's:@machine@:${machfile}:'"
385 sed_flags="${sed_flags} -e 's:@opsystem@:${opsysfile}:'"
386 for flag in `echo ${config_h_opts} | tr ':' ' '`; do
387 cflagname=`echo ${flag} | tr a-z A-Z`
388 val=`eval echo '$'${flag}`
389 case ${val} in
390 no | "")
391 f="-e 's:.*#define ${cflagname}.*:/\\* #define ${cflagname} \\*/:'"
392 ;;
393 yes)
394 f="-e 's:.*#define ${cflagname}.*:#define ${cflagname}:'"
395 ;;
396 *)
397 f="-e 's:.*#define ${cflagname}.*:#define ${cflagname} ${val}:'"
398 ;;
399 esac
400 sed_flags="${sed_flags} ${f}"
401 done
402 eval '/bin/sed '${sed_flags}' < src/config.h-dist > src/config.h'
403
404 # Modify the parameters in the top makefile.
405 echo "Editing ./Makefile..."
406 tempMakefile="tempMakefile"$$
407 /bin/sed < Makefile > ${tempMakefile} \
408 -e 's;^\(LIBROOT=\).*$;\1'"${libroot};" \
409 -e 's;^\(BINDIR=\).*$;\1'"${bindir};" \
410 -e 's;^\(LISPPATH=\).*$;\1'"${lisppath};" \
411 -e 's;^\(DATADIR=\).*$;\1'"${datadir};" \
412 -e 's;^\(LOCKDIR=\).*$;\1'"${lockdir};" \
413 -e 's;^\(LIBDIR=\).*$;\1'"${libdir};"
414 mv ${tempMakefile} Makefile
415
416 # Modify the parameters in the `build-install' script.
417 echo "Editing ./build-install..."
418 tempbi="tempbi"$$
419 /bin/sed < build-install > ${tempbi} \
420 -e 's;^\(LIBROOT=\).*$;\1'"${libroot};" \
421 -e 's;^\(BINDIR=\).*$;\1'"${bindir};" \
422 -e 's;^\(LISPPATH=\).*$;\1'"${lisppath};" \
423 -e 's;^\(DATADIR=\).*$;\1'"${datadir};" \
424 -e 's;^\(LOCKDIR=\).*$;\1'"${lockdir};" \
425 -e 's;^\(LIBDIR=\).*$;\1'"${libdir};"
426 mv ${tempbi} build-install
427 chmod a+x build-install
428
429 # Modify the parameters in the src makefile.
430 echo "Editing src/Makefile..."
431 tempMakefile="tempMakefile"$$
432 /bin/sed < src/Makefile > ${tempMakefile} \
433 -e 's;^\(CC[ ]*=\).*$;\1'"${cc};"
434 mv ${tempMakefile} src/Makefile
435
436 # Modify the parameters in the lib-src makefile.
437 echo "Editing lib-src/Makefile..."
438 tempMakefile="tempMakefile"$$
439 /bin/sed < lib-src/Makefile > ${tempMakefile} \
440 -e 's;^\(CFLAGS=\).*$;\1'"${c_switch_site};" \
441 -e 's;^\(LOADLIBES=\).*$;\1'"${libsrc_libs};" \
442 -e 's;^\(CC=\).*$;\1'"${cc};"
443 mv ${tempMakefile} lib-src/Makefile
444
445 # Create a verbal description of what we have done.
446 message="# Configured for machine \`${machine}' running \`${opsystem}'.
447 # The following values have been set in ./Makefile and ./build-install:
448 # Executables will be placed in
449 # ${bindir}.
450 # Emacs's lisp search path will be
451 # \`${lisppath}'.
452 # Emacs will look for its architecture-independent data in
453 # ${datadir}.
454 # Emacs will look for its utility programs and other architecture-
455 # dependent data in
456 # ${libdir}.
457 # Emacs will keep track of file-locking in
458 # ${lockdir}.
459 # The following values have been set in src/config.h:
460 # At how much higher than normal priority should Emacs run? ${highpri-none}
461 # Should Emacs use the GNU version of malloc? ${gnu_malloc}${gnu_malloc_reason}
462 # Should Emacs use the relocating allocator for buffers? ${rel_alloc}
463 # Should Emacs support a floating point Elisp type? ${lisp_float_type}
464 # What window system should Emacs use? ${window_system}
465 # Should Emacs support mouse menus, which require X11? ${have_x_menu}
466 # What compiler should emacs be built with? ${cc}
467 # Should the compilation use \`-g' and/or \`-O'? ${c_switch_site- neither}"
468
469 # Document the damage we have done by writing config.status.
470
471 echo '#!/bin/sh' > config.status
472
473 echo "# This file is generated by \`${progname}.'
474 # If you are thinking about editing it, you should seriously consider
475 # running \`${progname}' instead.
476 " >> config.status
477 echo "${message}" >> config.status
478 echo "'${progname}' \\
479 -machine='${machine}' \\
480 -opsystem='${opsystem}' \\
481 -g=${g} \\
482 -O=${O} \\
483 -cc=${cc} \\
484 -libdir='${libdir}' \\
485 -datadir='${datadir}' \\
486 -bindir='${bindir}' \\
487 -lisppath='${lisppath}' \\
488 -lockdir='${lockdir}' \\
489 -window_system='${window_system}' \\
490 -have_x_menu='${have_x_menu}' \\
491 -gnu_malloc='${gnu_malloc}'
492 -rel_malloc='${rel_alloc}' \\
493 -highpri='${highpri}' \\
494 -lisp_float_type='${lisp_float_type}'" >> config.status
495 chmod +x config.status
496
497 # Print the description.
498 echo
499 echo "${message}" | sed -e 's/^# //'
500
501 exit 0