Initial revision
[bpt/emacs.git] / configure1.in
CommitLineData
ca1d1d23
JB
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
31progname=$0
32
33short_usage="Type \`${progname} -usage' for more information about options."
34
35usage_message="Usage: ${progname} MACHINENAME [-OPTION[=VALUE] ...]
36Set compilation and installation parameters for GNU Emacs, and report.
37MACHINENAME is the machine to build for. See \`etc/MACHINES'.
38Options are:
39 -opsystem=SYSTEM - operating system to build for; see \`etc/MACHINES'.
40 -libroot=DIR - where to install Emacs's library files
41These 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 -installbin=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 floating point in Elisp
55If successful, ${progname} leaves its status in config.status. If
56unsuccessful after disturbing the status quo, config.status is removed."
57
58if [ ! -r ./src/lisp.h ]; then
59 echo "${progname}: Can't find Emacs sources in \`./src'.
60Run this config script in the top directory of the Emacs source tree." 1>&2
61 exit 1
62fi
63
64options=":\
65usage:help:\
66machine:opsystem:\
67g:O:cc:\
68libroot:datadir:libdir:installbin:lisppath:lockdir:\
69gnu_malloc:rel_alloc:highpri:lisp_float_type:\
70window_system:have_x_menu:\
71"
72
73boolean_opts=":\
74g:O:\
75gnu_malloc:rel_alloc:lisp_float_type:have_x_menu:\
76"
77
78config_h_opts=":\
79highpri:gnu_malloc:rel_alloc:lisp_float_type:\
80have_x_windows:have_x11:have_x_menu:\
81c_switch_site:sigtype:\
82"
83
84libroot=
85installbin=/usr/local/bin
86gnu_malloc=yes
87lisp_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.
91lisppath=""
92datadir=""
93libdir=""
94lockdir=""
95window_system=""
96have_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.
100if [ "$*" = "+distribute" ]; then
101 libroot=/usr/local/lib/emacs
102 machine=hp300bsd
103 opsystem=bsd4-3
104 shift
105fi
106
107echo "Examining options..."
108for 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
185done
186
187if [ "${machine}" = "" ]; then
188 (echo "You must specify a machine name as an argument to ${progname}."
189 echo "${short_usage}") | more
190 exit 1
191fi
192
193echo "Checking machine..."
194machfile="m/${machine}.h"
195if [ ! -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
198that Emacs has been ported to." 1>&2
199 exit 1
200fi
201
202echo "Checking operating system..."
203if [ "${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
213system a \`${machine}' machine might run. Try specifying the
214operating system explicitly by passing ${progname} an
215\`-opsystem=SYSTEM-NAME' flag. Look at etc/MACHINES for the
216names 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
222system, and Emacs's configuration info isn't clever enough to figure
223out 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
226file 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
237operating system for the machine \`${machine}' is \`${opsystem}',
238but there is no configuration file for \`${opsystem}', so Emacs's
239default info is screwed up. Try specifying the operating system
240explicitly by passing ${progname} an \`-opsystem=SYSTEM-NAME' flag." 1>&2
241 exit 1
242 fi
243else
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
248systems that Emacs has been ported to." 1>&2
249 exit 1
250 fi
251fi
252
253if [ "${libroot}" = "" ]; then
254 echo "Guessing library directory..."
255 libroot=`/bin/pwd`
256fi
257
258echo "Checking window system..."
259window_system="`echo ${window_system} | tr A-Z a-z`"
260case "${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 ;;
274esac
275
276case "${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 ;;
289esac
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.
294echo "Looking for return type of signal handler functions..."
295if [ -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
301fi
302
303
304# Do the opsystem or machine files prohibit the use of the GNU malloc?
305echo "Checking to see if the GNU malloc routines are permissible..."
306if (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.)"
310fi
311
312rel_alloc=${gnu_malloc}
313
314if [ "${have_x_menu}" = "" ]; then
315 have_x_menu=no
316fi
317
318if [ "${lisppath}" = "" ]; then
319 lisppath=${libroot}/local-lisp:${libroot}/lisp
320fi
321
322if [ "${datadir}" = "" ]; then
323 datadir=${libroot}/etc
324fi
325
326if [ "${libdir}" = "" ]; then
327 libdir=${libroot}/arch-lib
328fi
329
330if [ "${lockdir}" = "" ]; then
331 lockdir=${libroot}/lock
332fi
333
334echo "Checking for GCC..."
335case "${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 ;;
348esac
349
350case "${O},${g},${cc}" in
351 ,,gcc ) O=yes; g=yes ;;
352 ,,* ) O=yes; g=no ;;
353esac
354
355echo "Guessing which libraries the lib-src programs will want,"
356echo " based on the machine- and system-dependent files..."
357echo '#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
365libsrc_libs=LIBS_MACHINE LIBS_SYSTEM
366' > config-tmp-$$.c
367eval `${cc} -E config-tmp-$$.c | grep 'libsrc_libs='`
368rm config-tmp-$$.c
369
370rm -f config.status
371set -e
372
373# Make the proper settings in the config file.
374echo "Making src/config.h from src/config.h-dist"
375if [ "${highpri}" != "" ]; then
376 highpri="(-${highpri})"
377fi
378case "${g}" in
379 "yes" ) c_switch_site="${c_switch_site} -g" ;;
380esac
381case "${O}" in
382 "yes" ) c_switch_site="${c_switch_site} -O" ;;
383esac
384sed_flags="-e 's:@machine@:${machfile}:'"
385sed_flags="${sed_flags} -e 's:@opsystem@:${opsysfile}:'"
386for 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}"
401done
402eval '/bin/sed '${sed_flags}' < src/config.h-dist > src/config.h'
403
404# Modify the parameters in the top makefile.
405echo "Editing ./Makefile..."
406tempMakefile="tempMakefile"$$
407/bin/sed < Makefile > ${tempMakefile} \
408-e 's;^\(LIBROOT=\).*$;\1'"${libroot};" \
409-e 's;^\(INSTALLBIN=\).*$;\1'"${installbin};" \
410-e 's;^\(LISPPATH=\).*$;\1'"${lisppath};" \
411-e 's;^\(DATADIR=\).*$;\1'"${datadir};" \
412-e 's;^\(LOCKDIR=\).*$;\1'"${lockdir};" \
413-e 's;^\(LIBDIR=\).*$;\1'"${libdir};"
414mv ${tempMakefile} Makefile
415
416# Modify the parameters in the `build-install' script.
417echo "Editing ./build-install..."
418tempbi="tempbi"$$
419/bin/sed < build-install > ${tempbi} \
420-e 's;^\(LIBROOT=\).*$;\1'"${libroot};" \
421-e 's;^\(BINDIR=\).*$;\1'"${installbin};" \
422-e 's;^\(LISPPATH=\).*$;\1'"${lisppath};" \
423-e 's;^\(DATADIR=\).*$;\1'"${datadir};" \
424-e 's;^\(LOCKDIR=\).*$;\1'"${lockdir};" \
425-e 's;^\(LIBDIR=\).*$;\1'"${libdir};"
426mv ${tempbi} build-install
427chmod a+x build-install
428
429# Modify the parameters in the src makefile.
430echo "Editing src/Makefile..."
431tempMakefile="tempMakefile"$$
432/bin/sed < src/Makefile > ${tempMakefile} \
433-e 's;^\(CC[ ]*=\).*$;\1'"${cc};"
434mv ${tempMakefile} src/Makefile
435
436# Modify the parameters in the lib-src makefile.
437echo "Editing lib-src/Makefile..."
438tempMakefile="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};"
443mv ${tempMakefile} lib-src/Makefile
444
445# Document the damage we have done.
446echo
447echo "Configured for machine \`${machine}' running \`${opsystem}'.
448The following values have been set in ./Makefile and ./build-install:
449 Executables will be placed in
450 ${installbin}.
451 Emacs's lisp search path will be
452 \`${lisppath}'.
453 Emacs will look for its architecture-independent data in
454 ${datadir}.
455 Emacs will look for its utility programs and other architecture-
456 dependent data in
457 ${libdir}.
458 Emacs will keep track of file-locking in
459 ${lockdir}.
460The following values have been set in src/config.h:
461 At how much higher than normal priority should Emacs run? ${highpri-none}
462 Should Emacs use the GNU version of malloc? ${gnu_malloc}${gnu_malloc_reason}
463 Should Emacs use the relocating allocator for buffers? ${rel_alloc}
464 Should Emacs support a floating point Elisp type? ${lisp_float_type}
465 What window system should Emacs use? ${window_system}
466 Should Emacs support mouse menus, which require X11? ${have_x_menu}
467 What compiler should emacs be built with? ${cc}
468 Should the compilation use \`-g' and/or \`-O'? ${c_switch_site- neither}" \
469| tee config.status 1>&2
470
471exit 0