* keyboard.h (Qswitch_frame): Declare this extern.
[bpt/emacs.git] / 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 # 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.
37 #
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:^\./::'`"
43
44 short_usage="Type \`${progname} -usage' for more information about options."
45
46 usage_message="Usage: ${progname} MACHINENAME [-OPTION[=VALUE] ...]
47
48 This message needs to be updated.
49
50 Set compilation and installation parameters for GNU Emacs, and report.
51 MACHINENAME is the machine to build for. See \`etc/MACHINES'.
52 Options are:
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.
72
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
76 exit 1
77 fi
78
79 # The option names defined here are actually the shell variable names.
80 # They should have `_' in place of `-'.
81 options=":\
82 usage:help:\
83 machine:opsystem:\
84 g:O:cc:\
85 prefix:bindir:emacsdir:datadir:lispdir:locallisppath:\
86 lisppath:buildlisppath:statedir:lockdir:libdir:mandir:infodir:\
87 gnu_malloc:rel_alloc:lisp_float_type:\
88 window_system:\
89 "
90
91 boolean_opts=":\
92 g:O:\
93 gnu_malloc:rel_alloc:lisp_float_type:have_x_menu:with_x:with_x11:with_x10:\
94 "
95
96 config_h_opts=":\
97 gnu_malloc:rel_alloc:lisp_float_type:\
98 have_x_windows:have_x11:\
99 c_switch_site:sigtype:\
100 "
101
102 prefix=
103 bindir=/usr/local/bin
104 gnu_malloc=yes
105 lisp_float_type=yes
106
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.
109 lisppath=""
110 datadir=""
111 libdir=""
112 lockdir=""
113 window_system=""
114
115 # Record all the arguments, so we can save them in config.status.
116 arguments="$*"
117
118 echo "Examining options."
119 while [ $# != 0 ]; do
120 arg="$1"
121 case "${arg}" in
122 -*)
123 # Separate the switch name from the value it's being given.
124 # Also change `-' in the option name to `_'.
125 case "${arg}" in
126 -*=*)
127 opt=`echo ${arg} | sed 's:^-*\([^=]*\)=.*$:\1:' | tr - _`
128 val=`echo ${arg} | sed 's:^-*[^=]*=\(.*\)$:\1:'`
129 valomitted=no
130 ;;
131 -*)
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 - _`
136 val="yes"
137 valomitted=yes
138 ;;
139 esac
140
141 # Make sure the argument is valid and unambiguous.
142 case ${options} in
143 *:${opt}:* ) # Exact match.
144 optvar=${opt}
145 ;;
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) \
152 | grep "^${opt}"`
153 echo ${short_usage}
154 exit 1
155 ;;
156 *:${opt}*:* ) # Unambigous prefix.
157 optvar=`echo ${options} | sed 's/^.*:\('${opt}'[^:]*\):.*$/\1/'`
158 ;;
159 * )
160 (echo "\`-${opt}' is not a valid option."
161 echo "${short_usage}") | more
162 exit 1
163 ;;
164 esac
165
166 case "${optvar}" in
167 usage | help)
168 echo "${usage_message}" | more
169 exit 1
170 ;;
171 esac
172
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
175 # was given.
176 case "${boolean_opts}" in
177 *:${optvar}:* )
178 case "${val}" in
179 y | ye | yes ) val=yes ;;
180 n | no ) val=no ;;
181 * )
182 echo "The \`-${optvar}' option (\`-${opt}') is supposed to have a boolean
183 value - set it to either \`yes' or \`no'." >&2
184 exit 1
185 ;;
186 esac
187 ;;
188 *)
189 if [ "${valomitted}" = "yes" ]; then
190 if [ $# = 1 ]; then
191 (echo "${progname}: You must give a value for the \`-${opt}' option, as in
192 \`-${opt}=FOO'."
193 echo "${short_usage}") | more
194 exit 1
195 fi
196 shift; val="$1"
197 fi
198 ;;
199 esac
200
201 eval "${optvar}=\"${val}\""
202 ;;
203 *)
204 machine=${arg}
205 ;;
206 esac
207 shift
208 done
209
210 if [ "${machine}" = "" ]; then
211 (echo "You must specify a machine name as an argument to ${progname}."
212 echo "${short_usage}") | more
213 exit 1
214 fi
215
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
222 exit 1
223 fi
224
225 echo "Checking the operating system."
226 if [ "${opsystem}" = "" ]; then
227
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/'`
233
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
240 exit 1
241 fi
242
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.)
250
251 " >&2
252 sed < src/${machfile} -e '1,/NOTE-START/d' -e '/NOTE-END/,$d' | more
253 echo
254 exit 1
255 fi
256
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
264 exit 1
265 fi
266 else
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
272 exit 1
273 fi
274 fi
275
276 if [ ! "${prefix}" ]; then
277 prefix="/usr/local"
278 fi
279
280 if [ ! "${emacsdir}" ]; then
281 emacsdir="${prefix}/emacs-19.0"
282 fi
283
284 if [ ! "${datadir}" ]; then
285 datadir="${emacsdir}/etc"
286 fi
287
288 if [ ! "${lispdir}" ]; then
289 lispdir="${emacsdir}/lisp"
290 fi
291
292 if [ ! "${locallisppath}" ]; then
293 locallisppath="${emacsdir}/local-lisp"
294 fi
295
296 if [ ! "${lisppath}" ]; then
297 lisppath="${locallisppath}:${lispdir}"
298 fi
299
300 if [ ! "${buildlisppath}" ]; then
301 buildlisppath=../lisp
302 fi
303
304 if [ ! "${statedir}" ]; then
305 statedir="${emacsdir}"
306 fi
307
308 if [ ! "${lockdir}" ]; then
309 lockdir="${statedir}/lock"
310 fi
311
312 if [ "${libdir}" = "" ]; then
313 libdir="${emacsdir}/arch-lib"
314 fi
315
316 if [ ! "${mandir}" ]; then
317 mandir="/usr/man/man1"
318 fi
319
320 if [ ! "${infodir}" ]; then
321 infodir="${prefix}/info"
322 fi
323
324 echo "Checking window system."
325 case "${with_x11}" in
326 yes )
327 window_system=${window_system}x11
328 ;;
329 esac
330 case "${with_x}" in
331 yes )
332 window_system=${window_system}x11
333 ;;
334 esac
335 case "${with_x10}" in
336 yes )
337 window_system=${window_system}x10
338 ;;
339 esac
340
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 ;;
347 "" )
348 echo " No window system specifed. Looking for X Windows."
349 window_system=none
350 if [ -r /usr/lib/libX11.a -o -d /usr/include/X11 ]; then
351 window_system=x11
352 fi
353 ;;
354 * )
355 echo "Don\'t specify the window system more than once." >&2
356 exit 1
357 ;;
358 esac
359
360 case "${window_system}" in
361 x11 )
362 have_x_windows=yes
363 have_x11=yes
364 ;;
365 x10 )
366 have_x_windows=yes
367 have_x11=no
368 ;;
369 none )
370 have_x_windows=no
371 have_x11=no
372 ;;
373 esac
374
375 echo "Checking for GCC."
376 case "${cc}" in
377 "" )
378 temppath=`echo $PATH | sed 's/^:/.:/
379 s/::/:.:/g
380 s/:$/:./
381 s/:/ /g'`
382 cc=`(
383 for dir in ${temppath}; do
384 if [ -f ${dir}/gcc ]; then echo gcc; exit 0; fi
385 done
386 echo cc
387 )`
388 ;;
389 esac
390
391 case "${cc}" in
392 "gcc" )
393 # With GCC, both O and g should default to yes, no matter what
394 # the other is.
395 case "${O},${g}" in
396 , ) O=yes; g=yes ;;
397 ,* ) O=yes; ;;
398 *, ) g=yes ;;
399 esac
400 ;;
401 "*" )
402 # With other compilers, treat them as mutually exclusive,
403 # defaulting to debug.
404 case "${O},${g}" in
405 , ) O=no ; g=yes ;;
406 ,no ) O=yes; ;;
407 ,yes ) O=no ; ;;
408 no, ) g=yes ;;
409 yes, ) g=no ;;
410 esac
411 ;;
412 esac
413
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."
418 signal_h_file=''
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
423 fi
424 sigtype=void
425 if [ "${signal_h_file}" ]; then
426 sigpattern='[ ]*([ ]*\*[ ]*signal[ ]*('
427
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
433 sigtype=int
434 fi
435 rm -f ${tempcname}
436 fi
437
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}'"
444 #ifndef LIBS_MACHINE
445 #define LIBS_MACHINE
446 #endif
447 #ifndef LIBS_SYSTEM
448 #define LIBS_SYSTEM
449 #endif
450 @configure@ libsrc_libs=LIBS_MACHINE LIBS_SYSTEM
451 #ifdef SYSTEM_MALLOC
452 @configure@ system_malloc=yes
453 #else
454 @configure@ system_malloc=no
455 #endif
456 ' > ${tempcname}
457 eval `${cc} -E ${tempcname} \
458 | grep '@configure@' \
459 | sed -e 's/^@configure@//'`
460 rm ${tempcname}
461
462 # Do the opsystem or machine files prohibit the use of the GNU malloc?
463 if [ "${system_malloc}" = "yes" ]; then
464 gnu_malloc=no
465 gnu_malloc_reason="
466 (The GNU allocators don't work with this machine and/or operating system.)"
467 fi
468
469 if [ ! "${rel_alloc}" ]; then
470 rel_alloc=${gnu_malloc}
471 fi
472
473 rm -f config.status
474 set -e
475
476 # Make the proper settings in the config file.
477 echo "Making src/config.h from src/config.h.in"
478 case "${g}" in
479 "yes" ) c_switch_site="${c_switch_site} -g" ;;
480 esac
481 case "${O}" in
482 "yes" ) c_switch_site="${c_switch_site} -O" ;;
483 esac
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}`
491 case ${val} in
492 no | "")
493 f="-e 's:.*#define ${cflagname}.*:/\\* #define ${cflagname} \\*/:'"
494 ;;
495 yes)
496 f="-e 's:.*#define ${cflagname}.*:#define ${cflagname}:'"
497 ;;
498 *)
499 f="-e 's:.*#define ${cflagname}.*:#define ${cflagname} ${val}:'"
500 ;;
501 esac
502 sed_flags="${sed_flags} ${f}"
503 done
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
509
510 # Modify the parameters in the top makefile.
511 echo "Producing ./Makefile from ./Makefile.in."
512 rm -f Makefile.tmp
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 \
517 -e '/^# DIST: /d' \
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};" \
531 ) > ./Makefile.tmp
532 ./move-if-change Makefile.tmp Makefile
533 # Remind people not to edit this.
534 chmod -w ./Makefile
535
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
553
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 \
561 -e '/^# DIST: /d' \
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
566
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 \
574 -e '/^# DIST: /d' \
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
581
582
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
587 ${bindir}.
588 Emacs's lisp search path will be
589 \`${lisppath}'.
590 Emacs will look for its architecture-independent data in
591 ${datadir}.
592 Emacs will look for its utility programs and other architecture-
593 dependent data in
594 ${libdir}.
595 Emacs will keep track of file-locking in
596 ${lockdir}.
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}"
604
605 # Document the damage we have done by writing config.status.
606
607 echo '#!/bin/sh' > config.status
608
609 echo "# This file is generated by \`${progname}.'
610 # If you are thinking about editing it, you should seriously consider
611 # running \`${progname}' instead.
612 " >> config.status
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
618
619 # Print the description.
620 echo
621 echo "${message}"
622
623 exit 0