Continuation of previous change.
[bpt/emacs.git] / configure.ac
CommitLineData
067d23c9
KY
1dnl Autoconf script for GNU Emacs
2dnl To rebuild the `configure' script from this, execute the command
3dnl autoconf
4dnl in the directory containing this script.
5dnl If you changed any AC_DEFINES, also run autoheader.
6dnl
ab422c4d 7dnl Copyright (C) 1994-1996, 1999-2013 Free Software Foundation, Inc.
067d23c9
KY
8dnl
9dnl This file is part of GNU Emacs.
10dnl
11dnl GNU Emacs is free software: you can redistribute it and/or modify
12dnl it under the terms of the GNU General Public License as published by
13dnl the Free Software Foundation, either version 3 of the License, or
14dnl (at your option) any later version.
15dnl
16dnl GNU Emacs is distributed in the hope that it will be useful,
17dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
18dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19dnl GNU General Public License for more details.
20dnl
21dnl You should have received a copy of the GNU General Public License
22dnl along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24AC_PREREQ(2.65)
052f924a 25AC_INIT(emacs, 24.3.50)
1e8725cf 26
917c483a
PE
27dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
28dnl and then quoted again for a C string. Separate options with spaces.
29dnl Add some environment variables, if they were passed via the environment
30dnl rather than on the command-line.
31emacs_config_options=
32optsep=
60f5e585
GM
33dnl This is the documented way to record the args passed to configure,
34dnl rather than $ac_configure_args.
917c483a
PE
35for opt in ${1+"$@"} CFLAGS CPPFLAGS LDFLAGS; do
36 case $opt in
37 -n | --no-create | --no-recursion)
38 continue ;;
39 CFLAGS | CPPFLAGS | LDFLAGS)
40 eval 'test "${'$opt'+set}" = set' || continue
41 case " $*" in
42 *" $opt="*) continue ;;
43 esac
44 eval opt=$opt=\$$opt ;;
45 esac
46
47 emacs_shell_specials=$IFS\''"#$&()*;<>?@<:@\\`{|~'
48 case $opt in
49 *[["$emacs_shell_specials"]]*)
50 case $opt in
51 *\'*)
52 emacs_quote_apostrophes="s/'/'\\\\''/g"
53 opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_apostrophes"` ;;
54 esac
55 opt="'$opt'"
56 case $opt in
57 *[['"\\']]*)
58 emacs_quote_for_c='s/[["\\]]/\\&/g; $!s/$/\\n\\/'
59 opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_for_c"` ;;
60 esac ;;
61 esac
62 AS_VAR_APPEND([emacs_config_options], ["$optsep$opt"])
63 optsep=' '
1e8725cf
GM
64done
65
067d23c9
KY
66AC_CONFIG_HEADER(src/config.h:src/config.in)
67AC_CONFIG_SRCDIR(src/lisp.h)
24e0f6b1 68AC_CONFIG_AUX_DIR(build-aux)
7d732d1a
GM
69dnl Fairly arbitrary, older versions might work too.
70AM_INIT_AUTOMAKE(1.11)
067d23c9
KY
71
72dnl Support for --program-prefix, --program-suffix and
73dnl --program-transform-name options
74AC_ARG_PROGRAM
75
7b65c8d0 76dnl http://debbugs.gnu.org/15260
fb6f3c4a 77dnl Note that abs_srcdir and abs_builddir are not yet defined. :(
357a5081 78
da504eec 79dnl "`cd \"$srcdir\"`" is not portable.
357a5081
GM
80dnl See autoconf manual "Shell Substitutions":
81dnl "There is just no portable way to use double-quoted strings inside
82dnl double-quoted back-quoted expressions (pfew!)."
83temp_srcdir=`cd "$srcdir"; pwd`
84
da504eec 85for var in "`pwd`" "$temp_srcdir"; do
7b65c8d0
GM
86
87 dnl configure sets LC_ALL=C early on, so this range should work.
88 case "$var" in
da504eec 89 *[[^\ -~]]*) AC_MSG_ERROR([Emacs cannot be built in a directory whose name contains non-ASCII characters: $var]) ;;
7b65c8d0
GM
90 esac
91
92done
93
067d23c9
KY
94dnl It is important that variables on the RHS not be expanded here,
95dnl hence the single quotes. This is per the GNU coding standards, see
96dnl (autoconf) Installation Directory Variables
97dnl See also epaths.h below.
98lispdir='${datadir}/emacs/${version}/lisp'
d71dfe75 99leimdir='${datadir}/emacs/${version}/leim'
ca26824c 100standardlisppath='${lispdir}:${leimdir}'
067d23c9
KY
101locallisppath='${datadir}/emacs/${version}/site-lisp:'\
102'${datadir}/emacs/site-lisp'
ca26824c 103lisppath='${locallisppath}:${standardlisppath}'
067d23c9
KY
104etcdir='${datadir}/emacs/${version}/etc'
105archlibdir='${libexecdir}/emacs/${version}/${configuration}'
8496d8d7 106etcdocdir='${datadir}/emacs/${version}/etc'
067d23c9
KY
107gamedir='${localstatedir}/games/emacs'
108
da3d2105
DA
109dnl Special option to disable the most of other options.
110AC_ARG_WITH(all,
111[AS_HELP_STRING([--without-all],
c30d4aef
DA
112 [omit almost all features and build
113 small executable with minimal dependencies])],
da3d2105
DA
114 with_features=$withval,
115 with_features=yes)
c30d4aef 116
067d23c9
KY
117dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
118dnl Create a new --with option that defaults to being disabled.
119dnl NAME is the base name of the option. The shell variable with_NAME
120dnl will be set to either the user's value (if the option is
121dnl specified; 'yes' for a plain --with-NAME) or to 'no' (if the
122dnl option is not specified). Note that the shell variable name is
123dnl constructed as autoconf does, by replacing non-alphanumeric
124dnl characters with "_".
125dnl HELP-STRING is the help text for the option.
126AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
127 AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
128 m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
129])dnl
130
131dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
58556eb4 132dnl Create a new --with option that defaults to $with_features.
c30d4aef 133dnl NAME is the base name of the option. The shell variable with_NAME
067d23c9
KY
134dnl will be set either to 'no' (for a plain --without-NAME) or to
135dnl 'yes' (if the option is not specified). Note that the shell
136dnl variable name is constructed as autoconf does, by replacing
137dnl non-alphanumeric characters with "_".
138dnl HELP-STRING is the help text for the option.
139AC_DEFUN([OPTION_DEFAULT_ON], [dnl
140 AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
da3d2105 141 m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
067d23c9
KY
142])dnl
143
144OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail])
145if test "$with_pop" = yes; then
146 AC_DEFINE(MAIL_USE_POP)
147fi
148AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
149
150OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
151if test "$with_kerberos" != no; then
152 AC_DEFINE(KERBEROS)
153fi
154AH_TEMPLATE(KERBEROS,
155 [Define to support Kerberos-authenticated POP mail retrieval.])dnl
156
157OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
158if test "${with_kerberos5}" != no; then
159 if test "${with_kerberos}" = no; then
160 with_kerberos=yes
161 AC_DEFINE(KERBEROS)
162 fi
163 AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
164fi
165
166OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
167dnl FIXME hesiod support may not be present, so it seems like an error
168dnl to define, or at least use, this unconditionally.
169if test "$with_hesiod" != no; then
170 AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
171fi
172
173OPTION_DEFAULT_OFF([mmdf],[support MMDF mailboxes])
174if test "$with_mmdf" != no; then
175 AC_DEFINE(MAIL_USE_MMDF, 1, [Define to support MMDF mailboxes in movemail.])
176fi
177
178OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
179if test "$with_mail_unlink" != no; then
180 AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
181fi
182
183AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
184 [string giving default POP mail host])],
185 AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
186
885e792c 187AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
2c347217 188 [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio, no;
885e792c
GM
189default yes). Only for GNU/Linux, FreeBSD, NetBSD, MinGW.])],
190 [ case "${withval}" in
2c347217 191 yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
885e792c 192 *) AC_MSG_ERROR([`--with-sound=$withval' is invalid;
2c347217 193this option's value should be `yes', `no', `alsa', `oss', or `bsd-ossaudio'.])
885e792c
GM
194 ;;
195 esac
196 with_sound=$val
197 ],
198 [with_sound=$with_features])
067d23c9 199
067d23c9
KY
200dnl FIXME currently it is not the last.
201dnl This should be the last --with option, because --with-x is
3cc53d60 202dnl added later on when we find the file name of X, and it's best to
067d23c9
KY
203dnl keep them together visually.
204AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
d673aedc 205 [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
067d23c9
KY
206[ case "${withval}" in
207 y | ye | yes ) val=gtk ;;
208 n | no ) val=no ;;
209 l | lu | luc | luci | lucid ) val=lucid ;;
210 a | at | ath | athe | athen | athena ) val=athena ;;
211 m | mo | mot | moti | motif ) val=motif ;;
212 g | gt | gtk ) val=gtk ;;
d673aedc 213 gtk2 ) val=gtk2 ;;
067d23c9
KY
214 gtk3 ) val=gtk3 ;;
215 * )
216AC_MSG_ERROR([`--with-x-toolkit=$withval' is invalid;
d673aedc
JD
217this option's value should be `yes', `no', `lucid', `athena', `motif', `gtk',
218`gtk2' or `gtk3'. `yes' and `gtk' are synonyms.
219`athena' and `lucid' are synonyms.])
067d23c9
KY
220 ;;
221 esac
222 with_x_toolkit=$val
223])
224
81eafe29
PE
225OPTION_DEFAULT_OFF([wide-int], [prefer wide Emacs integers (typically 62-bit)])
226if test "$with_wide_int" = yes; then
227 AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
228fi
229
067d23c9
KY
230dnl _ON results in a '--without' option in the --help output, so
231dnl the help text should refer to "don't compile", etc.
232OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
233OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
234OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
235OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
236OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
237OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
238OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
239OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
240
241OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
242OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
243OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
244
245OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
246OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
247OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
b612ffc9 248OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
6758608f 249OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
067d23c9
KY
250
251OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
252OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
253OPTION_DEFAULT_ON([gconf],[don't compile with GConf support])
9851bfc5 254OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
067d23c9
KY
255OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
256OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
8d28d0ac 257OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
c9628c79
MA
258
259AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
260 [use a file notification library (LIB one of: yes, gfile, inotify, w32, no)])],
261 [ case "${withval}" in
262 y | ye | yes ) val=yes ;;
263 n | no ) val=no ;;
264 g | gf | gfi | gfil | gfile ) val=gfile ;;
265 i | in | ino | inot | inoti | inotif | inotify ) val=inotify ;;
266 w | w3 | w32 ) val=w32 ;;
267 * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid;
268this option's value should be `yes', `no', `gfile', `inotify' or `w32'.
671d4bfc
GM
269`yes' is a synonym for `w32' on MS-Windows, for `no' on Nextstep,
270otherwise for the first of `gfile' or `inotify' that is usable.])
c9628c79
MA
271 ;;
272 esac
273 with_file_notification=$val
274 ],
b0e22831 275 [with_file_notification=$with_features])
067d23c9
KY
276
277## For the times when you want to build Emacs but don't have
278## a suitable makeinfo, and can live without the manuals.
279dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
280OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
281
6c269a38
PE
282## Makefile.in needs the cache file name.
283AC_SUBST(cache_file)
284
067d23c9
KY
285## This is an option because I do not know if all info/man support
286## compressed files, nor how to test if they do so.
335142f9
GM
287OPTION_DEFAULT_ON([compress-install],
288 [don't compress some files (.el, .info, etc.) when installing. Equivalent to:
289make GZIP_PROG= install])
067d23c9
KY
290
291AC_ARG_WITH([pkg-config-prog],dnl
3cc53d60
PE
292[AS_HELP_STRING([--with-pkg-config-prog=FILENAME],
293 [file name of pkg-config for finding GTK and librsvg])])
067d23c9
KY
294if test "X${with_pkg_config_prog}" != X; then
295 if test "${with_pkg_config_prog}" != yes; then
296 PKG_CONFIG="${with_pkg_config_prog}"
297 fi
298fi
299
4fc5868a
UM
300AC_ARG_WITH(gameuser,dnl
301[AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])])
302test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
303 && gameuser="${with_gameuser}"
304test "X$gameuser" = X && gameuser=games
305
067d23c9 306AC_ARG_WITH([gnustep-conf],dnl
3cc53d60
PE
307[AS_HELP_STRING([--with-gnustep-conf=FILENAME],
308 [name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])])
067d23c9
KY
309test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
310 GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
311test "X$GNUSTEP_CONFIG_FILE" = "X" && \
312 GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
313
314AC_ARG_ENABLE(ns-self-contained,
315[AS_HELP_STRING([--disable-ns-self-contained],
316 [disable self contained build under NeXTstep])],
317 EN_NS_SELF_CONTAINED=$enableval,
318 EN_NS_SELF_CONTAINED=yes)
319
067d23c9
KY
320AC_ARG_ENABLE(locallisppath,
321[AS_HELP_STRING([--enable-locallisppath=PATH],
322 [directories Emacs should search for lisp files specific
323 to this site])],
324if test "${enableval}" = "no"; then
325 locallisppath=
326elif test "${enableval}" != "yes"; then
327 locallisppath=${enableval}
328fi)
329
330AC_ARG_ENABLE(checking,
331[AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
332 [enable expensive run-time checks. With LIST,
333 enable only specific categories of checks.
334 Categories are: all,yes,no.
335 Flags are: stringbytes, stringoverrun, stringfreelist,
e509cfa6 336 xmallocoverrun, conslist, glyphs])],
067d23c9
KY
337[ac_checking_flags="${enableval}"],[])
338IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
339for check in $ac_checking_flags
340do
341 case $check in
342 # these set all the flags to specific states
343 yes) ac_enable_checking=1 ;;
344 no) ac_enable_checking= ;
345 ac_gc_check_stringbytes= ;
346 ac_gc_check_string_overrun= ;
347 ac_gc_check_string_free_list= ;
348 ac_xmalloc_overrun= ;
e509cfa6 349 ac_gc_check_cons_list= ;
94eb8e0a 350 ac_glyphs_debug= ;;
067d23c9
KY
351 all) ac_enable_checking=1 ;
352 ac_gc_check_stringbytes=1 ;
353 ac_gc_check_string_overrun=1 ;
354 ac_gc_check_string_free_list=1 ;
355 ac_xmalloc_overrun=1 ;
e509cfa6 356 ac_gc_check_cons_list=1 ;
94eb8e0a 357 ac_glyphs_debug=1 ;;
067d23c9
KY
358 # these enable particular checks
359 stringbytes) ac_gc_check_stringbytes=1 ;;
360 stringoverrun) ac_gc_check_string_overrun=1 ;;
361 stringfreelist) ac_gc_check_string_free_list=1 ;;
362 xmallocoverrun) ac_xmalloc_overrun=1 ;;
363 conslist) ac_gc_check_cons_list=1 ;;
94eb8e0a 364 glyphs) ac_glyphs_debug=1 ;;
067d23c9
KY
365 *) AC_MSG_ERROR(unknown check category $check) ;;
366 esac
367done
368IFS="$ac_save_IFS"
369
370if test x$ac_enable_checking != x ; then
371 AC_DEFINE(ENABLE_CHECKING, 1,
a54e2c05 372[Define to 1 if expensive run-time data type and consistency checks are enabled.])
067d23c9
KY
373fi
374if test x$ac_gc_check_stringbytes != x ; then
375 AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
376[Define this temporarily to hunt a bug. If defined, the size of
377 strings is redundantly recorded in sdata structures so that it can
378 be compared to the sizes recorded in Lisp strings.])
379fi
40697cd9 380if test x$ac_gc_check_string_overrun != x ; then
067d23c9
KY
381 AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
382[Define this to check for short string overrun.])
383fi
384if test x$ac_gc_check_string_free_list != x ; then
385 AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
386[Define this to check the string free list.])
387fi
388if test x$ac_xmalloc_overrun != x ; then
389 AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
390[Define this to check for malloc buffer overrun.])
391fi
392if test x$ac_gc_check_cons_list != x ; then
393 AC_DEFINE(GC_CHECK_CONS_LIST, 1,
394[Define this to check for errors in cons list.])
395fi
94eb8e0a 396if test x$ac_glyphs_debug != x ; then
e509cfa6
DA
397 AC_DEFINE(GLYPH_DEBUG, 1,
398[Define this to enable glyphs debugging code.])
399fi
067d23c9 400
646b5f55
AS
401AC_ARG_ENABLE(check-lisp-object-type,
402[AS_HELP_STRING([--enable-check-lisp-object-type],
403 [enable compile time checks for the Lisp_Object data type.
404 This is useful for development for catching certain types of bugs.])],
067d23c9 405if test "${enableval}" != "no"; then
646b5f55
AS
406 AC_DEFINE(CHECK_LISP_OBJECT_TYPE, 1,
407 [Define this to enable compile time checks for the Lisp_Object data type.])
067d23c9
KY
408fi)
409
410
2ef26ceb
EZ
411dnl The name of this option is unfortunate. It predates, and has no
412dnl relation to, the "sampling-based elisp profiler" added in 24.3.
413dnl Actually, it stops it working.
414dnl http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00393.html
067d23c9
KY
415AC_ARG_ENABLE(profiling,
416[AS_HELP_STRING([--enable-profiling],
2ef26ceb
EZ
417 [build emacs with low-level, gprof profiling support.
418 Mainly useful for debugging Emacs itself. May not work on
419 all platforms. Stops profiler.el working.])],
067d23c9
KY
420[ac_enable_profiling="${enableval}"],[])
421if test x$ac_enable_profiling != x ; then
422 PROFILING_CFLAGS="-DPROFILING=1 -pg"
423else
424 PROFILING_CFLAGS=
425fi
426AC_SUBST(PROFILING_CFLAGS)
427
428AC_ARG_ENABLE(autodepend,
429[AS_HELP_STRING([--enable-autodepend],
430 [automatically generate dependencies to .h-files.
431 Requires GNU Make and Gcc. Enabled if GNU Make and Gcc is
432 found])],
433[ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
434
7ec363cf
JD
435AC_ARG_ENABLE(gtk-deprecation-warnings,
436[AS_HELP_STRING([--enable-gtk-deprecation-warnings],
437 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
438[ac_enable_gtk_deprecation_warnings="${enableval}"],[])
439
be9bc55e
EZ
440#### When building with MinGW inside the MSYS tree, 'pwd' produces
441#### directories relative to the root of the MSYS tree,
442#### e.g. '/home/user/foo' instead of '/d/MSYS/home/user/foo'. When
443#### such a value of srcdir is written to the top-level Makefile, it
444#### gets propagated to src/epaths.h, and that causes temacs to fail,
445#### because, being a MinGW program that knows nothing of MSYS root
446#### substitution, it cannot find the data directory. "pwd -W"
447#### produces Windows-style 'd:/foo/bar' absolute directory names, so
448#### we use it here to countermand that lossage.
b8e3b0a9 449test "$MSYSTEM" = "MINGW32" && abs_srcdir=`(cd "$abs_srcdir"; pwd -W | sed -e 's,^\([[A-Za-z]]\):,/\1,')`
be9bc55e 450
067d23c9
KY
451### Canonicalize the configuration name.
452
453AC_CANONICAL_HOST
454canonical=$host
455configuration=${host_alias-${build_alias-$host}}
456
457dnl This used to use changequote, but, apart from `changequote is evil'
458dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
459dnl the great gob of text. Thus it's not processed for possible expansion.
460dnl Just make sure the brackets remain balanced.
461dnl
462dnl Since Emacs can't find matching pairs of quotes, boundaries are
463dnl indicated by comments.
464dnl quotation begins
465[
466
467### If you add support for a new configuration, add code to this
468### switch statement to recognize your configuration name and select
34374650 469### the appropriate operating system file.
067d23c9 470
34374650 471### You would hope that you could choose an s/*.h
067d23c9 472### file based on the operating system portion. However, it turns out
34374650 473### that each s/*.h file is pretty manufacturer-specific.
067d23c9
KY
474### So we basically have to have a special case for each
475### configuration name.
476###
477### As far as handling version numbers on operating systems is
478### concerned, make sure things will fail in a fixable way. If
479### /etc/MACHINES doesn't say anything about version numbers, be
480### prepared to handle anything reasonably. If version numbers
481### matter, be sure /etc/MACHINES says something about it.
482
34374650 483opsys='' unported=no
067d23c9
KY
484case "${canonical}" in
485
695a3dc5
PE
486 ## GNU/Linux and similar ports
487 *-*-linux* )
d6a003a8 488 opsys=gnu-linux
d6a003a8
AS
489 ;;
490
067d23c9
KY
491 ## FreeBSD ports
492 *-*-freebsd* )
493 opsys=freebsd
067d23c9
KY
494 ;;
495
7e00831f
JM
496 ## DragonFly ports
497 *-*-dragonfly* )
498 opsys=dragonfly
499 ;;
500
067d23c9
KY
501 ## FreeBSD kernel + glibc based userland
502 *-*-kfreebsd*gnu* )
503 opsys=gnu-kfreebsd
067d23c9
KY
504 ;;
505
506 ## NetBSD ports
507 *-*-netbsd* )
508 opsys=netbsd
067d23c9
KY
509 ;;
510
511 ## OpenBSD ports
512 *-*-openbsd* )
513 opsys=openbsd
067d23c9
KY
514 ;;
515
067d23c9
KY
516 ## Apple Darwin / Mac OS X
517 *-apple-darwin* )
518 case "${canonical}" in
34374650
PE
519 i[3456]86-* ) ;;
520 powerpc-* ) ;;
521 x86_64-* ) ;;
067d23c9
KY
522 * ) unported=yes ;;
523 esac
524 opsys=darwin
136c45ee
GM
525 ## Use fink packages if available.
526 ## FIXME find a better way to do this: http://debbugs.gnu.org/11507
527## if test -d /sw/include && test -d /sw/lib; then
528## GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
529## NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
530## fi
067d23c9
KY
531 ;;
532
e8bdb06e
KB
533 ## Cygwin ports
534 *-*-cygwin )
535 opsys=cygwin
536 ;;
537
067d23c9
KY
538 ## HP 9000 series 700 and 800, running HP/UX
539 hppa*-hp-hpux10.2* )
d6a003a8 540 opsys=hpux10-20
067d23c9
KY
541 ;;
542 hppa*-hp-hpux1[1-9]* )
d6a003a8 543 opsys=hpux11
067d23c9
KY
544 CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
545 ;;
546
067d23c9 547 ## IBM machines
067d23c9 548 rs6000-ibm-aix4.[23]* )
34374650 549 opsys=aix4-2
067d23c9
KY
550 ;;
551 powerpc-ibm-aix4.[23]* )
34374650 552 opsys=aix4-2
067d23c9
KY
553 ;;
554 rs6000-ibm-aix[56]* )
34374650 555 opsys=aix4-2
067d23c9
KY
556 ;;
557 powerpc-ibm-aix[56]* )
34374650 558 opsys=aix4-2
067d23c9
KY
559 ;;
560
067d23c9
KY
561 ## Silicon Graphics machines
562 ## Iris 4D
563 mips-sgi-irix6.5 )
76b397fb 564 opsys=irix6-5
067d23c9
KY
565 # Without defining _LANGUAGE_C, things get masked out in the headers
566 # so that, for instance, grepping for `free' in stdlib.h fails and
567 # AC_HEADER_STD_C fails. (MIPSPro 7.2.1.2m compilers, Irix 6.5.3m).
067d23c9
KY
568 NON_GCC_TEST_OPTIONS="-D_LANGUAGE_C"
569 ;;
570
571 ## Suns
067d23c9
KY
572 *-sun-solaris* \
573 | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
574 | x86_64-*-solaris2* | x86_64-*-sunos5*)
575 case "${canonical}" in
34374650
PE
576 i[3456]86-*-* ) ;;
577 amd64-*-*|x86_64-*-*) ;;
578 sparc* ) ;;
067d23c9
KY
579 * ) unported=yes ;;
580 esac
581 case "${canonical}" in
582 *-sunos5.6* | *-solaris2.6* )
583 opsys=sol2-6
067d23c9
KY
584 RANLIB="ar -ts"
585 ;;
586 *-sunos5.[7-9]* | *-solaris2.[7-9]* )
587 opsys=sol2-6
588 emacs_check_sunpro_c=yes
067d23c9
KY
589 ;;
590 *-sunos5* | *-solaris* )
591 opsys=sol2-10
592 emacs_check_sunpro_c=yes
067d23c9
KY
593 ;;
594 esac
595 ## Watch out for a compiler that we know will not work.
596 case "${canonical}" in
597 *-solaris* | *-sunos5* )
598 if [ "x$CC" = x/usr/ucb/cc ]; then
599 ## /usr/ucb/cc doesn't work;
600 ## we should find some other compiler that does work.
601 unset CC
602 fi
603 ;;
604 *) ;;
605 esac
606 ;;
607
067d23c9
KY
608 ## Intel 386 machines where we don't care about the manufacturer.
609 i[3456]86-*-* )
067d23c9 610 case "${canonical}" in
27cb7be2 611 *-darwin* ) opsys=darwin ;;
31ff141c 612 *-mingw32 )
fb0862b2 613 opsys=mingw32
9e821c83 614 # MinGW overrides and adds some system headers in nt/inc.
845b7499 615 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
fb0862b2 616 ;;
f04940ae
PE
617 *-sysv4.2uw* ) opsys=unixware ;;
618 *-sysv5uw* ) opsys=unixware ;;
619 *-sysv5OpenUNIX* ) opsys=unixware ;;
067d23c9
KY
620 ## Otherwise, we'll fall through to the generic opsys code at the bottom.
621 esac
622 ;;
623
067d23c9
KY
624 * )
625 unported=yes
626 ;;
627esac
628
629### If the code above didn't choose an operating system, just choose
630### an operating system based on the configuration name. You really
631### only want to use this when you have no idea what the right
632### operating system is; if you know what operating systems a machine
633### runs, it's cleaner to make it explicit in the case statement
634### above.
635if test x"${opsys}" = x; then
636 case "${canonical}" in
637 *-gnu* ) opsys=gnu ;;
638 * )
639 unported=yes
640 ;;
641 esac
642fi
643
644]
645dnl quotation ends
646
647if test $unported = yes; then
648 AC_MSG_ERROR([Emacs hasn't been ported to `${canonical}' systems.
649Check `etc/MACHINES' for recognized configuration names.])
650fi
651
067d23c9
KY
652
653#### Choose a compiler.
27cb7be2 654
067d23c9
KY
655dnl Sets GCC=yes if using gcc.
656AC_PROG_CC
9a514d4a
PE
657AM_PROG_CC_C_O
658
067d23c9
KY
659if test x$GCC = xyes; then
660 test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
661else
662 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
663fi
664
a74b0e1b
EZ
665dnl This is used in lib/Makefile.am to use nt/gnulib.mk, the
666dnl alternative to lib/gnulib.mk, so as to avoid generating header files
667dnl that clash with MinGW.
668AM_CONDITIONAL([BUILDING_FOR_WINDOWSNT], [test "x$opsys" = "xmingw32"])
669
70743157
PE
670# Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
671# as we don't use them.
73dcdb9f 672AC_DEFUN([gl_FCNTL_O_FLAGS])
a615a3ae
PE
673# Avoid gnulib's threadlib module, as we do threads our own way.
674AC_DEFUN([gl_THREADLIB])
675
f04940ae 676# Initialize gnulib right after choosing the compiler.
58eaa9ec 677dnl Amongst other things, this sets AR and ARFLAGS.
f04940ae
PE
678gl_EARLY
679
6e8aca60 680if test "$ac_test_CFLAGS" != set; then
f780d632
PE
681 # It's helpful to have C macros available to GDB, so prefer -g3 to -g
682 # if -g3 works and the user does not specify CFLAGS.
683 # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
6e8aca60
PE
684 case $CFLAGS in
685 '-g')
686 emacs_g3_CFLAGS='-g3';;
687 '-g -O2')
688 emacs_g3_CFLAGS='-g3 -O2';;
689 *)
690 emacs_g3_CFLAGS='';;
691 esac
692 if test -n "$emacs_g3_CFLAGS"; then
693 emacs_save_CFLAGS=$CFLAGS
694 CFLAGS=$emacs_g3_CFLAGS
695 AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
696 [emacs_cv_prog_cc_g3],
697 [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
698 [emacs_cv_prog_cc_g3=yes],
f780d632
PE
699 [emacs_cv_prog_cc_g3=no])])
700 if test $emacs_cv_prog_cc_g3 != yes; then
6e8aca60
PE
701 CFLAGS=$emacs_save_CFLAGS
702 fi
f540ee86
EZ
703 if test $opsys = mingw32; then
704 CFLAGS="$CFLAGS -gdwarf-2"
705 fi
6e8aca60 706 fi
f780d632
PE
707
708 case $CFLAGS in
709 *-O*) ;;
710 *)
711 # No optimization flag was inferred for this non-GCC compiler.
712 # Try -O. This is needed for xlc on AIX; see Bug#14258.
713 emacs_save_CFLAGS=$CFLAGS
714 test -z "$CFLAGS" || CFLAGS="$CFLAGS "
715 CFLAGS=${CFLAGS}-O
716 AC_CACHE_CHECK([whether $CC accepts -O],
717 [emacs_cv_prog_cc_o],
718 [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
719 [emacs_cv_prog_cc_o=yes],
720 [emacs_cv_prog_cc_o=no])])
721 if test $emacs_cv_prog_cc_o != yes; then
722 CFLAGS=$emacs_save_CFLAGS
723 fi ;;
724 esac
6e8aca60
PE
725fi
726
b8df54ff
PE
727AC_ARG_ENABLE([gcc-warnings],
728 [AS_HELP_STRING([--enable-gcc-warnings],
c4e2ba0a 729 [turn on lots of GCC warnings/errors. This is intended for
f5c08e17
PE
730 developers, and may generate false alarms when used
731 with older or non-GNU development tools.])],
b8df54ff
PE
732 [case $enableval in
733 yes|no) ;;
734 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
735 esac
736 gl_gcc_warnings=$enableval],
737 [gl_gcc_warnings=no]
738)
739
94eb8e0a
DA
740AC_ARG_ENABLE(link-time-optimization,
741[AS_HELP_STRING([--enable-link-time-optimization],
742 [build emacs with link-time optimization.
743 This is supported only for GCC since 4.5.0.])],
744if test "${enableval}" != "no"; then
745 AC_MSG_CHECKING([whether link-time optimization is supported])
746 ac_lto_supported=no
747 if test x$GCC = xyes; then
748 CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
749 if test x$CPUS != x; then
750 LTO="-flto=$CPUS"
751 else
752 LTO="-flto"
f5c08e17 753 fi
94eb8e0a
DA
754 old_CFLAGS=$CFLAGS
755 CFLAGS="$CFLAGS $LTO"
756 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
757 [ac_lto_supported=yes], [ac_lto_supported=no])
758 CFLAGS="$old_CFLAGS"
759 fi
760 AC_MSG_RESULT([$ac_lto_supported])
761 if test "$ac_lto_supported" = "yes"; then
762 CFLAGS="$CFLAGS $LTO"
763 fi
764fi)
765
b8df54ff
PE
766# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
767# ------------------------------------------------
768# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
769# Otherwise, run RUN-IF-NOT-FOUND.
770AC_DEFUN([gl_GCC_VERSION_IFELSE],
771 [AC_PREPROC_IFELSE(
772 [AC_LANG_PROGRAM(
773 [[
774#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
775/* ok */
776#else
777# error "your version of gcc is older than $1.$2"
778#endif
779 ]]),
780 ], [$3], [$4])
781 ]
782)
783
8762e524
JD
784# clang is unduly picky about some things.
785AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
786 [AC_COMPILE_IFELSE(
787 [AC_LANG_PROGRAM([[
788 #ifndef __clang__
789 #error "not clang"
790 #endif
791 ]])],
792 [emacs_cv_clang=yes],
793 [emacs_cv_clang=no])])
794
b8df54ff
PE
795# When compiling with GCC, prefer -isystem to -I when including system
796# include files, to avoid generating useless diagnostics for the files.
797if test "$gl_gcc_warnings" != yes; then
798 isystem='-I'
8762e524
JD
799 if test "$emacs_cv_clang" = yes
800 then
801 # Turn off some warnings if supported.
802 gl_WARN_ADD([-Wno-switch])
803 gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
804 gl_WARN_ADD([-Wno-pointer-sign])
805 fi
b8df54ff
PE
806else
807 isystem='-isystem '
808
809 # This, $nw, is the list of warnings we disable.
810 nw=
811
812 case $with_x_toolkit in
813 lucid | athena | motif)
814 # Old toolkits mishandle 'const'.
815 nw="$nw -Wwrite-strings"
816 ;;
817 *)
818 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
819 ;;
820 esac
821 AC_SUBST([WERROR_CFLAGS])
822
b8df54ff 823 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
b8df54ff 824 nw="$nw -Woverlength-strings" # Not a problem these days
b8df54ff 825 nw="$nw -Wlogical-op" # any use of fwrite provokes this
6045c4fd 826 nw="$nw -Wformat-nonliteral" # we do this a lot
b8df54ff
PE
827 nw="$nw -Wvla" # warnings in gettext.h
828 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
b8df54ff 829 nw="$nw -Wswitch-default" # Too many warnings for now
6045c4fd 830 nw="$nw -Winline" # OK to ignore 'inline'
79a7bafe 831 nw="$nw -Wjump-misses-init" # We sometimes safely jump over init.
2ef26ceb
EZ
832 nw="$nw -Wstrict-overflow" # OK to optimize assuming that
833 # signed overflow has undefined behavior
6045c4fd
PE
834 nw="$nw -Wsync-nand" # irrelevant here, and provokes ObjC warning
835 nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
84575e67 836 nw="$nw -Wbad-function-cast" # These casts are no worse than others.
b8df54ff
PE
837
838 # Emacs doesn't care about shadowing; see
839 # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
840 nw="$nw -Wshadow"
841
a8e1690b
PE
842 # Emacs's use of alloca inhibits protecting the stack.
843 nw="$nw -Wstack-protector"
844
2ef26ceb 845 # The following line should be removable at some point.
b8df54ff
PE
846 nw="$nw -Wsuggest-attribute=pure"
847
4b73fc73
PE
848 # This part is merely for shortening the command line,
849 # since -Wno-FOO needs to be added below regardless.
850 nw="$nw -Wmissing-field-initializers"
851 nw="$nw -Wswitch"
852 nw="$nw -Wtype-limits"
853 nw="$nw -Wunused-parameter"
854
31ff141c
PE
855 if test $emacs_cv_clang = yes; then
856 nw="$nw -Wcast-align"
857 fi
858
b8df54ff
PE
859 gl_MANYWARN_ALL_GCC([ws])
860 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
861 for w in $ws; do
862 gl_WARN_ADD([$w])
863 done
864 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
865 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
866 gl_WARN_ADD([-Wno-type-limits]) # Too many warnings for now
867 gl_WARN_ADD([-Wno-switch]) # Too many warnings for now
868 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
869 gl_WARN_ADD([-Wno-format-nonliteral])
870
871 # In spite of excluding -Wlogical-op above, it is enabled, as of
872 # gcc 4.5.0 20090517.
873 gl_WARN_ADD([-Wno-logical-op])
874
31ff141c
PE
875 # More things that clang is unduly picky about.
876 if test $emacs_cv_clang = yes; then
877 gl_WARN_ADD([-Wno-format-extra-args])
878 gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
879 gl_WARN_ADD([-Wno-unused-command-line-argument])
880 gl_WARN_ADD([-Wno-unused-value])
881 fi
882
b8df54ff 883 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
2d3800d2
PE
884 AH_VERBATIM([FORTIFY_SOURCE],
885 [/* Enable compile-time and run-time bounds-checking, and some warnings,
886 without upsetting glibc 2.15+. */
7f8de58c 887 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
2d3800d2
PE
888 # define _FORTIFY_SOURCE 2
889 #endif
890 ])
b8df54ff
PE
891 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
892
893 # We use a slightly smaller set of warning options for lib/.
894 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
895 nw=
896 nw="$nw -Wunused-macros"
897
898 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
899 AC_SUBST([GNULIB_WARN_CFLAGS])
067d23c9 900fi
067d23c9 901
067d23c9
KY
902
903
f04940ae
PE
904dnl Some other nice autoconf tests.
905dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
906dnl AC_PROG_INSTALL
907dnl AC_PROG_MKDIR_P
908dnl if test "x$RANLIB" = x; then
909dnl AC_PROG_RANLIB
910dnl fi
4f8902cd
GM
911
912
913dnl Sadly, AC_PROG_LN_S is too restrictive. It also tests whether links
914dnl can be made to directories. This is not relevant for our usage, and
915dnl excludes some cases that work fine for us. Eg MS Windows or files
916dnl hosted on AFS, both examples where simple links work, but links to
917dnl directories fail. We use a cut-down version instead.
918dnl AC_PROG_LN_S
919
920AC_MSG_CHECKING([whether ln -s works for files in the same directory])
921rm -f conf$$ conf$$.file
922
923LN_S_FILEONLY='cp -p'
924
925if (echo >conf$$.file) 2>/dev/null; then
926 if ln -s conf$$.file conf$$ 2>/dev/null; then
927 LN_S_FILEONLY='ln -s'
928 elif ln conf$$.file conf$$ 2>/dev/null; then
929 LN_S_FILEONLY=ln
930 fi
931fi
932
933rm -f conf$$ conf$$.file
934
935if test "$LN_S_FILEONLY" = "ln -s"; then
936 AC_MSG_RESULT([yes])
937else
938 AC_MSG_RESULT([no, using $LN_S_FILEONLY])
939fi
940
941AC_SUBST(LN_S_FILEONLY)
942
067d23c9 943
f576f7fb
EZ
944dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
945dnl doesn't support links to directories, as in "ln file dir". But that
946dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
947dnl executables at "make install" time.
948dnl See http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00475.html
949dnl for more details.
64544985 950if test "$opsys" = "mingw32"; then
f576f7fb 951 LN_S="ln"
64544985 952fi
64544985 953
0e7a053e
PE
954AC_PATH_PROG(INSTALL_INFO, install-info, :,
955 $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
067d23c9
KY
956dnl Don't use GZIP, which is used by gzip for additional parameters.
957AC_PATH_PROG(GZIP_PROG, gzip)
958
66f3731f 959test $with_compress_install != yes && test -n "$GZIP_PROG" && \
335142f9
GM
960 GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
961
0b6b25d5
GM
962if test $opsys = gnu-linux; then
963 AC_PATH_PROG(PAXCTL, paxctl,,
964 [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
32d9ba9a
UM
965 if test "X$PAXCTL" != X; then
966 AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
967 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
968 [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then AC_MSG_RESULT(yes)
969 else AC_MSG_RESULT(no); PAXCTL=""; fi])
970 fi
0b6b25d5 971fi
067d23c9 972
23df914b 973## Need makeinfo >= 4.7 (?) to build the manuals.
067d23c9
KY
974AC_PATH_PROG(MAKEINFO, makeinfo, no)
975dnl By this stage, configure has already checked for egrep and set EGREP,
976dnl or exited with an error if no egrep was found.
3cc53d60
PE
977if test "$MAKEINFO" != "no"; then
978 case `
75d7aa24 979 $MAKEINFO --version 2> /dev/null |
3cc53d60
PE
980 $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)'
981 ` in
982 '') MAKEINFO=no;;
983 esac
067d23c9
KY
984fi
985
986## Makeinfo is unusual. For a released Emacs, the manuals are
987## pre-built, and not deleted by the normal clean rules. makeinfo is
988## therefore in the category of "special tools" not normally required, which
989## configure does not have to check for (eg autoconf itself).
990## In a Bazaar checkout on the other hand, the manuals are not included.
991## So makeinfo is a requirement to build from Bazaar, and configure
992## should test for it as it does for any other build requirement.
993## We use the presence of $srcdir/info/emacs to distinguish a release,
994## with pre-built manuals, from a Bazaar checkout.
e5365138
GM
995HAVE_MAKEINFO=yes
996
067d23c9 997if test "$MAKEINFO" = "no"; then
e5365138 998 MAKEINFO=makeinfo
067d23c9 999 if test "x${with_makeinfo}" = "xno"; then
e5365138 1000 HAVE_MAKEINFO=no
3cc53d60 1001 elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
23df914b 1002 AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your
067d23c9
KY
1003source tree does not seem to have pre-built manuals in the `info' directory.
1004Either install a suitable version of makeinfo, or re-run configure
1005with the `--without-makeinfo' option to build without the manuals.] )
1006 fi
1007fi
e5365138 1008AC_SUBST(HAVE_MAKEINFO)
067d23c9 1009
8045b906
GM
1010dnl Just so that there is only a single place we need to edit.
1011INFO_EXT=.info
1012INFO_OPTS=--no-split
1013AC_SUBST(INFO_EXT)
1014AC_SUBST(INFO_OPTS)
1015
1857cd3f 1016if test $opsys = mingw32; then
0acfedd3 1017 DOCMISC_W32=efaq-w32
1857cd3f 1018else
0acfedd3 1019 DOCMISC_W32=
1857cd3f 1020fi
0acfedd3 1021AC_SUBST(DOCMISC_W32)
1857cd3f 1022
067d23c9
KY
1023dnl Add our options to ac_link now, after it is set up.
1024
1025if test x$GCC = xyes; then
1026 test "x$GCC_LINK_TEST_OPTIONS" != x && \
1027 ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
1028else
1029 test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
1030 ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
1031fi
1032
1033dnl We need -znocombreloc if we're using a relatively recent GNU ld.
1034dnl If we can link with the flag, it shouldn't do any harm anyhow.
1035dnl (Don't use `-z nocombreloc' as -z takes no arg on Irix.)
1036dnl Treat GCC specially since it just gives a non-fatal `unrecognized option'
1037dnl if not built to support GNU ld.
1038
d7646461
GM
1039dnl For a long time, -znocombreloc was added to LDFLAGS rather than
1040dnl LD_SWITCH_SYSTEM_TEMACS. That is:
1041dnl * inappropriate, as LDFLAGS is a user option but this is essential.
1042dnl Eg "make LDFLAGS=... all" could run into problems,
71bd1a00 1043dnl http://bugs.debian.org/684788
d7646461
GM
1044dnl * unnecessary, since temacs is the only thing that actually needs it.
1045dnl Indeed this is where it was originally, prior to:
71bd1a00 1046dnl http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-03/msg00170.html
48b48f98 1047late_LDFLAGS="$LDFLAGS"
067d23c9 1048if test x$GCC = xyes; then
8d17ef8d 1049 LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
067d23c9 1050else
8d17ef8d 1051 LDFLAGS_NOCOMBRELOC="-znocombreloc"
067d23c9
KY
1052fi
1053
8d17ef8d
GM
1054LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
1055
067d23c9
KY
1056AC_MSG_CHECKING([for -znocombreloc])
1057AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1058 [AC_MSG_RESULT(yes)],
8d17ef8d 1059 LDFLAGS_NOCOMBRELOC=
067d23c9
KY
1060 [AC_MSG_RESULT(no)])
1061
48b48f98 1062LDFLAGS="$late_LDFLAGS"
067d23c9 1063
067d23c9
KY
1064dnl The function dump-emacs will not be defined and temacs will do
1065dnl (load "loadup") automatically unless told otherwise.
4004ef46 1066test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
067d23c9 1067case "$opsys" in
4004ef46 1068 your-opsys-here) CANNOT_DUMP=yes ;;
067d23c9 1069esac
4004ef46
GM
1070
1071test "$CANNOT_DUMP" = "yes" && \
1072 AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
1073
067d23c9
KY
1074AC_SUBST(CANNOT_DUMP)
1075
1076
1077UNEXEC_OBJ=unexelf.o
1078case "$opsys" in
1079 # MSDOS uses unexcoff.o
067d23c9
KY
1080 aix4-2)
1081 UNEXEC_OBJ=unexaix.o
1082 ;;
1083 cygwin)
1084 UNEXEC_OBJ=unexcw.o
1085 ;;
1086 darwin)
1087 UNEXEC_OBJ=unexmacosx.o
1088 ;;
1089 hpux10-20 | hpux11)
1090 UNEXEC_OBJ=unexhp9k800.o
1091 ;;
6758608f
EZ
1092 mingw32)
1093 UNEXEC_OBJ=unexw32.o
1094 ;;
067d23c9
KY
1095 sol2-10)
1096 # Use the Solaris dldump() function, called from unexsol.c, to dump
1097 # emacs, instead of the generic ELF dump code found in unexelf.c.
1098 # The resulting binary has a complete symbol table, and is better
1099 # for debugging and other observability tools (debuggers, pstack, etc).
b06b1098 1100 #
067d23c9
KY
1101 # If you encounter a problem using dldump(), please consider sending
1102 # a message to the OpenSolaris tools-linking mailing list:
1103 # http://mail.opensolaris.org/mailman/listinfo/tools-linking
b06b1098 1104 #
067d23c9
KY
1105 # It is likely that dldump() works with older Solaris too, but this has
1106 # not been tested, so for now this change is for Solaris 10 or newer.
1107 UNEXEC_OBJ=unexsol.o
1108 ;;
1109esac
1110
1111LD_SWITCH_SYSTEM=
1112case "$opsys" in
7e00831f 1113 freebsd|dragonfly)
067d23c9
KY
1114 ## Let `ld' find image libs and similar things in /usr/local/lib.
1115 ## The system compiler, GCC, has apparently been modified to not
1116 ## look there, contrary to what a stock GCC would do.
3c30e766
GM
1117### It's not our place to do this. See bug#10313#17.
1118### LD_SWITCH_SYSTEM=-L/usr/local/lib
1119 :
067d23c9
KY
1120 ;;
1121
1122 gnu-linux)
1123 ## cpp test was "ifdef __mips__", but presumably this is equivalent...
d6a003a8 1124 case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
067d23c9
KY
1125 ;;
1126
1127 netbsd)
3c30e766
GM
1128### It's not our place to do this. See bug#10313#17.
1129### LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
1130 :
067d23c9
KY
1131 ;;
1132
1133 openbsd)
bb8eb357 1134 ## Han Boetes <han@boetes.org> says this is necessary,
067d23c9
KY
1135 ## otherwise Emacs dumps core on elf systems.
1136 LD_SWITCH_SYSTEM="-Z"
1137 ;;
1138esac
1139AC_SUBST(LD_SWITCH_SYSTEM)
1140
1141ac_link="$ac_link $LD_SWITCH_SYSTEM"
1142
4d5c6349 1143## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
067d23c9
KY
1144## which has not been defined yet. When this was handled with cpp,
1145## it was expanded to null when configure sourced the s/*.h file.
1146## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1147## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1148## (or somesuch), but because it is supposed to go at the _front_
1149## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1150## Compare with the gnu-linux case below, which added to the end
1151## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1152## LD_SWITCH_SYSTEM_TEMACS.
1153case "$opsys" in
1154 netbsd|openbsd)
4d5c6349 1155 LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
067d23c9
KY
1156esac
1157
1158
1159C_SWITCH_MACHINE=
34374650
PE
1160case $canonical in
1161 alpha*)
067d23c9
KY
1162 AC_CHECK_DECL([__ELF__])
1163 if test "$ac_cv_have_decl___ELF__" = "yes"; then
1164 ## With ELF, make sure that all common symbols get allocated to in the
1165 ## data section. Otherwise, the dump of temacs may miss variables in
1166 ## the shared library that have been initialized. For example, with
1167 ## GNU libc, __malloc_initialized would normally be resolved to the
1168 ## shared library's .bss section, which is fatal.
1169 if test "x$GCC" = "xyes"; then
1170 C_SWITCH_MACHINE="-fno-common"
1171 else
9148ee92 1172 AC_MSG_ERROR([Non-GCC compilers are not supported.])
067d23c9
KY
1173 fi
1174 else
9148ee92
GM
1175 dnl This was the unexalpha.c case. Removed in 24.1, 2010-07-24,
1176 dnl albeit under the mistaken assumption that said file
1177 dnl was no longer used.
1178 AC_MSG_ERROR([Non-ELF systems are not supported since Emacs 24.1.])
067d23c9 1179 fi
34374650
PE
1180 ;;
1181esac
067d23c9
KY
1182AC_SUBST(C_SWITCH_MACHINE)
1183
1184AC_SUBST(UNEXEC_OBJ)
1185
1186C_SWITCH_SYSTEM=
1187## Some programs in src produce warnings saying certain subprograms
1188## are too complex and need a MAXMEM value greater than 2000 for
1189## additional optimization. --nils@exp-math.uni-essen.de
1190test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1191 C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
9e821c83 1192test "$opsys" = "mingw32" && C_SWITCH_SYSTEM="-mtune=pentium4"
067d23c9
KY
1193## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1194## It is redundant in glibc2, since we define _GNU_SOURCE.
1195AC_SUBST(C_SWITCH_SYSTEM)
1196
1197
1198LIBS_SYSTEM=
1199case "$opsys" in
1200 ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1201 aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1202
7e00831f 1203 freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
067d23c9
KY
1204
1205 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1206
1f5d53eb 1207 sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
067d23c9
KY
1208
1209 ## Motif needs -lgen.
1210 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1211esac
067d23c9 1212
7c4026b6 1213AC_SUBST(LIBS_SYSTEM)
067d23c9
KY
1214
1215### Make sure subsequent tests use flags consistent with the build flags.
1216
1217if test x"${OVERRIDE_CPPFLAGS}" != x; then
1218 CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1219else
1220 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1221fi
1222
c1e127f9
PE
1223# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
1224AC_DEFUN([AC_TYPE_SIZE_T])
2a84b02d
PE
1225# Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1226AC_DEFUN([AC_TYPE_UID_T])
c1e127f9 1227
067d23c9 1228
067d23c9 1229LIB_MATH=-lm
a9be7d2b
GM
1230dnl Current possibilities handled by sed (aix4-2 -> aix,
1231dnl gnu-linux -> gnu/linux, etc.):
1232dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux, irix.
1233dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
98d8c1f9 1234SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
067d23c9
KY
1235
1236case $opsys in
1237 cygwin )
1238 LIB_MATH=
067d23c9
KY
1239 ;;
1240 darwin )
1241 ## Adding -lm confuses the dynamic linker, so omit it.
1242 LIB_MATH=
067d23c9 1243 ;;
7e00831f 1244 freebsd | dragonfly )
a9be7d2b 1245 SYSTEM_TYPE=berkeley-unix
067d23c9
KY
1246 ;;
1247 gnu-linux | gnu-kfreebsd )
067d23c9
KY
1248 ;;
1249 hpux10-20 | hpux11 )
067d23c9 1250 ;;
6758608f
EZ
1251 mingw32 )
1252 LIB_MATH=
cb11bd95 1253 SYSTEM_TYPE=windows-nt
6758608f 1254 ;;
0538fab0 1255 dnl NB this may be adjusted below.
067d23c9 1256 netbsd | openbsd )
a9be7d2b 1257 SYSTEM_TYPE=berkeley-unix
067d23c9 1258 ;;
a9be7d2b
GM
1259
1260 sol2* | unixware )
1261 SYSTEM_TYPE=usg-unix-v
1262 ;;
1263
067d23c9
KY
1264esac
1265
1266AC_SUBST(LIB_MATH)
a9be7d2b
GM
1267AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1268 [The type of system you are compiling for; sets `system-type'.])
067d23c9 1269
adbc4ef4 1270
5dad233c
PE
1271pre_PKG_CONFIG_CFLAGS=$CFLAGS
1272pre_PKG_CONFIG_LIBS=$LIBS
d35af63c 1273
0e7a053e
PE
1274AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1275
067d23c9
KY
1276dnl This function definition taken from Gnome 2.0
1277dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1278dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1279dnl also defines GSTUFF_PKG_ERRORS on error
1280AC_DEFUN([PKG_CHECK_MODULES], [
1281 succeeded=no
1282
067d23c9
KY
1283 if test "$PKG_CONFIG" = "no" ; then
1284 ifelse([$4], , [AC_MSG_ERROR([
3cc53d60 1285 *** The pkg-config script could not be found. Make sure it is in your path, or give the full name of pkg-config with the PKG_CONFIG environment variable or --with-pkg-config-prog. Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.])], [$4])
067d23c9
KY
1286 else
1287 PKG_CONFIG_MIN_VERSION=0.9.0
75d7aa24 1288 if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
067d23c9
KY
1289 AC_MSG_CHECKING(for $2)
1290
3cc53d60
PE
1291 if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
1292 $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
1293 $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
b8df54ff
PE
1294 edit_cflags="
1295 s,///*,/,g
1296 s/^/ /
1297 s/ -I/ $isystem/g
1298 s/^ //
1299 "
1300 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
bf6bba2b
PE
1301 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
1302 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
1303 succeeded=yes
067d23c9
KY
1304 else
1305 AC_MSG_RESULT(no)
1306 $1_CFLAGS=""
1307 $1_LIBS=""
1308 ## If we have a custom action on failure, don't print errors, but
e3141fcf
PE
1309 ## do set a variable so people can do so. Do it in a subshell
1310 ## to capture any diagnostics in invoking pkg-config.
3cc53d60 1311 $1_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$2") 2>&1`
e3141fcf 1312 ifelse([$4], ,echo "$$1_PKG_ERRORS",)
067d23c9
KY
1313 fi
1314
1315 AC_SUBST($1_CFLAGS)
1316 AC_SUBST($1_LIBS)
1317 else
1318 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1319 echo "*** See http://www.freedesktop.org/software/pkgconfig"
1320 fi
1321 fi
1322
1323 if test $succeeded = yes; then
1324 ifelse([$3], , :, [$3])
1325 else
1326 ifelse([$4], , [AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])], [$4])
1327 fi
1328])
1329
885e792c 1330HAVE_SOUND=no
067d23c9 1331if test "${with_sound}" != "no"; then
cb11bd95 1332 # Sound support for GNU/Linux, the free BSDs, and MinGW.
57f8c490 1333 AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h],
803ee343
EZ
1334 have_sound_header=yes, [], [
1335 #ifdef __MINGW32__
1336 #define WIN32_LEAN_AND_MEAN
1337 #include <windows.h>
1338 #endif
1339 ])
2c347217
GM
1340 test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
1341 AC_MSG_ERROR([OSS sound support requested but not found.])
e0936eed 1342
2c347217 1343 if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
885e792c
GM
1344 # Emulation library used on NetBSD.
1345 AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
2c347217
GM
1346 test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
1347 AC_MSG_ERROR([bsd-ossaudio sound support requested but not found.])
1348 dnl FIXME? If we did find ossaudio, should we set with_sound=bsd-ossaudio?
885e792c
GM
1349 dnl Traditionally, we go on to check for alsa too. Does that make sense?
1350 fi
067d23c9
KY
1351 AC_SUBST(LIBSOUND)
1352
885e792c
GM
1353 if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
1354 ALSA_REQUIRED=1.0.0
1355 ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1356 PKG_CHECK_MODULES(ALSA, $ALSA_MODULES, HAVE_ALSA=yes, HAVE_ALSA=no)
1357 if test $HAVE_ALSA = yes; then
1358 SAVE_CFLAGS="$CFLAGS"
1359 SAVE_LIBS="$LIBS"
1360 CFLAGS="$ALSA_CFLAGS $CFLAGS"
1361 LIBS="$ALSA_LIBS $LIBS"
1362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <asoundlib.h>]], [[snd_lib_error_set_handler (0);]])],
1363 emacs_alsa_normal=yes,
1364 emacs_alsa_normal=no)
1365 if test "$emacs_alsa_normal" != yes; then
1366 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alsa/asoundlib.h>]],
1367 [[snd_lib_error_set_handler (0);]])],
1368 emacs_alsa_subdir=yes,
1369 emacs_alsa_subdir=no)
1370 if test "$emacs_alsa_subdir" != yes; then
1371 AC_MSG_ERROR([pkg-config found alsa, but it does not compile. See config.log for error messages.])
1372 fi
1373 ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
067d23c9 1374 fi
067d23c9 1375
885e792c
GM
1376 CFLAGS="$SAVE_CFLAGS"
1377 LIBS="$SAVE_LIBS"
1378 LIBSOUND="$LIBSOUND $ALSA_LIBS"
1379 CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1380 AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1381 elif test "${with_sound}" = "alsa"; then
1382 AC_MSG_ERROR([ALSA sound support requested but not found.])
1383 fi
1384 fi dnl with_sound = alsa|yes
067d23c9
KY
1385
1386 dnl Define HAVE_SOUND if we have sound support. We know it works and
1387 dnl compiles only on the specified platforms. For others, it
1388 dnl probably doesn't make sense to try.
885e792c
GM
1389 dnl FIXME So surely we should bypass this whole section if not using
1390 dnl one of these platforms?
067d23c9
KY
1391 if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1392 case "$opsys" in
1393 dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
885e792c 1394 dnl Adjust the --with-sound help text if you change this.
09e94df2 1395 gnu-linux|freebsd|netbsd|mingw32)
cb11bd95 1396 AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
885e792c 1397 HAVE_SOUND=yes
cb11bd95 1398 ;;
067d23c9
KY
1399 esac
1400 fi
1401
1402 AC_SUBST(CFLAGS_SOUND)
1403fi
1404
1405dnl checks for header files
0e7a053e 1406AC_CHECK_HEADERS_ONCE(
57f8c490 1407 sys/systeminfo.h
2ef26ceb 1408 coff.h pty.h
1ddc2bd6 1409 sys/resource.h
95ef7787 1410 sys/utsname.h pwd.h utmp.h util.h)
067d23c9
KY
1411
1412AC_MSG_CHECKING(if personality LINUX32 can be set)
181855e6 1413AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/personality.h>]], [[personality (PER_LINUX32)]])],
067d23c9
KY
1414 emacs_cv_personality_linux32=yes,
1415 emacs_cv_personality_linux32=no)
1416AC_MSG_RESULT($emacs_cv_personality_linux32)
1417
1418if test $emacs_cv_personality_linux32 = yes; then
1419 AC_DEFINE(HAVE_PERSONALITY_LINUX32, 1,
1420 [Define to 1 if personality LINUX32 can be set.])
1421fi
1422
1423dnl On Solaris 8 there's a compilation warning for term.h because
1424dnl it doesn't define `bool'.
1425AC_CHECK_HEADERS(term.h, , , -)
067d23c9 1426AC_HEADER_TIME
c622b48f
PE
1427AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>
1428 ]])
067d23c9
KY
1429if test $ac_cv_have_decl_sys_siglist != yes; then
1430 # For Tru64, at least:
c622b48f
PE
1431 AC_CHECK_DECLS([__sys_siglist], [], [], [[#include <signal.h>
1432 ]])
067d23c9
KY
1433fi
1434AC_HEADER_SYS_WAIT
1435
0e7a053e 1436AC_CHECK_HEADERS_ONCE(sys/socket.h)
067d23c9
KY
1437AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1438#if HAVE_SYS_SOCKET_H
1439#include <sys/socket.h>
1440#endif])
377538cb
JD
1441AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1442#if HAVE_SYS_SOCKET_H
1443#include <sys/socket.h>
1444#endif])
1445AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1446#if HAVE_SYS_SOCKET_H
1447#include <sys/socket.h>
1448#endif])
067d23c9
KY
1449
1450dnl checks for structure members
067d23c9
KY
1451AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1452 struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
377538cb
JD
1453 struct ifreq.ifr_addr,
1454 struct ifreq.ifr_addr.sa_len], , ,
067d23c9
KY
1455 [AC_INCLUDES_DEFAULT
1456#if HAVE_SYS_SOCKET_H
1457#include <sys/socket.h>
1458#endif
1459#if HAVE_NET_IF_H
1460#include <net/if.h>
1461#endif])
1462
4c36be58 1463dnl Check for endianness.
0e7a053e 1464dnl AC_C_BIGENDIAN is done by gnulib.
067d23c9
KY
1465
1466dnl check for Make feature
0e7a053e 1467dnl AC_PROG_MAKE_SET is done by Automake.
067d23c9
KY
1468
1469DEPFLAGS=
1470MKDEPDIR=":"
1471deps_frag=deps.mk
1472dnl check for GNU Make if we have GCC and autodepend is on.
1473if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1474 AC_MSG_CHECKING([whether we are using GNU Make])
1475 HAVE_GNU_MAKE=no
d2eaf3e4 1476 testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'`
067d23c9
KY
1477 if test "x$testval" != x; then
1478 HAVE_GNU_MAKE=yes
1479 else
1480 ac_enable_autodepend=no
1481 fi
1482 AC_MSG_RESULT([$HAVE_GNU_MAKE])
1483 if test $HAVE_GNU_MAKE = yes; then
1484 AC_MSG_CHECKING([whether gcc understands -MMD -MF])
1485 SAVE_CFLAGS="$CFLAGS"
52ec1feb 1486 CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
181855e6 1487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , ac_enable_autodepend=no)
067d23c9
KY
1488 CFLAGS="$SAVE_CFLAGS"
1489 test -f deps.d || ac_enable_autodepend=no
1490 rm -rf deps.d
1491 AC_MSG_RESULT([$ac_enable_autodepend])
1492 fi
1493 if test $ac_enable_autodepend = yes; then
52ec1feb 1494 DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP'
3fe7cdc8
GM
1495 ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe.
1496 MKDEPDIR='${MKDIR_P} ${DEPDIR}'
067d23c9
KY
1497 deps_frag=autodeps.mk
1498 fi
1499fi
1500deps_frag=$srcdir/src/$deps_frag
1501AC_SUBST(MKDEPDIR)
1502AC_SUBST(DEPFLAGS)
1503AC_SUBST_FILE(deps_frag)
1504
1505
b9704ad9
GM
1506lisp_frag=$srcdir/src/lisp.mk
1507AC_SUBST_FILE(lisp_frag)
1508
1509
067d23c9
KY
1510dnl checks for operating system services
1511AC_SYS_LONG_FILE_NAMES
1512
1513#### Choose a window system.
1514
17a2cbbd
DC
1515## We leave window_system equal to none if
1516## we end up building without one. Any new window system should
1517## set window_system to an appropriate value and add objects to
1518## window-system-specific substs.
1519
1520window_system=none
067d23c9 1521AC_PATH_X
17a2cbbd 1522if test "$no_x" != yes; then
067d23c9
KY
1523 window_system=x11
1524fi
1525
4d5c6349 1526LD_SWITCH_X_SITE_RPATH=
067d23c9
KY
1527if test "${x_libraries}" != NONE; then
1528 if test -n "${x_libraries}"; then
1529 LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
1056cb66 1530 LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"`
067d23c9
KY
1531 fi
1532 x_default_search_path=""
1533 x_search_path=${x_libraries}
1534 if test -z "${x_search_path}"; then
1535 x_search_path=/usr/lib
1536 fi
1537 for x_library in `echo ${x_search_path}: | \
1538 sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1539 x_search_path="\
1540${x_library}/X11/%L/%T/%N%C%S:\
1541${x_library}/X11/%l/%T/%N%C%S:\
1542${x_library}/X11/%T/%N%C%S:\
1543${x_library}/X11/%L/%T/%N%S:\
1544${x_library}/X11/%l/%T/%N%S:\
1545${x_library}/X11/%T/%N%S"
1546 if test x"${x_default_search_path}" = x; then
1547 x_default_search_path=${x_search_path}
1548 else
1549 x_default_search_path="${x_search_path}:${x_default_search_path}"
1550 fi
1551 done
1552fi
4d5c6349 1553AC_SUBST(LD_SWITCH_X_SITE_RPATH)
067d23c9
KY
1554
1555if test "${x_includes}" != NONE && test -n "${x_includes}"; then
b8df54ff 1556 C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
067d23c9
KY
1557fi
1558
1559if test x"${x_includes}" = x; then
1560 bitmapdir=/usr/include/X11/bitmaps
1561else
1562 # accumulate include directories that have X11 bitmap subdirectories
1563 bmd_acc="dummyval"
1564 for bmd in `echo ${x_includes} | sed -e "s/:/ /g"`; do
1565 if test -d "${bmd}/X11/bitmaps"; then
1566 bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1567 fi
1568 if test -d "${bmd}/bitmaps"; then
1569 bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1570 fi
1571 done
1572 if test ${bmd_acc} != "dummyval"; then
1573 bitmapdir=`echo ${bmd_acc} | sed -e "s/^dummyval://"`
1574 fi
1575fi
1576
1577HAVE_NS=no
1578NS_IMPL_COCOA=no
1579NS_IMPL_GNUSTEP=no
1580tmp_CPPFLAGS="$CPPFLAGS"
1581tmp_CFLAGS="$CFLAGS"
1582CPPFLAGS="$CPPFLAGS -x objective-c"
1583CFLAGS="$CFLAGS -x objective-c"
0cc87afb 1584GNU_OBJC_CFLAGS=
2550c6e4 1585LIBS_GNUSTEP=
067d23c9
KY
1586if test "${with_ns}" != no; then
1587 if test "${opsys}" = darwin; then
1588 NS_IMPL_COCOA=yes
1589 ns_appdir=`pwd`/nextstep/Emacs.app
9e6b06ed 1590 ns_appbindir=${ns_appdir}/Contents/MacOS
067d23c9 1591 ns_appresdir=${ns_appdir}/Contents/Resources
83da1b55 1592 ns_appsrc=Cocoa/Emacs.base
067d23c9
KY
1593 elif test -f $GNUSTEP_CONFIG_FILE; then
1594 NS_IMPL_GNUSTEP=yes
1595 ns_appdir=`pwd`/nextstep/Emacs.app
9e6b06ed 1596 ns_appbindir=${ns_appdir}
067d23c9 1597 ns_appresdir=${ns_appdir}/Resources
83da1b55 1598 ns_appsrc=GNUstep/Emacs.base
067d23c9
KY
1599 dnl FIXME sourcing this several times in subshells seems inefficient.
1600 GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
1601 GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
1602 dnl I seemed to need these as well with GNUstep-startup 0.25.
1603 GNUSTEP_LOCAL_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_HEADERS)"
1604 GNUSTEP_LOCAL_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_LIBRARIES)"
1605 test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1606 GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1607 test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1608 GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1609 CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1610 CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1611 LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
2550c6e4 1612 LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
0cc87afb
GM
1613 dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1614 dnl If they had chosen to either define it or not, we could have
1615 dnl just used AC_CHECK_DECL here.
1616 AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1617 emacs_cv_objc_exceptions,
1618AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1619[[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
16201;
1621#else
1622fail;
1623#endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1624 if test $emacs_cv_objc_exceptions = yes; then
1625 dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1626 AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1627 [Define if GNUstep uses ObjC exceptions.])
1628 GNU_OBJC_CFLAGS="-fobjc-exceptions"
1629 fi
067d23c9 1630 fi
0cc87afb
GM
1631
1632 dnl This is only used while we test the NS headers, it gets reset below.
1633 CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1634
067d23c9
KY
1635 AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1636 [AC_MSG_ERROR([`--with-ns' was specified, but the include
1637 files are missing or cannot be compiled.])])
335f5ae4 1638
3fa2054e
JD
1639 macfont_file=""
1640 if test "${NS_IMPL_COCOA}" = "yes"; then
1641 AC_MSG_CHECKING([for OSX 10.4 or newer])
1642 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
335f5ae4
JD
1643 [
1644#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1645#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
1646 ; /* OK */
1647#else
1648#error "OSX 10.4 or newer required"
1649#endif
1650#endif
1651 ])],
1652 ns_osx_have_104=yes,
1653 ns_osx_have_104=no)
3fa2054e
JD
1654 AC_MSG_RESULT([$ns_osx_have_104])
1655
1656 if test $ns_osx_have_104 = no; then
1657 AC_MSG_ERROR([`OSX 10.4 or newer is required']);
1658 fi
1659 AC_MSG_CHECKING([for OSX 10.5 or newer])
1660 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1661 [
1662#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1663#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
1664 ; /* OK */
1665#else
1666#error "OSX 10.5 not found"
1667#endif
1668#endif
1669 ])],
1670 ns_osx_have_105=yes,
1671 ns_osx_have_105=no)
1672 AC_MSG_RESULT([$ns_osx_have_105])
1673 if test $ns_osx_have_105 = yes; then
1674 macfont_file="macfont.o"
1675 fi
1676 fi
067d23c9
KY
1677 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>],
1678 [NSInteger i;])],
1679 ns_have_nsinteger=yes,
1680 ns_have_nsinteger=no)
b1aa797c
GM
1681 if test $ns_have_nsinteger = yes; then
1682 AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
067d23c9
KY
1683 fi
1684fi
0fda9b75 1685
2550c6e4 1686AC_SUBST(LIBS_GNUSTEP)
067d23c9 1687
0629a797 1688INSTALL_ARCH_INDEP_EXTRA=install-etc
b4a36200 1689ns_self_contained=no
067d23c9 1690NS_OBJ=
00b3c7ac 1691NS_OBJC_OBJ=
067d23c9 1692if test "${HAVE_NS}" = yes; then
44f92739 1693 if test "$with_toolkit_scroll_bars" = "no"; then
f52bac22 1694 AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for Nextstep.])
44f92739
GM
1695 fi
1696
067d23c9 1697 window_system=nextstep
067d23c9 1698 # set up packaging dirs
067d23c9 1699 if test "${EN_NS_SELF_CONTAINED}" = yes; then
b4a36200 1700 ns_self_contained=yes
067d23c9 1701 prefix=${ns_appresdir}
816be9f6 1702 exec_prefix=${ns_appbindir}
3a4155de
GM
1703 dnl This one isn't really used, only archlibdir is.
1704 libexecdir="\${ns_appbindir}/libexec"
1705 archlibdir="\${ns_appbindir}/libexec"
8496d8d7 1706 etcdocdir="\${ns_appresdir}/etc"
b42c720d 1707 etcdir="\${ns_appresdir}/etc"
40c117e7
GM
1708 dnl FIXME maybe set datarootdir instead.
1709 dnl That would also get applications, icons, man.
1710 infodir="\${ns_appresdir}/info"
37f36bcb 1711 mandir="\${ns_appresdir}/man"
b42c720d 1712 lispdir="\${ns_appresdir}/lisp"
d71dfe75 1713 leimdir="\${ns_appresdir}/leim"
0629a797 1714 INSTALL_ARCH_INDEP_EXTRA=
067d23c9 1715 fi
3fa2054e
JD
1716
1717 NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o $macfont_file"
067d23c9
KY
1718fi
1719CFLAGS="$tmp_CFLAGS"
1720CPPFLAGS="$tmp_CPPFLAGS"
0629a797 1721AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
b4a36200 1722AC_SUBST(ns_self_contained)
067d23c9 1723AC_SUBST(NS_OBJ)
00b3c7ac 1724AC_SUBST(NS_OBJC_OBJ)
067d23c9 1725
0fda9b75
DC
1726HAVE_W32=no
1727W32_OBJ=
1728W32_LIBS=
095bf253
EZ
1729EMACSRES=
1730CLIENTRES=
f540ee86 1731CLIENTW=
1cf1bbd5 1732W32_RES_LINK=
095bf253 1733EMACS_MANIFEST=
d4166523 1734UPDATE_MANIFEST=
0fda9b75 1735if test "${with_w32}" != no; then
09e94df2 1736 case "${opsys}" in
31ff141c 1737 cygwin)
09e94df2
EZ
1738 AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
1739 [AC_MSG_ERROR([`--with-w32' was specified, but windows.h
31ff141c 1740 cannot be found.])])
09e94df2
EZ
1741 ;;
1742 mingw32)
1743 ## Using --with-w32 with MinGW is a no-op, but we allow it.
1744 ;;
31ff141c 1745 *)
fb0862b2 1746 AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
09e94df2
EZ
1747 ;;
1748 esac
6758608f 1749fi
09e94df2 1750
6758608f 1751if test "${opsys}" = "mingw32"; then
1f8f81c8
EZ
1752 AC_MSG_CHECKING([whether Windows API headers are recent enough])
1753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1754 #include <windows.h>
1755 #include <usp10.h>]],
2aae948d
PR
1756 [[PIMAGE_NT_HEADERS pHeader;
1757 PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
09e94df2 1758 [emacs_cv_w32api=yes
31ff141c 1759 HAVE_W32=yes],
09e94df2 1760 emacs_cv_w32api=no)
1f8f81c8
EZ
1761 AC_MSG_RESULT($emacs_cv_w32api)
1762 if test "${emacs_cv_w32api}" = "no"; then
1763 AC_MSG_ERROR([the Windows API headers are too old to support this build.])
1764 fi
6758608f
EZ
1765fi
1766
095bf253 1767FIRSTFILE_OBJ=
030a1c5e 1768NTDIR=
d6db9fd6
EZ
1769LIBS_ECLIENT=
1770LIB_WSOCK32=
1771NTLIB=
86e93460 1772CM_OBJ="cm.o"
5e00cfa5 1773XARGS_LIMIT=
6758608f 1774if test "${HAVE_W32}" = "yes"; then
dc098568 1775 AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
1cf1bbd5
DC
1776 AC_CHECK_TOOL(WINDRES, [windres],
1777 [AC_MSG_ERROR([No resource compiler found.])])
0fda9b75
DC
1778 W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
1779 W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
095bf253
EZ
1780 EMACSRES="emacs.res"
1781 case "$canonical" in
1782 x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
1783 *) EMACS_MANIFEST="emacs-x86.manifest" ;;
1784 esac
d4166523 1785 UPDATE_MANIFEST=update-game-score.exe.manifest
fb0862b2 1786 if test "${opsys}" = "cygwin"; then
6758608f
EZ
1787 W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
1788 W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
d76bf86f
EZ
1789 # Tell the linker that emacs.res is an object (which we compile from
1790 # the rc file), not a linker script.
eb7a410c 1791 W32_RES_LINK="-Wl,emacs.res"
6758608f 1792 else
fb0862b2 1793 W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
7c4026b6 1794 W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
d6db9fd6 1795 W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
f1fecede 1796 W32_RES_LINK="\$(EMACSRES)"
095bf253 1797 CLIENTRES="emacsclient.res"
f540ee86 1798 CLIENTW="emacsclientw\$(EXEEXT)"
095bf253 1799 FIRSTFILE_OBJ=firstfile.o
030a1c5e 1800 NTDIR=nt
86e93460 1801 CM_OBJ=
d6db9fd6
EZ
1802 LIBS_ECLIENT="-lcomctl32"
1803 LIB_WSOCK32="-lwsock32"
1804 NTLIB="ntlib.$ac_objext"
5e00cfa5 1805 XARGS_LIMIT="-s 10000"
6758608f 1806 fi
0fda9b75
DC
1807fi
1808AC_SUBST(W32_OBJ)
1809AC_SUBST(W32_LIBS)
095bf253
EZ
1810AC_SUBST(EMACSRES)
1811AC_SUBST(EMACS_MANIFEST)
d4166523 1812AC_SUBST(UPDATE_MANIFEST)
095bf253 1813AC_SUBST(CLIENTRES)
f540ee86 1814AC_SUBST(CLIENTW)
1cf1bbd5 1815AC_SUBST(W32_RES_LINK)
095bf253 1816AC_SUBST(FIRSTFILE_OBJ)
030a1c5e 1817AC_SUBST(NTDIR)
86e93460 1818AC_SUBST(CM_OBJ)
d6db9fd6
EZ
1819AC_SUBST(LIBS_ECLIENT)
1820AC_SUBST(LIB_WSOCK32)
1821AC_SUBST(NTLIB)
5e00cfa5 1822AC_SUBST(XARGS_LIMIT)
0fda9b75
DC
1823
1824if test "${HAVE_W32}" = "yes"; then
1825 window_system=w32
1826 with_xft=no
1827fi
1828
17a2cbbd
DC
1829## $window_system is now set to the window system we will
1830## ultimately use.
1831
257b3b03
DA
1832if test "$window_system" = none && test "$gl_gcc_warnings" = yes; then
1833 # Too many warnings for now.
4b73fc73
PE
1834 nw=
1835 nw="$nw -Wsuggest-attribute=const"
1836 nw="$nw -Wsuggest-attribute=noreturn"
1837 gl_MANYWARN_COMPLEMENT([WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
1838
257b3b03
DA
1839 gl_WARN_ADD([-Wno-unused-variable])
1840 gl_WARN_ADD([-Wno-unused-but-set-variable])
1841 gl_WARN_ADD([-Wno-unused-but-set-parameter])
1842fi
1843
17a2cbbd
DC
1844term_header=
1845HAVE_X_WINDOWS=no
1846HAVE_X11=no
1847USE_X_TOOLKIT=none
1848
067d23c9
KY
1849case "${window_system}" in
1850 x11 )
1851 HAVE_X_WINDOWS=yes
1852 HAVE_X11=yes
17a2cbbd 1853 term_header=xterm.h
067d23c9
KY
1854 case "${with_x_toolkit}" in
1855 athena | lucid ) USE_X_TOOLKIT=LUCID ;;
1856 motif ) USE_X_TOOLKIT=MOTIF ;;
1857 gtk ) with_gtk=yes
17a2cbbd 1858 term_header=gtkutil.h
c7015153 1859dnl Don't set this for GTK. A lot of tests below assumes Xt when
067d23c9
KY
1860dnl USE_X_TOOLKIT is set.
1861 USE_X_TOOLKIT=none ;;
d673aedc
JD
1862 gtk2 ) with_gtk2=yes
1863 term_header=gtkutil.h
1864 USE_X_TOOLKIT=none ;;
067d23c9 1865 gtk3 ) with_gtk3=yes
17a2cbbd 1866 term_header=gtkutil.h
067d23c9
KY
1867 USE_X_TOOLKIT=none ;;
1868 no ) USE_X_TOOLKIT=none ;;
1869dnl If user did not say whether to use a toolkit, make this decision later:
1870dnl use the toolkit if we have gtk, or X11R5 or newer.
1871 * ) USE_X_TOOLKIT=maybe ;;
1872 esac
1873 ;;
17a2cbbd
DC
1874 nextstep )
1875 term_header=nsterm.h
067d23c9 1876 ;;
0fda9b75
DC
1877 w32 )
1878 term_header=w32term.h
1879 ;;
067d23c9
KY
1880esac
1881
1882if test "$window_system" = none && test "X$with_x" != "Xno"; then
1883 AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
1884 if test "$HAVE_XSERVER" = true ||
1885 test -n "$DISPLAY" ||
1886 test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
1887 AC_MSG_ERROR([You seem to be running X, but no X development libraries
1888were found. You should install the relevant development files for X
1889and for the toolkit you want, such as Gtk+, Lesstif or Motif. Also make
1890sure you have development files for image handling, i.e.
1891tiff, gif, jpeg, png and xpm.
1892If you are sure you want Emacs compiled without X window support, pass
1893 --without-x
1894to configure.])
1895 fi
1896fi
1897
50a5f95e
EZ
1898### We always support menus.
1899HAVE_MENUS=yes
067d23c9 1900
34374650 1901# Does the opsystem file prohibit the use of the GNU malloc?
067d23c9
KY
1902# Assume not, until told otherwise.
1903GNU_MALLOC=yes
4b5b5289
PE
1904
1905AC_CACHE_CHECK(
1906 [whether malloc is Doug Lea style],
1907 [emacs_cv_var_doug_lea_malloc],
1908 [AC_LINK_IFELSE(
1909 [AC_LANG_PROGRAM(
1910 [[#include <malloc.h>
1911 static void hook (void) {}]],
1912 [[malloc_set_state (malloc_get_state ());
1913 __after_morecore_hook = hook;
1914 __malloc_initialize_hook = hook;]])],
1915 [emacs_cv_var_doug_lea_malloc=yes],
1916 [emacs_cv_var_doug_lea_malloc=no])])
1917doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
067d23c9
KY
1918
1919
1920dnl See comments in aix4-2.h about maybe using system malloc there.
1921system_malloc=no
1922case "$opsys" in
1923 ## darwin ld insists on the use of malloc routines in the System framework.
1924 darwin|sol2-10) system_malloc=yes ;;
1925esac
1926
1927if test "${system_malloc}" = "yes"; then
1928 AC_DEFINE(SYSTEM_MALLOC, 1, [Define to use system malloc.])
1929 GNU_MALLOC=no
1930 GNU_MALLOC_reason="
1931 (The GNU allocators don't work with this system configuration.)"
1932 GMALLOC_OBJ=
1933 VMLIMIT_OBJ=
1934else
1935 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
1936 VMLIMIT_OBJ=vm-limit.o
1ddc2bd6
PE
1937
1938 AC_CHECK_HEADERS([sys/vlimit.h])
1939 AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
1940 [AC_LINK_IFELSE(
1941 [AC_LANG_PROGRAM(
1942 [[extern char data_start[]; char ch;]],
0e946786 1943 [[return data_start < &ch;]])],
1ddc2bd6
PE
1944 [emacs_cv_data_start=yes],
1945 [emacs_cv_data_start=no])])
1946 if test $emacs_cv_data_start = yes; then
1947 AC_DEFINE([HAVE_DATA_START], 1,
1948 [Define to 1 if data_start is the address of the start
1949 of the main data segment.])
1950 fi
067d23c9
KY
1951fi
1952AC_SUBST(GMALLOC_OBJ)
1953AC_SUBST(VMLIMIT_OBJ)
1954
1955if test "$doug_lea_malloc" = "yes" ; then
1956 if test "$GNU_MALLOC" = yes ; then
1957 GNU_MALLOC_reason="
1958 (Using Doug Lea's new malloc from the GNU C Library.)"
1959 fi
1960 AC_DEFINE(DOUG_LEA_MALLOC, 1,
1961 [Define to 1 if you are using the GNU C Library.])
1962
1963 ## Use mmap directly for allocating larger buffers.
1964 ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
1965 ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
bbd240ce 1966 ## Does the AC_FUNC_MMAP test below make this check unnecessary?
067d23c9
KY
1967 case "$opsys" in
1968 gnu*) REL_ALLOC=no ;;
1969 esac
1970fi
1971
1972if test x"${REL_ALLOC}" = x; then
1973 REL_ALLOC=${GNU_MALLOC}
1974fi
1975
1976use_mmap_for_buffers=no
1977case "$opsys" in
fe0e7ad7 1978 cygwin|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
067d23c9
KY
1979esac
1980
1981AC_FUNC_MMAP
1982if test $use_mmap_for_buffers = yes; then
1983 AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
1984 REL_ALLOC=no
1985fi
1986
1987LIBS="$LIBS_SYSTEM $LIBS"
1988
57f8c490 1989dnl If found, this adds -ldnet to LIBS, which Autoconf uses for checks.
067d23c9
KY
1990AC_CHECK_LIB(dnet, dnet_ntoa)
1991dnl This causes -lresolv to get used in subsequent tests,
1992dnl which causes failures on some systems such as HPUX 9.
1993dnl AC_CHECK_LIB(resolv, gethostbyname)
1994
1995dnl FIXME replace main with a function we actually want from this library.
1996AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
1997
ae9e757a
JD
1998dnl Check if pthreads is available.
1999LIB_PTHREAD=
0e7a053e 2000AC_CHECK_HEADERS_ONCE(pthread.h)
ae9e757a 2001if test "$ac_cv_header_pthread_h"; then
adee8a65
PE
2002 dnl gmalloc.c uses pthread_atfork, which is not available on older-style
2003 dnl hosts such as MirBSD 10, so test for pthread_atfork instead of merely
2004 dnl testing for pthread_self if Emacs uses gmalloc.c.
2005 if test "$GMALLOC_OBJ" = gmalloc.o; then
2006 emacs_pthread_function=pthread_atfork
2007 else
2008 emacs_pthread_function=pthread_self
2009 fi
2010 AC_CHECK_LIB(pthread, $emacs_pthread_function, HAVE_PTHREAD=yes)
ae9e757a
JD
2011fi
2012if test "$HAVE_PTHREAD" = yes; then
2013 case "${canonical}" in
2014 *-hpux*) ;;
e782cfab
PE
2015 *) LIB_PTHREAD="-lpthread"
2016 LIBS="$LIB_PTHREAD $LIBS" ;;
ae9e757a
JD
2017 esac
2018 AC_DEFINE(HAVE_PTHREAD, 1, [Define to 1 if you have pthread (-lpthread).])
2019fi
2020AC_SUBST([LIB_PTHREAD])
2021
067d23c9
KY
2022AC_CHECK_LIB(pthreads, cma_open)
2023
2024## Note: when using cpp in s/aix4.2.h, this definition depended on
2025## HAVE_LIBPTHREADS. That was not defined earlier in configure when
2026## the system file was sourced. Hence the value of LIBS_SYSTEM
2027## added to LIBS in configure would never contain the pthreads part,
2028## but the value used in Makefiles might. FIXME?
2029##
2030## -lpthreads seems to be necessary for Xlib in X11R6, and should
2031## be harmless on older versions of X where it happens to exist.
2032test "$opsys" = "aix4-2" && \
2033 test $ac_cv_lib_pthreads_cma_open = yes && \
2034 LIBS_SYSTEM="$LIBS_SYSTEM -lpthreads"
2035
2036dnl Check for need for bigtoc support on IBM AIX
2037
2038case ${host_os} in
2039aix*)
2040 AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
2041 case $GCC in
2042 yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
2043 *) gdb_cv_bigtoc=-bbigtoc ;;
2044 esac
2045
2046 LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
181855e6 2047 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
067d23c9
KY
2048 ])
2049 ;;
2050esac
2051
2052# Change CFLAGS and CPPFLAGS temporarily so that C_SWITCH_X_SITE gets
2053# used for the tests that follow. We set them back to REAL_CFLAGS and
2054# REAL_CPPFLAGS later on.
2055
2056REAL_CFLAGS="$CFLAGS"
2057REAL_CPPFLAGS="$CPPFLAGS"
2058
2059if test "${HAVE_X11}" = "yes"; then
2060 DEFS="$C_SWITCH_X_SITE $DEFS"
2061 LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
2062 LIBS="-lX11 $LIBS"
2063 CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
2064 CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
2065
2066 # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
4d5c6349 2067 # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
4737362e 2068 # but it's more convenient here to set LD_RUN_PATH since this
4d5c6349 2069 # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
067d23c9
KY
2070 if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
2071 LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
2072 export LD_RUN_PATH
2073 fi
2074
2075 if test "${opsys}" = "gnu-linux"; then
2076 AC_MSG_CHECKING(whether X on GNU/Linux needs -b to link)
181855e6
GM
2077 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2078 [[XOpenDisplay ("foo");]])],
423dbf9b
RS
2079 [xgnu_linux_first_failure=no],
2080 [xgnu_linux_first_failure=yes])
2081 if test "${xgnu_linux_first_failure}" = "yes"; then
067d23c9
KY
2082 OLD_LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE"
2083 OLD_C_SWITCH_X_SITE="$C_SWITCH_X_SITE"
2084 OLD_CPPFLAGS="$CPPFLAGS"
2085 OLD_LIBS="$LIBS"
2086 LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
2087 C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
2088 CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
2089 LIBS="$LIBS -b i486-linuxaout"
181855e6
GM
2090 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2091 [[XOpenDisplay ("foo");]])],
423dbf9b
RS
2092 [xgnu_linux_second_failure=no],
2093 [xgnu_linux_second_failure=yes])
2094 if test "${xgnu_linux_second_failure}" = "yes"; then
067d23c9
KY
2095 # If we get the same failure with -b, there is no use adding -b.
2096 # So take it out. This plays safe.
2097 LD_SWITCH_X_SITE="$OLD_LD_SWITCH_X_SITE"
2098 C_SWITCH_X_SITE="$OLD_C_SWITCH_X_SITE"
2099 CPPFLAGS="$OLD_CPPFLAGS"
2100 LIBS="$OLD_LIBS"
2101 AC_MSG_RESULT(no)
2102 else
2103 AC_MSG_RESULT(yes)
2104 fi
2105 else
2106 AC_MSG_RESULT(no)
2107 fi
2108 fi
2109
2110 # Reportedly, some broken Solaris systems have XKBlib.h but are missing
2111 # header files included from there.
2112 AC_MSG_CHECKING(for Xkb)
181855e6
GM
2113 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
2114#include <X11/XKBlib.h>]],
2115 [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
067d23c9
KY
2116 emacs_xkb=yes, emacs_xkb=no)
2117 AC_MSG_RESULT($emacs_xkb)
2118 if test $emacs_xkb = yes; then
a4cedbf7 2119 AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
067d23c9
KY
2120 fi
2121
2122 AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
9232a6d9 2123XScreenNumberOfScreen)
067d23c9
KY
2124fi
2125
2126if test "${window_system}" = "x11"; then
2127 AC_MSG_CHECKING(X11 version 6)
2128 AC_CACHE_VAL(emacs_cv_x11_version_6,
181855e6
GM
2129 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
2130[[#if XlibSpecificationRelease < 6
067d23c9
KY
2131fail;
2132#endif
181855e6 2133]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
067d23c9
KY
2134 if test $emacs_cv_x11_version_6 = yes; then
2135 AC_MSG_RESULT(6 or newer)
2136 AC_DEFINE(HAVE_X11R6, 1,
2137 [Define to 1 if you have the X11R6 or newer version of Xlib.])
2138 AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
2139 ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
2140 ## XIM support.
2141 case "$opsys" in
2142 sol2-*) : ;;
2143 *) AC_DEFINE(HAVE_X11R6_XIM, 1,
2144 [Define if you have usable X11R6-style XIM support.])
2145 ;;
2146 esac
2147 else
2148 AC_MSG_RESULT(before 6)
2149 fi
2150fi
2151
2152
2153### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
2154HAVE_RSVG=no
fb0862b2 2155if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
067d23c9
KY
2156 if test "${with_rsvg}" != "no"; then
2157 RSVG_REQUIRED=2.11.0
2158 RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2159
2160 PKG_CHECK_MODULES(RSVG, $RSVG_MODULE, HAVE_RSVG=yes, :)
2161 AC_SUBST(RSVG_CFLAGS)
2162 AC_SUBST(RSVG_LIBS)
2163
2164 if test $HAVE_RSVG = yes; then
2165 AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2166 CFLAGS="$CFLAGS $RSVG_CFLAGS"
2167 LIBS="$RSVG_LIBS $LIBS"
2168 fi
2169 fi
2170fi
2171
2172HAVE_IMAGEMAGICK=no
e4b1e5af 2173if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
067d23c9 2174 if test "${with_imagemagick}" != "no"; then
f5b06c35
GM
2175 ## 6.2.8 is the earliest version known to work, but earlier versions
2176 ## might work - let us know if you find one.
2177 ## 6.0.7 does not work. See bug#7955.
19151a7f
PE
2178 ## 6.8.2 makes Emacs crash; see Bug#13867.
2179 IMAGEMAGICK_MODULE="Wand >= 6.2.8 Wand != 6.8.2"
067d23c9
KY
2180 PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, HAVE_IMAGEMAGICK=yes, :)
2181 AC_SUBST(IMAGEMAGICK_CFLAGS)
2182 AC_SUBST(IMAGEMAGICK_LIBS)
b06b1098 2183
067d23c9
KY
2184 if test $HAVE_IMAGEMAGICK = yes; then
2185 AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.])
2186 CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
2187 LIBS="$IMAGEMAGICK_LIBS $LIBS"
03043c1b 2188 AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
067d23c9
KY
2189 fi
2190 fi
2191fi
2192
2193
2194HAVE_GTK=no
c195f2de 2195GTK_OBJ=
8f5f35cc 2196gtk_term_header=$term_header
d673aedc
JD
2197check_gtk2=no
2198gtk3_pkg_errors=
fb0862b2
EZ
2199if test "${opsys}" != "mingw32"; then
2200 if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
2201 GLIB_REQUIRED=2.28
2202 GTK_REQUIRED=3.0
2203 GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2204
2205 dnl Checks for libraries.
2206 PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
2207 if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
2208 AC_MSG_ERROR($GTK_PKG_ERRORS)
2209 fi
2210 if test "$pkg_check_gtk" = "yes"; then
2211 AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
2212 GTK_OBJ=emacsgtkfixed.o
8f5f35cc 2213 gtk_term_header=gtkutil.h
fb0862b2 2214 USE_GTK_TOOLKIT="GTK3"
d76bf86f
EZ
2215 if test "x$ac_enable_gtk_deprecation_warnings" = x; then
2216 GTK_CFLAGS="$GTK_CFLAGS -DGDK_DISABLE_DEPRECATION_WARNINGS"
31ff141c 2217 GTK_CFLAGS="$GTK_CFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS"
d76bf86f 2218 fi
fb0862b2
EZ
2219 else
2220 check_gtk2=yes
2221 gtk3_pkg_errors="$GTK_PKG_ERRORS "
2222 fi
d673aedc 2223 fi
067d23c9 2224
fb0862b2
EZ
2225 if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
2226 GLIB_REQUIRED=2.10
2227 GTK_REQUIRED=2.10
2228 GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2229
2230 dnl Checks for libraries.
2231 PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
2232 if test "$pkg_check_gtk" = "no" &&
2233 { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
2234 then
2235 AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
2236 fi
2237 test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
067d23c9
KY
2238 fi
2239fi
067d23c9 2240
067d23c9
KY
2241if test x"$pkg_check_gtk" = xyes; then
2242
2243 AC_SUBST(GTK_CFLAGS)
2244 AC_SUBST(GTK_LIBS)
2245 C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
2246 CFLAGS="$CFLAGS $GTK_CFLAGS"
2247 LIBS="$GTK_LIBS $LIBS"
2248 dnl Try to compile a simple GTK program.
5583dcb6 2249 AC_MSG_CHECKING([whether GTK compiles])
067d23c9 2250 GTK_COMPILES=no
5583dcb6
PE
2251 AC_LINK_IFELSE(
2252 [AC_LANG_PROGRAM(
2253 [[/* Check the Gtk and Glib APIs. */
2254 #include <gtk/gtk.h>
2255 #include <glib-object.h>
2256 static void
2257 callback (GObject *go, GParamSpec *spec, gpointer user_data)
2258 {}
2259 ]],
2260 [[
2261 GtkSettings *gs = 0;
2262 /* Use G_CALLBACK to make sure function pointers can be cast to void *;
2263 strict C prohibits this. Use gtk_main_iteration to test that the
2264 libraries are there. */
2265 if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
2266 0, 0, 0, G_CALLBACK (callback), 0))
2267 gtk_main_iteration ();
2268 ]])],
2269 [GTK_COMPILES=yes])
2270 AC_MSG_RESULT([$GTK_COMPILES])
067d23c9 2271 if test "${GTK_COMPILES}" != "yes"; then
8f5f35cc 2272 GTK_OBJ=
067d23c9
KY
2273 if test "$USE_X_TOOLKIT" != "maybe"; then
2274 AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log. Maybe some x11-devel files missing?]);
2275 fi
2276 else
2277 HAVE_GTK=yes
2278 AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
c195f2de 2279 GTK_OBJ="gtkutil.o $GTK_OBJ"
8f5f35cc 2280 term_header=$gtk_term_header
067d23c9 2281 USE_X_TOOLKIT=none
3cc53d60 2282 if "$PKG_CONFIG" --atleast-version=2.10 gtk+-2.0; then
067d23c9
KY
2283 :
2284 else
2285 AC_MSG_WARN([[Your version of Gtk+ will have problems with
2286 closing open displays. This is no problem if you just use
2287 one display, but if you use more than one and close one of them
2288 Emacs may crash.]])
2289 sleep 3
2290 fi
2291 fi
2292
2293fi
2294AC_SUBST(GTK_OBJ)
2295
2296
2297if test "${HAVE_GTK}" = "yes"; then
2298
2299 dnl GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2300 dnl a lot if #ifdef:s, say we have toolkit scrollbars.
2301 if test "$with_toolkit_scroll_bars" != no; then
2302 with_toolkit_scroll_bars=yes
2303 fi
2304
2305 dnl Check if we have the old file selection dialog declared and
2306 dnl in the link library. In 2.x it may be in the library,
2307 dnl but not declared if deprecated featured has been selected out.
2308 dnl AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2309 HAVE_GTK_FILE_SELECTION=no
2310 AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2311 HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2312#include <gtk/gtk.h>])
2313 if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2314 AC_CHECK_FUNCS(gtk_file_selection_new)
2315 fi
2316
5a1d858b
JD
2317 dnl Same as above for gtk_handle_box.
2318 HAVE_GTK_HANDLE_BOX=no
2319 AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
2320 HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
2321#include <gtk/gtk.h>])
2322 if test "$HAVE_GTK_HANDLE_BOX" = yes; then
2323 AC_CHECK_FUNCS(gtk_handle_box_new)
2324 fi
067d23c9 2325
8b745d92
JD
2326 dnl Same as above for gtk_tearoff_menu_item.
2327 HAVE_GTK_TEAROFF_MENU_ITEM=no
2328 AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
2329 HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
2330#include <gtk/gtk.h>])
2331 if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
2332 AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
2333 fi
067d23c9
KY
2334
2335 dnl Check for functions introduced in 2.14 and later.
2336 AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
2337 gtk_dialog_get_action_area gtk_widget_get_sensitive \
2338 gtk_widget_get_mapped gtk_adjustment_get_page_size \
54e9e3bf
JD
2339 gtk_orientable_set_orientation \
2340 gtk_window_set_has_resize_grip)
17a2cbbd
DC
2341
2342 term_header=gtkutil.h
067d23c9
KY
2343fi
2344
2345dnl D-Bus has been tested under GNU/Linux only. Must be adapted for
dcbf5805 2346dnl other platforms.
067d23c9
KY
2347HAVE_DBUS=no
2348DBUS_OBJ=
2349if test "${with_dbus}" = "yes"; then
2350 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, HAVE_DBUS=yes, HAVE_DBUS=no)
2351 if test "$HAVE_DBUS" = yes; then
2352 LIBS="$LIBS $DBUS_LIBS"
2353 AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
dcbf5805 2354 dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
e3a3e213
MA
2355 dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2356 dnl D-Bus 1.5.12.
dcbf5805 2357 AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
e3a3e213 2358 dbus_type_is_valid \
dcbf5805
MA
2359 dbus_validate_bus_name \
2360 dbus_validate_path \
2361 dbus_validate_interface \
2362 dbus_validate_member)
067d23c9
KY
2363 DBUS_OBJ=dbusbind.o
2364 fi
2365fi
2366AC_SUBST(DBUS_OBJ)
2367
9851bfc5
JD
2368dnl GSettings has been tested under GNU/Linux only.
2369HAVE_GSETTINGS=no
2370if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2ad77c9d 2371 PKG_CHECK_MODULES(GSETTINGS, gio-2.0 >= 2.26, HAVE_GSETTINGS=yes, HAVE_GSETTINGS=no)
2e6e11eb 2372 if test "$HAVE_GSETTINGS" = "yes"; then
9851bfc5
JD
2373 AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2374 SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2375 SETTINGS_LIBS="$GSETTINGS_LIBS"
2376 fi
2377fi
2378
067d23c9
KY
2379dnl GConf has been tested under GNU/Linux only.
2380dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2381HAVE_GCONF=no
869795d6 2382if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
067d23c9
KY
2383 PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no)
2384 if test "$HAVE_GCONF" = yes; then
2385 AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2386 dnl Newer GConf doesn't link with g_objects, so this is not defined.
869795d6
JD
2387 SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2388 SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
067d23c9
KY
2389 fi
2390fi
2391
2e6e11eb 2392if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
f278d339
JD
2393 PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= 2.0, HAVE_GOBJECT=yes, HAVE_GOBJECT=no)
2394 if test "$HAVE_GOBJECT" = "yes"; then
2395 SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2396 SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2397 fi
9851bfc5 2398 SAVE_CFLAGS="$CFLAGS"
46d14be7 2399 SAVE_LIBS="$LIBS"
9851bfc5 2400 CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
46d14be7 2401 LIBS="$SETTINGS_LIBS $LIBS"
9851bfc5 2402 CFLAGS="$SAVE_CFLAGS"
46d14be7 2403 LIBS="$SAVE_LIBS"
9851bfc5
JD
2404fi
2405AC_SUBST(SETTINGS_CFLAGS)
2406AC_SUBST(SETTINGS_LIBS)
2407
2408
067d23c9
KY
2409dnl SELinux is available for GNU/Linux only.
2410HAVE_LIBSELINUX=no
2411LIBSELINUX_LIBS=
2412if test "${with_selinux}" = "yes"; then
2413 AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2414 if test "$HAVE_LIBSELINUX" = yes; then
2415 AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2416 LIBSELINUX_LIBS=-lselinux
2417 fi
2418fi
2419AC_SUBST(LIBSELINUX_LIBS)
2420
2421HAVE_GNUTLS=no
e1f9f9e3 2422HAVE_GNUTLS3=no
067d23c9 2423if test "${with_gnutls}" = "yes" ; then
e1f9f9e3 2424 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 3.0.0], HAVE_GNUTLS3=yes, HAVE_GNUTLS3=no)
e1f9f9e3
TZ
2425 if test "${HAVE_GNUTLS3}" = "yes"; then
2426 AC_DEFINE(HAVE_GNUTLS3, 1, [Define if using GnuTLS v3.])
c5fc0178
SM
2427 HAVE_GNUTLS="yes"
2428 else
2429 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.6.6], HAVE_GNUTLS=yes, HAVE_GNUTLS=no)
2430 fi
2431 if test "${HAVE_GNUTLS}" = "yes"; then
2432 AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
e1f9f9e3
TZ
2433 fi
2434
a414bed5
EZ
2435 # Windows loads GnuTLS dynamically
2436 if test "${opsys}" = "mingw32"; then
2437 LIBGNUTLS_LIBS=
57f8c490
PE
2438 else
2439 CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
2440 LIBS="$LIBGNUTLS_LIBS $LIBS"
a414bed5 2441 fi
067d23c9 2442fi
33630d51 2443
067d23c9
KY
2444AC_SUBST(LIBGNUTLS_LIBS)
2445AC_SUBST(LIBGNUTLS_CFLAGS)
2446
c9628c79
MA
2447NOTIFY_OBJ=
2448NOTIFY_SUMMARY=no
2449
671d4bfc
GM
2450dnl FIXME? Don't auto-detect on NS, but do allow someone to specify
2451dnl a particular library. This doesn't make much sense?
2452if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
2453 with_file_notification=no
2454fi
2455
c04bbd85
PE
2456dnl MS Windows native file monitor is available for mingw32 only.
2457case $with_file_notification,$opsys in
2458 w32,* | yes,mingw32)
2459 AC_CHECK_HEADER(windows.h)
2460 if test "$ac_cv_header_windows_h" = yes ; then
2461 AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2462 NOTIFY_OBJ=w32notify.o
2463 NOTIFY_SUMMARY="yes (w32)"
2464 fi ;;
2465esac
c9628c79 2466
c04bbd85
PE
2467dnl g_file_monitor exists since glib 2.18. G_FILE_MONITOR_EVENT_MOVED
2468dnl has been added in glib 2.24. It has been tested under
2469dnl GNU/Linux only. We take precedence over inotify, but this makes
2470dnl only sense when glib has been compiled with inotify support. How
2471dnl to check?
2472case $with_file_notification,$NOTIFY_OBJ in
2473 gfile, | yes,)
2474 PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no)
2475 if test "$HAVE_GFILENOTIFY" = "yes"; then
2476 AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2477 NOTIFY_OBJ=gfilenotify.o
2478 NOTIFY_SUMMARY="yes -lgio (gfile)"
2479 fi ;;
2480esac
2481
2482dnl inotify is only available on GNU/Linux.
2483case $with_file_notification,$NOTIFY_OBJ in
2484 inotify, | yes,)
2485 AC_CHECK_HEADER(sys/inotify.h)
2486 if test "$ac_cv_header_sys_inotify_h" = yes ; then
2487 AC_CHECK_FUNC(inotify_init1)
2488 if test "$ac_cv_func_inotify_init1" = yes; then
2489 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2490 NOTIFY_OBJ=inotify.o
2491 NOTIFY_SUMMARY="yes -lglibc (inotify)"
2492 fi
2493 fi ;;
2494esac
2495
2496case $with_file_notification,$NOTIFY_OBJ in
2497 yes,* | no,* | *,?*) ;;
2498 *) AC_MSG_ERROR([File notification `$with_file_notification' requested but requirements not found.]) ;;
2499esac
671d4bfc 2500
c9628c79
MA
2501if test -n "$NOTIFY_OBJ"; then
2502 AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
81606b10 2503fi
c9628c79 2504AC_SUBST(NOTIFY_OBJ)
7f203aa1
EZ
2505AC_SUBST(GFILENOTIFY_CFLAGS)
2506AC_SUBST(GFILENOTIFY_LIBS)
81606b10 2507
067d23c9
KY
2508dnl Do not put whitespace before the #include statements below.
2509dnl Older compilers (eg sunos4 cc) choke on it.
2510HAVE_XAW3D=no
2511LUCID_LIBW=
2512if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
2513 if test "$with_xaw3d" != no; then
067d23c9 2514 AC_CACHE_VAL(emacs_cv_xaw3d,
181855e6 2515 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2516#include <X11/Intrinsic.h>
181855e6
GM
2517#include <X11/Xaw3d/Simple.h>]],
2518 [[]])],
37f7b784
CY
2519 [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
2520 emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
067d23c9
KY
2521 emacs_cv_xaw3d=no)])
2522 else
2523 emacs_cv_xaw3d=no
2524 fi
2525 if test $emacs_cv_xaw3d = yes; then
2c484e75 2526 AC_MSG_CHECKING(for xaw3d)
067d23c9
KY
2527 AC_MSG_RESULT([yes; using Lucid toolkit])
2528 USE_X_TOOLKIT=LUCID
2529 HAVE_XAW3D=yes
2530 LUCID_LIBW=-lXaw3d
2531 AC_DEFINE(HAVE_XAW3D, 1,
2532 [Define to 1 if you have the Xaw3d library (-lXaw3d).])
2533 else
2c484e75 2534 AC_MSG_CHECKING(for xaw3d)
067d23c9
KY
2535 AC_MSG_RESULT(no)
2536 AC_MSG_CHECKING(for libXaw)
2537 AC_CACHE_VAL(emacs_cv_xaw,
181855e6 2538 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2539#include <X11/Intrinsic.h>
181855e6
GM
2540#include <X11/Xaw/Simple.h>]],
2541 [[]])],
067d23c9
KY
2542 emacs_cv_xaw=yes,
2543 emacs_cv_xaw=no)])
2544 if test $emacs_cv_xaw = yes; then
2545 AC_MSG_RESULT([yes; using Lucid toolkit])
2546 USE_X_TOOLKIT=LUCID
2547 LUCID_LIBW=-lXaw
2548 elif test x"${USE_X_TOOLKIT}" = xLUCID; then
2549 AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
2550 else
d681f183
GM
2551 AC_MSG_ERROR([No X toolkit could be found.
2552If you are sure you want Emacs compiled without an X toolkit, pass
2553 --with-x-toolkit=no
2554to configure. Otherwise, install the development libraries for the toolkit
2555that you want to use (e.g. Gtk+) and re-run configure.])
067d23c9
KY
2556 fi
2557 fi
2558fi
2559
2560X_TOOLKIT_TYPE=$USE_X_TOOLKIT
2561
2562LIBXTR6=
2563if test "${USE_X_TOOLKIT}" != "none"; then
2564 AC_MSG_CHECKING(X11 toolkit version)
2565 AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
181855e6
GM
2566 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
2567[[#if XtSpecificationRelease < 6
067d23c9
KY
2568fail;
2569#endif
181855e6 2570]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
067d23c9
KY
2571 HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
2572 if test $emacs_cv_x11_toolkit_version_6 = yes; then
2573 AC_MSG_RESULT(6 or newer)
2574 AC_DEFINE(HAVE_X11XTR6, 1,
2575 [Define to 1 if you have the X11R6 or newer version of Xt.])
2576 LIBXTR6="-lSM -lICE"
2577 case "$opsys" in
2578 ## Use libw.a along with X11R6 Xt.
2579 unixware) LIBXTR6="$LIBXTR6 -lw" ;;
2580 esac
2581 else
2582 AC_MSG_RESULT(before 6)
2583 fi
2584
2585dnl If using toolkit, check whether libXmu.a exists.
2586dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
2587 OLDLIBS="$LIBS"
2588 if test x$HAVE_X11XTR6 = xyes; then
2589 LIBS="-lXt -lSM -lICE $LIBS"
2590 else
2591 LIBS="-lXt $LIBS"
2592 fi
2593 AC_CHECK_LIB(Xmu, XmuConvertStandardSelection)
2594 test $ac_cv_lib_Xmu_XmuConvertStandardSelection = no && LIBS="$OLDLIBS"
ba9e4b84 2595 dnl ac_cv_lib_Xmu_XmuConvertStandardSelection is also referenced below.
067d23c9
KY
2596fi
2597AC_SUBST(LIBXTR6)
2598
2599dnl FIXME the logic here seems weird, but this is what cpp was doing.
2600dnl Why not just test for libxmu in the normal way?
2601LIBXMU=-lXmu
d6a003a8
AS
2602case $opsys in
2603 ## These systems don't supply Xmu.
067d23c9
KY
2604 hpux* | aix4-2 )
2605 test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
2606 ;;
fb0862b2
EZ
2607 mingw32 )
2608 LIBXMU=
2609 ;;
067d23c9
KY
2610esac
2611AC_SUBST(LIBXMU)
2612
2613# On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
2614if test "${HAVE_X11}" = "yes"; then
2615 if test "${USE_X_TOOLKIT}" != "none"; then
2616 AC_CHECK_LIB(Xext, XShapeQueryExtension)
2617 fi
2618fi
2619
2620LIBXP=
2621if test "${USE_X_TOOLKIT}" = "MOTIF"; then
c09bfb2f
DA
2622 # OpenMotif may be installed in such a way on some GNU/Linux systems.
2623 if test -d /usr/include/openmotif; then
2624 CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
2625 emacs_cv_openmotif=yes
2626 case "$canonical" in
2627 x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
2628 test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
2629 ;;
2630 *)
2631 test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
2632 esac
2633 else
2634 emacs_cv_openmotif=no
2635 fi
2636 AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
181855e6
GM
2637 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
2638 [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
067d23c9
KY
2639int x = 5;
2640#else
2641Motif version prior to 2.1.
181855e6 2642#endif]])],
067d23c9
KY
2643 emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
2644 if test $emacs_cv_motif_version_2_1 = yes; then
2645 AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
c09bfb2f
DA
2646 if test x$emacs_cv_openmotif = xyes; then
2647 REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
2648 fi
067d23c9
KY
2649 else
2650 AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
2651 # We put this in CFLAGS temporarily to precede other -I options
2652 # that might be in CFLAGS temporarily.
2653 # We put this in CPPFLAGS where it precedes the other -I options.
2654 OLD_CPPFLAGS=$CPPFLAGS
2655 OLD_CFLAGS=$CFLAGS
2656 CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
2657 CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
181855e6
GM
2658 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
2659 [[int x = 5;]])],
067d23c9
KY
2660 emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
2661 if test $emacs_cv_lesstif = yes; then
2662 # Make sure this -I option remains in CPPFLAGS after it is set
2663 # back to REAL_CPPFLAGS.
2664 # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
2665 # have those other -I options anyway. Ultimately, having this
2666 # directory ultimately in CPPFLAGS will be enough.
2667 REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
2668 LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
2669 else
2670 CFLAGS=$OLD_CFLAGS
2671 CPPFLAGS=$OLD_CPPFLAGS
2672 fi
2673 fi
e4070def
GM
2674 AC_CHECK_HEADER([Xm/BulletinB.h], [],
2675 [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
067d23c9
KY
2676fi
2677
2678dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
2679dnl using Motif or Xaw3d is available, and unless
2680dnl --with-toolkit-scroll-bars=no was specified.
2681
2682AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
2683 [Define to 1 if we should use toolkit scroll bars.])dnl
2684USE_TOOLKIT_SCROLL_BARS=no
2685if test "${with_toolkit_scroll_bars}" != "no"; then
2686 if test "${USE_X_TOOLKIT}" != "none"; then
2687 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
2688 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2689 HAVE_XAW3D=no
2690 USE_TOOLKIT_SCROLL_BARS=yes
8d8939e8 2691 elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
067d23c9
KY
2692 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2693 USE_TOOLKIT_SCROLL_BARS=yes
2694 fi
2695 elif test "${HAVE_GTK}" = "yes"; then
2696 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2697 USE_TOOLKIT_SCROLL_BARS=yes
2698 elif test "${HAVE_NS}" = "yes"; then
2699 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2700 USE_TOOLKIT_SCROLL_BARS=yes
0fda9b75
DC
2701 elif test "${HAVE_W32}" = "yes"; then
2702 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2703 USE_TOOLKIT_SCROLL_BARS=yes
067d23c9
KY
2704 fi
2705fi
2706
2707dnl See if XIM is available.
181855e6 2708AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2709 #include <X11/Xlib.h>
181855e6
GM
2710 #include <X11/Xresource.h>]],
2711 [[XIMProc callback;]])],
067d23c9
KY
2712 [HAVE_XIM=yes
2713 AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
2714 HAVE_XIM=no)
2715
2716dnl `--with-xim' now controls only the initial value of use_xim at run time.
2717
2718if test "${with_xim}" != "no"; then
2719 AC_DEFINE(USE_XIM, 1,
2720 [Define to 1 if we should use XIM, if it is available.])
2721fi
2722
2723
2724if test "${HAVE_XIM}" != "no"; then
2725 late_CFLAGS=$CFLAGS
2726 if test "$GCC" = yes; then
2727 CFLAGS="$CFLAGS --pedantic-errors"
2728 fi
181855e6 2729 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2730#include <X11/Xlib.h>
181855e6
GM
2731#include <X11/Xresource.h>]],
2732[[Display *display;
067d23c9
KY
2733XrmDatabase db;
2734char *res_name;
2735char *res_class;
2736XIMProc callback;
2737XPointer *client_data;
2738#ifndef __GNUC__
2739/* If we're not using GCC, it's probably not XFree86, and this is
2740 probably right, but we can't use something like --pedantic-errors. */
2741extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
2742 char*, XIMProc, XPointer*);
2743#endif
2744(void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
181855e6 2745 client_data);]])],
067d23c9
KY
2746 [emacs_cv_arg6_star=yes])
2747 AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
2748 [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
2749either XPointer or XPointer*.])dnl
2750 if test "$emacs_cv_arg6_star" = yes; then
2751 AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
2752 else
2753 AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
2754 fi
2755 CFLAGS=$late_CFLAGS
2756fi
2757
2758### Start of font-backend (under any platform) section.
2759# (nothing here yet -- this is a placeholder)
2760### End of font-backend (under any platform) section.
2761
2762### Start of font-backend (under X11) section.
2763if test "${HAVE_X11}" = "yes"; then
2764 PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2.0, HAVE_FC=yes, HAVE_FC=no)
2765
2766 ## Use -lXft if available, unless `--with-xft=no'.
2767 HAVE_XFT=maybe
2768 if test "${HAVE_FC}" = "no" || test "x${with_x}" = "xno"; then
2769 with_xft="no";
2770 fi
2771 if test "x${with_xft}" != "xno"; then
2772
2773 PKG_CHECK_MODULES(XFT, xft >= 0.13.0, , HAVE_XFT=no)
2774 ## Because xftfont.c uses XRenderQueryExtension, we also
2775 ## need to link to -lXrender.
2776 HAVE_XRENDER=no
2777 AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
2778 if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
2779 OLD_CPPFLAGS="$CPPFLAGS"
2780 OLD_CFLAGS="$CFLAGS"
2781 OLD_LIBS="$LIBS"
2782 CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
2783 CFLAGS="$CFLAGS $XFT_CFLAGS"
2784 XFT_LIBS="-lXrender $XFT_LIBS"
2785 LIBS="$XFT_LIBS $LIBS"
2786 AC_CHECK_HEADER(X11/Xft/Xft.h,
ab6a27d8
GM
2787 AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
2788 [[#include <X11/X.h>]])
067d23c9
KY
2789
2790 if test "${HAVE_XFT}" = "yes"; then
2791 AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
2792 AC_SUBST(XFT_LIBS)
2793 C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
2794 else
2795 CPPFLAGS="$OLD_CPPFLAGS"
2796 CFLAGS="$OLD_CFLAGS"
2797 LIBS="$OLD_LIBS"
2798 fi # "${HAVE_XFT}" = "yes"
2799 fi # "$HAVE_XFT" != no
2800 fi # "x${with_xft}" != "xno"
2801
870d9cf6
GM
2802 ## We used to allow building with FreeType and without Xft.
2803 ## However, the ftx font backend driver is not in good shape.
067d23c9 2804 if test "$HAVE_XFT" != "yes"; then
870d9cf6 2805 dnl For the "Does Emacs use" message at the end.
067d23c9 2806 HAVE_XFT=no
870d9cf6
GM
2807 HAVE_FREETYPE=no
2808 else
2809 dnl Strict linkers fail with
2810 dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
2811 dnl if -lfreetype is not specified.
2812 dnl The following is needed to set FREETYPE_LIBS.
2813 PKG_CHECK_MODULES(FREETYPE, freetype2, HAVE_FREETYPE=yes,
46dcfee4 2814 HAVE_FREETYPE=no)
870d9cf6
GM
2815
2816 test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
067d23c9
KY
2817 fi
2818
067d23c9
KY
2819 HAVE_LIBOTF=no
2820 if test "${HAVE_FREETYPE}" = "yes"; then
2821 AC_DEFINE(HAVE_FREETYPE, 1,
2822 [Define to 1 if using the freetype and fontconfig libraries.])
2823 if test "${with_libotf}" != "no"; then
2824 PKG_CHECK_MODULES(LIBOTF, libotf, HAVE_LIBOTF=yes,
2825 HAVE_LIBOTF=no)
2826 if test "$HAVE_LIBOTF" = "yes"; then
2827 AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
2828 AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
2829 HAVE_OTF_GET_VARIATION_GLYPHS=yes,
2830 HAVE_OTF_GET_VARIATION_GLYPHS=no)
2831 if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
2832 AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
2833 [Define to 1 if libotf has OTF_get_variation_glyphs.])
2834 fi
2835 fi
2836 fi
2837 dnl FIXME should there be an error if HAVE_FREETYPE != yes?
2838 dnl Does the new font backend require it, or can it work without it?
2839 fi
2840
2841 HAVE_M17N_FLT=no
2842 if test "${HAVE_LIBOTF}" = yes; then
2843 if test "${with_m17n_flt}" != "no"; then
2844 PKG_CHECK_MODULES(M17N_FLT, m17n-flt, HAVE_M17N_FLT=yes, HAVE_M17N_FLT=no)
2845 if test "$HAVE_M17N_FLT" = "yes"; then
2846 AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
2847 fi
2848 fi
2849 fi
2850else
2851 HAVE_XFT=no
2852 HAVE_FREETYPE=no
2853 HAVE_LIBOTF=no
2854 HAVE_M17N_FLT=no
2855fi
2856
2857### End of font-backend (under X11) section.
2858
2859AC_SUBST(FREETYPE_CFLAGS)
2860AC_SUBST(FREETYPE_LIBS)
2861AC_SUBST(FONTCONFIG_CFLAGS)
2862AC_SUBST(FONTCONFIG_LIBS)
2863AC_SUBST(LIBOTF_CFLAGS)
2864AC_SUBST(LIBOTF_LIBS)
2865AC_SUBST(M17N_FLT_CFLAGS)
2866AC_SUBST(M17N_FLT_LIBS)
2867
2868### Use -lXpm if available, unless `--with-xpm=no'.
fb0862b2 2869### mingw32 doesn't use -lXpm, since it loads the library dynamically.
067d23c9
KY
2870HAVE_XPM=no
2871LIBXPM=
fb0862b2 2872if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
0fda9b75
DC
2873 if test "${with_xpm}" != "no"; then
2874 SAVE_CPPFLAGS="$CPPFLAGS"
2875 SAVE_LDFLAGS="$LDFLAGS"
2876 CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
2877 LDFLAGS="$LDFLAGS -L/usr/lib/noX"
2878 AC_CHECK_HEADER(X11/xpm.h,
2879 [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
2880 if test "${HAVE_XPM}" = "yes"; then
2881 AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2882 AC_EGREP_CPP(no_return_alloc_pixels,
2883 [#include "X11/xpm.h"
2884#ifndef XpmReturnAllocPixels
2885no_return_alloc_pixels
2886#endif
2887 ], HAVE_XPM=no, HAVE_XPM=yes)
2888
2889 if test "${HAVE_XPM}" = "yes"; then
2890 REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
2891 AC_MSG_RESULT(yes)
2892 else
2893 AC_MSG_RESULT(no)
2894 CPPFLAGS="$SAVE_CPPFLAGS"
2895 LDFLAGS="$SAVE_LDFLAGS"
2896 fi
2897 fi
2898 fi
2899
2900 if test "${HAVE_XPM}" = "yes"; then
791ef5f8 2901 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
0fda9b75
DC
2902 LIBXPM=-lXpm
2903 fi
2904fi
2905
067d23c9
KY
2906if test "${HAVE_X11}" = "yes"; then
2907 if test "${with_xpm}" != "no"; then
2908 AC_CHECK_HEADER(X11/xpm.h,
2909 [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
2910 if test "${HAVE_XPM}" = "yes"; then
2911 AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2912 AC_EGREP_CPP(no_return_alloc_pixels,
2913 [#include "X11/xpm.h"
2914#ifndef XpmReturnAllocPixels
2915no_return_alloc_pixels
2916#endif
2917 ], HAVE_XPM=no, HAVE_XPM=yes)
2918
2919 if test "${HAVE_XPM}" = "yes"; then
2920 AC_MSG_RESULT(yes)
2921 else
2922 AC_MSG_RESULT(no)
2923 fi
2924 fi
2925 fi
2926
2927 if test "${HAVE_XPM}" = "yes"; then
20db1522 2928 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
067d23c9
KY
2929 LIBXPM=-lXpm
2930 fi
2931fi
0fda9b75 2932
09e94df2
EZ
2933### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
2934### slightly different requirements wrt image libraries (it doesn't
2935### use -lXpm because it loads the xpm shared library dynamically at
2936### run time).
fb0862b2
EZ
2937if test "${opsys}" = "mingw32"; then
2938 if test "${with_xpm}" != "no"; then
1f8f81c8 2939 AC_CHECK_HEADER(X11/xpm.h, HAVE_XPM=yes, HAVE_XPM=no, [
fb0862b2 2940#define FOR_MSW 1])
fb0862b2
EZ
2941 fi
2942
2943 if test "${HAVE_XPM}" = "yes"; then
2944 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
2945 fi
2946fi
2947
067d23c9
KY
2948AC_SUBST(LIBXPM)
2949
2950### Use -ljpeg if available, unless `--with-jpeg=no'.
fb0862b2 2951### mingw32 doesn't use -ljpeg, since it loads the library dynamically.
067d23c9
KY
2952HAVE_JPEG=no
2953LIBJPEG=
fb0862b2 2954if test "${opsys}" = "mingw32"; then
067d23c9
KY
2955 if test "${with_jpeg}" != "no"; then
2956 dnl Checking for jpeglib.h can lose because of a redefinition of
fb0862b2
EZ
2957 dnl HAVE_STDLIB_H.
2958 AC_CHECK_HEADER(jerror.h, HAVE_JPEG=yes, HAVE_JPEG=no)
067d23c9 2959 fi
067d23c9
KY
2960 AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
2961 if test "${HAVE_JPEG}" = "yes"; then
2962 AC_DEFINE(HAVE_JPEG)
2963 AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
2964 [#include <jpeglib.h>
2965 version=JPEG_LIB_VERSION
2966],
2967 [AC_DEFINE(HAVE_JPEG)],
2968 [AC_MSG_WARN([libjpeg found, but not version 6b or later])
2969 HAVE_JPEG=no])
2970 fi
fb0862b2
EZ
2971elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2972 if test "${with_jpeg}" != "no"; then
2973 dnl Checking for jpeglib.h can lose because of a redefinition of
2974 dnl HAVE_STDLIB_H.
2975 AC_CHECK_HEADER(jerror.h,
2976 [AC_CHECK_LIB(jpeg, jpeg_destroy_compress, HAVE_JPEG=yes)])
2977 fi
2978
2979 AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
2980 if test "${HAVE_JPEG}" = "yes"; then
2981 AC_DEFINE(HAVE_JPEG)
2982 AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
2983 [#include <jpeglib.h>
2984 version=JPEG_LIB_VERSION
2985],
2986 [AC_DEFINE(HAVE_JPEG)],
2987 [AC_MSG_WARN([libjpeg found, but not version 6b or later])
2988 HAVE_JPEG=no])
2989 fi
067d23c9
KY
2990 if test "${HAVE_JPEG}" = "yes"; then
2991 LIBJPEG=-ljpeg
2992 fi
2993fi
2994AC_SUBST(LIBJPEG)
2995
2996### Use -lpng if available, unless `--with-png=no'.
fb0862b2 2997### mingw32 doesn't use -lpng, since it loads the library dynamically.
067d23c9
KY
2998HAVE_PNG=no
2999LIBPNG=
fb0862b2
EZ
3000if test "${opsys}" = "mingw32"; then
3001 if test "${with_png}" != "no"; then
3002 AC_CHECK_HEADER(png.h, HAVE_PNG=yes, HAVE_PNG=no)
3003 fi
3004 if test "${HAVE_PNG}" = "yes"; then
3005 AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
3006
3007 AC_CHECK_DECL(png_longjmp,
3008 [],
3009 [AC_DEFINE(PNG_DEPSTRUCT, [],
3010 [Define to empty to suppress deprecation warnings when building
3011 with --enable-gcc-warnings and with libpng versions before 1.5,
3012 which lack png_longjmp.])],
3013 [[#ifdef HAVE_LIBPNG_PNG_H
3014 # include <libpng/png.h>
3015 #else
3016 # include <png.h>
3017 #endif
3018 ]])
3019 fi
3020elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
3021 if test "${with_png}" != "no"; then
3022 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3023 # in /usr/include/libpng.
0ccb0b09 3024 AC_CHECK_HEADERS(png.h libpng/png.h, break)
067d23c9
KY
3025 if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
3026 AC_CHECK_LIB(png, png_get_channels, HAVE_PNG=yes, , -lz -lm)
3027 fi
3028 fi
3029
3030 if test "${HAVE_PNG}" = "yes"; then
3031 AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
3032 LIBPNG="-lpng -lz -lm"
0ccb0b09
PE
3033
3034 AC_CHECK_DECL(png_longjmp,
3035 [],
cda158b4 3036 [AC_DEFINE(PNG_DEPSTRUCT, [],
0ccb0b09
PE
3037 [Define to empty to suppress deprecation warnings when building
3038 with --enable-gcc-warnings and with libpng versions before 1.5,
3039 which lack png_longjmp.])],
3040 [[#ifdef HAVE_LIBPNG_PNG_H
3041 # include <libpng/png.h>
3042 #else
3043 # include <png.h>
3044 #endif
3045 ]])
067d23c9
KY
3046 fi
3047fi
3048AC_SUBST(LIBPNG)
3049
313546eb
LMI
3050HAVE_ZLIB=no
3051LIBZ=
8d28d0ac 3052if test "${with_zlib}" != "no"; then
1d238bc7
PE
3053 OLIBS=$LIBS
3054 AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
3055 LIBS=$OLIBS
3056 case $ac_cv_search_inflateEnd in
3057 -*) LIBZ=$ac_cv_search_inflateEnd ;;
3058 esac
313546eb 3059fi
8d28d0ac
PE
3060if test "${HAVE_ZLIB}" = "yes"; then
3061 AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
aa942e2b
EZ
3062 ### mingw32 doesn't use -lz, since it loads the library dynamically.
3063 if test "${opsys}" = "mingw32"; then
3064 LIBZ=
3065 fi
8d28d0ac 3066fi
313546eb
LMI
3067AC_SUBST(LIBZ)
3068
3069
067d23c9 3070### Use -ltiff if available, unless `--with-tiff=no'.
fb0862b2 3071### mingw32 doesn't use -ltiff, since it loads the library dynamically.
067d23c9
KY
3072HAVE_TIFF=no
3073LIBTIFF=
fb0862b2
EZ
3074if test "${opsys}" = "mingw32"; then
3075 if test "${with_tiff}" != "no"; then
3076 AC_CHECK_HEADER(tiffio.h, HAVE_TIFF=yes, HAVE_TIFF=no)
3077 fi
3078 if test "${HAVE_TIFF}" = "yes"; then
3079 AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3080 fi
3081elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
3082 if test "${with_tiff}" != "no"; then
3083 AC_CHECK_HEADER(tiffio.h,
3084 [tifflibs="-lz -lm"
3085 # At least one tiff package requires the jpeg library.
3086 if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
3087 AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
3088 fi
3089
3090 if test "${HAVE_TIFF}" = "yes"; then
3091 AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3092 dnl FIXME -lz -lm, as per libpng?
3093 LIBTIFF=-ltiff
3094 fi
3095fi
3096AC_SUBST(LIBTIFF)
3097
3098### Use -lgif or -lungif if available, unless `--with-gif=no'.
fb0862b2 3099### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
067d23c9
KY
3100HAVE_GIF=no
3101LIBGIF=
fb0862b2
EZ
3102if test "${opsys}" = "mingw32"; then
3103 if test "${with_gif}" != "no"; then
3104 AC_CHECK_HEADER(gif_lib.h, HAVE_GIF=yes, HAVE_GIF=no)
3105 fi
3106 if test "${HAVE_GIF}" = "yes"; then
3107 AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3108 fi
3109elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
0fda9b75 3110 || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
3111 AC_CHECK_HEADER(gif_lib.h,
3112# EGifPutExtensionLast only exists from version libungif-4.1.0b1.
f3606ef7
BF
3113# Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
3114 [AC_CHECK_LIB(gif, GifMakeMapObject, HAVE_GIF=yes,
3115 [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])])
067d23c9
KY
3116
3117 if test "$HAVE_GIF" = yes; then
3118 LIBGIF=-lgif
3119 elif test "$HAVE_GIF" = maybe; then
3120# If gif_lib.h but no libgif, try libungif.
3121 AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
3122 test "$HAVE_GIF" = yes && LIBGIF=-lungif
3123 fi
3124
3125 if test "${HAVE_GIF}" = "yes"; then
3126 AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3127 fi
3128fi
3129AC_SUBST(LIBGIF)
3130
3131dnl Check for required libraries.
3132if test "${HAVE_X11}" = "yes"; then
3133 MISSING=""
3134 WITH_NO=""
3135 test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
3136 MISSING="libXpm" && WITH_NO="--with-xpm=no"
3137 test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
3138 MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
3139 test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
3140 MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
3141 test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
3142 MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
3143 test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
3144 MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
3145
3146 if test "X${MISSING}" != X; then
3147 AC_MSG_ERROR([The following required libraries were not found:
3148 $MISSING
3149Maybe some development libraries/packages are missing?
3150If you don't want to link with them give
3151 $WITH_NO
3152as options to configure])
3153 fi
3154fi
3155
3156### Use -lgpm if available, unless `--with-gpm=no'.
3157HAVE_GPM=no
3158LIBGPM=
067d23c9
KY
3159if test "${with_gpm}" != "no"; then
3160 AC_CHECK_HEADER(gpm.h,
3161 [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
3162
3163 if test "${HAVE_GPM}" = "yes"; then
3164 AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
3165 LIBGPM=-lgpm
067d23c9
KY
3166 fi
3167fi
3168AC_SUBST(LIBGPM)
3169
3170dnl Check for malloc/malloc.h on darwin
0e7a053e 3171AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
067d23c9 3172
2f097256 3173GNUSTEP_CFLAGS=
067d23c9
KY
3174### Use NeXTstep API to implement GUI.
3175if test "${HAVE_NS}" = "yes"; then
3176 AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
3177 if test "${NS_IMPL_COCOA}" = "yes"; then
3178 AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under MacOS X.])
067d23c9
KY
3179 fi
3180 if test "${NS_IMPL_GNUSTEP}" = "yes"; then
3181 AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
3182 # See also .m.o rule in Makefile.in */
3183 # FIXME: are all these flags really needed? Document here why. */
2f097256 3184 GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
0cc87afb
GM
3185 ## Extra CFLAGS applied to src/*.m files.
3186 GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"
067d23c9 3187 fi
067d23c9
KY
3188 OTHER_FILES=ns-app
3189fi
3190
067d23c9
KY
3191### Use session management (-lSM -lICE) if available
3192HAVE_X_SM=no
3193LIBXSM=
3194if test "${HAVE_X11}" = "yes"; then
3195 AC_CHECK_HEADER(X11/SM/SMlib.h,
3196 [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
3197
3198 if test "${HAVE_X_SM}" = "yes"; then
3199 AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
3200 LIBXSM="-lSM -lICE"
3201 case "$LIBS" in
3202 *-lSM*) ;;
3203 *) LIBS="$LIBXSM $LIBS" ;;
3204 esac
3205 fi
3206fi
3207AC_SUBST(LIBXSM)
3208
4e3f9230
YM
3209### Use XRandr (-lXrandr) if available
3210HAVE_XRANDR=no
3211if test "${HAVE_X11}" = "yes"; then
3212 XRANDR_REQUIRED=1.2.2
3213 XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
3214 PKG_CHECK_MODULES(XRANDR, $XRANDR_MODULES, HAVE_XRANDR=yes, HAVE_XRANDR=no)
3215 if test $HAVE_XRANDR = no; then
3216 # Test old way in case pkg-config doesn't have it (older machines).
3217 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
2d8ac645 3218 [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)])
4e3f9230
YM
3219 if test $HAVE_XRANDR = yes; then
3220 XRANDR_LIBS=-lXrandr
3221 AC_SUBST(XRANDR_LIBS)
3222 fi
3223 fi
3224 if test $HAVE_XRANDR = yes; then
3225 SAVE_CFLAGS="$CFLAGS"
3226 SAVE_LIBS="$LIBS"
3227 CFLAGS="$XRANDR_CFLAGS $CFLAGS"
3228 LIBS="$XRANDR_LIBS $LIBS"
3229 AC_CHECK_FUNCS(XRRGetOutputPrimary XRRGetScreenResourcesCurrent)
3230 CFLAGS="$SAVE_CFLAGS"
3231 LIBS="$SAVE_LIBS"
3232
3233 AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
3234 fi
3235fi
3236
3237### Use Xinerama (-lXinerama) if available
3238HAVE_XINERAMA=no
3239if test "${HAVE_X11}" = "yes"; then
3240 XINERAMA_REQUIRED=1.0.2
3241 XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
3242 PKG_CHECK_MODULES(XINERAMA, $XINERAMA_MODULES, HAVE_XINERAMA=yes,
3243 HAVE_XINERAMA=no)
3244 if test $HAVE_XINERAMA = no; then
3245 # Test old way in case pkg-config doesn't have it (older machines).
3246 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
3247 [AC_CHECK_LIB(Xinerama, XineramaQueryExtension, HAVE_XINERAMA=yes)])
3248 if test $HAVE_XINERAMA = yes; then
3249 XINERAMA_LIBS=-lXinerama
3250 AC_SUBST(XINERAMA_LIBS)
3251 fi
3252 fi
3253 if test $HAVE_XINERAMA = yes; then
3254 AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if you have the Xinerama extension.])
3255 fi
3256fi
3257
3258
067d23c9 3259### Use libxml (-lxml2) if available
fb0862b2 3260### mingw32 doesn't use -lxml2, since it loads the library dynamically.
04d51ad4 3261HAVE_LIBXML2=no
067d23c9
KY
3262if test "${with_xml2}" != "no"; then
3263 ### I'm not sure what the version number should be, so I just guessed.
dab73760 3264 PKG_CHECK_MODULES(LIBXML2, libxml-2.0 > 2.6.17, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
6b4914d2
YM
3265 # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
3266 if test "${HAVE_LIBXML2}" != "yes" -a "$opsys" = "darwin"; then
3267 SAVE_CPPFLAGS="$CPPFLAGS"
3268 CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
3269 AC_CHECK_HEADER(libxml/HTMLparser.h,
3270 [AC_CHECK_DECL(HTML_PARSE_RECOVER, HAVE_LIBXML2=yes, ,
3271 [#include <libxml/HTMLparser.h>])])
3272 CPPFLAGS="$SAVE_CPPFLAGS"
3273 if test "${HAVE_LIBXML2}" = "yes"; then
3274 LIBXML2_LIBS="-lxml2"
3275 LIBXML2_CFLAGS="-I/usr/include/libxml2"
3276 fi
3277 fi
067d23c9 3278 if test "${HAVE_LIBXML2}" = "yes"; then
fb0862b2
EZ
3279 if test "${opsys}" != "mingw32"; then
3280 LIBS="$LIBXML2_LIBS $LIBS"
3281 AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
a414bed5
EZ
3282 else
3283 LIBXML2_LIBS=""
fb0862b2 3284 fi
067d23c9
KY
3285 if test "${HAVE_LIBXML2}" = "yes"; then
3286 AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
3287 else
3288 LIBXML2_LIBS=""
3289 LIBXML2_CFLAGS=""
3290 fi
3291 fi
3292fi
3293AC_SUBST(LIBXML2_LIBS)
3294AC_SUBST(LIBXML2_CFLAGS)
3295
3296# If netdb.h doesn't declare h_errno, we must declare it by hand.
9e821c83 3297# On MinGW, that is provided by nt/inc/sys/socket.h and w32.c.
fb0862b2
EZ
3298if test "${opsys}" = "mingw32"; then
3299 emacs_cv_netdb_declares_h_errno=yes
3300fi
067d23c9
KY
3301AC_CACHE_CHECK(whether netdb declares h_errno,
3302 emacs_cv_netdb_declares_h_errno,
181855e6
GM
3303[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
3304 [[return h_errno;]])],
067d23c9
KY
3305 emacs_cv_netdb_declares_h_errno=yes, emacs_cv_netdb_declares_h_errno=no)])
3306if test $emacs_cv_netdb_declares_h_errno = yes; then
3307 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.])
3308fi
3309
c990426a 3310# sqrt and other floating-point functions such as fmod and frexp
fb0862b2
EZ
3311# are found in -lm on most systems, but mingw32 doesn't use -lm.
3312if test "${opsys}" != "mingw32"; then
3313 AC_CHECK_LIB(m, sqrt)
3314fi
067d23c9
KY
3315
3316# Check for mail-locking functions in a "mail" library. Probably this should
3317# have the same check as for liblockfile below.
3318AC_CHECK_LIB(mail, maillock, have_mail=yes, have_mail=no)
3319if test $have_mail = yes; then
3320 LIBS_MAIL=-lmail
3321 LIBS="$LIBS_MAIL $LIBS"
3322 AC_DEFINE(HAVE_LIBMAIL, 1, [Define to 1 if you have the `mail' library (-lmail).])
3323else
3324 LIBS_MAIL=
3325fi
3326dnl Debian, at least:
3327AC_CHECK_LIB(lockfile, maillock, have_lockfile=yes, have_lockfile=no)
3328if test $have_lockfile = yes; then
3329 LIBS_MAIL=-llockfile
3330 LIBS="$LIBS_MAIL $LIBS"
3331 AC_DEFINE(HAVE_LIBLOCKFILE, 1, [Define to 1 if you have the `lockfile' library (-llockfile).])
3332else
3333# If we have the shared liblockfile, assume we must use it for mail
3334# locking (e.g. Debian). If we couldn't link against liblockfile
3335# (no liblockfile.a installed), ensure that we don't need to.
3336 dnl This works for files generally, not just executables.
3337 dnl Should we look elsewhere for it? Maybe examine /etc/ld.so.conf?
3338 AC_CHECK_PROG(liblockfile, liblockfile.so, yes, no,
3339 /usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH)
3340 if test $ac_cv_prog_liblockfile = yes; then
3341 AC_MSG_ERROR([Shared liblockfile found but can't link against it.
3342This probably means that movemail could lose mail.
3343There may be a `development' package to install containing liblockfile.])
3344 fi
3345fi
0e7a053e 3346AC_CHECK_HEADERS_ONCE(maillock.h)
067d23c9
KY
3347AC_SUBST(LIBS_MAIL)
3348
3349## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
3350## interlock access to the mail spool. The alternative is a lock file named
3351## /usr/spool/mail/$USER.lock.
3352mail_lock=no
3353case "$opsys" in
3354 aix4-2) mail_lock="lockf" ;;
3355
7e00831f 3356 gnu|freebsd|dragonfly|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;;
067d23c9
KY
3357
3358 ## On GNU/Linux systems, both methods are used by various mail programs.
3359 ## I assume most people are using newer mailers that have heard of flock.
3360 ## Change this if you need to.
3361 ## Debian contains a patch which says: ``On Debian/GNU/Linux systems,
3362 ## configure gets the right answers, and that means *NOT* using flock.
3363 ## Using flock is guaranteed to be the wrong thing. See Debian Policy
3364 ## for details.'' and then uses `#ifdef DEBIAN'. Unfortunately the
3365 ## Debian maintainer hasn't provided a clean fix for Emacs.
3366 ## movemail.c will use `maillock' when MAILDIR, HAVE_LIBMAIL and
3367 ## HAVE_MAILLOCK_H are defined, so the following appears to be the
3368 ## correct logic. -- fx
3369 ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
3370 ## liblockfile is a Free Software replacement for libmail, used on
3371 ## Debian systems and elsewhere. -rfr.
3372 gnu-*)
3373 mail_lock="flock"
3374 if test $have_mail = yes || test $have_lockfile = yes; then
3375 test $ac_cv_header_maillock_h = yes && mail_lock=no
3376 fi
3377 ;;
64544985
EZ
3378
3379 mingw32)
3380 mail_lock="none-needed" ;;
067d23c9
KY
3381esac
3382
3383BLESSMAIL_TARGET=
3384case "$mail_lock" in
3385 flock) AC_DEFINE(MAIL_USE_FLOCK, 1, [Define if the mailer uses flock to interlock the mail spool.]) ;;
3386
3387 lockf) AC_DEFINE(MAIL_USE_LOCKF, 1, [Define if the mailer uses lockf to interlock the mail spool.]) ;;
3388
64544985
EZ
3389 none-needed) ;;
3390
067d23c9
KY
3391 *) BLESSMAIL_TARGET="need-blessmail" ;;
3392esac
3393AC_SUBST(BLESSMAIL_TARGET)
3394
3395
9caab067 3396AC_CHECK_FUNCS(accept4 gethostname \
95ef7787 3397getrusage get_current_dir_name \
dd0333b6 3398lrand48 \
2ef26ceb 3399select getpagesize setlocale \
57f8c490 3400getrlimit setrlimit shutdown getaddrinfo \
8148369c 3401strsignal setitimer \
03043c1b 3402sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
e0fdb694 3403gai_strerror getline getdelim sync \
9232a6d9 3404difftime posix_memalign \
316411f0 3405getpwent endpwent getgrent endgrent \
03043c1b 3406touchlock \
89561f72 3407cfmakeraw cfsetspeed copysign __executable_start log2)
067d23c9 3408
4516fbef
GM
3409## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
3410## has a broken `rint' in some library versions including math library
3411## version number A.09.05.
3412## You can fix the math library by installing patch number PHSS_4630.
3413## But we can fix it more reliably for Emacs by just not using rint.
5af2266c 3414## We also skip HAVE_RANDOM - see comments in src/conf_post.h.
4516fbef
GM
3415case $opsys in
3416 hpux*) : ;;
3417 *) AC_CHECK_FUNCS(random rint) ;;
3418esac
3419
2018939f
AS
3420dnl Cannot use AC_CHECK_FUNCS
3421AC_CACHE_CHECK([for __builtin_unwind_init],
3422 emacs_cv_func___builtin_unwind_init,
3423[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
3424 emacs_cv_func___builtin_unwind_init=yes,
3425 emacs_cv_func___builtin_unwind_init=no)])
3426if test $emacs_cv_func___builtin_unwind_init = yes; then
3427 AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
3428 [Define to 1 if you have the `__builtin_unwind_init' function.])
3429fi
3430
0e7a053e 3431AC_CHECK_HEADERS_ONCE(sys/un.h)
067d23c9 3432
067d23c9
KY
3433AC_FUNC_FSEEKO
3434
067d23c9 3435# UNIX98 PTYs.
54e8a418 3436AC_CHECK_FUNCS(grantpt)
067d23c9
KY
3437
3438# PTY-related GNU extensions.
1598ef28 3439AC_CHECK_FUNCS(getpt posix_openpt)
067d23c9
KY
3440
3441# Check this now, so that we will NOT find the above functions in ncurses.
3442# That is because we have not set up to link ncurses in lib-src.
3443# It's better to believe a function is not available
3444# than to expect to find it in ncurses.
3445# Also we need tputs and friends to be able to build at all.
f20f95c6
PE
3446AC_MSG_CHECKING([for library containing tputs])
3447# Run a test program that contains a call to tputs, a call that is
3448# never executed. This tests whether a pre-'main' dynamic linker
3449# works with the library. It's too much trouble to actually call
3450# tputs in the test program, due to portability hassles. When
3451# cross-compiling, assume the test program will run if it links.
3452AC_DEFUN([tputs_link_source], [
3453 AC_LANG_SOURCE(
3454 [[extern void tputs (const char *, int, int (*)(int));
3455 int main (int argc, char **argv)
3456 {
3457 if (argc == 10000)
3458 tputs (argv[0], 0, 0);
3459 return 0;
3460 }]])
3461])
a414bed5 3462if test "${opsys}" = "mingw32"; then
fb0862b2
EZ
3463 msg='none required'
3464else
3465 # Maybe curses should be tried earlier?
3466 # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
3467 for tputs_library in '' tinfo ncurses terminfo termcap curses; do
3468 OLIBS=$LIBS
3469 if test -z "$tputs_library"; then
3470 LIBS_TERMCAP=
3471 msg='none required'
3472 else
3473 LIBS_TERMCAP=-l$tputs_library
3474 msg=$LIBS_TERMCAP
3475 LIBS="$LIBS_TERMCAP $LIBS"
3476 fi
3477 AC_RUN_IFELSE([tputs_link_source], [], [msg=no],
3478 [AC_LINK_IFELSE([tputs_link_source], [], [msg=no])])
3479 LIBS=$OLIBS
3480 if test "X$msg" != Xno; then
3481 break
3482 fi
3483 done
3484fi
f20f95c6
PE
3485AC_MSG_RESULT([$msg])
3486if test "X$msg" = Xno; then
fd8dea03 3487 AC_MSG_ERROR([The required function `tputs' was not found in any library.
a4a18b8b
GM
3488The following libraries were tried (in order):
3489 libtinfo, libncurses, libterminfo, libtermcap, libcurses
fd8dea03
GM
3490Please try installing whichever of these libraries is most appropriate
3491for your system, together with its header files.
3492For example, a libncurses-dev(el) or similar package.])
067d23c9 3493fi
067d23c9 3494
262f06da
GM
3495## Use termcap instead of terminfo?
3496## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
3497TERMINFO=yes
a4a18b8b
GM
3498## FIXME? In the cases below where we unconditionally set
3499## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
3500## if that was found above to have tputs.
3501## Should we use the gnu* logic everywhere?
067d23c9 3502case "$opsys" in
067d23c9
KY
3503 ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
3504 ## The ncurses library has been moved out of the System framework in
3505 ## Mac OS X 10.2. So if configure detects it, set the command-line
3506 ## option to use it.
a4a18b8b
GM
3507 darwin) LIBS_TERMCAP="-lncurses" ;;
3508
01319a4e 3509 gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
067d23c9
KY
3510
3511 freebsd)
3512 AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
3513 AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
181855e6
GM
3514 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
3515[[#if __FreeBSD_version < 400000
067d23c9
KY
3516fail;
3517#endif
181855e6 3518]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
067d23c9
KY
3519
3520 AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
3521
3522 if test $emacs_cv_freebsd_terminfo = yes; then
067d23c9
KY
3523 LIBS_TERMCAP="-lncurses"
3524 else
262f06da 3525 TERMINFO=no
067d23c9
KY
3526 LIBS_TERMCAP="-ltermcap"
3527 fi
3528 ;;
3529
fb0862b2
EZ
3530 mingw32)
3531 TERMINFO=no
3532 LIBS_TERMCAP=
3533 ;;
3534
067d23c9 3535 netbsd)
01319a4e 3536 if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
262f06da 3537 TERMINFO=no
067d23c9
KY
3538 LIBS_TERMCAP="-ltermcap"
3539 fi
3540 ;;
3541
7e00831f 3542 openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
067d23c9 3543
067d23c9
KY
3544 ## hpux: Make sure we get select from libc rather than from libcurses
3545 ## because libcurses on HPUX 10.10 has a broken version of select.
3546 ## We used to use -lc -lcurses, but this may be cleaner.
e3da5b19
GM
3547 ## FIXME? But TERMINFO = yes on hpux (it used to be explicitly
3548 # set that way, now it uses the default). Isn't this a contradiction?
067d23c9
KY
3549 hpux*) LIBS_TERMCAP="-ltermcap" ;;
3550
067d23c9
KY
3551esac
3552
3553TERMCAP_OBJ=tparam.o
3554if test $TERMINFO = yes; then
3555 AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
067d23c9
KY
3556 TERMCAP_OBJ=terminfo.o
3557fi
a29c3e6d
PE
3558if test "X$LIBS_TERMCAP" = "X-lncurses"; then
3559 AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
3560fi
067d23c9
KY
3561AC_SUBST(LIBS_TERMCAP)
3562AC_SUBST(TERMCAP_OBJ)
3563
3564
3565# Do we have res_init, for detecting changes in /etc/resolv.conf?
4516fbef
GM
3566# On Darwin, res_init appears not to be useful: see bug#562 and
3567# http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html
067d23c9 3568resolv=no
4516fbef
GM
3569
3570if test $opsys != darwin; then
3571
3572 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
067d23c9 3573#include <arpa/nameser.h>
181855e6
GM
3574#include <resolv.h>]],
3575 [[return res_init();]])],
067d23c9 3576 have_res_init=yes, have_res_init=no)
4516fbef
GM
3577 if test "$have_res_init" = no; then
3578 OLIBS="$LIBS"
3579 LIBS="$LIBS -lresolv"
3580 AC_MSG_CHECKING(for res_init with -lresolv)
3581 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
067d23c9 3582#include <arpa/nameser.h>
181855e6 3583#include <resolv.h>]],
4516fbef
GM
3584 [[return res_init();]])],
3585 have_res_init=yes, have_res_init=no)
3586 AC_MSG_RESULT($have_res_init)
3587 if test "$have_res_init" = yes ; then
3588 resolv=yes
3589 fi
3590 LIBS="$OLIBS"
067d23c9 3591 fi
067d23c9 3592
4516fbef
GM
3593 if test "$have_res_init" = yes; then
3594 AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if res_init is available.])
3595 fi
3596fi dnl !darwin
067d23c9
KY
3597
3598# Do we need the Hesiod library to provide the support routines?
4516fbef 3599dnl FIXME? Should we be skipping this on Darwin too?
067d23c9
KY
3600LIBHESIOD=
3601if test "$with_hesiod" != no ; then
3602 # Don't set $LIBS here -- see comments above. FIXME which comments?
3603 AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
3604 [AC_CHECK_LIB(resolv, res_send, resolv=yes,
3605 [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
3606 if test "$resolv" = yes ; then
3607 RESOLVLIB=-lresolv
3608 else
3609 RESOLVLIB=
3610 fi
3611 AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
3612 hesiod=yes, :, $RESOLVLIB)])
3613
3614 if test x"$hesiod" = xyes; then
067d23c9
KY
3615 LIBHESIOD=-lhesiod
3616 fi
3617fi
3618AC_SUBST(LIBHESIOD)
3619
3620# Do we need libresolv (due to res_init or Hesiod)?
4516fbef 3621if test "$resolv" = yes && test $opsys != darwin; then
067d23c9
KY
3622 LIBRESOLV=-lresolv
3623else
3624 LIBRESOLV=
3625fi
3626AC_SUBST(LIBRESOLV)
3627
3628# These tell us which Kerberos-related libraries to use.
3629COM_ERRLIB=
3630CRYPTOLIB=
3631KRB5LIB=
3632DESLIB=
3633KRB4LIB=
3634
3635if test "${with_kerberos}" != no; then
3636 AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
3637 if test $have_com_err = yes; then
3638 COM_ERRLIB=-lcom_err
3639 LIBS="$COM_ERRLIB $LIBS"
067d23c9
KY
3640 fi
3641 AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
3642 if test $have_crypto = yes; then
3643 CRYPTOLIB=-lcrypto
3644 LIBS="$CRYPTOLIB $LIBS"
067d23c9
KY
3645 fi
3646 AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
3647 if test $have_k5crypto = yes; then
3648 CRYPTOLIB=-lk5crypto
3649 LIBS="$CRYPTOLIB $LIBS"
067d23c9
KY
3650 fi
3651 AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
3652 if test $have_krb5=yes; then
3653 KRB5LIB=-lkrb5
3654 LIBS="$KRB5LIB $LIBS"
067d23c9
KY
3655 fi
3656 dnl FIXME Simplify. Does not match 22 logic, thanks to default_off?
3657 if test "${with_kerberos5}" = no; then
3658 AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
3659 if test $have_des425 = yes; then
3660 DESLIB=-ldes425
3661 LIBS="$DESLIB $LIBS"
067d23c9
KY
3662 else
3663 AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
3664 if test $have_des = yes; then
3665 DESLIB=-ldes
3666 LIBS="$DESLIB $LIBS"
067d23c9
KY
3667 fi
3668 fi
3669 AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
3670 if test $have_krb4 = yes; then
3671 KRB4LIB=-lkrb4
3672 LIBS="$KRB4LIB $LIBS"
067d23c9
KY
3673 else
3674 AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
3675 if test $have_krb = yes; then
3676 KRB4LIB=-lkrb
3677 LIBS="$KRB4LIB $LIBS"
067d23c9
KY
3678 fi
3679 fi
3680 fi
3681
3682 if test "${with_kerberos5}" != no; then
3683 AC_CHECK_HEADERS(krb5.h,
3684 [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
3685 [#include <krb5.h>])])
3686 else
067d23c9
KY
3687 AC_CHECK_HEADERS(krb.h,,
3688 [AC_CHECK_HEADERS(kerberosIV/krb.h,,
3689 [AC_CHECK_HEADERS(kerberos/krb.h)])])
3690 fi
3691 AC_CHECK_HEADERS(com_err.h)
3692fi
3693
3694AC_SUBST(COM_ERRLIB)
3695AC_SUBST(CRYPTOLIB)
3696AC_SUBST(KRB5LIB)
3697AC_SUBST(DESLIB)
3698AC_SUBST(KRB4LIB)
3699
a84683fd
DC
3700AC_CHECK_HEADERS(valgrind/valgrind.h)
3701
554fef51 3702AC_CHECK_FUNCS_ONCE(tzset)
067d23c9
KY
3703AC_MSG_CHECKING(whether localtime caches TZ)
3704AC_CACHE_VAL(emacs_cv_localtime_cache,
3705[if test x$ac_cv_func_tzset = xyes; then
181855e6 3706AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
067d23c9
KY
3707char TZ_GMT0[] = "TZ=GMT0";
3708char TZ_PST8[] = "TZ=PST8";
3709main()
3710{
3711 time_t now = time ((time_t *) 0);
3712 int hour_GMT0, hour_unset;
3713 if (putenv (TZ_GMT0) != 0)
3714 exit (1);
3715 hour_GMT0 = localtime (&now)->tm_hour;
3716 unsetenv("TZ");
3717 hour_unset = localtime (&now)->tm_hour;
3718 if (putenv (TZ_PST8) != 0)
3719 exit (1);
3720 if (localtime (&now)->tm_hour == hour_GMT0)
3721 exit (1);
3722 unsetenv("TZ");
3723 if (localtime (&now)->tm_hour != hour_unset)
3724 exit (1);
3725 exit (0);
181855e6 3726}]])], emacs_cv_localtime_cache=no, emacs_cv_localtime_cache=yes,
067d23c9
KY
3727[# If we have tzset, assume the worst when cross-compiling.
3728emacs_cv_localtime_cache=yes])
3729else
3730 # If we lack tzset, report that localtime does not cache TZ,
3731 # since we can't invalidate the cache if we don't have tzset.
3732 emacs_cv_localtime_cache=no
3733fi])dnl
3734AC_MSG_RESULT($emacs_cv_localtime_cache)
3735if test $emacs_cv_localtime_cache = yes; then
3736 AC_DEFINE(LOCALTIME_CACHE, 1,
3737 [Define to 1 if localtime caches TZ.])
3738fi
3739
067d23c9
KY
3740ok_so_far=yes
3741AC_CHECK_FUNC(socket, , ok_so_far=no)
3742if test $ok_so_far = yes; then
3743 AC_CHECK_HEADER(netinet/in.h, , ok_so_far=no)
3744fi
3745if test $ok_so_far = yes; then
3746 AC_CHECK_HEADER(arpa/inet.h, , ok_so_far=no)
3747fi
3748if test $ok_so_far = yes; then
3749dnl Fixme: Not used. Should this be HAVE_SOCKETS?
3750 AC_DEFINE(HAVE_INET_SOCKETS, 1,
3751 [Define to 1 if you have inet sockets.])
3752fi
3753
eeceac93
PE
3754dnl Check for a Solaris 2.4 vfork bug that Autoconf misses (through 2.69).
3755dnl This can be removed once we assume Autoconf 2.70.
3756case $canonical in
3757 *-solaris2.4 | *-solaris2.4.*)
3758 dnl Disable the Autoconf-generated vfork test.
3759 : ${ac_cv_func_vfork_works=no};;
3760esac
3761
067d23c9
KY
3762AC_FUNC_FORK
3763
54e8a418 3764AC_CHECK_FUNCS(snprintf)
55e5faa1 3765
55a87246
JD
3766dnl Check this late. It depends on what other libraries (lrsvg, Gtk+ etc)
3767dnl Emacs uses.
3768XGSELOBJ=
3769AC_MSG_CHECKING([whether GLib is linked in])
3770AC_LINK_IFELSE([AC_LANG_PROGRAM(
3771 [[#include <glib.h>
3772 ]],
3773 [[g_print ("Hello world");]])],
3774 [links_glib=yes],
3775 [links_glib=no])
3776AC_MSG_RESULT([$links_glib])
3777if test "${links_glib}" = "yes"; then
3778 AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib is linked in.])
b33f93ee
JD
3779 if test "$HAVE_NS" = no;then
3780 XGSELOBJ=xgselect.o
3781 fi
55a87246
JD
3782fi
3783AC_SUBST(XGSELOBJ)
3784
067d23c9
KY
3785dnl Adapted from Haible's version.
3786AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
181855e6
GM
3787 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
3788 [[char* cs = nl_langinfo(CODESET);]])],
067d23c9
KY
3789 emacs_cv_langinfo_codeset=yes,
3790 emacs_cv_langinfo_codeset=no)
3791 ])
3792if test $emacs_cv_langinfo_codeset = yes; then
3793 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
3794 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
3795fi
3796
067d23c9
KY
3797AC_TYPE_MBSTATE_T
3798
067d23c9 3799AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr,
181855e6 3800 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void fred (int x[__restrict]);]], [[]])],
067d23c9
KY
3801 emacs_cv_c_restrict_arr=yes, emacs_cv_c_restrict_arr=no)])
3802if test "$emacs_cv_c_restrict_arr" = yes; then
3803 AC_DEFINE(__restrict_arr, __restrict,
3804 [Define to compiler's equivalent of C99 restrict keyword in array
3805 declarations. Define as empty for no equivalent.])
3806fi
3807
3808dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
3809dnl how the tty code is related to POSIX and/or other versions of termios.
3810dnl The following looks like a useful start.
3811dnl
3812dnl AC_SYS_POSIX_TERMIOS
3813dnl if test $ac_cv_sys_posix_termios = yes; then
3814dnl AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
3815dnl and macros for terminal control.])
3816dnl AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
3817dnl fi
3818
8d8e2dfe 3819dnl Turned on June 1996 supposing nobody will mind it.
cb11bd95
EZ
3820dnl MinGW emulates passwd database, so this feature doesn't make sense there.
3821if test "${opsys}" != "mingw32"; then
3822 AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
3823 in the full name stands for the login id.])
3824fi
8d8e2dfe 3825
52aa6b17
EZ
3826dnl Every platform that uses configure supports this.
3827dnl There is a create-lockfiles option you can
172bedef
GM
3828dnl customize if you do not want the lock files to be written.
3829dnl So it is not clear that this #define still needs to exist.
52aa6b17
EZ
3830AC_DEFINE(CLASH_DETECTION, 1, [Define if you want lock files to be written,
3831 so that Emacs can tell instantly when you try to modify a file that
3832 someone else has modified in his/her Emacs.])
172bedef 3833
ee1cf5cf
GM
3834dnl Everybody supports this, except MS.
3835dnl Seems like the kind of thing we should be testing for, though.
3836## Note: PTYs are broken on darwin <6. Use at your own risk.
fb0862b2
EZ
3837if test "${opsys}" != "mingw32"; then
3838 AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
3839fi
ee1cf5cf
GM
3840
3841dnl Everybody supports this, except MS-DOS.
3842dnl Seems like the kind of thing we should be testing for, though.
3843dnl Compare with HAVE_INET_SOCKETS (which is unused...) above.
3844AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
3845 4.2-compatible sockets.])
3846
ca35a5f7
GM
3847AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
3848
d4d22399
EZ
3849AH_TEMPLATE(NULL_DEVICE, [Name of the file to open to get
3850 a null file, or a data sink.])
fb0862b2 3851if test "${opsys}" = "mingw32"; then
d4d22399 3852 AC_DEFINE(NULL_DEVICE, ["NUL:"])
fb0862b2 3853else
d4d22399 3854 AC_DEFINE(NULL_DEVICE, ["/dev/null"])
fb0862b2 3855fi
b2c7a106 3856
d4d22399 3857AH_TEMPLATE(SEPCHAR, [Character that separates PATH elements.])
fb0862b2 3858if test "${opsys}" = "mingw32"; then
d4d22399 3859 AC_DEFINE(SEPCHAR, [';'])
fb0862b2 3860else
d4d22399 3861 AC_DEFINE(SEPCHAR, [':'])
fb0862b2 3862fi
b2c7a106 3863
8d8e2dfe
GM
3864dnl Everybody supports this, except MS-DOS.
3865AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
3866
b2c7a106
GM
3867AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
3868
ee1cf5cf 3869
9374581a
GM
3870AC_DEFINE(DIRECTORY_SEP, ['/'],
3871 [Character that separates directories in a file name.])
3872
fb0862b2 3873if test "${opsys}" = "mingw32"; then
57f8c490 3874 AC_DEFINE(IS_DEVICE_SEP(_c_), [((_c_) == ':')],
fb0862b2 3875 [Returns true if character is a device separator.])
5c0c0e8a 3876
fb0862b2
EZ
3877 AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == '/' || (_c_) == '\\')],
3878 [Returns true if character is a directory separator.])
5c0c0e8a 3879
fb0862b2
EZ
3880 AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))],
3881 [Returns true if character is any form of separator.])
3882else
fb0862b2
EZ
3883 AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
3884 [Returns true if character is a device separator.])
5c0c0e8a 3885
fb0862b2
EZ
3886 AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
3887 [Returns true if character is a directory separator.])
3888
3889 AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
3890 [Returns true if character is any form of separator.])
3891fi
5c0c0e8a 3892
ba9e4b84
GM
3893AH_TEMPLATE(NO_EDITRES, [Define if XEditRes should not be used.])
3894
3895case $opsys in
3896 aix4-2)
3897 dnl Unfortunately without libXmu we cannot support EditRes.
3898 if test x$ac_cv_lib_Xmu_XmuConvertStandardSelection != xyes; then
5dad233c 3899 AC_DEFINE(NO_EDITRES, 1)
ba9e4b84
GM
3900 fi
3901 ;;
3902
3903 hpux*)
3904 dnl Assar Westerlund <assar@sics.se> says this is necessary for
3905 dnl HP-UX 10.20, and that it works for HP-UX 0 as well.
3906 AC_DEFINE(NO_EDITRES, 1)
3907 ;;
3908esac
3909
3910
45fa9c0f 3911case $opsys in
739ae010
GM
3912 irix6-5 | sol2* | unixware )
3913 dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
3914 dnl instead, there's a system variable _sys_nsig. Unfortunately, we
3915 dnl need the constant to dimension an array. So wire in the appropriate
3916 dnl value here.
3917 AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
3918 ;;
45fa9c0f
GM
3919esac
3920
4a4bbad2 3921emacs_broken_SIGIO=no
ea0bbd17 3922
45fa9c0f 3923case $opsys in
ea0bbd17
GM
3924 dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
3925 dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
b4f581f0 3926 hpux* | irix6-5 | openbsd | sol2* | unixware )
4a4bbad2 3927 emacs_broken_SIGIO=yes
c5564388
GM
3928 ;;
3929
ea0bbd17 3930 aix4-2)
42bd1719
GM
3931 dnl On AIX Emacs uses the gmalloc.c malloc implementation. But given
3932 dnl the way this system works, libc functions that return malloced
3933 dnl memory use the libc malloc implementation. Calling xfree or
3934 dnl xrealloc on the results of such functions results in a crash.
3935 dnl
3936 dnl One solution for this could be to define SYSTEM_MALLOC in configure,
3937 dnl but that does not currently work on this system.
3938 dnl
3939 dnl It is possible to completely override the malloc implementation on
3940 dnl AIX, but that involves putting the malloc functions in a shared
3941 dnl library and setting the MALLOCTYPE environment variable to point to
3942 dnl that shared library.
3943 dnl
3944 dnl Emacs currently calls xrealloc on the results of get_current_dir name,
3945 dnl to avoid a crash just use the Emacs implementation for that function.
3946 dnl
3947 dnl FIXME We could change the AC_CHECK_FUNCS call near the start
3948 dnl of this file, so that we do not check for get_current_dir_name
3949 dnl on AIX. But that might be fragile if something else ends
3950 dnl up testing for get_current_dir_name as a dependency.
3951 AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
3952 get_current_dir_name should not be used.])
3953 ;;
3954
3955 freebsd)
3956 dnl Circumvent a bug in FreeBSD. In the following sequence of
3957 dnl writes/reads on a PTY, read(2) returns bogus data:
3958 dnl
3959 dnl write(2) 1022 bytes
3960 dnl write(2) 954 bytes, get EAGAIN
3961 dnl read(2) 1024 bytes in process_read_output
3962 dnl read(2) 11 bytes in process_read_output
3963 dnl
3964 dnl That is, read(2) returns more bytes than have ever been written
3965 dnl successfully. The 1033 bytes read are the 1022 bytes written
3966 dnl successfully after processing (for example with CRs added if the
3967 dnl terminal is set up that way which it is here). The same bytes will
3968 dnl be seen again in a later read(2), without the CRs.
3969 AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
3970 work around an issue when reading from a PTY.])
ea0bbd17 3971 ;;
45fa9c0f
GM
3972esac
3973
b4492cba
GM
3974case $opsys in
3975 gnu-* | sol2-10 )
3976 dnl FIXME Can't we test if this exists (eg /proc/$$)?
3977 AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
3978 ;;
3979esac
3980
9d596af3 3981case $opsys in
7e00831f 3982 darwin | dragonfly | freebsd | netbsd | openbsd )
9d596af3
GM
3983 AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
3984 close a pty to make it a controlling terminal (it is already a
3985 controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
3986 ;;
3987esac
3988
20e94fdd
GM
3989dnl FIXME Surely we can test for this rather than hard-code it.
3990case $opsys in
3991 netbsd | openbsd) sound_device="/dev/audio" ;;
3992 *) sound_device="/dev/dsp" ;;
3993esac
3994
3995dnl Used in sound.c
3996AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
3997 [Name of the default sound device.])
3998
09f4e3b0 3999
c43fb4c3
GM
4000dnl Emacs can read input using SIGIO and buffering characters itself,
4001dnl or using CBREAK mode and making C-g cause SIGINT.
4002dnl The choice is controlled by the variable interrupt_input.
4003dnl
4004dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
4005dnl
4a4bbad2 4006dnl Emacs uses the presence of the USABLE_SIGIO macro
c43fb4c3
GM
4007dnl to indicate whether or not signal-driven I/O is possible. It uses
4008dnl INTERRUPT_INPUT to decide whether to use it by default.
4009dnl
4010dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
4011dnl CBREAK mode has two disadvantages
4012dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
4013dnl I hear that in system V this problem does not exist.
4014dnl 2) Control-G causes output to be discarded.
4015dnl I do not know whether this can be fixed in system V.
4016dnl
4017dnl Another method of doing input is planned but not implemented.
4018dnl It would have Emacs fork off a separate process
4019dnl to read the input and send it to the true Emacs process
4020dnl through a pipe.
4021case $opsys in
4022 darwin | gnu-linux | gnu-kfreebsd )
4023 AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
4024 ;;
4025esac
4026
4027
308aab79
GM
4028dnl If the system's imake configuration file defines `NeedWidePrototypes'
4029dnl as `NO', we must define NARROWPROTO manually. Such a define is
4030dnl generated in the Makefile generated by `xmkmf'. If we don't define
4031dnl NARROWPROTO, we will see the wrong function prototypes for X functions
4032dnl taking float or double parameters.
4033case $opsys in
4034 cygwin|gnu|gnu-linux|gnu-kfreebsd|irix6-5|freebsd|netbsd|openbsd)
4035 AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
4036 file defines `NeedWidePrototypes' as `NO'.])
4037 ;;
4038esac
4039
4040
6e777848
GM
4041dnl Used in process.c, this must be a loop, even if it only runs once.
4042dnl (Except on SGI; see below. Take that, clarity and consistency!)
4043AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
4044dnl Only used if !PTY_ITERATION. Iterate from FIRST_PTY_LETTER to z,
4045dnl trying suffixes 0-16.
4046AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
4047 first PTY, if PTYs are supported.])
0ab7b23a 4048AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
3f922c37
GM
4049AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
4050 end of a PTY, if non-standard.])
4051AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
4052 end of a PTY, if non-standard.])
6e777848
GM
4053
4054case $opsys in
4055 aix4-2 )
ef834897 4056 AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
3f922c37
GM
4057 dnl You allocate a pty by opening /dev/ptc to get the master side.
4058 dnl To get the name of the slave side, you just ttyname() the master side.
ef834897
GM
4059 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
4060 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
6e777848
GM
4061 ;;
4062
4063 cygwin )
ef834897 4064 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
0ab7b23a 4065 dnl multi-line AC_DEFINEs are hard. :(
2fe28299 4066 AC_DEFINE(PTY_OPEN, [ do { int dummy; sigset_t blocked, procmask; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, &procmask); if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) fd = -1; pthread_sigmask (SIG_SETMASK, &procmask, 0); if (fd >= 0) emacs_close (dummy); } while (0)])
ef834897
GM
4067 AC_DEFINE(PTY_NAME_SPRINTF, [])
4068 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
4069 ;;
4070
1598ef28 4071 dnl FIXME? Maybe use same as freebsd - see bug#12040.
6e777848 4072 darwin )
ef834897 4073 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
6e777848
GM
4074 dnl Not used, because PTY_ITERATION is defined.
4075 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
0ab7b23a
GM
4076 dnl Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8.
4077 dnl But we don't have to block SIGCHLD because it is blocked in the
4078 dnl implementation of grantpt.
ef834897
GM
4079 AC_DEFINE(PTY_OPEN, [ do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)])
4080 AC_DEFINE(PTY_NAME_SPRINTF, [])
4081 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
4082 ;;
4083
1598ef28 4084 gnu | openbsd )
6e777848
GM
4085 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4086 ;;
4087
7e00831f 4088 gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd )
6e777848
GM
4089 dnl if HAVE_GRANTPT
4090 if test "x$ac_cv_func_grantpt" = xyes; then
3e91a053 4091 AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
ef834897 4092 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
3f922c37
GM
4093 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD
4094 dnl to prevent sigchld_handler from intercepting the child's death.
6496aec9 4095 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }])
1598ef28
JB
4096 dnl if HAVE_POSIX_OPENPT
4097 if test "x$ac_cv_func_posix_openpt" = xyes; then
f035e3a9 4098 AC_DEFINE(PTY_OPEN, [do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (0)])
a09710e9 4099 AC_DEFINE(PTY_NAME_SPRINTF, [])
0ab7b23a 4100 dnl if HAVE_GETPT
1598ef28 4101 elif test "x$ac_cv_func_getpt" = xyes; then
0ab7b23a 4102 AC_DEFINE(PTY_OPEN, [fd = getpt ()])
ef834897 4103 AC_DEFINE(PTY_NAME_SPRINTF, [])
3f922c37 4104 else
ef834897 4105 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
0ab7b23a 4106 fi
6e777848
GM
4107 else
4108 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4109 fi
4110 ;;
4111
3f922c37
GM
4112 hpux*)
4113 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
ef834897
GM
4114 AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
4115 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
3f922c37
GM
4116 ;;
4117
6e777848
GM
4118 irix6-5 )
4119 dnl It looks like this cannot be right, because it is not a loop.
4120 dnl However, process.c actually does this:
4121 dnl # ifndef __sgi
4122 dnl continue;
4123 dnl # else
4124 dnl return -1;
4125 dnl # endif
4126 dnl which presumably makes it OK, since irix == sgi (?).
4127 dnl FIXME it seems like this special treatment is unnecessary?
4128 dnl Why can't irix use a single-trip loop like eg cygwin?
4129 AC_DEFINE(PTY_ITERATION, [])
4130 dnl Not used, because PTY_ITERATION is defined.
4131 AC_DEFINE(FIRST_PTY_LETTER, ['q'])
d983a10b 4132 AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
5dad233c 4133 dnl No need to get the pty name at all.
ef834897 4134 AC_DEFINE(PTY_NAME_SPRINTF, [])
3f922c37 4135 dnl No need to use sprintf to get the tty name--we get that from _getpty.
ef834897 4136 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
4137 ;;
4138
3f922c37 4139 sol2* )
3f922c37
GM
4140 dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
4141 dnl from intercepting that death. If any child but grantpt's should die
4142 dnl within, it should be caught after sigrelse(2).
6496aec9 4143 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }])
3f922c37
GM
4144 ;;
4145
3f922c37 4146 unixware )
33d63ff4 4147 dnl Comments are as per sol2*.
6496aec9 4148 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }])
33d63ff4
GM
4149 ;;
4150esac
4151
4152
4153case $opsys in
4154 sol2* | unixware )
4155 dnl This change means that we don't loop through allocate_pty too
4156 dnl many times in the (rare) event of a failure.
3f922c37 4157 AC_DEFINE(FIRST_PTY_LETTER, ['z'])
ef834897 4158 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
33d63ff4
GM
4159 dnl Push various streams modules onto a PTY channel. Used in process.c.
4160 AC_DEFINE(SETUP_SLAVE_PTY, [if (ioctl (xforkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (xforkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");], [How to set up a slave PTY, if needed.])
6e777848
GM
4161 ;;
4162esac
4163
4164
09f4e3b0
GM
4165AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
4166"typing" a signal character on the pty.])
4167
4168case $opsys in
4169 dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
4170 dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX.
7e00831f 4171 aix4-2 | cygwin | gnu | irix6-5 | dragonfly | freebsd | netbsd | openbsd | darwin )
09f4e3b0
GM
4172 AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4173 ;;
4174
5dad233c 4175 dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
09f4e3b0
GM
4176 dnl FIXME Does gnu-kfreebsd have linux/version.h? It seems unlikely...
4177 gnu-linux | gnu-kfreebsd )
4178
4179 AC_MSG_CHECKING([for signals via characters])
4180 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4181#include <linux/version.h>
4182#if LINUX_VERSION_CODE < 0x20400
4183# error "Linux version too old"
4184#endif
4185 ]], [[]])], emacs_signals_via_chars=yes, emacs_signals_via_chars=no)
4186
4187 AC_MSG_RESULT([$emacs_signals_via_chars])
4188 test $emacs_signals_via_chars = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4189 ;;
4190esac
4191
4192
1ddc2bd6 4193dnl Used in lisp.h, emacs.c, vm-limit.c
c8add24e
GM
4194dnl NEWS.18 describes this as "a number which contains
4195dnl the high bits to be inclusive or'ed with pointers that are unpacked."
4196AH_TEMPLATE(DATA_SEG_BITS, [Extra bits to be or'd in with any pointers
4197stored in a Lisp_Object.])
4198dnl if Emacs uses fewer than 32 bits for the value field of a LISP_OBJECT.
4199
4200case $opsys in
35b3a27e
PE
4201 aix*)
4202 dnl This works with 32-bit executables; Emacs doesn't support 64-bit.
35b3a27e 4203 AC_DEFINE(DATA_SEG_BITS, [0x20000000])
882cf227 4204 ;;
882cf227
GM
4205 hpux*)
4206 dnl The data segment on this machine always starts at address 0x40000000.
882cf227
GM
4207 AC_DEFINE(DATA_SEG_BITS, [0x40000000])
4208 ;;
4209 irix6-5)
882cf227
GM
4210 AC_DEFINE(DATA_SEG_BITS, [0x10000000])
4211 ;;
4212esac
4213
7ccad002
GM
4214
4215AH_TEMPLATE(TAB3, [Undocumented.])
4216
b4492cba 4217case $opsys in
7ccad002 4218 darwin) AC_DEFINE(TAB3, OXTABS) ;;
8a07a8c6 4219
7e00831f 4220 gnu | dragonfly | freebsd | netbsd | openbsd )
ef834897 4221 AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
7ccad002
GM
4222 AC_DEFINE(TAB3, OXTABS)
4223 ;;
1cce6920 4224
dbee5793 4225 gnu-linux | gnu-kfreebsd )
5b633342
GM
4226 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4227#ifndef __ia64__
4228# error "not ia64"
4229#endif
4230 ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
4231 [do { extern void *__libc_ia64_register_backing_store_base; __builtin_ia64_flushrs (); mark_memory (__libc_ia64_register_backing_store_base, __builtin_ia64_bsp ());} while (0)],
4232 [Mark a secondary stack, like the register stack on the ia64.]), [])
dbee5793
GM
4233 ;;
4234
7ccad002
GM
4235 hpux*)
4236 AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
4237 run_time_remap; for HPUX.])
4238 ;;
4239esac
4240
4241
444b01bb 4242dnl This won't be used automatically yet. We also need to know, at least,
5b3f250f
GM
4243dnl that the stack is continuous.
4244AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
4245 registers relevant for conservative garbage collection in the jmp_buf.])
4246
5b3f250f
GM
4247
4248case $opsys in
5b3f250f
GM
4249 dnl Not all the architectures are tested, but there are Debian packages
4250 dnl for SCM and/or Guile on them, so the technique must work. See also
4251 dnl comments in alloc.c concerning setjmp and gcc.
4252 dnl Fixme: it's probably safe to just use the GCC conditional below.
4253 gnu-linux | gnu-kfreebsd )
4254 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4255#if defined __i386__ || defined __sparc__ || defined __mc68000__ \
4256 || defined __alpha__ || defined __mips__ || defined __s390__ \
4257 || defined __arm__ || defined __powerpc__ || defined __amd64__ \
4258 || defined __ia64__ || defined __sh__
4259/* ok */
4260#else
4261# error "setjmp not known to work on this arch"
4262#endif
444b01bb 4263 ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
5b3f250f
GM
4264 ;;
4265esac
4266
4267
4268if test x$GCC = xyes; then
4269 dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
4270 AC_DEFINE(GC_SETJMP_WORKS, 1)
4271else
4272 case $opsys in
4273 dnl irix: Tested on Irix 6.5. SCM worked on earlier versions.
7e00831f 4274 dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
5b3f250f
GM
4275 AC_DEFINE(GC_SETJMP_WORKS, 1)
4276 ;;
4277 esac
4278fi dnl GCC?
4279
9e821c83 4280dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
7b6c362e
PE
4281AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
4282 [AC_LINK_IFELSE(
4283 [AC_LANG_PROGRAM(
4284 [[#include <setjmp.h>
9e821c83
EZ
4285 #ifdef __MINGW32__
4286 # define _longjmp longjmp
4287 #endif
7b6c362e
PE
4288 ]],
4289 [[jmp_buf j;
4290 if (! _setjmp (j))
4291 _longjmp (j, 1);]])],
4292 [emacs_cv_func__setjmp=yes],
4293 [emacs_cv_func__setjmp=no])])
0328b6de
PE
4294if test $emacs_cv_func__setjmp = yes; then
4295 AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
4296else
4297 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
4298 [AC_LINK_IFELSE(
4299 [AC_LANG_PROGRAM(
4300 [[#include <setjmp.h>
4301 ]],
4302 [[sigjmp_buf j;
4303 if (! sigsetjmp (j, 1))
4304 siglongjmp (j, 1);]])],
4305 [emacs_cv_func_sigsetjmp=yes],
4306 [emacs_cv_func_sigsetjmp=no])])
4307 if test $emacs_cv_func_sigsetjmp = yes; then
4308 AC_DEFINE([HAVE_SIGSETJMP], 1,
4309 [Define to 1 if sigsetjmp and siglongjmp work.
4310 The value of this symbol is irrelevant if HAVE__SETJMP is defined.])
4311 fi
7b6c362e 4312fi
b65e7c46 4313
0a763bd1
GM
4314case $opsys in
4315 sol2* | unixware )
b65e7c46
GM
4316 dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
4317 dnl subprocesses the usual way. But TIOCSIGNAL does work for PTYs,
4318 dnl and this is all we need.
4319 AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
0a763bd1
GM
4320 ;;
4321esac
4322
5b3f250f 4323
7ccad002
GM
4324case $opsys in
4325 hpux* | sol2* )
32bac6d6 4326 dnl Used in xfaces.c.
7ccad002
GM
4327 AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
4328 some systems, where it requires time.h.])
4329 ;;
4330esac
4331
4332
983188fd
GM
4333dnl Define symbols to identify the version of Unix this is.
4334dnl Define all the symbols that apply correctly.
ae21c275
GM
4335AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
4336AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
983188fd 4337AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
268e2432 4338AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
983188fd
GM
4339
4340case $opsys in
4341 aix4-2)
4342 AC_DEFINE(USG, [])
983188fd
GM
4343 dnl This symbol should be defined on AIX Version 3 ???????
4344 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4345#ifndef _AIX
4346# error "_AIX not defined"
4347#endif
4348 ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
4349 ;;
4350
4351 cygwin)
4352 AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
4353 ;;
4354
4355 darwin)
47d7532e
PE
4356 dnl Not __APPLE__, as this may not be defined on non-OSX Darwin.
4357 dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
983188fd
GM
4358 dnl distinguish OS X from pure Darwin.
4359 AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
4360 ;;
4361
983188fd
GM
4362 gnu-linux | gnu-kfreebsd )
4363 AC_DEFINE(USG, [])
4364 AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
4365 ;;
4366
4367 hpux*)
4368 AC_DEFINE(USG, [])
983188fd
GM
4369 AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
4370 ;;
4371
4372 irix6-5)
4373 AC_DEFINE(USG, [])
268e2432 4374 AC_DEFINE(USG5_4, [])
983188fd
GM
4375 AC_DEFINE(IRIX6_5, [], [Define if the system is IRIX.])
4376 ;;
4377
fb0862b2
EZ
4378 mingw32)
4379 AC_DEFINE(DOS_NT, [])
4380 AC_DEFINE(WINDOWSNT, 1, [Define if compiling for native MS Windows.])
095bf253
EZ
4381 if test "x$ac_enable_checking" != "x" ; then
4382 AC_DEFINE(EMACSDEBUG, 1, [Define to 1 to enable w32 debug facilities.])
4383 fi
fb0862b2
EZ
4384 ;;
4385
983188fd
GM
4386 sol2*)
4387 AC_DEFINE(USG, [])
268e2432 4388 AC_DEFINE(USG5_4, [])
983188fd
GM
4389 AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
4390 ;;
4391
4392 unixware)
4393 AC_DEFINE(USG, [])
268e2432 4394 AC_DEFINE(USG5_4, [])
983188fd
GM
4395 ;;
4396esac
4397
4a4bbad2
PE
4398AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
4399 [case $opsys in
4400 aix4-2)
4401 dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
4402 emacs_cv_usable_FIONREAD=no
4403 ;;
4404
fb0862b2
EZ
4405 mingw32)
4406 emacs_cv_usable_FIONREAD=yes
4407 ;;
4408
4a4bbad2
PE
4409 *)
4410 AC_COMPILE_IFELSE(
4411 [AC_LANG_PROGRAM([[#include <sys/types.h>
4412 #include <sys/ioctl.h>
4413 #ifdef USG5_4
4414 # include <sys/filio.h>
4415 #endif
4416 ]],
4417 [[int foo = ioctl (0, FIONREAD, &foo);]])],
4418 [emacs_cv_usable_FIONREAD=yes],
4419 [emacs_cv_usable_FIONREAD=no])
4420 ;;
4421 esac])
4422if test $emacs_cv_usable_FIONREAD = yes; then
4423 AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
4424
4425 if test $emacs_broken_SIGIO = no; then
4426 AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
4427 [AC_COMPILE_IFELSE(
4428 [AC_LANG_PROGRAM([[#include <fcntl.h>
4429 #include <signal.h>
4430 ]],
4431 [[int foo = SIGIO | F_SETFL | FASYNC;]])],
4432 [emacs_cv_usable_SIGIO=yes],
4433 [emacs_cv_usable_SIGIO=no])],
4434 [emacs_cv_usable_SIGIO=yes],
4435 [emacs_cv_usable_SIGIO=no])
4436 if test $emacs_cv_usable_SIGIO = yes; then
4437 AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
4438 fi
4439 fi
4440fi
4441
983188fd 4442
7ccad002 4443case $opsys in
0fe73012
KB
4444 dnl Emacs supplies its own malloc, but glib calls posix_memalign,
4445 dnl and on Cygwin prior to version 1.7.24 that becomes the
4446 dnl Cygwin-supplied posix_memalign. As malloc is not the Cygwin
4447 dnl malloc, the Cygwin posix_memalign always returns ENOSYS. A
4448 dnl workaround is to set G_SLICE=always-malloc. This is no longer
4449 dnl needed starting with cygwin-1.7.24, and it is no longer
4450 dnl effective starting with glib-2.36. */
42bd1719
GM
4451 cygwin)
4452 AC_DEFINE(G_SLICE_ALWAYS_MALLOC, 1, [Define to set the
0fe73012 4453 G_SLICE environment variable to "always-malloc" at startup.])
42bd1719
GM
4454 ;;
4455
7ccad002 4456 hpux11)
7ccad002
GM
4457 dnl It works to open the pty's tty in the parent (Emacs), then
4458 dnl close and reopen it in the child.
4459 AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
4460 works to open a pty's tty in the parent process, then close and
4461 reopen it in the child.])
7ccad002
GM
4462 ;;
4463
4464 irix6-5)
4465 AC_DEFINE(PREFER_VSUSP, 1, [Define if process_send_signal should
4466 use VSUSP instead of VSWTCH.])
7ccad002
GM
4467 ;;
4468
7ccad002
GM
4469 sol2-10)
4470 AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
4471 on Solaris.])
7ccad002 4472 ;;
0d369729
GM
4473esac
4474
067d23c9
KY
4475# Set up the CFLAGS for real compilation, so we can substitute it.
4476CFLAGS="$REAL_CFLAGS"
4477CPPFLAGS="$REAL_CPPFLAGS"
4478
4479## Hack to detect a buggy GCC version.
4480if test "x$GCC" = xyes \
4481 && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
4482 && test x"`echo $CFLAGS | grep '\-O@<:@23@:>@'`" != x \
4483 && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
4484 AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'.])
4485fi
4486
16fab143 4487version=$PACKAGE_VERSION
067d23c9 4488
ab422c4d 4489copyright="Copyright (C) 2013 Free Software Foundation, Inc."
78f83752
GM
4490AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
4491 [Short copyright string for this version of Emacs.])
4492AC_SUBST(copyright)
4493
067d23c9
KY
4494### Specify what sort of things we'll be editing into Makefile and config.h.
4495### Use configuration here uncanonicalized to avoid exceeding size limits.
4496AC_SUBST(version)
4497AC_SUBST(configuration)
4498## Unused?
4499AC_SUBST(canonical)
4500AC_SUBST(srcdir)
4501AC_SUBST(prefix)
4502AC_SUBST(exec_prefix)
4503AC_SUBST(bindir)
4504AC_SUBST(datadir)
4505AC_SUBST(sharedstatedir)
4506AC_SUBST(libexecdir)
4507AC_SUBST(mandir)
4508AC_SUBST(infodir)
4509AC_SUBST(lispdir)
d71dfe75 4510AC_SUBST(leimdir)
ca26824c 4511AC_SUBST(standardlisppath)
067d23c9
KY
4512AC_SUBST(locallisppath)
4513AC_SUBST(lisppath)
4514AC_SUBST(x_default_search_path)
4515AC_SUBST(etcdir)
4516AC_SUBST(archlibdir)
8496d8d7 4517AC_SUBST(etcdocdir)
067d23c9
KY
4518AC_SUBST(bitmapdir)
4519AC_SUBST(gamedir)
4520AC_SUBST(gameuser)
4521## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
4522## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
4523## end of LIBX_BASE, but nothing ever set it.
4524AC_SUBST(LD_SWITCH_X_SITE)
4525AC_SUBST(C_SWITCH_X_SITE)
2f097256 4526AC_SUBST(GNUSTEP_CFLAGS)
067d23c9
KY
4527AC_SUBST(CFLAGS)
4528## Used in lwlib/Makefile.in.
4529AC_SUBST(X_TOOLKIT_TYPE)
067d23c9
KY
4530AC_SUBST(ns_appdir)
4531AC_SUBST(ns_appbindir)
4532AC_SUBST(ns_appresdir)
4533AC_SUBST(ns_appsrc)
4534AC_SUBST(GNU_OBJC_CFLAGS)
4535AC_SUBST(OTHER_FILES)
4536
17a2cbbd
DC
4537if test -n "${term_header}"; then
4538 AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
4539 [Define to the header for the built-in window system.])
4540fi
4541
067d23c9
KY
4542AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION, "${canonical}",
4543 [Define to the canonical Emacs configuration name.])
60f5e585 4544AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
067d23c9 4545 [Define to the options passed to configure.])
68169a33
GM
4546AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure
4547 define this to include extra configuration information.])
067d23c9 4548
cb11bd95
EZ
4549case $opsys in
4550 mingw32)
4551 AC_DEFINE(config_opsysfile, <ms-w32.h>, [])
4552 ;;
4553esac
4554
067d23c9
KY
4555XMENU_OBJ=
4556XOBJ=
4557FONT_OBJ=
4558if test "${HAVE_X_WINDOWS}" = "yes" ; then
4559 AC_DEFINE(HAVE_X_WINDOWS, 1,
4560 [Define to 1 if you want to use the X window system.])
4561 XMENU_OBJ=xmenu.o
55a87246 4562 XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
067d23c9
KY
4563 FONT_OBJ=xfont.o
4564 if test "$HAVE_XFT" = "yes"; then
4565 FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
4566 elif test "$HAVE_FREETYPE" = "yes"; then
4567 FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
4568 fi
4569 AC_SUBST(FONT_OBJ)
4570fi
4571AC_SUBST(XMENU_OBJ)
4572AC_SUBST(XOBJ)
4573AC_SUBST(FONT_OBJ)
4574
4575WIDGET_OBJ=
4576MOTIF_LIBW=
4577if test "${USE_X_TOOLKIT}" != "none" ; then
4578 WIDGET_OBJ=widget.o
4579 AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
4580 if test "${USE_X_TOOLKIT}" = "LUCID"; then
4581 AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
4582 elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
4583 AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
4584 MOTIF_LIBW=-lXm
4585 case "$opsys" in
4586 gnu-linux)
4587 ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
4588 MOTIF_LIBW="$MOTIF_LIBW -lXpm"
4589 ;;
4590
4591 unixware)
4592 ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
4593 ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
4594 MOTIF_LIBW="MOTIF_LIBW -lXimp"
4595 ;;
4596
4597 aix4-2)
4598 ## olson@mcs.anl.gov says -li18n is needed by -lXm.
4599 MOTIF_LIBW="$MOTIF_LIBW -li18n"
4600 ;;
4601 esac
4602 MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
4603 fi
4604fi
4605AC_SUBST(WIDGET_OBJ)
4606
4607TOOLKIT_LIBW=
4608case "$USE_X_TOOLKIT" in
4609 MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
4610 LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
4611 none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
4612esac
4613AC_SUBST(TOOLKIT_LIBW)
4614
9e821c83
EZ
4615if test "${opsys}" != "mingw32"; then
4616 if test "$USE_X_TOOLKIT" = "none"; then
4617 LIBXT_OTHER="\$(LIBXSM)"
4618 OLDXMENU_TARGET="really-oldXMenu"
4619 else
4620 LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
4621 OLDXMENU_TARGET="really-lwlib"
4622 fi
067d23c9
KY
4623fi
4624AC_SUBST(LIBXT_OTHER)
4625
4626## The X Menu stuff is present in the X10 distribution, but missing
4627## from X11. If we have X10, just use the installed library;
4628## otherwise, use our own copy.
4629if test "${HAVE_X11}" = "yes" ; then
4630 AC_DEFINE(HAVE_X11, 1,
4631 [Define to 1 if you want to use version 11 of X windows.
4632 Otherwise, Emacs expects to use version 10.])
4633
4634 if test "$USE_X_TOOLKIT" = "none"; then
4635 OLDXMENU="\${oldXMenudir}/libXMenu11.a"
4636 else
4637 OLDXMENU="\${lwlibdir}/liblw.a"
4638 fi
4639 LIBXMENU="\$(OLDXMENU)"
4640 LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
4641 OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
4642else
4643 ## For a syntactically valid Makefile; not actually used for anything.
4644 ## See comments in src/Makefile.in.
4645 OLDXMENU=nothing
4646 ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
4647 if test "${HAVE_X_WINDOWS}" = "yes"; then
4648 LIBXMENU="-lXMenu"
4649 else
4650 LIBXMENU=
4651 fi
4652 LIBX_OTHER=
4653 OLDXMENU_DEPS=
4654fi
4655
4656if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
4657 OLDXMENU_TARGET=
b06b1098 4658 OLDXMENU=nothing
067d23c9
KY
4659 LIBXMENU=
4660 OLDXMENU_DEPS=
4661fi
4662
4663AC_SUBST(OLDXMENU_TARGET)
4664AC_SUBST(OLDXMENU)
4665AC_SUBST(LIBXMENU)
4666AC_SUBST(LIBX_OTHER)
4667AC_SUBST(OLDXMENU_DEPS)
4668
4669if test "${HAVE_MENUS}" = "yes" ; then
4670 AC_DEFINE(HAVE_MENUS, 1,
50a5f95e 4671 [Define to 1 if you have mouse menus. (This is supported in all configurations, but the option to specify it remains.)])
067d23c9
KY
4672fi
4673
4674if test "${GNU_MALLOC}" = "yes" ; then
4675 AC_DEFINE(GNU_MALLOC, 1,
4676 [Define to 1 if you want to use the GNU memory allocator.])
4677fi
4678
4679RALLOC_OBJ=
4680if test "${REL_ALLOC}" = "yes" ; then
4681 AC_DEFINE(REL_ALLOC, 1,
4682 [Define REL_ALLOC if you want to use the relocating allocator for
4683 buffer space.])
4684
4685 test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
4686fi
4687AC_SUBST(RALLOC_OBJ)
4688
4689if test "$opsys" = "cygwin"; then
0fda9b75 4690 CYGWIN_OBJ="sheap.o cygw32.o"
067d23c9
KY
4691 ## Cygwin differs because of its unexec().
4692 PRE_ALLOC_OBJ=
4693 POST_ALLOC_OBJ=lastfile.o
fb0862b2
EZ
4694elif test "$opsys" = "mingw32"; then
4695 CYGWIN_OBJ=
4696 PRE_ALLOC_OBJ=
4697 POST_ALLOC_OBJ=lastfile.o
067d23c9
KY
4698else
4699 CYGWIN_OBJ=
4700 PRE_ALLOC_OBJ=lastfile.o
4701 POST_ALLOC_OBJ=
4702fi
4703AC_SUBST(CYGWIN_OBJ)
4704AC_SUBST(PRE_ALLOC_OBJ)
4705AC_SUBST(POST_ALLOC_OBJ)
4706
f5f0132b
PE
4707dnl Call this 'FORTIFY_SOUR' so that it sorts before the 'FORTIFY_SOURCE'
4708dnl verbatim defined above. The tricky name is apropos, as this hack
4709dnl makes Fortify go sour!
4710AH_VERBATIM([FORTIFY_SOUR],
4711[/* Without the following workaround, Emacs runs slowly on OS X 10.8.
4712 The workaround disables some useful run-time checking, so it
4713 should be conditional to the platforms with the performance bug.
4714 Perhaps Apple will fix this some day; also see m4/extern-inline.m4. */
4715#if defined __APPLE__ && defined __GNUC__
4716# ifndef _DONT_USE_CTYPE_INLINE_
4717# define _DONT_USE_CTYPE_INLINE_
4718# endif
4719# ifndef _FORTIFY_SOURCE
4720# define _FORTIFY_SOURCE 0
4721# endif
4722#endif
4723])
4724
5dad233c
PE
4725# Configure gnulib. Although this does not affect CFLAGS or LIBS permanently.
4726# it temporarily reverts them to their pre-pkg-config values,
4727# because gnulib needs to work with both src (which uses the
4728# pkg-config stuff) and lib-src (which does not). For example, gnulib
4729# may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
4730# and it therefore needs to run in an environment where LIBS does not
4731# already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
4732# for some package unrelated to lib-src.
4733SAVE_CFLAGS=$CFLAGS
4734SAVE_LIBS=$LIBS
4735CFLAGS=$pre_PKG_CONFIG_CFLAGS
4736LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
4737gl_ASSERT_NO_GNULIB_POSIXCHECK
4738gl_ASSERT_NO_GNULIB_TESTS
4739gl_INIT
4740CFLAGS=$SAVE_CFLAGS
4741LIBS=$SAVE_LIBS
4742
9e821c83 4743if test "${opsys}" = "mingw32"; then
eb9a3661 4744 CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
9e821c83
EZ
4745 # Remove unneeded switches from the value of CC that goes to Makefiles
4746 CC=`echo $CC | sed -e "s,$GCC_TEST_OPTIONS,,"`
4747fi
4748
067d23c9
KY
4749case "$opsys" in
4750 aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
4751
4752 darwin)
4753 ## The -headerpad option tells ld (see man page) to leave room at the
4754 ## end of the header for adding load commands. Needed for dumping.
4755 ## 0x690 is the total size of 30 segment load commands (at 56
4756 ## each); under Cocoa 31 commands are required.
4757 if test "$HAVE_NS" = "yes"; then
4758 libs_nsgui="-framework AppKit"
4465bfb4
JD
4759 if test "$NS_IMPL_COCOA" = "yes"; then
4760 libs_nsgui="$libs_nsgui -framework IOKit"
4761 fi
067d23c9
KY
4762 headerpad_extra=6C8
4763 else
4764 libs_nsgui=
4765 headerpad_extra=690
4766 fi
c8618a06 4767 LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
b06b1098 4768
067d23c9 4769 ## This is here because src/Makefile.in did some extra fiddling around
47d7532e
PE
4770 ## with LD_SWITCH_SYSTEM. It seems cleaner to put this in
4771 ## LD_SWITCH_SYSTEM_TEMACS instead,
067d23c9
KY
4772 test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
4773 LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
4774 ;;
4775
4d5c6349 4776 ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
4737362e
GM
4777 ## find X at run-time.
4778 ## When handled by cpp, this was in LD_SWITCH_SYSTEM. However, at the
4d5c6349 4779 ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
067d23c9
KY
4780 ## had not yet been defined and was expanded to null. Hence LD_SWITCH_SYSTEM
4781 ## had different values in configure (in ac_link) and src/Makefile.in.
4782 ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
4d5c6349 4783 gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
067d23c9 4784
a414bed5 4785 mingw32)
d14365f9
EZ
4786 ## MinGW64 does not prepend an underscore to symbols, so we must
4787 ## pass a different -entry switch to linker. FIXME: It is better
4788 ## to make the entry points the same by changing unexw32.c.
095bf253 4789 case "$canonical" in
54ab7d34
EZ
4790 x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,_start -Wl,-Map,./temacs.map" ;;
4791 *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
095bf253 4792 esac
a414bed5
EZ
4793 ;;
4794
bb8eb357 4795 openbsd) LD_SWITCH_SYSTEM_TEMACS='-nopie' ;;
522fe43b 4796
067d23c9
KY
4797 *) LD_SWITCH_SYSTEM_TEMACS= ;;
4798esac
4799
876da980
PE
4800if test x$ac_enable_profiling != x ; then
4801 case $opsys in
4802 *freebsd | gnu-linux) ;;
4803 *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
4804 esac
4805fi
4806
8d17ef8d
GM
4807LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
4808
067d23c9
KY
4809AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
4810
095bf253
EZ
4811## MinGW-specific post-link processing of temacs.
4812TEMACS_POST_LINK=":"
4813ADDSECTION=
4814EMACS_HEAPSIZE=
4815if test "${opsys}" = "mingw32"; then
4816 TEMACS_POST_LINK="\$(MINGW_TEMACS_POST_LINK)"
4817 ADDSECTION="../nt/addsection\$(EXEEXT)"
4818 ## Preload heap size of temacs.exe in MB.
4819 case "$canonical" in
4820 x86_64-*-*) EMACS_HEAPSIZE=42 ;;
4821 *) EMACS_HEAPSIZE=27 ;;
4822 esac
4823fi
4824
4825AC_SUBST(ADDSECTION)
4826AC_SUBST(TEMACS_POST_LINK)
4827AC_SUBST(EMACS_HEAPSIZE)
4828
17a2cbbd
DC
4829## Common for all window systems
4830if test "$window_system" != "none"; then
067d23c9 4831 AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
17a2cbbd 4832 WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
067d23c9 4833fi
067d23c9 4834
17a2cbbd 4835AC_SUBST(WINDOW_SYSTEM_OBJ)
067d23c9
KY
4836
4837AH_TOP([/* GNU Emacs site configuration template file.
73b0cd50 4838
f0ddbf7b 4839Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2013
73b0cd50 4840 Free Software Foundation, Inc.
067d23c9
KY
4841
4842This file is part of GNU Emacs.
4843
4844GNU Emacs is free software: you can redistribute it and/or modify
4845it under the terms of the GNU General Public License as published by
4846the Free Software Foundation, either version 3 of the License, or
4847(at your option) any later version.
4848
4849GNU Emacs is distributed in the hope that it will be useful,
4850but WITHOUT ANY WARRANTY; without even the implied warranty of
4851MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4852GNU General Public License for more details.
4853
4854You should have received a copy of the GNU General Public License
4855along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
4856
4857
4858/* No code in Emacs #includes config.h twice, but some bits of code
4859 intended to work with other packages as well (like gmalloc.c)
4860 think they can include it as many times as they like. */
4861#ifndef EMACS_CONFIG_H
4862#define EMACS_CONFIG_H
4863])dnl
4864
b429a4ee 4865AH_BOTTOM([#include <conf_post.h>
067d23c9 4866
067d23c9
KY
4867#endif /* EMACS_CONFIG_H */
4868
4869/*
4870Local Variables:
4871mode: c
4872End:
4873*/
4874])dnl
4875
4876#### Report on what we decided to do.
4877#### Report GTK as a toolkit, even if it doesn't use Xt.
4878#### It makes printing result more understandable as using GTK sets
4879#### toolkit_scroll_bars to yes by default.
4880if test "${HAVE_GTK}" = "yes"; then
5fb91e71 4881 USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
067d23c9
KY
4882fi
4883
2a540847
PE
4884if test $USE_ACL -ne 0; then
4885 acl_summary="yes $LIB_ACL"
4886else
4887 acl_summary=no
4888fi
4889
067d23c9
KY
4890echo "
4891Configured for \`${canonical}'.
4892
4893 Where should the build process find the source code? ${srcdir}
067d23c9
KY
4894 What compiler should emacs be built with? ${CC} ${CFLAGS}
4895 Should Emacs use the GNU version of malloc? ${GNU_MALLOC}${GNU_MALLOC_reason}
4896 Should Emacs use a relocating allocator for buffers? ${REL_ALLOC}
4897 Should Emacs use mmap(2) for buffer allocation? $use_mmap_for_buffers
4898 What window system should Emacs use? ${window_system}
4899 What toolkit should Emacs use? ${USE_X_TOOLKIT}"
4900
4901if test -n "${x_includes}"; then
4902echo " Where do we find X Windows header files? ${x_includes}"
4903else
4904echo " Where do we find X Windows header files? Standard dirs"
4905fi
4906if test -n "${x_libraries}"; then
4907echo " Where do we find X Windows libraries? ${x_libraries}"
4908else
4909echo " Where do we find X Windows libraries? Standard dirs"
4910fi
4911
4912echo " Does Emacs use -lXaw3d? ${HAVE_XAW3D}"
4913echo " Does Emacs use -lXpm? ${HAVE_XPM}"
4914echo " Does Emacs use -ljpeg? ${HAVE_JPEG}"
4915echo " Does Emacs use -ltiff? ${HAVE_TIFF}"
4916echo " Does Emacs use a gif library? ${HAVE_GIF} $LIBGIF"
4917echo " Does Emacs use -lpng? ${HAVE_PNG}"
4918echo " Does Emacs use -lrsvg-2? ${HAVE_RSVG}"
4919echo " Does Emacs use imagemagick? ${HAVE_IMAGEMAGICK}"
4920
885e792c
GM
4921echo " Does Emacs support sound? ${HAVE_SOUND}"
4922
067d23c9
KY
4923echo " Does Emacs use -lgpm? ${HAVE_GPM}"
4924echo " Does Emacs use -ldbus? ${HAVE_DBUS}"
4925echo " Does Emacs use -lgconf? ${HAVE_GCONF}"
9851bfc5 4926echo " Does Emacs use GSettings? ${HAVE_GSETTINGS}"
c9628c79 4927echo " Does Emacs use a file notification library? ${NOTIFY_SUMMARY}"
2a540847 4928echo " Does Emacs use access control lists? ${acl_summary}"
067d23c9 4929echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}"
9f77899d 4930echo " Does Emacs use -lgnutls? ${HAVE_GNUTLS}"
067d23c9
KY
4931echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}"
4932
4933echo " Does Emacs use -lfreetype? ${HAVE_FREETYPE}"
4934echo " Does Emacs use -lm17n-flt? ${HAVE_M17N_FLT}"
4935echo " Does Emacs use -lotf? ${HAVE_LIBOTF}"
4936echo " Does Emacs use -lxft? ${HAVE_XFT}"
8d28d0ac 4937echo " Does Emacs directly use zlib? ${HAVE_ZLIB}"
067d23c9
KY
4938
4939echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}"
4940echo
4941
5f77c86c
GM
4942if test -n "${EMACSDATA}"; then
4943 echo " Environment variable EMACSDATA set to: $EMACSDATA"
4944fi
4945if test -n "${EMACSDOC}"; then
4946 echo " Environment variable EMACSDOC set to: $EMACSDOC"
4947fi
4948
067d23c9
KY
4949echo
4950
4951if test "$HAVE_NS" = "yes"; then
4952 echo
507ea258 4953 echo "You must run \"${MAKE-make} install\" in order to test the built application.
067d23c9
KY
4954The installed application will go to nextstep/Emacs.app and can be
4955run or moved from there."
4956 if test "$EN_NS_SELF_CONTAINED" = "yes"; then
4957 echo "The application will be fully self-contained."
4958 else
4959 echo "The lisp resources for the application will be installed under ${prefix}.
507ea258 4960You may need to run \"${MAKE-make} install\" with sudo. The application will fail
067d23c9
KY
4961to run if these resources are not installed."
4962 fi
4963 echo
4964fi
4965
badf86af
KB
4966if test "${opsys}" = "cygwin"; then
4967 case `uname -r` in
4968 1.5.*) AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
4969 echo
4970 ;;
4971 esac
4972fi
067d23c9
KY
4973
4974# Remove any trailing slashes in these variables.
4975[test "${prefix}" != NONE &&
4976 prefix=`echo "${prefix}" | sed 's,\([^/]\)/*$,\1,'`
4977test "${exec_prefix}" != NONE &&
4978 exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`]
4979
83da1b55
GM
4980if test "$HAVE_NS" = "yes"; then
4981 if test "$NS_IMPL_GNUSTEP" = yes; then
4982 AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
4983 nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
de3d0b57 4984 ns_check_file=Resources/Info-gnustep.plist
83da1b55
GM
4985 else
4986 AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
4987 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
de3d0b57 4988 ns_check_file=Contents/Info.plist
83da1b55 4989 fi
de3d0b57 4990 AC_SUBST(ns_check_file)
83da1b55
GM
4991fi
4992
bdd556a2 4993dnl Obviously there is duplication here wrt $SUBDIR_MAKEFILES.
d0ff0c7d
GM
4994dnl You _can_ use that variable in AC_CONFIG_FILES, so long as any directory
4995dnl using automake (ie lib/) is explicitly listed and not "hidden" in a variable
bdd556a2
GM
4996dnl (else you get "no `Makefile.am' found for any configure output").
4997dnl This will work, but you get a config.status that is not quite right
4998dnl (see http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00028.html).
4999dnl That doesn't have any obvious consequences for Emacs, but on the whole
5000dnl it seems better to just live with the duplication.
095bf253 5001SUBDIR_MAKEFILES="lib/Makefile lib-src/Makefile oldXMenu/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile leim/Makefile nextstep/Makefile nt/Makefile"
bdd556a2
GM
5002
5003AC_CONFIG_FILES([Makefile lib/Makefile lib-src/Makefile oldXMenu/Makefile \
5004 doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
5005 doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile \
095bf253 5006 leim/Makefile nextstep/Makefile nt/Makefile])
6c7e099d
GM
5007
5008dnl test/ is not present in release tarfiles.
70716b1d
GM
5009opt_makefile=test/automated/Makefile
5010
3cc53d60 5011if test -f "$srcdir/$opt_makefile.in"; then
70716b1d 5012 SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
bdd556a2
GM
5013 dnl Again, it's best not to use a variable. Though you can add
5014 dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
5015 AC_CONFIG_FILES([test/automated/Makefile])
5016fi
70716b1d 5017
a9f72fc1
GM
5018
5019dnl admin/ may or may not be present.
5020opt_makefile=admin/unidata/Makefile
5021
3cc53d60 5022if test -f "$srcdir/$opt_makefile.in"; then
a9f72fc1
GM
5023 SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
5024 AC_CONFIG_FILES([admin/unidata/Makefile])
5025fi
5026
5027
bdd556a2 5028SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
70716b1d
GM
5029
5030AC_SUBST(SUBDIR_MAKEFILES_IN)
1e8dbdc6 5031
067d23c9
KY
5032dnl You might wonder (I did) why epaths.h is generated by running make,
5033dnl rather than just letting configure generate it from epaths.in.
5034dnl One reason is that the various paths are not fully expanded (see above);
5035dnl eg gamedir=${prefix}/var/games/emacs.
5036dnl Secondly, the GNU Coding standards require that one should be able
5037dnl to run `make prefix=/some/where/else' and override the values set
5038dnl by configure. This also explains the `move-if-change' test and
5039dnl the use of force in the `epaths-force' rule in Makefile.in.
1813e115 5040AC_CONFIG_COMMANDS([src/epaths.h], [
d6db9fd6
EZ
5041if test "${opsys}" = "mingw32"; then
5042 ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
5043else
5044 ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
5045fi
5046], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
067d23c9 5047
98434155
GM
5048dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
5049dnl is not yet set, sigh. Or we could use ../$srcdir/src/.gdbinit,
5050dnl or a symlink?
1813e115 5051AC_CONFIG_COMMANDS([src/.gdbinit], [
3cc53d60 5052if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
98434155 5053 echo "source $ac_abs_top_srcdir/src/.gdbinit" > src/.gdbinit
067d23c9 5054fi
1e8dbdc6 5055])
067d23c9 5056
1e8dbdc6 5057AC_OUTPUT