2 # Configuration script for GNU Emacs
3 # Copyright (C) 1992 Free Software Foundation, Inc.
5 #This file is part of GNU Emacs.
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)
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.
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.
21 # Shell script to edit files and make symlinks in preparation for
24 # Usage: configure machine
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.
31 # Remove any leading "." elements from the path name. If we don't
32 # remove them, then another "./" will be prepended to the file name
33 # each time we use config.status, and the program name will get larger
34 # and larger. This wouldn't be a problem, except that since progname
35 # gets recorded in all the Makefiles this script produces,
36 # move-if-changed thinks they're different when they're not.
38 # It would be nice if we could put the ./ in a \( \) group and then
39 # apply the * operator to that, so we remove as many leading ./././'s
40 # as are present, but some seds (like Ultrix's sed) don't allow you to
41 # apply * to a \( \) group. Bleah.
42 progname
="`echo $0 | sed 's:^\./::'`"
44 short_usage
="Type \`${progname} -usage' for more information about options."
46 usage_message
="Usage: ${progname} MACHINENAME [-OPTION[=VALUE] ...]
48 This message needs to be updated.
50 Set compilation and installation parameters for GNU Emacs, and report.
51 MACHINENAME is the machine to build for. See \`etc/MACHINES'.
53 --opsystem=SYSTEM - operating system to build for; see \`etc/MACHINES'.
54 --prefix=DIR - where to install Emacs's library files
55 These options have reasonable defaults (in []s), and may not be needed:
56 -g, -O - Passed to the compiler. Default is -g, plus -O if using gcc.
57 --cc=COMPILER - Which compiler to use. Defaults to gcc if available.
58 --libdir=DIR - where to look for arch-dependent library files
59 --datadir=DIR - where to look for architecture-independent library files
60 --bindir=DIR - where to install the Emacs executable, and some friends
61 --lisppath=PATH - colon-separated list of Emacs Lisp directories
62 --lockdir=DIR - where Emacs should do its file-locking stuff
63 --with-x or --with-x10 - what window system to use;
64 default is to use X11 if present
65 If successful, ${progname} leaves its status in config.status. If
66 unsuccessful after disturbing the status quo, config.status is removed."
67 # These are omitted since users should not mess with them.
68 # --gnu-malloc=[yes] or no - use the GNU memory allocator
69 # --rel-alloc=[yes] or no - use compacting allocator for buffers
70 # --lisp-float-type=[yes] or no - Support floating point in Emacs Lisp.
71 # --window-system is omitted because --with... follow the conventions.
73 if [ ! -r .
/src
/lisp.h
]; then
74 echo "${progname}: Can't find Emacs sources in \`./src'.
75 Run this config script in the top directory of the Emacs source tree." >&2
79 # The option names defined here are actually the shell variable names.
80 # They should have `_' in place of `-'.
85 prefix:bindir:emacsdir:datadir:lispdir:locallisppath:\
86 lisppath:buildlisppath:statedir:lockdir:libdir:mandir:infodir:\
87 gnu_malloc:rel_alloc:lisp_float_type:\
93 gnu_malloc:rel_alloc:lisp_float_type:have_x_menu:with_x:with_x11:with_x10:\
97 gnu_malloc:rel_alloc:lisp_float_type:\
98 have_x_windows:have_x11:\
99 c_switch_site:sigtype:\
103 bindir
=/usr
/local
/bin
107 # The default values for the following options are guessed at after other
108 # options have been checked and given values, so we set them to null here.
115 # Record all the arguments, so we can save them in config.status.
118 echo "Examining options."
119 while [ $# != 0 ]; do
123 # Separate the switch name from the value it's being given.
124 # Also change `-' in the option name to `_'.
127 opt
=`echo ${arg} | sed 's:^-*\([^=]*\)=.*$:\1:' | tr - _`
128 val
=`echo ${arg} | sed 's:^-*[^=]*=\(.*\)$:\1:'`
132 # If FOO is a boolean argument, -FOO is equivalent to
133 # -FOO=yes. Otherwise, the value comes from the next
134 # argument - see below.
135 opt
=`echo ${arg} | sed 's:^-*\(.*\)$:\1:' | tr - _`
141 # Make sure the argument is valid and unambiguous.
143 *:${opt}:* ) # Exact match.
146 *:${opt}*:${opt}*:* ) # Ambiguous prefix.
147 echo "\`-${opt}' is an ambiguous switch; it could be any of the following:"
148 # We can't just use tr to translate colons to newlines, since
149 # BSD sed and SYSV sed use different syntaxes for that.
150 spaced_options
=`echo ${options} | tr ':' ' '`
151 echo `(for option in ${spaced_options}; do echo $option; done) \
156 *:${opt}*:* ) # Unambigous prefix.
157 optvar
=`echo ${options} | sed 's/^.*:\('${opt}'[^:]*\):.*$/\1/'`
160 (echo "\`-${opt}' is not a valid option."
161 echo "${short_usage}") |
more
168 echo "${usage_message}" |
more
173 # If the variable is supposed to be boolean, make sure the value
174 # given is either "yes" or "no". If not, make sure some value
176 case "${boolean_opts}" in
179 y | ye |
yes ) val
=yes ;;
182 echo "The \`-${optvar}' option (\`-${opt}') is supposed to have a boolean
183 value - set it to either \`yes' or \`no'." >&2
189 if [ "${valomitted}" = "yes" ]; then
191 (echo "${progname}: You must give a value for the \`-${opt}' option, as in
193 echo "${short_usage}") |
more
201 eval "${optvar}=\"${val}\""
210 if [ "${machine}" = "" ]; then
211 (echo "You must specify a machine name as an argument to ${progname}."
212 echo "${short_usage}") |
more
216 echo "Checking the machine."
217 machfile
="m/${machine}.h"
218 if [ ! -r src
/${machfile} ]; then
219 echo "${progname}: Emacs has no configuration info for the machine called
220 \`${machine}'. Look at etc/MACHINES for the names of machines
221 that Emacs has been ported to." >&2
225 echo "Checking the operating system."
226 if [ "${opsystem}" = "" ]; then
228 echo " No operating system explicitly specified."
229 echo " Guessing, based on machine."
230 # Get the default operating system to go with the specified machine.
231 opsystem
=`grep 'USUAL-OPSYS="' src/${machfile} \
232 | sed 's/^.*USUAL-OPSYS="\([^"]*\)".*$/\1/'`
234 if [ "${opsystem}" = "" ]; then
235 echo "${progname}: Emacs's configuration files don't suggest what operating
236 system a \`${machine}' machine might run. Try specifying the
237 operating system explicitly by passing ${progname} an
238 \`-opsystem=SYSTEM-NAME' flag. Look at etc/MACHINES for the
239 names of operating systems that Emacs has been ported to." >&2
243 if [ "${opsystem}" = "note" ]; then
244 echo "The \`${machine}' machine can be used with more than one operating
245 system, and Emacs's configuration info isn't clever enough to figure
246 out which one you're running. Run ${progname} with -machine and
247 -opsystem arguments as specified below for the appropriate system.
248 (This information comes from the file \`etc/MACHINES' - see that
249 file for more detail.)
252 sed < src
/${machfile} -e '1,/NOTE-START/d' -e '/NOTE-END/,$d' |
more
257 opsysfile
="s/${opsystem}.h"
258 if [ ! -r src
/${opsysfile} ]; then
259 echo "${progname}: Emacs's configuration files say that the default
260 operating system for the machine \`${machine}' is \`${opsystem}',
261 but there is no configuration file for \`${opsystem}', so Emacs's
262 default info is screwed up. Try specifying the operating system
263 explicitly by passing ${progname} an \`-opsystem=SYSTEM-NAME' flag." >&2
267 opsysfile
="s/${opsystem}.h"
268 if [ ! -r src
/${opsysfile} ]; then
269 echo "${progname}: Emacs has no configuration info for the operating system
270 \`${opsystem}'. Look at etc/MACHINES for the names of operating
271 systems that Emacs has been ported to." >&2
276 if [ ! "${prefix}" ]; then
280 if [ ! "${emacsdir}" ]; then
281 emacsdir
="${prefix}/emacs-19.0"
284 if [ ! "${datadir}" ]; then
285 datadir
="${emacsdir}/etc"
288 if [ ! "${lispdir}" ]; then
289 lispdir
="${emacsdir}/lisp"
292 if [ ! "${locallisppath}" ]; then
293 locallisppath
="${emacsdir}/local-lisp"
296 if [ ! "${lisppath}" ]; then
297 lisppath
="${locallisppath}:${lispdir}"
300 if [ ! "${buildlisppath}" ]; then
301 buildlisppath
=..
/lisp
304 if [ ! "${statedir}" ]; then
305 statedir
="${emacsdir}"
308 if [ ! "${lockdir}" ]; then
309 lockdir
="${statedir}/lock"
312 if [ "${libdir}" = "" ]; then
313 libdir
="${emacsdir}/arch-lib"
316 if [ ! "${mandir}" ]; then
317 mandir
="/usr/man/man1"
320 if [ ! "${infodir}" ]; then
321 infodir
="${prefix}/info"
324 echo "Checking window system."
325 case "${with_x11}" in
327 window_system
=${window_system}x11
332 window_system
=${window_system}x11
335 case "${with_x10}" in
337 window_system
=${window_system}x10
341 # Note that SYSV `tr' doesn't handle character ranges.
342 window_system
="`echo ${window_system} \
343 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
344 case "${window_system}" in
345 "none" |
"x11" |
"x10" ) ;;
346 "x" ) window_system
=x11
;;
348 echo " No window system specifed. Looking for X Windows."
350 if [ -r /usr
/lib
/libX11.a
-o -d /usr
/include
/X11
]; then
355 echo "Don\'t specify the window system more than once." >&2
360 case "${window_system}" in
375 echo "Checking for GCC."
378 temppath
=`echo $PATH | sed 's/^:/.:/
383 for dir in ${temppath}; do
384 if [ -f ${dir}/gcc ]; then echo gcc; exit 0; fi
393 # With GCC, both O and g should default to yes, no matter what
402 # With other compilers, treat them as mutually exclusive,
403 # defaulting to debug.
414 # What is the return type of a signal handler? We run
415 # /usr/include/signal.h through cpp and grep for the declaration of
416 # the signal function. Yuck.
417 echo "Looking for return type of signal handler functions."
419 if [ -r /usr
/include
/signal.h
]; then
420 signal_h_file
=/usr
/include
/signal.h
421 elif [ -r /usr
/include
/sys
/signal.h
]; then
422 signal_h_file
=/usr
/include
/sys
/signal.h
425 if [ "${signal_h_file}" ]; then
426 sigpattern
='[ ]*([ ]*\*[ ]*signal[ ]*('
428 # We make a copy whose name ends in .c, so the compiler
429 # won't complain about having only been given a .h file.
430 tempcname
="configure.tmp.$$.c"
431 cp ${signal_h_file} ${tempcname}
432 if ${cc} -E ${tempcname} | grep "int${sigpattern}" > /dev/null; then
438 echo "Examining the machine- and system-dependent files to
find out
"
439 echo " - which libraries the lib-src programs will want
, and
"
440 echo " - whether the GNU malloc routines are usable.
"
441 tempcname="configure.tmp.$$.c
"
442 echo '#include "src
/'${opsysfile}'"
443 #include "src
/'${machfile}'"
450 @configure@ libsrc_libs=LIBS_MACHINE LIBS_SYSTEM
452 @configure@ system_malloc=yes
454 @configure@ system_malloc=no
457 eval `${cc} -E ${tempcname} \
458 | grep '@configure@' \
459 | sed -e 's/^@configure@//'`
462 # Do the opsystem or machine files prohibit the use of the GNU malloc?
463 if [ "${system_malloc}" = "yes" ]; then
466 (The GNU allocators don
't work with this machine and/or operating system.)"
469 if [ ! "${rel_alloc}" ]; then
470 rel_alloc=${gnu_malloc}
476 # Make the proper settings in the config file.
477 echo "Making src/config.h from src/config.h.in"
479 "yes" ) c_switch_site="${c_switch_site} -g" ;;
482 "yes" ) c_switch_site="${c_switch_site} -O" ;;
484 sed_flags="-e 's
:@machine@
:${machfile}:'"
485 sed_flags="${sed_flags} -e 's
:@opsystem@
:${opsysfile}:'"
486 for flag in `echo ${config_h_opts} | tr ':' ' '`; do
487 # Note that SYSV `tr' doesn
't handle character ranges.
488 cflagname=`echo ${flag} \
489 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
490 val=`eval echo '$
'${flag}`
493 f="-e 's
:.
*#define ${cflagname}.*:/\\* #define ${cflagname} \\*/:'"
496 f
="-e 's:.*#define ${cflagname}.*:#define ${cflagname}:'"
499 f
="-e 's:.*#define ${cflagname}.*:#define ${cflagname} ${val}:'"
502 sed_flags
="${sed_flags} ${f}"
504 rm -f src
/config.h.tmp
505 eval '/bin/sed '${sed_flags}' < src/config.h.in > src/config.h.tmp'
506 .
/move-if-change src
/config.h.tmp src
/config.h
507 # Remind people not to edit this.
508 chmod -w src
/config.h
510 # Modify the parameters in the top makefile.
511 echo "Producing ./Makefile from ./Makefile.in."
513 (echo "# This file is generated by \`${progname}' from \`./Makefile.in'.
514 # If you are thinking about editing it, you should seriously consider
515 # editing \`./Makefile.in' itself, or running \`${progname}' instead."
516 /bin
/sed < Makefile.
in \
518 -e 's;^\(prefix=\).*$;\1'"${prefix};" \
519 -e 's;^\(bindir=\).*$;\1'"${bindir};" \
520 -e 's;^\(emacsdir=\).*$;\1'"${emacsdir};" \
521 -e 's;^\(datadir=\).*$;\1'"${datadir};" \
522 -e 's;^\(lispdir=\).*$;\1'"${lispdir};" \
523 -e 's;^\(locallisppath=\).*$;\1'"${locallisppath};" \
524 -e 's;^\(lisppath=\).*$;\1'"${lisppath};" \
525 -e 's;^\(buildlisppath=\).*$;\1'"${buildlisppath};" \
526 -e 's;^\(statedir=\).*$;\1'"${statedir};" \
527 -e 's;^\(lockdir=\).*$;\1'"${lockdir};" \
528 -e 's;^\(libdir=\).*$;\1'"${libdir};" \
529 -e 's;^\(mandir=\).*$;\1'"${mandir};" \
530 -e 's;^\(infodir=\).*$;\1'"${infodir};" \
532 .
/move-if-change Makefile.tmp Makefile
533 # Remind people not to edit this.
536 # Modify the parameters in the `build-install' script.
537 echo "Producing ./build-install from ./build-install.in."
538 rm -f .
/build-install.tmp
539 (echo "# This file is generated by \`${progname}' from \`./build-install.in'.
540 # If you are thinking about editing it, you should seriously consider
541 # editing \`./build-install.in' itself, or running \`${progname}' instead."
542 /bin
/sed < build-install.
in \
543 -e 's;^\(prefix=\).*$;\1'"${prefix};" \
544 -e 's;^\(bindir=\).*$;\1'"${bindir};" \
545 -e 's;^\(lisppath=\).*$;\1'"${lisppath};" \
546 -e 's;^\(datadir=\).*$;\1'"${datadir};" \
547 -e 's;^\(lockdir=\).*$;\1'"${lockdir};" \
548 -e 's;^\(libdir=\).*$;\1'"${libdir};") > .
/build-install.tmp
549 .
/move-if-change build-install.tmp build-install
550 # Remind people not to edit this.
551 chmod -w build-install
552 chmod +x build-install
554 # Modify the parameters in the src makefile.
555 echo "Producing src/Makefile from src/Makefile.in."
556 rm -f src
/Makefile.tmp
557 (echo "# This file is generated by \`${progname}' from \`Makefile.in'.
558 # If you are thinking about editing it, you should seriously consider
559 # editing \`Makefile.in' itself, or running \`${progname}' instead."
560 /bin
/sed < src
/Makefile.
in \
562 -e 's;^\(CC[ ]*=\).*$;\1'"${cc};") > src
/Makefile.tmp
563 .
/move-if-change src
/Makefile.tmp src
/Makefile
564 # Remind people not to edit this.
565 chmod -w src
/Makefile
567 # Modify the parameters in the lib-src makefile.
568 echo "Producing lib-src/Makefile from lib-src/Makefile.in."
569 rm -f lib-src
/Makefile.tmp
570 (echo "# This file is generated by \`${progname}' from \`Makefile.in'.
571 # If you are thinking about editing it, you should seriously consider
572 # editing \`Makefile.in' itself, or running \`${progname}' instead."
573 /bin
/sed < lib-src
/Makefile.
in \
575 -e 's;^\(CFLAGS=\).*$;\1'"${c_switch_site};" \
576 -e 's;^\(LOADLIBES=\).*$;\1'"${libsrc_libs};" \
577 -e 's;^\(CC=\).*$;\1'"${cc};") > lib-src
/Makefile.tmp
578 .
/move-if-change lib-src
/Makefile.tmp lib-src
/Makefile
579 # Remind people not to edit this.
580 chmod -w lib-src
/Makefile
583 # Create a verbal description of what we have done.
584 message
="Configured for machine \`${machine}' running \`${opsystem}'.
585 The following values have been set in ./Makefile and ./build-install:
586 \`make install' or \`build-install' will placed executables in
588 Emacs's lisp search path will be
590 Emacs will look for its architecture-independent data in
592 Emacs will look for its utility programs and other architecture-
595 Emacs will keep track of file-locking in
597 The following values have been set in src/config.h:
598 Should Emacs use the GNU version of malloc? ${gnu_malloc}${gnu_malloc_reason}
599 Should Emacs use the relocating allocator for buffers? ${rel_alloc}
600 Should Emacs support a floating point data type? ${lisp_float_type}
601 What window system should Emacs use? ${window_system}
602 What compiler should emacs be built with? ${cc}
603 Should the compilation use \`-g' and/or \`-O'? ${c_switch_site- neither}"
605 # Document the damage we have done by writing config.status.
607 echo '#!/bin/sh' > config.status
609 echo "# This file is generated by \`${progname}.'
610 # If you are thinking about editing it, you should seriously consider
611 # running \`${progname}' instead.
613 echo "${message}" |
sed -e 's/^/# /' >> config.status
614 echo "'${progname}' ${arguments} "'$@' >> config.status
615 # Remind people not to edit this.
616 chmod -w config.status
617 chmod +x config.status
619 # Print the description.