1# configure.ac for GNU Objective-C library
2# Process this file with autoconf to produce a configure script.
3#
4#   Copyright (C) 1993,1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5#
6#   Written by:  Andrew Kachites McCallum <mccallum@cs.rochester.edu>
7#   Dept. of Computer Science, U. of Rochester, Rochester, NY  14627
8#
9#   This file is part of the GNU Objective-C library.
10#
11#   This library is free software; you can redistribute it and/or
12#   modify it under the terms of the GNU General Public
13#   License as published by the Free Software Foundation; either
14#   version 2 of the License, or (at your option) any later version.
15#
16#   This library is distributed in the hope that it will be useful,
17#   but WITHOUT ANY WARRANTY; without even the implied warranty of
18#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19#   General Public License for more details.
20#
21#   You should have received a copy of the GNU General Public
22#   License along with this library; if not, write to the Free
23#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24#   Boston, MA 02111 USA
25
26#
27# DEPENDENCIES POLICY
28#
29# Generally the aim in the base library is to minimise dependencies on
30# external libraries which may not come as standard on all systems, and
31# you should not, as a rule, add such dependencies.
32#
33# However, in some cases there are large areas of functionality where it
34# would just be too much effort to implement things ourselves and it makes
35# sense to use external software to do the job.
36#
37# In such cases this configure.ac script should include options to allow
38# people to build with the dependency or to disable those parts of the
39# base library which require the external dependency and build without it.
40# The configure script should support a --disable-xxx option in such a case,
41# where 'xxx' is the name of the dependency.
42#
43# If a major dependency is NOT specifically disabled, the configuration
44# process must fail with an error message ... all builds of gnustep-base
45# should support all expected functionality unless the person configuring
46# and building is very certain they don't want it.
47#
48# Where a dependency is introduced this script should do this by setting
49# HAVE_XXX to 1 or 0 and calling AC_SUBST(XXX) to substitute the information
50# into the make files:
51#   config.mak.in: used to build the base library itsself
52#   base.make.in: the makefile fragment used to build software which uses base
53# These files then define GNUSTEP_BASE_HAVE_XXX to 1 or 0 so that the variable
54# may be used to control conditional compilation of particular files.
55#
56# In addition the values should be substituted into the header file
57# Headers/GNUstepBase/GSConfig.h.in so that it can define a
58# preprocessor constant of the form GS_USE_XXX to 1 or 0, providing a
59# standard mechanism for parts of a particular file to compile to make
60# use of the external code or not.
61# This file is included by all the base library source code, and may also
62# be included by code which uses the base library.
63#
64
65builtin(include, config/objc-con-autoload.m4)dnl
66builtin(include, config/objc-sys-dynamic.m4)dnl
67builtin(include, config/procfs-exe-link.m4)dnl
68builtin(include, config/procfs.m4)dnl
69builtin(include, config/pathxml.m4)dnl
70builtin(include, config/pathtls.m4)dnl
71builtin(include, config/codeset.m4)dnl
72builtin(include, config/addlibrarypath.m4)dnl
73builtin(include, config/pkg.m4)dnl
74
75AC_INIT
76AC_PREREQ([2.60])
77AC_CONFIG_SRCDIR([Source/NSArray.m])
78
79# If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it.
80if test -z "$GNUSTEP_MAKEFILES"; then
81  GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>&5`
82fi
83
84if test -z "$GNUSTEP_MAKEFILES"; then
85  AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
86fi
87
88# If LIBRARY_COMBO is undefined, try to use gnustep-config to determine it.
89if test -z "$LIBRARY_COMBO"; then
90  LIBRARY_COMBO=`gnustep-config --variable=LIBRARY_COMBO 2>&5`
91fi
92
93if test "$OBJC_RUNTIME_LIB" = "ng"; then
94  nonfragile=yes
95  BASE_NONFRAGILE_ABI=1
96else
97  nonfragile=`gnustep-config --objc-flags | grep _NONFRAGILE_ABI 2>&5`
98  if test -z "$nonfragile"; then
99    nonfragile=no
100    BASE_NONFRAGILE_ABI=0
101  else
102    nonfragile=yes
103    BASE_NONFRAGILE_ABI=1
104  fi
105fi
106AC_SUBST(BASE_NONFRAGILE_ABI)
107
108MAKECPPFLAGS=`gnustep-config --variable=CPPFLAGS`
109if test "$CPPFLAGS" = ""; then
110  CPPFLAGS=$MAKECPPFLAGS
111  export CPPFLAGS
112else
113  if test "$CPPFLAGS" != "$MAKECPPFLAGS"; then
114    AC_MSG_WARN([You are running configure with the preprocessor options ($CPPFLAGS) set to a different value from that used by gnustep-make ($MAKECPPFLAGS).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CPPFLAGS=$CPPFLAGS or run the gnustep-base configure again with your CPPFLAGS environment variable set to $MAKECPPFLAGS])
115  fi
116fi
117
118MAKELDFLAGS=`gnustep-config --variable=LDFLAGS`
119if test "$LDFLAGS" = ""; then
120  LDFLAGS=$MAKELDFLAGS
121  export LDFLAGS
122else
123  if test "$LDFLAGS" != "$MAKELDFLAGS"; then
124    AC_MSG_WARN([You are running configure with the link options ($LDFLAGS) set to a different value from that used by gnustep-make ($MAKELDFLAGS).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use LDFLAGS=$LDFLAGS or run the gnustep-base configure again with your LDFLAGS environment variable set to $MAKELDFLAGS])
125  fi
126fi
127
128# We shouldn't be loading GNUstep.sh here.  It would load in a lot of
129# variables which might get confused with the ones that will be used
130# at runtime.  We will load it later once we have determined (and
131# saved) the runtime configuration.
132
133# This variable might get temporarily overwritten with the
134# GNUSTEP_MAKEFILES of the runtime configuration, make sure we keep
135# track of the original one.  CURRENT_GNUSTEP_MAKEFILES is the one
136# that we use to locate the actual gnustep-make installation that
137# will build the software.
138CURRENT_GNUSTEP_MAKEFILES="$GNUSTEP_MAKEFILES"
139
140#--------------------------------------------------------------------
141# Use config.guess, config.sub and install-sh provided by gnustep-make
142#--------------------------------------------------------------------
143AC_CONFIG_AUX_DIR($CURRENT_GNUSTEP_MAKEFILES)
144
145#--------------------------------------------------------------------
146# Use a .h file with #define's, instead of -D command-line switches
147#--------------------------------------------------------------------
148AC_CONFIG_HEADER(Headers/GNUstepBase/config.h)
149
150#--------------------------------------------------------------------
151# Determine the host, build, and target systems
152#--------------------------------------------------------------------
153AC_CANONICAL_TARGET([])
154
155#--------------------------------------------------------------------
156# Setup cross-compilation-information
157#--------------------------------------------------------------------
158
159AC_ARG_WITH(cross-compilation-info,
160[  --with-cross-compilation-info=PATH
161				Specify path to the configuration file that
162				contains information for the configure script in
163				case of cross compilation. This information
164				replaces those obtained from running programmes
165				during the configuration phase.],
166  cross_result="$withval",
167  cross_result="no"
168)
169CROSS_CONFIG="./cross.config"
170if test "$cross_result" != "no"
171then
172 if test -f "$cross_result" && test -r "$cross_result"
173  then
174    CROSS_CONFIG="$cross_result"
175  else
176    AC_MSG_ERROR(["Could not load cross-compilation variables from $cross_result"])
177  fi
178fi
179
180# import information from the cross-config.
181. "$CROSS_CONFIG"
182
183
184
185#---------------------------------------------------------------------
186# Location of the GNUstep.conf config file (--with-config-file)
187#---------------------------------------------------------------------
188AC_MSG_CHECKING([for GNUstep configuration file to use at runtime])
189
190# This requires gnustep-make > 1.13.0 to work.  For gnustep-make =
191# 1.13.0 we would have to parse
192# $CURRENT_GNUSTEP_MAKEFILES/$obj_dir/config.make, but $obj_dir is not defined
193# yet at this stage in config, not sure if it's worth trying to make
194# it work.  For gnustep-make < 1.13.0 we would have to parse
195# $CURRENT_GNUSTEP_MAKEFILES/config.make.
196GNUSTEP_MAKE_CONFIG=`(grep '^GNUSTEP_CONFIG_FILE *=' $CURRENT_GNUSTEP_MAKEFILES/config-noarch.make | sed -e 's/GNUSTEP_CONFIG_FILE *= *\(.*\)/\1/') 2>&5`
197
198# So, for backwards compatiblity, we try the plain config.make too.
199# This should work with gnustep-make < 1.13.0, and with 1.13.0 too if
200# they haven't deleted the file.
201if test "$GNUSTEP_MAKE_CONFIG"  = ""; then
202  GNUSTEP_MAKE_CONFIG=`(grep '^GNUSTEP_CONFIG_FILE *=' $CURRENT_GNUSTEP_MAKEFILES/config.make | sed -e 's/GNUSTEP_CONFIG_FILE *= *\(.*\)/\1/') 2>&5`
203fi
204
205AC_ARG_WITH(config-file,
206[  --with-config-file=PATH       Specify path to the GNUstep config file.
207				This is the location to be used by the base
208				library to locate path information at
209				application or tool runtime.
210				This file might not even exist now; it is
211				not read at configure time.  The base library
212				will only read it at runtime.
213				If unspecified, this uses the same value as
214				the GNUstep make package on unix-like systems,
215				but uses ./GNUstep.conf on mingw so that
216				it is relative to the location of the
217				base library DLL.
218				If a leading './' is specified, the path
219				is taken to be relative to the base library
220				linked runtime, not all operating systems
221				can support this, so on some platforms you
222				may need to specify the location of the
223				config file using the GNUSTEP_CONFIG_FILE
224				environment variable at runtime.
225				If a trailing '/' is specified, the path is
226				used for locating domains but no GNUstep
227				config file is read at runtime.],
228  result="$withval",
229  result="no"
230)
231if test "$result" != "no"
232then
233  GNUSTEP_TARGET_CONFIG_FILE="$result"
234fi
235if test x"$GNUSTEP_TARGET_CONFIG_FILE" = x""; then
236  case "$target_os" in
237    mingw*)
238      GNUSTEP_TARGET_CONFIG_FILE=./GNUstep.conf ;;
239    *)
240      GNUSTEP_TARGET_CONFIG_FILE="$GNUSTEP_MAKE_CONFIG" ;;
241  esac
242fi
243AC_MSG_RESULT($GNUSTEP_TARGET_CONFIG_FILE)
244
245#-----------------------------------------------------------------
246# Whether the GNUstep.conf file path can be set in the environment
247# By default this is enabled on unix, but disabled on mswindows
248# since the normal setup on mswindows is to have the config file
249# located with the base library dll for runtime configuration and
250# use the environment variable to control the developer config file
251# location (used by gnustep-make when building).
252#-----------------------------------------------------------------
253case "$target_os" in
254    mingw*)	enable_env_config=no;;
255    *)		enable_env_config=yes;;
256esac
257AC_MSG_CHECKING([whether the GNUstep.conf file path can be set in the environment])
258AC_ARG_ENABLE(environment-config-file,
259[  --disable-environment-config-file
260                                Disables the use of the GNUSTEP_CONFIG_FILE
261				environment variable to specify/override
262				the location of the GNUstep config file
263				at runtime.  This option is occasionally
264				useful to disable the environment variable
265				for sites which wish to 'lock down' users
266				to always work with a specific system-wide
267				configuration.  On unix-like systems the
268				default is for this option to be enabled.
269				It is disabled by default on windows systems
270				so that the base library will not use a
271				config file intended for the gnustep-make
272				system (and containing unix-style paths
273				which cannot be used by windows apps).
274				Normally this should be left at its default
275				setting.],
276  ac_cv_environment_config_file=$enableval,
277  ac_cv_environment_config_file=$enable_env_config)
278if test "$ac_cv_environment_config_file" = "yes"; then
279  AC_DEFINE(OPTION_NO_ENVIRONMENT, 0,
280    [Enable GNUSTEP_CONFIG_FILE environment variable])
281  AC_MSG_RESULT([yes])
282else
283  AC_DEFINE(OPTION_NO_ENVIRONMENT, 1,
284    [Disable GNUSTEP_CONFIG_FILE environment variable])
285  AC_MSG_RESULT([no: disabled from the command-line])
286fi
287
288#--------------------------------------------------------------------
289# We are now trying to determine the default GNUstep paths to be
290# used at runtime.  So all GNUSTEP_xxx variables from now on are to be
291# considered as 'runtime' ones.  They refer to paths that might not
292# make any sense now, but might make sense once gnustep-base is
293# installed in its final location.
294#---------------------------------------------------------------------
295
296#
297# Set 'standard' defaults for values from configuration file.
298#
299case "$target_os" in
300  *)
301    GNUSTEP_SYSTEM_ROOT=/usr/GNUstep/System
302    GNUSTEP_LOCAL_ROOT=/usr/GNUstep/Local
303    GNUSTEP_NETWORK_ROOT=/usr/GNUstep/Local
304    GNUSTEP_USER_DEFAULTS_DIR=GNUstep/Defaults
305    GNUSTEP_USER_CONFIG_FILE=.GNUstep.conf
306    ;;
307esac
308
309#---------------------------------------------------------------------
310# Now read/import the existing configuration file, if any
311#---------------------------------------------------------------------
312
313# Reading/importing an existing configuration file is good as it means
314# the built-in default paths in the code will match those of your
315# installation (or of the config file you specify).
316# It can be annoying in certain cases though; this option lets you
317# turn it off.
318AC_MSG_CHECKING([if we should import an existing configuration file now])
319AC_ARG_ENABLE(importing-config-file,
320[  --disable-importing-config-file
321                                Disable importing of an existing GNUstep config
322				file and use inbuilt defaults instead.],
323  ac_cv_importing_config_file=$enableval,
324  ac_cv_importing_config_file="yes")
325if test "$ac_cv_importing_config_file" = "no"; then
326  AC_MSG_RESULT([no: disabled from the command-line])
327else
328  AC_MSG_RESULT([yes])
329fi
330
331
332if test "$ac_cv_importing_config_file" = "yes" ;
333then
334  AC_MSG_CHECKING([for default GNUstep configuration file to use])
335  AC_ARG_WITH(default-config,
336[  --with-default-config=PATH   Specify path to a GNUstep config file to be
337				imported at configure time (now) and used to
338				provide default values for the base library
339				to use at runtime if no GNUstep config file
340				is found at runtime.  If this is not specified
341				then the path from the gnustep-make package
342				is used.],
343    result="$withval",
344    result="no"
345  )
346  if test "$result" != "no"
347  then
348    GNUSTEP_DEFAULT_CONFIG="$result"
349  fi
350  if test "$GNUSTEP_DEFAULT_CONFIG" = ""; then
351    # No file to import has been specified.  We need to read the paths
352    # from somewhere though!  GNUstep.sh might not have been sourced,
353    # so at this stage we have no knowledge of what the paths must be.
354    # The only place that we can read them from is the gnustep-make
355    # GNUstep.conf file.
356    # So we fall back to useing the make settings for the built-in ones.
357    # However, on mingw these will be msys style paths, and we don't
358    # want that ... so later on we convert these to portable relative
359    # paths based on the directory in which the base library will be
360    # installed.
361    GNUSTEP_DEFAULT_CONFIG="$GNUSTEP_MAKE_CONFIG"
362  fi
363  AC_MSG_RESULT($GNUSTEP_DEFAULT_CONFIG)
364
365  #
366  # Only try importing if the default config file has been specified.
367  #
368  if test "$GNUSTEP_DEFAULT_CONFIG" != ""; then
369    # Make sure we have a slash in the path so that '.' will source it
370    case $GNUSTEP_DEFAULT_CONFIG in
371      /*) ;;
372      *) GNUSTEP_DEFAULT_CONFIG="./$GNUSTEP_DEFAULT_CONFIG" ;;
373    esac
374    #
375    # Use the default config file to override standard values.
376    #
377    if test ! -f "$GNUSTEP_DEFAULT_CONFIG"; then
378      AC_MSG_RESULT([fail: file "$GNUSTEP_DEFAULT_CONFIG" does not exist])
379      # Ohoh ... things are not going well.  We are asked to import
380      # a config file that doesn't exist.  So all paths might be unset
381      # and who knows what we'll end up hardcoding into gnustep-base.
382      # It looks like we need to make sure the user knows what they
383      # are doing, as there is a high chance they don't and might end
384      # up with a confused/non-working system.  As far as we know, the
385      # system might be already screwed.  If they don't want to import
386      # a config file (eg, they don't have one and they don't care about
387      # the hardcoded paths) they should just say so. ;-)
388      AC_MSG_ERROR([Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option])
389      exit 1
390    else
391      AC_MSG_RESULT([trying to import "$GNUSTEP_DEFAULT_CONFIG"])
392      if test -r "$GNUSTEP_DEFAULT_CONFIG"
393      then
394        AC_MSG_NOTICE([If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option])
395        . "$GNUSTEP_DEFAULT_CONFIG"
396      else
397        AC_MSG_RESULT([fail: file "$GNUSTEP_DEFAULT_CONFIG" is not readable])
398	AC_MSG_ERROR([Unable to import configuration file at $GNUSTEP_DEFAULT_CONFIG.  Please run configure again with a revised/corrected --with-default-config= option or with --disable-importing-config-file.])
399	exit 1
400      fi
401    fi
402  fi
403fi
404
405# Now we have the problem of what to do if some of the paths were not
406# set by GNUstep.conf (eg, old gnustep-make), or if no config file was
407# read, or if the config file was corrupt.  We decide that the most
408# likely case is an old gnustep-make, so by default we configure the
409# other paths basing on GNUSTEP_*_ROOT.
410
411# TODO/FIXME: We should really have better checks once the situation
412# has stabilized.  This is a reasonable hack for now.
413
414if test x"$GNUSTEP_MAKEFILES" = x""; then GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles; fi
415
416if test x"$GNUSTEP_SYSTEM_USERS_DIR" = x""; then GNUSTEP_SYSTEM_USERS_DIR=/home; fi
417if test x"$GNUSTEP_NETWORK_USERS_DIR" = x""; then GNUSTEP_NETWORK_USERS_DIR=/home; fi
418if test x"$GNUSTEP_LOCAL_USERS_DIR" = x""; then GNUSTEP_LOCAL_USERS_DIR=/home; fi
419
420if test x"$GNUSTEP_SYSTEM_APPS" = x""; then GNUSTEP_SYSTEM_APPS=$GNUSTEP_SYSTEM_ROOT/Applications; fi
421if test x"$GNUSTEP_SYSTEM_ADMIN_APPS" = x""; then GNUSTEP_SYSTEM_ADMIN_APPS=$GNUSTEP_SYSTEM_ROOT/Applications/Admin; fi
422if test x"$GNUSTEP_SYSTEM_WEB_APPS" = x""; then GNUSTEP_SYSTEM_WEB_APPS=$GNUSTEP_SYSTEM_ROOT/WebApplications; fi
423if test x"$GNUSTEP_SYSTEM_TOOLS" = x""; then GNUSTEP_SYSTEM_TOOLS=$GNUSTEP_SYSTEM_ROOT/Tools; fi
424if test x"$GNUSTEP_SYSTEM_ADMIN_TOOLS" = x""; then GNUSTEP_SYSTEM_ADMIN_TOOLS=$GNUSTEP_SYSTEM_ROOT/Tools/Admin; fi
425if test x"$GNUSTEP_SYSTEM_LIBRARY" = x""; then GNUSTEP_SYSTEM_LIBRARY=$GNUSTEP_SYSTEM_ROOT/Library; fi
426if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then GNUSTEP_SYSTEM_LIBRARIES=$GNUSTEP_SYSTEM_LIBRARY/Libraries; fi
427if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then GNUSTEP_SYSTEM_HEADERS=$GNUSTEP_SYSTEM_LIBRARY/Headers; fi
428if test x"$GNUSTEP_SYSTEM_DOC" = x""; then GNUSTEP_SYSTEM_DOC=$GNUSTEP_SYSTEM_LIBRARY/Documentation; fi
429if test x"$GNUSTEP_SYSTEM_DOC_MAN" = x""; then GNUSTEP_SYSTEM_DOC_MAN=$GNUSTEP_SYSTEM_LIBRARY/Documentation/man; fi
430if test x"$GNUSTEP_SYSTEM_DOC_INFO" = x""; then GNUSTEP_SYSTEM_DOC_INFO=$GNUSTEP_SYSTEM_LIBRARY/Documentation/info; fi
431
432if test x"$GNUSTEP_NETWORK_APPS" = x""; then GNUSTEP_NETWORK_APPS=$GNUSTEP_NETWORK_ROOT/Applications; fi
433if test x"$GNUSTEP_NETWORK_ADMIN_APPS" = x""; then GNUSTEP_NETWORK_ADMIN_APPS=$GNUSTEP_NETWORK_ROOT/Applications/Admin; fi
434if test x"$GNUSTEP_NETWORK_WEB_APPS" = x""; then GNUSTEP_NETWORK_APPS=$GNUSTEP_NETWORK_ROOT/WebApplications; fi
435if test x"$GNUSTEP_NETWORK_TOOLS" = x""; then GNUSTEP_NETWORK_TOOLS=$GNUSTEP_NETWORK_ROOT/Tools; fi
436if test x"$GNUSTEP_NETWORK_ADMIN_TOOLS" = x""; then GNUSTEP_NETWORK_ADMIN_TOOLS=$GNUSTEP_NETWORK_ROOT/Tools/Admin; fi
437if test x"$GNUSTEP_NETWORK_LIBRARY" = x""; then GNUSTEP_NETWORK_LIBRARY=$GNUSTEP_NETWORK_ROOT/Library; fi
438if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then GNUSTEP_NETWORK_LIBRARIES=$GNUSTEP_NETWORK_LIBRARY/Libraries; fi
439if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then GNUSTEP_NETWORK_HEADERS=$GNUSTEP_NETWORK_LIBRARY/Headers; fi
440if test x"$GNUSTEP_NETWORK_DOC" = x""; then GNUSTEP_NETWORK_DOC=$GNUSTEP_NETWORK_LIBRARY/Documentation; fi
441if test x"$GNUSTEP_NETWORK_DOC_MAN" = x""; then GNUSTEP_NETWORK_DOC_MAN=$GNUSTEP_NETWORK_LIBRARY/Documentation/man; fi
442if test x"$GNUSTEP_NETWORK_DOC_INFO" = x""; then GNUSTEP_NETWORK_DOC_INFO=$GNUSTEP_NETWORK_LIBRARY/Documentation/info; fi
443
444if test x"$GNUSTEP_LOCAL_APPS" = x""; then GNUSTEP_LOCAL_APPS=$GNUSTEP_LOCAL_ROOT/Applications; fi
445if test x"$GNUSTEP_LOCAL_ADMIN_APPS" = x""; then GNUSTEP_LOCAL_ADMIN_APPS=$GNUSTEP_LOCAL_ROOT/Applications/Admin; fi
446if test x"$GNUSTEP_LOCAL_WEB_APPS" = x""; then GNUSTEP_LOCAL_APPS=$GNUSTEP_LOCAL_ROOT/WebApplications; fi
447if test x"$GNUSTEP_LOCAL_TOOLS" = x""; then GNUSTEP_LOCAL_TOOLS=$GNUSTEP_LOCAL_ROOT/Tools; fi
448if test x"$GNUSTEP_LOCAL_ADMIN_TOOLS" = x""; then GNUSTEP_LOCAL_ADMIN_TOOLS=$GNUSTEP_LOCAL_ROOT/Tools/Admin; fi
449if test x"$GNUSTEP_LOCAL_LIBRARY" = x""; then GNUSTEP_LOCAL_LIBRARY=$GNUSTEP_LOCAL_ROOT/Library; fi
450if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then GNUSTEP_LOCAL_LIBRARIES=$GNUSTEP_LOCAL_LIBRARY/Libraries; fi
451if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then GNUSTEP_LOCAL_HEADERS=$GNUSTEP_LOCAL_LIBRARY/Headers; fi
452if test x"$GNUSTEP_LOCAL_DOC" = x""; then GNUSTEP_LOCAL_DOC=$GNUSTEP_LOCAL_LIBRARY/Documentation; fi
453if test x"$GNUSTEP_LOCAL_DOC_MAN" = x""; then GNUSTEP_LOCAL_DOC_MAN=$GNUSTEP_LOCAL_LIBRARY/Documentation/man; fi
454if test x"$GNUSTEP_LOCAL_DOC_INFO" = x""; then GNUSTEP_LOCAL_DOC_INFO=$GNUSTEP_LOCAL_LIBRARY/Documentation/info; fi
455
456if test x"$GNUSTEP_USER_DIR_APPS" = x""; then GNUSTEP_USER_DIR_APPS=$GNUSTEP_USER_DIR/Applications; fi
457if test x"$GNUSTEP_USER_DIR_ADMIN_APPS" = x""; then GNUSTEP_USER_DIR_ADMIN_APPS=$GNUSTEP_USER_DIR/Applications/Admin; fi
458if test x"$GNUSTEP_USER_DIR_WEB_APPS" = x""; then GNUSTEP_USER_DIR_APPS=$GNUSTEP_USER_DIR/WebApplications; fi
459if test x"$GNUSTEP_USER_DIR_TOOLS" = x""; then GNUSTEP_USER_DIR_TOOLS=$GNUSTEP_USER_DIR/Tools; fi
460if test x"$GNUSTEP_USER_DIR_ADMIN_TOOLS" = x""; then GNUSTEP_USER_DIR_ADMIN_TOOLS=$GNUSTEP_USER_DIR/Tools/Admin; fi
461if test x"$GNUSTEP_USER_DIR_LIBRARY" = x""; then GNUSTEP_USER_DIR_LIBRARY=$GNUSTEP_USER_DIR/Library; fi
462if test x"$GNUSTEP_USER_DIR_LIBRARIES" = x""; then GNUSTEP_USER_DIR_LIBRARIES=$GNUSTEP_USER_DIR/Libraries; fi
463if test x"$GNUSTEP_USER_DIR_HEADERS" = x""; then GNUSTEP_USER_DIR_HEADERS=$GNUSTEP_USER_DIR/Headers; fi
464if test x"$GNUSTEP_USER_DIR_DOC" = x""; then GNUSTEP_USER_DIR_DOC=$GNUSTEP_USER_DIR/Documentation; fi
465if test x"$GNUSTEP_USER_DIR_DOC_MAN" = x""; then GNUSTEP_USER_DIR_DOC_MAN=$GNUSTEP_USER_DIR/Documentation/man; fi
466if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNUSTEP_USER_DIR/Documentation/info; fi
467
468AC_MSG_CHECKING([for GNUstep-base installation domain])
469AC_ARG_WITH(installation-domain,
470[  --with-installation-domain=DOMAIN
471				Specify the domain (SYSTEM, LOCAL,
472				NETWORK or USER) into which
473				gnustep-base will be installed.
474				Whenever relative paths are hardcoded
475				into gnustep-base (at the moment, this
476				happens only on MinGW) this option
477				must be used and must match the domain
478				where you will be installing
479				gnustep-base.
480				If this is not specified, the output of
481				gnustep-config --installation-domain-for=gnustep-base
482				(which should normally be LOCAL) is used.],
483  result="$withval",
484  result="no"
485)
486if test "$result" = "no"
487then
488  # Check if gnustep-config supports the option
489  # --installation-domain-for, and use it if available.  That option
490  # will automatically use the shell variable GNUSTEP_INSTALLATION_DOMAIN or
491  # the installation-domains.conf files (or the LOCAL default) as appropriate.
492  # Otherwise, if that option is not available just fall back to
493  # using GNUSTEP_INSTALLATION_DOMAIN or (if that was not defiend) LOCAL.
494  if (gnustep-config --help | grep installation-domain) >&5 2>&5
495  then
496    result=`gnustep-config --installation-domain-for=gnustep-base 2>&5`
497  else
498    AC_MSG_WARN([The 'gnustep-config' script was not found or out of date.])
499    result=$GNUSTEP_INSTALLATION_DOMAIN
500    if test "$result" = ""
501    then
502      # This case was added on December 2008 and is only for backwards
503      # compatibility with older versions of gnustep-make.
504      result=LOCAL
505    fi
506  fi
507fi
508case "$result" in
509  SYSTEM)
510    AC_MSG_RESULT([SYSTEM])
511    GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS";;
512  LOCAL)
513    AC_MSG_RESULT([LOCAL])
514    GNUSTEP_BASE_PATH="$GNUSTEP_LOCAL_TOOLS";;
515  NETWORK)
516    AC_MSG_RESULT([NETWORK])
517    GNUSTEP_BASE_PATH="$GNUSTEP_NETWORK_TOOLS";;
518  USER)
519    AC_MSG_RESULT([USER])
520    GNUSTEP_BASE_PATH="$GNUSTEP_USER_TOOLS";;
521  *)
522    AC_MSG_ERROR([Unknown installation domain '$result' (it should be SYSTEM, LOCAL, NETWORK or USER).  Please run configure again with the option --with-installation-domain=LOCAL (or whatever domain you want to install into).])
523    exit 1;;
524esac
525# We store GNUSTEP_BASE_DOMAIN in config.mak so that we can check
526# at runtime and make sure it is consistent with the
527# GNUSTEP_INSTALLATION_DOMAIN that is used at runtime.
528GNUSTEP_BASE_DOMAIN=$result
529AC_SUBST(GNUSTEP_BASE_DOMAIN)
530
531#
532# If we are on mingw, we now want to convert the paths to relative
533# paths (relative to libgnustep-base.dll).
534#
535case "$target_os" in
536  mingw*)
537    # TODO: Improve this hack.
538    # According to Wikipedia, this is the default for Windows 2000,
539    # Windows XP and Windows Server 2003.  For Windows Vista this will
540    # change to C:\Users.  The directory name needs to be localized though
541    # (and the disk may need changing as well ?).
542    GNUSTEP_SYSTEM_USERS_DIR="C:\Documents and Settings"
543    GNUSTEP_NETWORK_USERS_DIR="C:\Documents and Settings"
544    GNUSTEP_LOCAL_USERS_DIR="C:\Documents and Settings"
545
546    # TODO: It would be nice to use the 'short' output of
547    # relative_path.sh, but older versions of relative_path.sh
548    # did not support specifying the type of output and
549    # would abort if they were given more than 2 parameters,
550    # so we can not use the 'short' option if we want gnustep-base
551    # to work with older versions of gnustep-make.
552    # Once everyone has upgraded to gnustep-make >= 2.0.5 (I'd say
553    # two years after it has been released ?), we could switch to the
554    # 'short' output though.
555    GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS`
556    GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS`
557    GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS`
558    GNUSTEP_SYSTEM_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_TOOLS`
559    GNUSTEP_SYSTEM_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_TOOLS`
560    GNUSTEP_SYSTEM_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_LIBRARY`
561    GNUSTEP_SYSTEM_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_LIBRARIES`
562    GNUSTEP_SYSTEM_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_HEADERS`
563    GNUSTEP_SYSTEM_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC`
564    GNUSTEP_SYSTEM_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC_MAN`
565    GNUSTEP_SYSTEM_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC_INFO`
566
567    GNUSTEP_NETWORK_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_APPS`
568    GNUSTEP_NETWORK_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_ADMIN_APPS`
569    GNUSTEP_NETWORK_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_WEB_APPS`
570    GNUSTEP_NETWORK_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_TOOLS`
571    GNUSTEP_NETWORK_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_ADMIN_TOOLS`
572    GNUSTEP_NETWORK_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_LIBRARY`
573    GNUSTEP_NETWORK_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_LIBRARIES`
574    GNUSTEP_NETWORK_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_HEADERS`
575    GNUSTEP_NETWORK_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC`
576    GNUSTEP_NETWORK_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC_MAN`
577    GNUSTEP_NETWORK_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC_INFO`
578
579    GNUSTEP_LOCAL_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_APPS`
580    GNUSTEP_LOCAL_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_ADMIN_APPS`
581    GNUSTEP_LOCAL_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_WEB_APPS`
582    GNUSTEP_LOCAL_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_TOOLS`
583    GNUSTEP_LOCAL_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_ADMIN_TOOLS`
584    GNUSTEP_LOCAL_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_LIBRARY`
585    GNUSTEP_LOCAL_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_LIBRARIES`
586    GNUSTEP_LOCAL_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_HEADERS`
587    GNUSTEP_LOCAL_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC`
588    GNUSTEP_LOCAL_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC_MAN`
589    GNUSTEP_LOCAL_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC_INFO`
590# It would be nice to now store this stuff into a ./GNUstep.conf file
591# installed with gnustep-base.dll.  This would clarify.
592    ;;
593esac
594
595GNUSTEP_BASE_RELATIVE_PATHS=no
596
597# Now, check if any of the paths is a relative path.
598for path in \
599 "$GNUSTEP_SYSTEM_APPS" "$GNUSTEP_SYSTEM_ADMIN_APPS" "$GNUSTEP_SYSTEM_WEB_APPS" \
600 "$GNUSTEP_SYSTEM_TOOLS" "$GNUSTEP_SYSTEM_ADMIN_TOOLS" \
601 "$GNUSTEP_SYSTEM_LIBRARY" "$GNUSTEP_SYSTEM_LIBRARIES" "$GNUSTEP_SYSTEM_HEADERS" \
602 "$GNUSTEP_SYSTEM_DOC" "$GNUSTEP_SYSTEM_DOC_MAN" "$GNUSTEP_SYSTEM_DOC_INFO" \
603 "$GNUSTEP_NETWORK_APPS" "$GNUSTEP_NETWORK_ADMIN_APPS" "$GNUSTEP_NETWORK_WEB_APPS" \
604 "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_NETWORK_ADMIN_TOOLS" \
605 "$GNUSTEP_NETWORK_LIBRARY" "$GNUSTEP_NETWORK_LIBRARIES" "$GNUSTEP_NETWORK_HEADERS" \
606 "$GNUSTEP_NETWORK_DOC" "$GNUSTEP_NETWORK_DOC_MAN" "$GNUSTEP_NETWORK_DOC_INFO" \
607 "$GNUSTEP_LOCAL_APPS" "$GNUSTEP_LOCAL_ADMIN_APPS" "$GNUSTEP_LOCAL_WEB_APPS" \
608 "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_LOCAL_ADMIN_TOOLS" \
609 "$GNUSTEP_LOCAL_LIBRARY" "$GNUSTEP_LOCAL_LIBRARIES" "$GNUSTEP_LOCAL_HEADERS" \
610 "$GNUSTEP_LOCAL_DOC" "$GNUSTEP_LOCAL_DOC_MAN" "$GNUSTEP_LOCAL_DOC_INFO"; do
611case "$path" in
612  ./*)  GNUSTEP_BASE_RELATIVE_PATHS=yes ;;
613  ../*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;;
614esac
615done
616
617AC_MSG_CHECKING([if we are hardcoding any relative paths in gnustep-base])
618AC_MSG_RESULT($GNUSTEP_BASE_RELATIVE_PATHS)
619AC_SUBST(GNUSTEP_BASE_RELATIVE_PATHS)
620
621#
622# Now, we want to print out the paths that we're going to hardcode
623# into gnustep-base.  This is to help users in finding
624# misconfigurations.
625#
626AC_MSG_NOTICE([We store the following filesystem layout into gnustep-base, to be used when no config file is found])
627AC_MSG_CHECKING([for Makefiles directory])
628AC_MSG_RESULT($GNUSTEP_MAKEFILES)
629AC_MSG_CHECKING([for user defaults directory])
630AC_MSG_RESULT($GNUSTEP_USER_DEFAULTS_DIR)
631AC_MSG_CHECKING([for user config file])
632AC_MSG_RESULT($GNUSTEP_USER_CONFIG_FILE)
633
634AC_MSG_CHECKING([for System Applications directory])
635AC_MSG_RESULT($GNUSTEP_SYSTEM_APPS)
636AC_MSG_CHECKING([for System Admin Applications directory])
637AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_APPS)
638AC_MSG_CHECKING([for System Web Applications directory])
639AC_MSG_RESULT($GNUSTEP_SYSTEM_WEB_APPS)
640AC_MSG_CHECKING([for System Tools directory])
641AC_MSG_RESULT($GNUSTEP_SYSTEM_TOOLS)
642AC_MSG_CHECKING([for System Admin Tools directory])
643AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_TOOLS)
644AC_MSG_CHECKING([for System Library directory])
645AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARY)
646AC_MSG_CHECKING([for System Libraries directory])
647AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARIES)
648AC_MSG_CHECKING([for System Headers directory])
649AC_MSG_RESULT($GNUSTEP_SYSTEM_HEADERS)
650AC_MSG_CHECKING([for System Documentation directory])
651AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC)
652AC_MSG_CHECKING([for System Info Documentation directory])
653AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_INFO)
654AC_MSG_CHECKING([for System Man Documentation directory])
655AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_MAN)
656
657AC_MSG_CHECKING([for Network Applications directory])
658AC_MSG_RESULT($GNUSTEP_NETWORK_APPS)
659AC_MSG_CHECKING([for Network Admin Applications directory])
660AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_APPS)
661AC_MSG_CHECKING([for Network Web Applications directory])
662AC_MSG_RESULT($GNUSTEP_NETWORK_WEB_APPS)
663AC_MSG_CHECKING([for Network Tools directory])
664AC_MSG_RESULT($GNUSTEP_NETWORK_TOOLS)
665AC_MSG_CHECKING([for Network Admin Tools directory])
666AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_TOOLS)
667AC_MSG_CHECKING([for Network Library directory])
668AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARY)
669AC_MSG_CHECKING([for Network Libraries directory])
670AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARIES)
671AC_MSG_CHECKING([for Network Headers directory])
672AC_MSG_RESULT($GNUSTEP_NETWORK_HEADERS)
673AC_MSG_CHECKING([for Network Documentation directory])
674AC_MSG_RESULT($GNUSTEP_NETWORK_DOC)
675AC_MSG_CHECKING([for Network Info Documentation directory])
676AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_INFO)
677AC_MSG_CHECKING([for Network Man Documentation directory])
678AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_MAN)
679
680AC_MSG_CHECKING([for Local Applications directory])
681AC_MSG_RESULT($GNUSTEP_LOCAL_APPS)
682AC_MSG_CHECKING([for Local Admin Applications directory])
683AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_APPS)
684AC_MSG_CHECKING([for Local Web Applications directory])
685AC_MSG_RESULT($GNUSTEP_LOCAL_WEB_APPS)
686AC_MSG_CHECKING([for Local Tools directory])
687AC_MSG_RESULT($GNUSTEP_LOCAL_TOOLS)
688AC_MSG_CHECKING([for Local Admin Tools directory])
689AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_TOOLS)
690AC_MSG_CHECKING([for Local Library directory])
691AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARY)
692AC_MSG_CHECKING([for Local Libraries directory])
693AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARIES)
694AC_MSG_CHECKING([for Local Headers directory])
695AC_MSG_RESULT($GNUSTEP_LOCAL_HEADERS)
696AC_MSG_CHECKING([for Local Documentation directory])
697AC_MSG_RESULT($GNUSTEP_LOCAL_DOC)
698AC_MSG_CHECKING([for Local Info Documentation directory])
699AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_INFO)
700AC_MSG_CHECKING([for Local Man Documentation directory])
701AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_MAN)
702
703AC_MSG_CHECKING([for User Applications directory])
704AC_MSG_RESULT($GNUSTEP_USER_DIR_APPS)
705AC_MSG_CHECKING([for User Admin Applications directory])
706AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_APPS)
707AC_MSG_CHECKING([for User Web Applications directory])
708AC_MSG_RESULT($GNUSTEP_USER_DIR_WEB_APPS)
709AC_MSG_CHECKING([for User Tools directory])
710AC_MSG_RESULT($GNUSTEP_USER_DIR_TOOLS)
711AC_MSG_CHECKING([for User Admin Tools directory])
712AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_TOOLS)
713AC_MSG_CHECKING([for User Library directory])
714AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARY)
715AC_MSG_CHECKING([for User Libraries directory])
716AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARIES)
717AC_MSG_CHECKING([for User Headers directory])
718AC_MSG_RESULT($GNUSTEP_USER_DIR_HEADERS)
719AC_MSG_CHECKING([for User Documentation directory])
720AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC)
721AC_MSG_CHECKING([for User Info Documentation directory])
722AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_INFO)
723AC_MSG_CHECKING([for User Man Documentation directory])
724AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_MAN)
725
726AC_MSG_CHECKING([for System User directory])
727AC_MSG_RESULT($GNUSTEP_SYSTEM_USERS_DIR)
728AC_MSG_CHECKING([for Network User directory])
729AC_MSG_RESULT($GNUSTEP_NETWORK_USERS_DIR)
730AC_MSG_CHECKING([for Local User directory])
731AC_MSG_RESULT($GNUSTEP_LOCAL_USERS_DIR)
732
733#
734# Set the default configuration file values in config.h to be hard-coded
735# into NSPathUtilities.m
736#
737GNUSTEP_MAKEFILES=`echo $GNUSTEP_MAKEFILES|sed -e 's/\\\\/\\\\\\\\/g'`
738AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_MAKEFILES,
739  "$GNUSTEP_MAKEFILES",
740  [Built in default value for GNUstep Makefiles])
741GNUSTEP_USER_DEFAULTS_DIR=`echo $GNUSTEP_USER_DEFAULTS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
742AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DEFAULTS_DIR,
743  "$GNUSTEP_USER_DEFAULTS_DIR",
744  [Built in default value for GNUstep user defaults directory])
745GNUSTEP_USER_CONFIG_FILE=`echo $GNUSTEP_USER_CONFIG_FILE|sed -e 's/\\\\/\\\\\\\\/g'`
746AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_CONFIG_FILE,
747  "$GNUSTEP_USER_CONFIG_FILE",
748  [Built in default value for GNUstep user config file])
749GNUSTEP_TARGET_CONFIG_FILE=`echo $GNUSTEP_TARGET_CONFIG_FILE|sed -e 's/\\\\/\\\\\\\\/g'`
750AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_CONFIG_FILE,
751  "$GNUSTEP_TARGET_CONFIG_FILE",
752  [Built in default value for GNUstep config file])
753
754#
755# SYSTEM domain paths
756#
757GNUSTEP_SYSTEM_APPS=`echo $GNUSTEP_SYSTEM_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
758AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_APPS,
759  "$GNUSTEP_SYSTEM_APPS",
760  [Built in default value for GNUstep system apps])
761
762GNUSTEP_SYSTEM_ADMIN_APPS=`echo $GNUSTEP_SYSTEM_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
763AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_ADMIN_APPS,
764  "$GNUSTEP_SYSTEM_ADMIN_APPS",
765  [Built in default value for GNUstep system apps])
766
767GNUSTEP_SYSTEM_WEB_APPS=`echo $GNUSTEP_SYSTEM_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
768AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_WEB_APPS,
769  "$GNUSTEP_SYSTEM_WEB_APPS",
770  [Built in default value for GNUstep web apps])
771
772GNUSTEP_SYSTEM_TOOLS=`echo $GNUSTEP_SYSTEM_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
773AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_TOOLS,
774  "$GNUSTEP_SYSTEM_TOOLS",
775  [Built in default value for GNUstep system tools])
776
777GNUSTEP_SYSTEM_ADMIN_TOOLS=`echo $GNUSTEP_SYSTEM_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
778AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_ADMIN_TOOLS,
779  "$GNUSTEP_SYSTEM_ADMIN_TOOLS",
780  [Built in default value for GNUstep system tools])
781
782GNUSTEP_SYSTEM_LIBRARY=`echo $GNUSTEP_SYSTEM_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
783AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_LIBRARY,
784  "$GNUSTEP_SYSTEM_LIBRARY",
785  [Built in default value for GNUstep system library])
786
787GNUSTEP_SYSTEM_LIBRARIES=`echo $GNUSTEP_SYSTEM_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
788AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_LIBRARIES,
789  "$GNUSTEP_SYSTEM_LIBRARIES",
790  [Built in default value for GNUstep system libraries])
791
792GNUSTEP_SYSTEM_HEADERS=`echo $GNUSTEP_SYSTEM_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
793AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_HEADERS,
794  "$GNUSTEP_SYSTEM_HEADERS",
795  [Built in default value for GNUstep system headers])
796
797GNUSTEP_SYSTEM_DOC=`echo $GNUSTEP_SYSTEM_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
798AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC,
799  "$GNUSTEP_SYSTEM_DOC",
800  [Built in default value for GNUstep system documentation])
801
802GNUSTEP_SYSTEM_DOC_MAN=`echo $GNUSTEP_SYSTEM_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
803AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC_MAN,
804  "$GNUSTEP_SYSTEM_DOC_MAN",
805  [Built in default value for GNUstep system manpages documentation])
806
807GNUSTEP_SYSTEM_DOC_INFO=`echo $GNUSTEP_SYSTEM_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
808AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC_INFO,
809  "$GNUSTEP_SYSTEM_DOC_INFO",
810  [Built in default value for GNUstep system info documentation])
811
812#
813# NETWORK domain paths
814#
815GNUSTEP_NETWORK_APPS=`echo $GNUSTEP_NETWORK_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
816AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_APPS,
817  "$GNUSTEP_NETWORK_APPS",
818  [Built in default value for GNUstep network apps])
819
820GNUSTEP_NETWORK_ADMIN_APPS=`echo $GNUSTEP_NETWORK_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
821AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_ADMIN_APPS,
822  "$GNUSTEP_NETWORK_ADMIN_APPS",
823  [Built in default value for GNUstep network apps])
824
825GNUSTEP_NETWORK_WEB_APPS=`echo $GNUSTEP_NETWORK_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
826AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_WEB_APPS,
827  "$GNUSTEP_NETWORK_WEB_APPS",
828  [Built in default value for GNUstep network web apps])
829
830GNUSTEP_NETWORK_TOOLS=`echo $GNUSTEP_NETWORK_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
831AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_TOOLS,
832  "$GNUSTEP_NETWORK_TOOLS",
833  [Built in default value for GNUstep network tools])
834
835GNUSTEP_NETWORK_ADMIN_TOOLS=`echo $GNUSTEP_NETWORK_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
836AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_ADMIN_TOOLS,
837  "$GNUSTEP_NETWORK_ADMIN_TOOLS",
838  [Built in default value for GNUstep system tools])
839
840GNUSTEP_NETWORK_LIBRARY=`echo $GNUSTEP_NETWORK_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
841AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_LIBRARY,
842  "$GNUSTEP_NETWORK_LIBRARY",
843  [Built in default value for GNUstep network library])
844
845GNUSTEP_NETWORK_LIBRARIES=`echo $GNUSTEP_NETWORK_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
846AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_LIBRARIES,
847  "$GNUSTEP_NETWORK_LIBRARIES",
848  [Built in default value for GNUstep network libraries])
849
850GNUSTEP_NETWORK_HEADERS=`echo $GNUSTEP_NETWORK_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
851AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_HEADERS,
852  "$GNUSTEP_NETWORK_HEADERS",
853  [Built in default value for GNUstep network headers])
854
855GNUSTEP_NETWORK_DOC=`echo $GNUSTEP_NETWORK_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
856AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC,
857  "$GNUSTEP_NETWORK_DOC",
858  [Built in default value for GNUstep network documentation])
859
860GNUSTEP_NETWORK_DOC_MAN=`echo $GNUSTEP_NETWORK_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
861AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC_MAN,
862  "$GNUSTEP_NETWORK_DOC_MAN",
863  [Built in default value for GNUstep network manpages documentation])
864
865GNUSTEP_NETWORK_DOC_INFO=`echo $GNUSTEP_NETWORK_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
866AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC_INFO,
867  "$GNUSTEP_NETWORK_DOC_INFO",
868  [Built in default value for GNUstep network info documentation])
869
870#
871# LOCAL domain paths
872#
873GNUSTEP_LOCAL_APPS=`echo $GNUSTEP_LOCAL_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
874AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_APPS,
875  "$GNUSTEP_LOCAL_APPS",
876  [Built in default value for GNUstep local apps])
877
878GNUSTEP_LOCAL_ADMIN_APPS=`echo $GNUSTEP_LOCAL_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
879AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_ADMIN_APPS,
880  "$GNUSTEP_LOCAL_ADMIN_APPS",
881  [Built in default value for GNUstep local apps])
882
883GNUSTEP_LOCAL_WEB_APPS=`echo $GNUSTEP_LOCAL_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
884AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_WEB_APPS,
885  "$GNUSTEP_LOCAL_WEB_APPS",
886  [Built in default value for GNUstep local web apps])
887
888GNUSTEP_LOCAL_TOOLS=`echo $GNUSTEP_LOCAL_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
889AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_TOOLS,
890  "$GNUSTEP_LOCAL_TOOLS",
891  [Built in default value for GNUstep local tools])
892
893GNUSTEP_LOCAL_ADMIN_TOOLS=`echo $GNUSTEP_LOCAL_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
894AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_ADMIN_TOOLS,
895  "$GNUSTEP_LOCAL_ADMIN_TOOLS",
896  [Built in default value for GNUstep local tools])
897
898GNUSTEP_LOCAL_LIBRARY=`echo $GNUSTEP_LOCAL_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
899AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_LIBRARY,
900  "$GNUSTEP_LOCAL_LIBRARY",
901  [Built in default value for GNUstep local library])
902
903GNUSTEP_LOCAL_LIBRARIES=`echo $GNUSTEP_LOCAL_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
904AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_LIBRARIES,
905  "$GNUSTEP_LOCAL_LIBRARIES",
906  [Built in default value for GNUstep local libraries])
907
908GNUSTEP_LOCAL_HEADERS=`echo $GNUSTEP_LOCAL_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
909AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_HEADERS,
910  "$GNUSTEP_LOCAL_HEADERS",
911  [Built in default value for GNUstep local headers])
912
913GNUSTEP_LOCAL_DOC=`echo $GNUSTEP_LOCAL_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
914AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC,
915  "$GNUSTEP_LOCAL_DOC",
916  [Built in default value for GNUstep local documentation])
917
918GNUSTEP_LOCAL_DOC_MAN=`echo $GNUSTEP_LOCAL_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
919AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC_MAN,
920  "$GNUSTEP_LOCAL_DOC_MAN",
921  [Built in default value for GNUstep local manpages documentation])
922
923GNUSTEP_LOCAL_DOC_INFO=`echo $GNUSTEP_LOCAL_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
924AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC_INFO,
925  "$GNUSTEP_LOCAL_DOC_INFO",
926  [Built in default value for GNUstep local info documentation])
927
928#
929# USER_DIR domain paths
930#
931GNUSTEP_USER_DIR_APPS=`echo $GNUSTEP_USER_DIR_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
932AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_APPS,
933  "$GNUSTEP_USER_DIR_APPS",
934  [Built in default value for GNUstep user_dir apps])
935
936GNUSTEP_USER_DIR_ADMIN_APPS=`echo $GNUSTEP_USER_DIR_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
937AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_ADMIN_APPS,
938  "$GNUSTEP_USER_DIR_ADMIN_APPS",
939  [Built in default value for GNUstep user_dir admin apps])
940
941GNUSTEP_USER_DIR_WEB_APPS=`echo $GNUSTEP_USER_DIR_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
942AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_WEB_APPS,
943  "$GNUSTEP_USER_DIR_WEB_APPS",
944  [Built in default value for GNUstep user_dir web apps])
945
946GNUSTEP_USER_DIR_TOOLS=`echo $GNUSTEP_USER_DIR_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
947AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_TOOLS,
948  "$GNUSTEP_USER_DIR_TOOLS",
949  [Built in default value for GNUstep user_dir tools])
950
951GNUSTEP_USER_DIR_ADMIN_TOOLS=`echo $GNUSTEP_USER_DIR_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
952AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_ADMIN_TOOLS,
953  "$GNUSTEP_USER_DIR_ADMIN_TOOLS",
954  [Built in default value for GNUstep user_dir tools])
955
956GNUSTEP_USER_DIR_LIBRARY=`echo $GNUSTEP_USER_DIR_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
957AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_LIBRARY,
958  "$GNUSTEP_USER_DIR_LIBRARY",
959  [Built in default value for GNUstep user_dir library])
960
961GNUSTEP_USER_DIR_LIBRARIES=`echo $GNUSTEP_USER_DIR_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
962AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_LIBRARIES,
963  "$GNUSTEP_USER_DIR_LIBRARIES",
964  [Built in default value for GNUstep user_dir libraries])
965
966GNUSTEP_USER_DIR_HEADERS=`echo $GNUSTEP_USER_DIR_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
967AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_HEADERS,
968  "$GNUSTEP_USER_DIR_HEADERS",
969  [Built in default value for GNUstep user_dir headers])
970
971GNUSTEP_USER_DIR_DOC=`echo $GNUSTEP_USER_DIR_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
972AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC,
973  "$GNUSTEP_USER_DIR_DOC",
974  [Built in default value for GNUstep user_dir documentation])
975
976GNUSTEP_USER_DIR_DOC_MAN=`echo $GNUSTEP_USER_DIR_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
977AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC_MAN,
978  "$GNUSTEP_USER_DIR_DOC_MAN",
979  [Built in default value for GNUstep user_dir manpages documentation])
980
981GNUSTEP_USER_DIR_DOC_INFO=`echo $GNUSTEP_USER_DIR_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
982AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC_INFO,
983  "$GNUSTEP_USER_DIR_DOC_INFO",
984  [Built in default value for GNUstep user_dir info documentation])
985
986GNUSTEP_TARGET_SYSTEM_USERS_DIR=`echo $GNUSTEP_TARGET_SYSTEM_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
987AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_USERS_DIR,
988  "$GNUSTEP_TARGET_SYSTEM_USERS_DIR",
989  [Built in default value for GNUstep System Users directory])
990GNUSTEP_TARGET_NETWORK_USERS_DIR=`echo $GNUSTEP_TARGET_NETWORK_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
991AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_USERS_DIR,
992  "$GNUSTEP_TARGET_NETWORK_USERS_DIR",
993  [Built in default value for GNUstep Network Users directory])
994GNUSTEP_TARGET_LOCAL_USERS_DIR=`echo $GNUSTEP_TARGET_LOCAL_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
995AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_USERS_DIR,
996  "$GNUSTEP_TARGET_LOCAL_USERS_DIR",
997  [Built in default value for GNUstep Local Users directory])
998
999#
1000# Now load the values to be used in locating libraries etc used when
1001# building the base library ... as supplied by the gnustep-make package
1002#
1003# It looks like we ought to source the whole GNUstep.sh here, and even
1004# ask it to output all variables!  That way we have access to (eg)
1005# GNUSTEP_SYSTEM_HEADERS below.
1006#
1007# We need to unset any values that we really need, or existing settings
1008# would be used by GNUstep.sh
1009#
1010unset GNUSTEP_SYSTEM_HEADERS
1011unset GNUSTEP_SYSTEM_LIBRARIES
1012unset GNUSTEP_NETWORK_HEADERS
1013unset GNUSTEP_NETWORK_LIBRARIES
1014unset GNUSTEP_LOCAL_HEADERS
1015unset GNUSTEP_LOCAL_LIBRARIES
1016GNUSTEP_MAKEFILES="$CURRENT_GNUSTEP_MAKEFILES"
1017GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes
1018. "$CURRENT_GNUSTEP_MAKEFILES/GNUstep.sh"
1019unset GNUSTEP_SH_EXPORT_ALL_VARIABLES
1020
1021# For backwards compatibility, define GNUSTEP_SYSTEM_HEADERS from
1022# GNUSTEP_SYSTEM_ROOT if not set yet.
1023if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then
1024  GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_ROOT/Library/Headers"
1025fi
1026
1027if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then
1028  GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries"
1029fi
1030
1031if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then
1032  GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_ROOT/Library/Headers"
1033fi
1034
1035if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then
1036  GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_ROOT/Library/Libraries"
1037fi
1038
1039if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then
1040  GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers"
1041fi
1042
1043if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then
1044  GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries"
1045fi
1046
1047#
1048# Add standard library and header directories for configure to use to locate
1049# plain C developer headers/libraries which have been installed in the
1050# GNUstep hierarchy. These take precedence
1051#
1052if test x"$GNUSTEP_IS_FLATTENED" = x"yes"; then
1053  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS"
1054  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS"
1055  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS"
1056  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES"
1057  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES"
1058  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES"
1059else
1060  # FIXME: Cross-compiling should read the target from the configure
1061  # options and use it.   GNUSTEP_TARGET_* variables do not exist in
1062  # this context (so "$GNUSTEP_TARGET_CPU" will always be "")
1063  if test x"$GNUSTEP_TARGET_CPU" = x""; then
1064    ARCH="$GNUSTEP_HOST_CPU-$GNUSTEP_HOST_OS"
1065  else
1066    ARCH=$GNUSTEP_TARGET_CPU-$GNUSTEP_TARGET_OS
1067  fi
1068  ALIB="$ARCH/$LIBRARY_COMBO"
1069  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS/$ALIB"
1070  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS/$ARCH"
1071  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS"
1072  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS/$ALIB"
1073  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS/$ARCH"
1074  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS"
1075  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS/$ALIB"
1076  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS/$ARCH"
1077  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS"
1078  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES/$ALIB"
1079  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES/$ARCH"
1080  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES"
1081  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES/$ALIB"
1082  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES/$ARCH"
1083  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES"
1084  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES/$ALIB"
1085  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES/$ARCH"
1086  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES"
1087fi
1088
1089
1090#--------------------------------------------------------------------
1091# Find the compiler
1092#--------------------------------------------------------------------
1093MAKECC=`gnustep-config --variable=CC`
1094MAKECPP=`gnustep-config --variable=CPP`
1095MAKECXX=`gnustep-config --variable=CXX`
1096if test "$CC" = ""; then
1097  CC=$MAKECC
1098  export CC
1099else
1100  if test "$CC" != "$MAKECC"; then
1101    AC_MSG_WARN([You are running configure with the compiler ($CC) set to a different value from that used by gnustep-make ($MAKECC).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CC=$CC or run the gnustep-base configure again with your CC environment variable set to $MAKECC])
1102  fi
1103fi
1104if test "$CPP" = ""; then
1105  CPP=$MAKECPP
1106  export CPP
1107else
1108  if test "$CPP" != "$MAKECPP"; then
1109    AC_MSG_WARN([You are running configure with the preprocessor ($CPP) set to a different value from that used by gnustep-make ($MAKECPP).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CPP=$CPP or run the gnustep-base configure again with your CPP environment variable set to $MAKECPP])
1110  fi
1111fi
1112if test "$CXX" = ""; then
1113  CXX=$MAKECXX
1114  export CXX
1115else
1116  if test "$CXX" != "$MAKECXX"; then
1117    AC_MSG_WARN([You are running configure with the compiler ($CXX) set to a different value from that used by gnustep-make ($MAKECXX).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CXX=$CXX or run the gnustep-base configure again with your CXX environment variable set to $MAKECXX])
1118  fi
1119fi
1120AC_PROG_CC
1121AC_PROG_CPP
1122AC_USE_SYSTEM_EXTENSIONS
1123
1124AC_MSG_CHECKING(whether the compiler is clang)
1125if test ! x"${GCC}" = x"yes" ; then
1126  CLANG_CC=no
1127  AC_MSG_RESULT(no)
1128else
1129  if "${CC}" -v 2>&1 | grep -q 'clang version'; then
1130    CLANG_CC=yes
1131    AC_MSG_RESULT(yes)
1132  else
1133    CLANG_CC=no
1134    AC_MSG_RESULT(no)
1135  fi
1136fi
1137AC_SUBST(CLANG_CC)
1138
1139
1140# Large file support needed by NSData/NSFileHandle.
1141# These macros must be called after AC_USE_SYSTEM_EXTENSIONS because
1142# the `fseeko' declaration may be hidden by default on some systems.
1143AC_FUNC_FSEEKO
1144AH_BOTTOM([
1145/* Define `fseeko' to `fseek' if the former is missing.
1146   Likewise for `ftello'.  */
1147#if !HAVE_FSEEKO
1148# define fseeko fseek
1149# define ftello ftell
1150#endif
1151])
1152AC_SYS_LARGEFILE
1153AC_TYPE_OFF_T
1154
1155#--------------------------------------------------------------------
1156# Check how to enable builtins for atomic operations
1157#--------------------------------------------------------------------
1158
1159AC_LANG_PUSH(C)
1160AC_MSG_CHECKING([whether the compiler supports atomic operations]);
1161  AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
1162    [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
1163  have_atomic=yes,
1164  have_atomic=no);
1165  if test "$have_atomic" = "yes"; then
1166    AC_MSG_RESULT([yes]);
1167    AC_DEFINE(USE_ATOMIC_BUILTINS,1,
1168      [Define if the compiler provides builtins for atomic operations])
1169  else
1170    AC_MSG_RESULT([no]);
1171    if test "$CC" = "gcc"; then
1172      saved_CFLAGS="$CFLAGS";
1173      ATOMIC_CFLAGS="";
1174
1175      # FIXME: Forcing -march=i568 for any i568 or later CPU is a
1176      # stop gap measure to make the compiler emit native assembly
1177      # for atomic operations on i586 or latter processors (GCC by
1178      # default emits code compatible with the original i386 and
1179      # requires library functions to emulate atomic operations).
1180      # When gnustep-make takes care of this kind of target setting,
1181      # the check can safely be removed.
1182      case "$target_cpu" in
1183        i586*|i686*|i786*)
1184          ATOMIC_CFLAGS="-march=i586"
1185          CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
1186          ;;
1187        x86_64)
1188          ATOMIC_CFLAGS="-march=x86-64"
1189          CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
1190          ;;
1191      esac
1192      AC_MSG_CHECKING([whether CC supports atomic operations with -march]);
1193        AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
1194          [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y+1);]])],
1195        need_march=yes,
1196      need_march=no);
1197
1198      if test "$need_march" = "yes"; then
1199        AC_MSG_RESULT([yes]);
1200	OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS";
1201        AC_DEFINE(USE_ATOMIC_BUILTINS,1,
1202          [Define if the compiler provides builtins for atomic operations])
1203      else
1204        AC_MSG_RESULT([no]);
1205        saved_LDFLAGS="$LDFLAGS";
1206        LDFLAGS="$saved_LDFLAGS -lgcc";
1207        AC_MSG_CHECKING([whether CC supports atomic operations using libgcc]);
1208          AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
1209            [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y+1);]])],
1210          atomic_in_libgcc=yes,
1211        atomic_in_libgcc=no);
1212        if test "$atomic_in_libgcc" = "yes"; then
1213          AC_MSG_RESULT([yes]);
1214          LIBS="$LIBS -lgcc";
1215          AC_DEFINE(USE_ATOMIC_BUILTINS,1,
1216            [Define if the compiler provides builtins for atomic operations])
1217        else
1218          LDFLAGS="$saved_LDFLAGS";
1219          AC_MSG_RESULT([no]);
1220        fi
1221      fi
1222    fi
1223  fi
1224AC_LANG_POP(C)
1225
1226
1227AC_PATH_PROG(WHOAMI, whoami, echo, $PATH:/usr/ucb)
1228PKG_PROG_PKG_CONFIG
1229# If the modern mechanism failswe may havew an older pkg-config
1230# so try looking it up the old fashioned way.
1231if test -z "$PKG_CONFIG"; then
1232  AC_PATH_PROG(PKG_CONFIG,pkg-config,,)
1233fi
1234
1235
1236#--------------------------------------------------------------------
1237# specific target_os options
1238#--------------------------------------------------------------------
1239INCLUDE_FLAGS="$CPPFLAGS"
1240LDIR_FLAGS="$LDFLAGS"
1241# This is just for configuring. Later, in config.make, INCLUDE_FLAGS
1242# goes in CONFIG_SYSTEM_INCL and LIBS goes in CONFIG_SYSTEM_LIBS
1243case "$target_os" in
1244  freebsd* | openbsd* )
1245	        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
1246		LDFLAGS="$LDFLAGS -L/usr/local/lib";;
1247  netbsd*)	CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
1248		LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
1249  linux-android* )
1250		# link against libandroid for native application APIs
1251		LIBS="$LIBS -landroid";;
1252esac
1253
1254#--------------------------------------------------------------------
1255# Set Apple/Darwin/OSX/NeXT information for other tests
1256#--------------------------------------------------------------------
1257OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'`
1258AC_MSG_CHECKING(the Objective-C runtime)
1259if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then
1260  AC_MSG_RESULT(NeXT)
1261  OBJCFLAGS="$OBJCFLAGS -fnext-runtime -DNeXT_RUNTIME"
1262elif test "$OBJC_RUNTIME_LIB" = "ng"; then
1263  AC_MSG_RESULT(Next Gen)
1264else
1265  AC_MSG_RESULT(GNU)
1266  if test "$CLANG_CC" = "yes"; then
1267    OBJCFLAGS="$OBJCFLAGS -fobjc-runtime=gcc"
1268  fi
1269fi
1270LIBOBJC=`gnustep-config --objc-libs`
1271if test "$LIBOBJC" = ""; then
1272  AC_MSG_ERROR([The command 'gnustep-config --objc-libs' (provided by the gnustep-make package) returned no Objective-C library.  Unable to continue configuring without Objective-C support.])
1273  exit 1
1274fi
1275
1276#--------------------------------------------------------------------
1277# Miscellaneous flags
1278#--------------------------------------------------------------------
1279
1280# Check to see if the libobjc library is in our GNUSTEP_SYSTEM_LIBRARIES.
1281# If so, there are probably other libraries that we want there also, so
1282# leave the proper includes in CPPFLAGS and LDFLAGS
1283AC_MSG_CHECKING(for custom shared objc library)
1284AC_CACHE_VAL(gs_cv_objc_libdir,
1285[dnl
1286gs_cv_objc_libdir=NONE
1287gs_cv_objc_incdir=NONE
1288# Try GNUSTEP_SYSTEM_LIBRARIES first
1289if test "$GNUSTEP_IS_FLATTENED" = yes; then
1290  GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES"
1291  GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS"
1292else
1293  GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir"
1294  GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO"
1295fi
1296
1297if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
1298  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then
1299    gs_cv_objc_libdir="$GNUSTEP_LDIR"
1300    gs_cv_objc_incdir="$GNUSTEP_HDIR"
1301  fi
1302fi
1303
1304# Try GNUSTEP_NETWORK_LIBRARIES second (override GNUSTEP_SYSTEM if
1305# found)
1306if test "$GNUSTEP_IS_FLATTENED" = yes; then
1307  GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES"
1308  GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS"
1309else
1310  GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES/$obj_dir"
1311  GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO"
1312fi
1313
1314if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
1315  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then
1316    gs_cv_objc_libdir="$GNUSTEP_LDIR"
1317    gs_cv_objc_incdir="$GNUSTEP_HDIR"
1318  fi
1319fi
1320
1321# Try GNUSTEP_LOCAL_LIBRARIES third (override GNUSTEP_SYSTEM and
1322# GNUSTEP_NETWORK if found)
1323if test "$GNUSTEP_IS_FLATTENED" = yes; then
1324  GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES"
1325  GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS"
1326else
1327  GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES/$obj_dir"
1328  GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO"
1329fi
1330
1331if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
1332  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then
1333    gs_cv_objc_libdir="$GNUSTEP_LDIR"
1334    gs_cv_objc_incdir="$GNUSTEP_HDIR"
1335  fi
1336fi
1337])
1338AC_MSG_RESULT($gs_cv_objc_libdir)
1339
1340if test "$gs_cv_objc_libdir" != "NONE"; then
1341  #
1342  # The following one is so that headers of custom libraries into
1343  # $GNUSTEP_HDIR are used before the standard ones
1344  #
1345  INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gs_cv_objc_incdir"
1346  LDIR_FLAGS="$LDIR_FLAGS -L$gs_cv_objc_libdir/$LIBRARY_COMBO -L$gs_cv_objc_libdir"
1347  CPPFLAGS="$CPPFLAGS -I$gs_cv_objc_incdir"
1348  LDFLAGS="$LDFLAGS -L$gs_cv_objc_libdir"
1349fi
1350
1351#--------------------------------------------------------------------
1352# Check if Objective-C is installed
1353#--------------------------------------------------------------------
1354AC_CHECK_HEADERS(objc/runtime.h)
1355AC_CHECK_HEADERS(objc/objc.h)
1356if test $ac_cv_header_objc_objc_h = no; then
1357  echo "Check to make sure you have the Objective-C runtime library"
1358  echo "and its headers installed."
1359  AC_MSG_ERROR(Could not find Objective-C headers)
1360fi
1361
1362#--------------------------------------------------------------------
1363# Check for strange network stuff used by gdomap
1364#--------------------------------------------------------------------
1365AC_MSG_NOTICE(for gdomap network details)
1366AC_MSG_CHECKING(for variable length socket addresses)
1367AC_TRY_COMPILE([
1368  #include <sys/types.h>
1369  #include <sys/socket.h>
1370  #include <net/if.h>
1371  ],
1372  [struct ifreq s; s.ifr_addr.sa_len = 0;],
1373  sa_len=1, sa_len=0)
1374if test $sa_len = 1; then
1375  AC_MSG_RESULT([found])
1376  AC_DEFINE(HAVE_SA_LEN,1,
1377            [Define if your system has variable length network addresses])
1378else
1379  AC_MSG_RESULT([not found])
1380fi
1381
1382AC_MSG_CHECKING(for compiler visibility attribute support)
1383saved_CFLAGS="$CFLAGS"
1384CFLAGS="$CFLAGS -Werror"
1385AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1386  #include <stdio.h>
1387  int foo() __attribute__ ((visibility("internal")));
1388  int foo(){ return 1; }
1389  int main(){ return foo(); }])],
1390  AC_MSG_RESULT([found])
1391  gs_visibility=1,
1392  AC_MSG_RESULT([not present])
1393  gs_visibility=0
1394)
1395AC_DEFINE_UNQUOTED(HAVE_VISIBILITY_ATTRIBUTE,$gs_visibility,
1396  [Says whether the visibility attribute works])
1397CFLAGS="$saved_CFLAGS"
1398
1399
1400#--------------------------------------------------------------------
1401# Check if system has buggy SO_REUSEADDR
1402#--------------------------------------------------------------------
1403AC_MSG_CHECKING(whether SO_REUSEADDR is broken)
1404AC_TRY_RUN([#include "$srcdir/config/config.reuseaddr.c"],
1405	reuseaddr_ok=1,
1406	reuseaddr_ok=0,
1407	reuseaddr_ok="$cross_reuseaddr_ok")
1408if test $reuseaddr_ok = 0; then
1409  AC_DEFINE(BROKEN_SO_REUSEADDR,1,
1410            [Define if SO_REUSEADDR is broken on this system])
1411  echo
1412  echo "The SO_REUSEADDR socket option for controlling re-use of network"
1413  echo "sockets immediately after shutdown appears to be broken on this"
1414  echo "machine.  Networking code will be built without using this"
1415  echo "feature."
1416  echo "The effect of this lack is that when a network service is shut"
1417  echo "down, it cannot be re-started on the same network port until"
1418  echo "an operating-system timeout has expired."
1419  echo "For servers other than gdomap, GNUstep does not normally need"
1420  echo "a particular network port, so the problem is unlikely to arise."
1421  AC_MSG_RESULT(yes)
1422else
1423  AC_MSG_RESULT(no)
1424fi
1425
1426#--------------------------------------------------------------------
1427# Check for thread flags for libobjc.
1428#--------------------------------------------------------------------
1429#
1430AC_MSG_CHECKING(for objc threading flags)
1431#
1432# Get them from gnustep-make which contains the real code to get them
1433#
1434objc_threaded=`grep objc_threaded: $CURRENT_GNUSTEP_MAKEFILES/$lobj_dir/config.make | sed -e 's/objc_threaded:=//'`
1435#
1436AC_MSG_RESULT($objc_threaded)
1437
1438#--------------------------------------------------------------------
1439# Byte order information needed for foundation headers.
1440#--------------------------------------------------------------------
1441AC_C_BIGENDIAN
1442if test $ac_cv_c_bigendian = yes; then
1443  GS_WORDS_BIGENDIAN=1
1444else
1445  GS_WORDS_BIGENDIAN=0
1446fi
1447AC_SUBST(GS_WORDS_BIGENDIAN)
1448
1449#--------------------------------------------------------------------
1450# Type size information needed for foundation headers.
1451#--------------------------------------------------------------------
1452AC_CHECK_SIZEOF(void*)
1453
1454GS_SINT8="signed char"
1455GS_UINT8="unsigned char"
1456AC_SUBST(GS_SINT8)
1457AC_SUBST(GS_UINT8)
1458
1459AC_CHECK_SIZEOF(short)
1460AC_SUBST(ac_cv_sizeof_short)
1461
1462AC_CHECK_SIZEOF(int)
1463AC_SUBST(ac_cv_sizeof_int)
1464
1465AC_CHECK_SIZEOF(long)
1466AC_SUBST(ac_cv_sizeof_long)
1467
1468AC_CHECK_SIZEOF(long long)
1469AC_SUBST(ac_cv_sizeof_long_long)
1470
1471AC_CHECK_SIZEOF(float)
1472AC_SUBST(ac_cv_sizeof_float)
1473
1474AC_CHECK_SIZEOF(double)
1475AC_SUBST(ac_cv_sizeof_double)
1476
1477AC_SUBST(ac_cv_sizeof_voidp)
1478if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_int; then
1479  GS_SADDR="int"
1480  GS_UADDR="unsigned int"
1481else
1482  if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_long; then
1483    GS_SADDR="long"
1484    GS_UADDR="unsigned long"
1485  else
1486    if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_long_long; then
1487      GS_SADDR="long long"
1488      GS_UADDR="unsigned long long"
1489    else
1490      AC_MSG_ERROR([Unable to find integer of same size as void*])
1491    fi
1492  fi
1493fi
1494AC_SUBST(GS_SADDR)
1495AC_SUBST(GS_UADDR)
1496
1497if test $ac_cv_sizeof_short = 2; then
1498  GS_SINT16="signed short"
1499  GS_UINT16="unsigned short"
1500else
1501  if test $ac_cv_sizeof_int = 2; then
1502    GS_SINT16="signed int"
1503    GS_UINT16="unsigned int"
1504  else
1505    AC_MSG_ERROR([Unable to determine type for 16-bit integer])
1506  fi
1507fi
1508AC_SUBST(GS_SINT16)
1509AC_SUBST(GS_UINT16)
1510
1511if test $ac_cv_sizeof_int = 4; then
1512  GS_SINT32="signed int"
1513  GS_UINT32="unsigned int"
1514else
1515  if test $ac_cv_sizeof_long = 4; then
1516    GS_SINT32="signed long"
1517    GS_UINT32="unsigned long"
1518  else
1519    if test $ac_cv_sizeof_short = 4; then
1520      GS_SINT32="signed short"
1521      GS_UINT32="unsigned short"
1522    else
1523      AC_MSG_ERROR([Unable to determine type for 32-bit integer])
1524    fi
1525  fi
1526fi
1527AC_SUBST(GS_SINT32)
1528AC_SUBST(GS_UINT32)
1529
1530GS_HAVE_I64=1
1531if test $ac_cv_sizeof_int = 8; then
1532  GS_SINT64="signed int"
1533  GS_UINT64="unsigned int"
1534else
1535  if test $ac_cv_sizeof_long = 8; then
1536    GS_SINT64="signed long"
1537    GS_UINT64="unsigned long"
1538  else
1539    if test $ac_cv_sizeof_long_long = 8; then
1540      GS_SINT64="signed long long"
1541      GS_UINT64="unsigned long long"
1542    else
1543#     64-bit ints not supported - but we need a dummy type for byte-swapping
1544#     of 64-bit values arriving from another system.
1545      GS_SINT64="struct { gsu8 a[8]; }"
1546      GS_UINT64="struct { gsu8 a[8]; }"
1547      GS_HAVE_I64=0
1548    fi
1549  fi
1550fi
1551AC_SUBST(GS_SINT64)
1552AC_SUBST(GS_UINT64)
1553AC_SUBST(GS_HAVE_I64)
1554
1555GS_HAVE_I128=1
1556if test $ac_cv_sizeof_long = 16; then
1557  GS_SINT128="signed long"
1558  GS_UINT128="unsigned long"
1559else
1560  if test $ac_cv_sizeof_long_long = 16; then
1561    GS_SINT128="signed long long"
1562    GS_UINT128="unsigned long long"
1563  else
1564#     128-bit ints not supported - but we need a dummy type for byte-swapping
1565#     of 128-bit values arriving from another system.
1566    GS_SINT128="struct { gsu8 a[[16]]; }"
1567    GS_UINT128="struct { gsu8 a[[16]]; }"
1568    GS_HAVE_I128=0
1569  fi
1570fi
1571AC_SUBST(GS_SINT128)
1572AC_SUBST(GS_UINT128)
1573AC_SUBST(GS_HAVE_I128)
1574
1575if test $ac_cv_sizeof_float = 4; then
1576  GS_FLT32="float"
1577else
1578  AC_MSG_ERROR([Unable to determine type for 32-bit float])
1579fi
1580AC_SUBST(GS_FLT32)
1581
1582if test $ac_cv_sizeof_double = 8; then
1583  GS_FLT64="double"
1584else
1585  AC_MSG_ERROR([Unable to determine type for 64-bit float])
1586fi
1587AC_SUBST(GS_FLT64)
1588
1589#--------------------------------------------------------------------
1590# Type-size information for encoding into archives using NSArchiver etc.
1591#--------------------------------------------------------------------
1592if test $ac_cv_sizeof_short = 2; then
1593  _GSC_S_SHT=_GSC_I16
1594else
1595  _GSC_S_SHT=_GSC_I32
1596fi
1597AC_SUBST(_GSC_S_SHT)
1598
1599if test $ac_cv_sizeof_int = 2; then
1600  _GSC_S_INT=_GSC_I16
1601else
1602  if test $ac_cv_sizeof_int = 4; then
1603    _GSC_S_INT=_GSC_I32
1604  else
1605    if test $ac_cv_sizeof_int = 8; then
1606      _GSC_S_INT=_GSC_I64
1607    else
1608      if test $ac_cv_sizeof_int = 16; then
1609	_GSC_S_INT=_GSC_I128
1610      fi
1611    fi
1612  fi
1613fi
1614AC_SUBST(_GSC_S_INT)
1615
1616if test $ac_cv_sizeof_long = 4; then
1617  _GSC_S_LNG=_GSC_I32
1618else
1619  if test $ac_cv_sizeof_long = 8; then
1620    _GSC_S_LNG=_GSC_I64
1621  else
1622    if test $ac_cv_sizeof_long = 16; then
1623      _GSC_S_LNG=_GSC_I128
1624    fi
1625  fi
1626fi
1627AC_SUBST(_GSC_S_LNG)
1628
1629if test $ac_cv_sizeof_long_long = 4; then
1630  _GSC_S_LNG_LNG=_GSC_I32
1631else
1632  if test $ac_cv_sizeof_long_long = 8; then
1633    _GSC_S_LNG_LNG=_GSC_I64
1634  else
1635    if test $ac_cv_sizeof_long_long = 16; then
1636      _GSC_S_LNG_LNG=_GSC_I128
1637    fi
1638  fi
1639fi
1640AC_SUBST(_GSC_S_LNG_LNG)
1641
1642
1643#--------------------------------------------------------------------
1644# Limit information needed for foundation headers.
1645#--------------------------------------------------------------------
1646AC_LANG_PUSH(C)
1647AC_MSG_CHECKING([for working INTPTR_MAX, INTPTR_MIN, UINTPTR_MAX]);
1648AC_COMPILE_IFELSE(
1649  [AC_LANG_PROGRAM([[#include <inttypes.h>]],
1650    [[int imax = INTPTR_MAX; int imin = INTPTR_MIN; unsigned umax = UINTPTR_MAX;]])],
1651  have_valid_ptr_limits=yes,
1652  have_valid_ptr_limits=no);
1653  if test "$have_valid_ptr_limits" = "yes"; then
1654    AC_MSG_RESULT([yes]);
1655    BUGGY_PTR_LIMITS=0
1656  else
1657    AC_MSG_RESULT([no]);
1658    BUGGY_PTR_LIMITS=1
1659    case "$target_os" in
1660      solaris*)
1661        case "$target_cpu" in
1662          sparc64*|x86_64*)
1663            GS_INTPTR_MAX="INT64_MAX"
1664            GS_INTPTR_MIN="INT64_MIN"
1665            GS_UINTPTR_MAX="UINT64_MAX"
1666            ;;
1667          sparc*|i386*|i586*|i686*)
1668            GS_INTPTR_MAX="INT32_MAX"
1669            GS_INTPTR_MIN="INT32_MIN"
1670            GS_UINTPTR_MAX="UINT32_MAX"
1671            ;;
1672          *) ;;
1673        esac ;;
1674      # support for other OS's with broken macros to be added here (HP-UX, IRIX being known)
1675      *)
1676      ;;
1677    esac
1678    AC_SUBST(GS_INTPTR_MAX)
1679    AC_SUBST(GS_INTPTR_MIN)
1680    AC_SUBST(GS_UINTPTR_MAX)
1681  fi
1682AC_SUBST(BUGGY_PTR_LIMITS)
1683AC_LANG_POP(C)
1684
1685#--------------------------------------------------------------------
1686# Setup dynamic linking
1687#--------------------------------------------------------------------
1688OBJC_SYS_DYNAMIC_LINKER()
1689# NOTE: libdl should be in LIBS now if it's available.
1690AC_CHECK_FUNCS(dladdr)
1691
1692AC_CHECK_FUNCS(gethostbyname)
1693if test "$ac_cv_func_gethostbyname" = "no"; then
1694  # QNX has gethostbyname and friends in libsocket
1695  AC_CHECK_LIB(socket, gethostbyname)
1696fi
1697
1698AC_CHECK_FUNCS(getaddrinfo)
1699
1700#--------------------------------------------------------------------
1701# Check for pthread.h
1702#--------------------------------------------------------------------
1703AC_CHECK_HEADERS([pthread.h])
1704AC_CHECK_HEADERS([pthread_np.h],[],[],[AC_INCLUDES_DEFAULT
1705		  #ifdef HAVE_PTHREAD_H
1706		  #include <pthread.h>
1707		  #endif
1708		  ])
1709if test $ac_cv_header_pthread_h = yes ; then
1710  AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT
1711#include <pthread.h>])
1712  GS_SIZEOF_MUTEX_T=$ac_cv_sizeof_pthread_mutex_t
1713  if test $ac_cv_sizeof_pthread_mutex_t = 0 ; then
1714    AC_MSG_ERROR([Unable to find size of pthread_mutex_t (required).])
1715  fi
1716  AC_SUBST(GS_SIZEOF_MUTEX_T)
1717# pthread_mutex_t.__data.__owner is non-standard since pthread_mutex_t is
1718# nominally an opaque type.  We must not rely on this for anything other
1719# than debug output!
1720  AC_CHECK_MEMBER([pthread_mutex_t.__data.__owner],,,[AC_INCLUDES_DEFAULT
1721#include <pthread.h>])
1722  if test $ac_cv_member_pthread_mutex_t___data___owner = yes ; then
1723    AC_DEFINE(HAVE_PTHREAD_MUTEX_OWNER, 1,
1724      [Define if you have pthread_mutex_t.__data.__owner])
1725  fi
1726  AC_CHECK_SIZEOF(pthread_cond_t,,[AC_INCLUDES_DEFAULT
1727#include <pthread.h>])
1728  if test $ac_cv_sizeof_pthread_cond_t = 0 ; then
1729    AC_MSG_ERROR([Unable to find size of pthread_cond_t (required).])
1730  fi
1731  GS_SIZEOF_COND_T=$ac_cv_sizeof_pthread_cond_t
1732  AC_SUBST(GS_SIZEOF_COND_T)
1733  AC_CHECK_ALIGNOF(pthread_mutex_t,[AC_INCLUDES_DEFAULT
1734#include <pthread.h>])
1735  GS_ALIGNOF_MUTEX_T=$ac_cv_alignof_pthread_mutex_t
1736  if test $ac_cv_alignof_pthread_mutex_t = 0 ; then
1737    AC_MSG_ERROR([Unable to find align of pthread_mutex_t (required).])
1738  fi
1739  AC_SUBST(GS_ALIGNOF_MUTEX_T)
1740  AC_CHECK_ALIGNOF(pthread_cond_t,[AC_INCLUDES_DEFAULT
1741#include <pthread.h>])
1742  if test $ac_cv_alignof_pthread_cond_t = 0 ; then
1743    AC_MSG_ERROR([Unable to find align of pthread_cond_t (required).])
1744  fi
1745  GS_ALIGNOF_COND_T=$ac_cv_alignof_pthread_cond_t
1746  AC_SUBST(GS_ALIGNOF_COND_T)
1747else
1748  AC_MSG_ERROR([Unable to find pthread.h (needed for thread support).])
1749fi
1750AC_CHECK_LIB(pthread, pthread_join, pthread_ok=yes, pthread_ok=no)
1751ismingw=no
1752checkinlibc=no
1753case "$target_os" in
1754  mingw*)	ismingw=yes;;
1755  nto*)		checkinlibc=yes;;
1756  qnx*)		checkinlibc=yes;;
1757  *android*)   checkinlibc=yes;;
1758esac
1759if test $pthread_ok = yes ; then
1760  LIBS="$LIBS -lpthread"
1761else
1762  if test $ismingw = yes ; then
1763    AC_CHECK_LIB(pthreadGC2, pthread_join, pthread_ok=yes, pthread_ok=no)
1764    if test $pthread_ok = yes ; then
1765      LIBS="$LIBS -lpthreadGC2"
1766    fi
1767  fi
1768  # Android and QNX have pthread in libc instead of libpthread
1769  if test $checkinlibc = yes ; then
1770    AC_CHECK_LIB(c, pthread_join, pthread_ok=yes, pthread_ok=no)
1771    if test $pthread_ok = yes ; then
1772       LIBS="$LIBS -lc"
1773    fi
1774  fi
1775fi
1776if test $pthread_ok = no ; then
1777  AC_MSG_ERROR([Unable to find pthread library (needed for thread support).])
1778fi
1779
1780# Check threading extensions
1781AC_CHECK_FUNCS(pthread_getthreadid_np pthread_main_np)
1782
1783# Typically need librt on Solaris for sched_yield
1784AC_CHECK_LIB(rt, sched_yield)
1785
1786
1787#--------------------------------------------------------------------
1788# One of these function needed by NSThread.m and objc initialize test
1789#--------------------------------------------------------------------
1790AC_CHECK_FUNCS(nanosleep usleep Sleep)
1791
1792AC_MSG_CHECKING(for objc_root_class attribute support)
1793saved_CFLAGS="$CFLAGS"
1794CFLAGS="$CFLAGS -Werror $OBJCFLAGS -x objective-c"
1795AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1796  __attribute__((objc_root_class)) @interface RootObject
1797  @end
1798  @implementation RootObject
1799  @end])],
1800  AC_MSG_RESULT([found])
1801  gs_objc_root_class_attr=1,
1802  AC_MSG_RESULT([not present])
1803  gs_objc_root_class_attr=0
1804)
1805
1806GS_HAVE_OBJC_ROOT_CLASS_ATTR=$gs_objc_root_class_attr
1807AC_SUBST(GS_HAVE_OBJC_ROOT_CLASS_ATTR)
1808AC_DEFINE_UNQUOTED(HAVE_OBJC_ROOT_CLASS_ATTRIBUTE,$gs_objc_root_class_attr,
1809  [Says whether the objc_root_class attribute works])
1810CFLAGS=$saved_CFLAGS
1811
1812
1813#--------------------------------------------------------------------
1814# Check if we can name pthreads
1815#--------------------------------------------------------------------
1816
1817AC_CACHE_CHECK([for pthread_setname_np()], gs_cv_pthread_setname_np,
1818[AC_LINK_IFELSE(
1819  [AC_LANG_PROGRAM([#include <pthread.h>],
1820    [pthread_setname_np("name");])],
1821  [gs_cv_pthread_setname_np=darwin],
1822  [AC_LINK_IFELSE(
1823    [AC_LANG_PROGRAM([#include <pthread.h>],
1824      [pthread_setname_np(pthread_self(), "name");])],
1825    [gs_cv_pthread_setname_np=glibc],
1826    [AC_LINK_IFELSE(
1827      [AC_LANG_PROGRAM([#include <pthread.h>],
1828        [pthread_setname_np(pthread_self(), "%s", "name");])],
1829      [gs_cv_pthread_setname_np=netbsd],
1830      [gs_cv_pthread_setname_np=none])])])])
1831case $gs_cv_pthread_setname_np in
1832  darwin)
1833    AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(a),
1834      [Description: Define set name function for pthread with one arg])
1835    ;;
1836  glibc)
1837    AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),a),
1838      [Description: Define setname function for pthread with two args])
1839    ;;
1840  netbsd)
1841    AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),"%s",a),
1842      [Description: Define setname function for pthread with three args])
1843    ;;
1844esac
1845
1846#--------------------------------------------------------------------
1847# Check if we have spinlock support
1848#--------------------------------------------------------------------
1849AC_CHECK_FUNCS(pthread_spin_lock)
1850
1851#--------------------------------------------------------------------
1852# Check whether we can get the system thread ID
1853#--------------------------------------------------------------------
1854AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
1855[AC_TRY_RUN(#define _GNU_SOURCE
1856#include <unistd.h>
1857#include <sys/syscall.h>
1858#include <sys/types.h>
1859int main(int argc, char **argv) {
1860pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
1861[ac_cv_gettid=yes], [ac_cv_gettid=no], [ac_cv_gettid=no])])
1862if test "$ac_cv_gettid" = "yes"; then
1863  AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
1864fi
1865
1866#--------------------------------------------------------------------
1867# Check whether Objective-C /really/ works
1868#--------------------------------------------------------------------
1869AC_MSG_CHECKING(whether objc really works)
1870saved_LIBS="$LIBS"
1871saved_CPPFLAGS="$CPPFLAGS"
1872LIBS="$LIBS $LIBOBJC"
1873CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
1874if test x"$objc_threaded" != x""; then
1875  LIBS="$LIBS $objc_threaded"
1876fi
1877LIBS="$LIBS $extra_LIBS"
1878AC_CACHE_VAL(gs_cv_objc_works,
1879  AC_TRY_RUN([#include "$srcdir/config/config.objc.m"],
1880  gs_cv_objc_works=yes,
1881  gs_cv_objc_works=no,
1882  gs_cv_objc_works="$cross_gs_cv_objc_works")
1883)
1884if test $gs_cv_objc_works = yes; then
1885  AC_MSG_RESULT(yes)
1886else
1887  AC_MSG_RESULT(no)
1888  echo "I don't seem to be able to use your Objective-C compiler to produce"
1889  echo "working binaries!  Please check your Objective-C compiler installation."
1890  echo "If you are using gcc-3.x make sure that your compiler's libgcc_s and libobjc"
1891  echo "can be found by the dynamic linker - usually that requires you to play"
1892  echo "with LD_LIBRARY_PATH or /etc/ld.so.conf."
1893  echo "Please refer to your compiler installation instructions for more help."
1894  AC_MSG_ERROR(The Objective-C compiler does not work or is not installed properly.)
1895fi
1896
1897# Don't revert any Objective-C flags as they are used in the next test
1898
1899#---------------------------------------------------------------------
1900# See if we are using a compiler which allows us to change the class
1901# to be used for constant strings by using the -fconstant-string-class
1902# option.  If that is the case, we change it to NSConstantString.
1903# Unless we are building for the apple runtime (ie only building base
1904# additions library and not implementing a constant string class).
1905#---------------------------------------------------------------------
1906if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then
1907  NX_CONST_STRING_OBJCFLAGS=""
1908  NX_CONST_STRING_CLASS=NXConstantString
1909else
1910  strclass_CPPFLAGS="$CPPFLAGS"
1911  CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString"
1912  AC_MSG_CHECKING(if the compiler supports -fconstant-string-class)
1913  AC_CACHE_VAL(gs_cv_objc_compiler_supports_constant_string_class,
1914    AC_TRY_RUN([#include "$srcdir/config/config.constant-string-class.m"],
1915    gs_cv_objc_compiler_supports_constant_string_class=yes,
1916    gs_cv_objc_compiler_supports_constant_string_class=no,
1917    gs_cv_objc_compiler_supports_constant_string_class="$cross_gs_cv_objc_compiler_supports_constant_string_class")
1918  )
1919  if test $gs_cv_objc_compiler_supports_constant_string_class = yes; then
1920    NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString"
1921    NX_CONST_STRING_CLASS=NSConstantString
1922    AC_MSG_RESULT(yes)
1923  else
1924    AC_MSG_RESULT(no)
1925    AC_ARG_ENABLE(nxconstantstring,
1926        [  --enable-nxconstantstring
1927	    Enables the use of the NXConstantString class for old compilers.],,
1928        enable_nxconstantstring=no)
1929    if test $enable_nxconstantstring = yes; then
1930      NX_CONST_STRING_OBJCFLAGS=""
1931      NX_CONST_STRING_CLASS=NXConstantString
1932      AC_MSG_WARN([You have enabled the use of NXConstantString as the string class in gnustep-base.  The objective-c runtime library typically implements its own class of the same name, so you must either enforce a link order which ensures that the gnustep-base implementation is used, or (better) you must remove the class from the runtime library!])
1933    else
1934      AC_MSG_ERROR([Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings.  Please check for a more recent version or consider using --enable-nxconstantstring])
1935    fi
1936  fi
1937  CPPFLAGS="$strclass_CPPFLAGS"
1938fi
1939
1940AC_SUBST(NX_CONST_STRING_OBJCFLAGS)
1941AC_SUBST(NX_CONST_STRING_CLASS)
1942
1943# Don't revert any Objective-C flags as they are used in the next test
1944
1945#---------------------------------------------------------------------
1946# Guess if we are using a compiler which has the (GNU extension) +load
1947# method which is executed before main.
1948# Defines HAVE_LOAD_METHOD if +load methods are called before main.
1949# Needed by NSProcessInfo.m
1950#---------------------------------------------------------------------
1951AC_MSG_CHECKING(if +load method is executed before main)
1952AC_CACHE_VAL(gs_cv_objc_load_method_worked,
1953  AC_TRY_RUN([#include "$srcdir/config/config.loadtest.m"],
1954	gs_cv_objc_load_method_worked=yes,
1955	gs_cv_objc_load_method_worked=no,
1956	gs_cv_objc_load_method_worked="$cross_gs_cv_objc_load_method_worked")
1957)
1958if test $gs_cv_objc_load_method_worked = yes; then
1959  AC_DEFINE(HAVE_LOAD_METHOD,1,
1960            [Define if your Obj-C compiler calls +load methods before main])
1961  AC_MSG_RESULT(yes)
1962else
1963  AC_MSG_RESULT(no)
1964fi
1965
1966# Don't revert any Objective-C flags as they are used in the next test
1967
1968#--------------------------------------------------------------------
1969# Check for thread synchronisation support in runtime
1970#--------------------------------------------------------------------
1971AC_CHECK_FUNCS(objc_sync_enter)
1972if test $ac_cv_func_objc_sync_enter = yes ; then
1973  OBJCSYNC=1
1974else
1975  OBJCSYNC=0
1976  if test "$OBJC_RUNTIME_LIB" = "ng"; then
1977    AC_MSG_ERROR([The objc runtime library does not appear to have synchronisation support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
1978  fi
1979fi
1980AC_SUBST(OBJCSYNC)
1981
1982# Don't revert any Objective-C flags as they are used in the next test
1983
1984#--------------------------------------------------------------------
1985# Check for ObjC2 support in runtime
1986#--------------------------------------------------------------------
1987if test "$cross_compiling" = "yes"; then
1988  AC_MSG_NOTICE(["Cross compiling! Using predefined OBJC2RUNTIME variable"])
1989  OBJC2RUNTIME="$cross_objc2_runtime"
1990else
1991  AC_CHECK_FUNCS(objc_setProperty)
1992  if test $ac_cv_func_objc_setProperty = yes ; then
1993    OBJC2RUNTIME=1
1994  else
1995    OBJC2RUNTIME=0
1996    if test "$OBJC_RUNTIME_LIB" = "ng"; then
1997      AC_MSG_ERROR([The objc runtime library does not appear to have property support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
1998    fi
1999  fi
2000fi
2001AC_SUBST(OBJC2RUNTIME)
2002
2003#--------------------------------------------------------------------
2004# Check for blocks support in runtime
2005#--------------------------------------------------------------------
2006AC_CHECK_FUNCS(_Block_copy)
2007if test $ac_cv_func__Block_copy = yes ; then
2008  HAVE_BLOCKS=1
2009else
2010  HAVE_BLOCKS=0
2011  if test "$OBJC_RUNTIME_LIB" = "ng"; then
2012    AC_MSG_ERROR([The objc runtime library does not appear to have blocks support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
2013  fi
2014fi
2015AC_SUBST(HAVE_BLOCKS)
2016
2017# Don't revert any Objective-C flags as they are used in the next test
2018
2019GS_NONFRAGILE=0
2020GS_MIXEDABI=0
2021if test "$nonfragile" = "yes"; then
2022  saved_CPPFLAGS="$CPPFLAGS"
2023  CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
2024  AC_MSG_CHECKING(for non-fragile-abi support)
2025  AC_RUN_IFELSE([AC_LANG_SOURCE(
2026    [[#include "$srcdir/config/config.non-fragile-ivars.m"]])],
2027    non_fragile=yes, non_fragile=no,
2028    non_fragile="$cross_non_fragile")
2029  CPPFLAGS="$saved_CPPFLAGS"
2030  if test $non_fragile = yes; then
2031    GS_NONFRAGILE=1
2032    if test "$OBJC_RUNTIME_LIB" != "ng"; then
2033      AC_ARG_ENABLE(mixedabi,
2034        [  --disable-mixedabi
2035	    Disables the combined use of fragile and nonfragile ABI so that base
2036	    can be built taking full advantage of the nonfragile ABI.],,
2037        enable_mixedabi=yes)
2038      if test $enable_mixedabi = yes; then
2039        GS_MIXEDABI=1
2040      fi
2041    fi
2042  fi
2043  AC_MSG_RESULT($non_fragile)
2044fi
2045AC_SUBST(GS_NONFRAGILE)
2046AC_SUBST(GS_MIXEDABI)
2047
2048
2049# Don't revert any Objective-C flags as they are used in the next test
2050
2051#--------------------------------------------------------------------
2052# get_uninstalled_dtable used by behavior.m and objc-load.m
2053#--------------------------------------------------------------------
2054AC_EGREP_HEADER(objc_get_uninstalled_dtable, objc/objc-api.h,
2055	AC_DEFINE(HAVE_OBJC_GET_UNINSTALLED_DTABLE,1,
2056                  [ Define if objc-api.h defines this function]),)
2057
2058# Don't revert any Objective-C flags as they are used in the next test
2059
2060
2061#--------------------------------------------------------------------
2062# Native Objective-C exceptions
2063#--------------------------------------------------------------------
2064
2065if test "$OBJC_RUNTIME_LIB" = "ng"; then
2066  exceptions=yes
2067else
2068  # Determine if native Objective-C exceptions are enabled
2069  # in gnustep-make.  They are enabled if the compiler supports it; they
2070  # are disabled if it doesn't.  And, of course, the user may have
2071  # forced one behaviour or the other.  Note that we go and look at the
2072  # actual config.make file to be able to know what was configured in
2073  # gnustep-make regardless of any gnustep-base that is currently
2074  # installed.  We can't use `gnustep-config --objc-flags` because that
2075  # may report native exceptions as disabled because the currently
2076  # installed gnustep-base has them disabled.
2077  if grep USE_OBJC_EXCEPTIONS $CURRENT_GNUSTEP_MAKEFILES/$lobj_dir/config.make | grep yes >&5 2>&5; then
2078    exceptions=yes
2079  else
2080    exceptions=no
2081  fi
2082fi
2083
2084# At this point, if exceptions=no, then native exceptions are disabled
2085# and won't be used.  If exceptions=yes, we need to check if they work
2086# and if the runtime has proper support for them.  If it does, we'll
2087# happily use them; if it doesn't, we'll automatically disable them
2088# because they don't work. ;-)
2089
2090#--------------------------------------------------------------------
2091# One of these is needed by for handling uncaught exceptions
2092#--------------------------------------------------------------------
2093
2094# TODO: These checks are not really needed if native exceptions are
2095# disabled.  So maybe we should not run them at all in that case.  On
2096# the other hand, that case is going to become more and more unusual.
2097
2098AC_MSG_CHECKING(for objc_setUncaughtExceptionHandler() in runtime)
2099AC_LINK_IFELSE([AC_LANG_SOURCE(
2100  [[#include "$srcdir/config/config.setUncaughtExceptionHandler.m"]])],
2101	have_set_uncaught_exception_handler=yes, have_set_uncaught_exception_handler=no)
2102if test $have_set_uncaught_exception_handler = yes; then
2103  AC_DEFINE(HAVE_SET_UNCAUGHT_EXCEPTION_HANDLER,1,
2104	    [Define if libobjc has the objc_setUncaughtExceptionHandler() function])
2105fi
2106AC_MSG_RESULT($have_set_uncaught_exception_handler)
2107
2108# Don't revert any Objective-C flags as they are used in the next test
2109
2110AC_MSG_CHECKING(for objc_set_unexpected() in runtime)
2111AC_LINK_IFELSE(
2112  [AC_LANG_SOURCE([[#include "$srcdir/config/config.set_unexpected.m"]])],
2113	have_set_unexpected=yes, have_set_unexpected=no)
2114if test $have_set_unexpected = yes; then
2115  AC_DEFINE(HAVE_SET_UNEXPECTED,1,
2116	    [Define if libobjc has the objc_set_unexpected() function])
2117fi
2118AC_MSG_RESULT($have_set_unexpected)
2119
2120# Don't revert any Objective-C flags as they are used in the next test
2121
2122AC_MSG_CHECKING(for _objc_unexpected_exception in runtime)
2123AC_RUN_IFELSE(
2124  [AC_LANG_SOURCE([[#include "$srcdir/config/config.unexpected.m"]])],
2125    have_unexpected=yes,
2126    have_unexpected=no,
2127    have_unexpected="$cross_have_unexpected")
2128if test $have_unexpected = yes; then
2129  AC_DEFINE(HAVE_UNEXPECTED,1,
2130	    [Define if libobjc has the _objc_unexpected_exception callback])
2131fi
2132AC_MSG_RESULT($have_unexpected)
2133
2134# TODO: It would also be nice to actually test that native Objective-C
2135# exceptions work.
2136
2137if test "$exceptions" = "yes"; then
2138  if test x"$have_set_uncaught_exception_handler" = x"no"; then
2139    if test x"$have_set_unexpected" = x"no"; then
2140      if test x"$have_unexpected" = x"no"; then
2141        AC_MSG_NOTICE([Disabling native Objective-C exceptions because the ObjC runtime])
2142        AC_MSG_NOTICE([has no way to set an uncaught exception handler.  Please install])
2143        AC_MSG_NOTICE([a recent Objective-C runtime if you want to use them.])
2144        exceptions="no";
2145      fi
2146    fi
2147  fi
2148fi
2149
2150AC_MSG_CHECKING(whether to enable native Objective-C exceptions)
2151if test "$exceptions" = "yes"; then
2152  AC_MSG_RESULT(yes)
2153  BASE_NATIVE_OBJC_EXCEPTIONS=1
2154else
2155  AC_MSG_RESULT(no)
2156  BASE_NATIVE_OBJC_EXCEPTIONS=0
2157fi
2158AC_SUBST(BASE_NATIVE_OBJC_EXCEPTIONS)
2159
2160# Don't revert any Objective-C flags as they are used in the next test
2161
2162#--------------------------------------------------------------------
2163# Function needed by @synchronize directive
2164#--------------------------------------------------------------------
2165AC_CHECK_FUNCS(objc_sync_enter)
2166
2167HAVE_OBJC_SYNC_ENTER=no
2168if test $ac_cv_func_objc_sync_enter = yes ; then
2169  HAVE_OBJC_SYNC_ENTER=yes
2170fi
2171AC_SUBST(HAVE_OBJC_SYNC_ENTER)
2172
2173# Don't revert any Objective-C flags as they are used in the next test
2174
2175AC_MSG_CHECKING(for thread-safe +initialize in runtime)
2176AC_RUN_IFELSE(
2177  [AC_LANG_SOURCE([[#include "$srcdir/config/config.initialize.m"]])],
2178	safe_initialize=yes, safe_initialize=no, safe_initialize="$cross_safe_initialize")
2179if test $safe_initialize = yes; then
2180  AC_DEFINE(HAVE_INITIALIZE,1,
2181	    [Define if libobjc has thread-safe +initialize support])
2182else
2183  AC_MSG_WARN([Your ObjectiveC runtime does not support thread-safe class initialisation.  Please use a different runtime if you intend to use threads.])
2184fi
2185AC_MSG_RESULT($safe_initialize)
2186
2187LIBS="$saved_LIBS"
2188CPPFLAGS="$saved_CPPFLAGS"
2189
2190AC_SUBST(OBJCFLAGS)
2191
2192#--------------------------------------------------------------------
2193# Generic settings needed by NSZone.m
2194#--------------------------------------------------------------------
2195AC_TYPE_SIZE_T
2196AC_C_INLINE
2197
2198#--------------------------------------------------------------------
2199# Following header checks needed for bzero in Storage.m and other places
2200#--------------------------------------------------------------------
2201AC_HEADER_STDC
2202AC_CHECK_HEADERS(string.h memory.h alloca.h)
2203
2204#--------------------------------------------------------------------
2205# Following header check needed NSConnection.h
2206#--------------------------------------------------------------------
2207AC_CHECK_HEADERS(float.h)
2208
2209#--------------------------------------------------------------------
2210# Header files and functions for files and filesystems
2211#--------------------------------------------------------------------
2212AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h)
2213AC_CHECK_HEADERS(sys/cdefs.h sys/syslimits.h sys/param.h)
2214# Twisted header checks for some BSDs with stupid interdependencies
2215AC_CHECK_HEADERS([sys/syslimits.h], [], [],
2216  [#if HAVE_SYS_CDEFS_H
2217   #include <sys/cdefs.h>
2218   #endif
2219   #include <sys/syslimits.h>
2220  ])
2221AC_CHECK_HEADERS([sys/param.h], [], [],
2222  [#if HAVE_SYS_CDEFS_H
2223   #include <sys/cdefs.h>
2224   #endif
2225   #if HAVE_SYS_SYSLIMITS_H
2226   #include <sys/syslimits.h>
2227   #endif
2228  ])
2229AC_CHECK_HEADERS([sys/mount.h], [], [],
2230  [#if HAVE_SYS_CDEFS_H
2231   #include <sys/cdefs.h>
2232   #endif
2233   #if HAVE_SYS_SYSLIMITS_H
2234   #include <sys/syslimits.h>
2235   #endif
2236   #if HAVE_SYS_PARAM_H
2237   #include <sys/param.h>
2238   #endif
2239  ])
2240AC_CHECK_HEADERS(sys/types.h windows.h locale.h langinfo.h)
2241saved_LIBS="$LIBS"
2242AC_CHECK_LIB(m, main)
2243AC_CHECK_FUNCS(statvfs link symlink readlink geteuid getlogin getpwnam getpwnam_r getpwuid getpwuid_r getgrgid getgrgid_r getgrnam getgrnam_r rint getopt malloc_usable_size)
2244LIBS="$saved_LIBS"
2245
2246AC_CACHE_CHECK([for pw_gecos field in struct passwd],
2247		ac_cv_have_pw_gecos_in_struct_passwd, [
2248	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
2249	[[ struct passwd p; p.pw_gecos = 0; ]])],
2250	[ ac_cv_have_pw_gecos_in_struct_passwd="yes" ],
2251	[ ac_cv_have_pw_gecos_in_struct_passwd="no"
2252	])
2253])
2254if test "x$ac_cv_have_pw_gecos_in_struct_passwd" = "xyes" ; then
2255	AC_DEFINE([HAVE_PW_GECOS_IN_PASSWD], [1],
2256		[Define if you have pw_gecos field in struct passwd])
2257fi
2258
2259AC_CACHE_CHECK([for currency_symbol field in struct lconv],
2260		ac_cv_have_currency_symbol_in_struct_lconv, [
2261	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <locale.h> ]],
2262	[[ struct lconv l; l.currency_symbol = NULL; ]])],
2263	[ ac_cv_have_currency_symbol_in_struct_lconv="yes" ],
2264	[ ac_cv_have_currency_symbol_in_struct_lconv="no"
2265	])
2266])
2267if test "x$ac_cv_have_currency_symbol_in_struct_lconv" = "xyes" ; then
2268	AC_DEFINE([HAVE_CURRENCY_SYMBOL_IN_LCONV], [1],
2269		[Define if you have currency_symbol field in struct lconv])
2270fi
2271
2272#--------------------------------------------------------------------
2273# These two headers (functions) needed by Time.m
2274#--------------------------------------------------------------------
2275dnl AC_REPLACE_FUNCS(getrusage gettimeofday)
2276
2277AC_CHECK_HEADERS(time.h sys/time.h tzfile.h sys/rusage.h ucbinclude/sys/resource.h)
2278AC_CHECK_FUNCS(time ctime tzset)
2279
2280# Check if tzfile contains the proper definitions
2281if test $ac_cv_header_tzfile_h = yes; then
2282  AC_EGREP_HEADER(tzhead, tzfile.h,
2283	AC_DEFINE(HAVE_TZHEAD,1,
2284                  [ Define if tzfile.h includes the proper definitions]),)
2285fi
2286
2287#--------------------------------------------------------------------
2288# These headers/functions needed by GSTcpPort.m
2289#--------------------------------------------------------------------
2290AC_CHECK_HEADERS(sys/socket.h netinet/in.h)
2291AC_CHECK_TYPES([socklen_t])
2292dnl AC_REPLACE_FUNCS(recvfrom)
2293
2294#--------------------------------------------------------------------
2295# These headers/functions needed for stacktrace in NSException.m
2296#--------------------------------------------------------------------
2297AC_ARG_ENABLE(bfd,
2298  [  --enable-bfd
2299	Enables the use of libbfd to provide symbolic stack traces.
2300	Enabling this option provides support for symbolic stack traces
2301	on platforms where the backtrace_symbols() function is not
2302	available or does not work properly.
2303	Enabling this option also has the effect of changing the license
2304	of gnustep-base from LGPL to GPL since libbfd uses the GPL license],,
2305  enable_bfd=no)
2306if test $enable_bfd = yes ; then
2307  AC_DEFINE(USE_BFD,1, [Define to use bfd library for stack traces])
2308  AC_MSG_WARN([You enabled bfd, which causes gnustep-base to link with libbfd. This makes the license GPL rather than the normal LGPL.])
2309fi
2310
2311AC_CHECK_HEADERS(bfd.h)
2312AC_CHECK_LIB(intl, libintl_fprintf)
2313AC_CHECK_LIB(iberty, dyn_string_append)
2314AC_CHECK_LIB(bfd, bfd_openr)
2315if test $ismingw = yes ; then
2316  AC_CHECK_HEADERS(dbghelp.h)
2317else
2318  AC_CHECK_HEADERS(execinfo.h)
2319  AC_CHECK_FUNCS(backtrace)
2320fi
2321
2322AC_CHECK_FUNCS(__builtin_extract_return_address)
2323
2324AC_CHECK_HEADERS(unwind.h)
2325
2326#--------------------------------------------------------------------
2327# These headers/functions needed by NSLog.m
2328#--------------------------------------------------------------------
2329AC_CHECK_HEADERS(syslog.h sys/slog.h sys/slogcodes.h)
2330AC_CHECK_FUNCS(syslog)
2331if test "$ac_cv_header_sys_slog_h" = "yes"; then
2332  oldLibs="$LIBS";
2333  LIBS="$LIBS -l:libc.a";
2334  AC_CHECK_FUNCS(slogf)
2335  if test "$ac_cv_func_slogf" = "no"; then
2336    LIBS="$oldLibs"
2337  fi
2338fi
2339#--------------------------------------------------------------------
2340# These headers/functions needed by NSRunLoop.m
2341#--------------------------------------------------------------------
2342AC_CHECK_HEADERS(poll.h)
2343AC_CHECK_FUNCS(poll)
2344have_poll=no
2345if test $ac_cv_header_poll_h = yes; then
2346  have_poll=yes
2347  AC_MSG_CHECKING(for poll emulation)
2348  AC_EGREP_CPP(emulating_poll, [#include "config/config.poll.c"],
2349  	have_poll=no,)
2350  if test $have_poll = yes; then
2351    AC_MSG_RESULT(no)
2352    AC_MSG_CHECKING([if poll supports devices])
2353    AC_TRY_RUN([#include "$srcdir/config/config.poll-dev.c"i], ,have_poll=no, have_poll="$cross_have_poll" )
2354    if test $have_poll = yes; then
2355      AC_MSG_RESULT(yes)
2356      AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select])
2357    else
2358      AC_MSG_RESULT(no)
2359    fi
2360  else
2361    AC_MSG_RESULT(yes)
2362  fi
2363fi
2364
2365#--------------------------------------------------------------------
2366# This function needed by StdioStream.m
2367#--------------------------------------------------------------------
2368AC_CHECK_FUNCS(vsprintf vasprintf snprintf vsnprintf)
2369if test $ac_cv_func_vsprintf = yes ; then
2370    AC_TRY_RUN([#include "$srcdir/config/config.vsprintf.c"],
2371		VSPRINTF_RETURNS_LENGTH=1,
2372		VSPRINTF_RETURNS_LENGTH=0,
2373		VSPRINTF_RETURNS_LENGTH="$cross_VSPRINTF_RETURNS_LENGTH")
2374    AC_DEFINE_UNQUOTED(VSPRINTF_RETURNS_LENGTH, $VSPRINTF_RETURNS_LENGTH,
2375                       [Define if vsprintf returns the length printed])
2376fi
2377if test $ac_cv_func_vasprintf = yes ; then
2378    AC_TRY_RUN([#include "$srcdir/config/config.vasprintf.c"],
2379		VASPRINTF_RETURNS_LENGTH=1,
2380		VASPRINTF_RETURNS_LENGTH=0,
2381		VASPRINTF_RETURNS_LENGTH="$cross_VASPRINTF_RETURNS_LENGTH")
2382    AC_DEFINE_UNQUOTED(VASPRINTF_RETURNS_LENGTH, $VASPRINTF_RETURNS_LENGTH,
2383                       [Define if vasprintf returns the length printed])
2384fi
2385
2386#--------------------------------------------------------------------
2387# This function needed by NSFileManager.m
2388#--------------------------------------------------------------------
2389AC_CHECK_FUNCS(getcwd)
2390AC_HEADER_DIRENT
2391
2392#--------------------------------------------------------------------
2393# This function needed by gdomap.c
2394#--------------------------------------------------------------------
2395AC_CHECK_HEADERS(getopt.h)
2396
2397#--------------------------------------------------------------------
2398# This function needed by NSPage.m
2399#--------------------------------------------------------------------
2400AC_CHECK_FUNCS(posix_memalign valloc)
2401
2402#--------------------------------------------------------------------
2403# This function needed by Time.m
2404#--------------------------------------------------------------------
2405AC_CHECK_FUNCS(times)
2406
2407#--------------------------------------------------------------------
2408# These functions needed by NSData.m and GSFFIInvocation.m
2409#--------------------------------------------------------------------
2410AC_CHECK_FUNCS(mkstemp)
2411AC_CHECK_FUNCS(shmctl)
2412AC_CHECK_FUNCS(mmap)
2413AC_CHECK_FUNCS(mprotect)
2414AC_CHECK_HEADERS(sys/mman.h)
2415
2416#--------------------------------------------------------------------
2417# These functions needed by NSTask.m
2418#--------------------------------------------------------------------
2419AC_CHECK_FUNCS(killpg setpgrp setpgid setsid grantpt)
2420if test "x$ac_cv_func_setpgrp" = xyes; then
2421  AC_FUNC_SETPGRP
2422fi
2423
2424HAVE_PTS_STREAM_MODULES=0
2425case "${target}" in
2426  *-sysv-*)
2427    HAVE_PTS_STREAM_MODULES=1
2428    ;;
2429esac
2430AC_DEFINE_UNQUOTED(HAVE_PTS_STREAM_MODULES, $HAVE_PTS_STREAM_MODULES,
2431                   [Define this if you work on sysv])
2432AC_SUBST(HAVE_PTS_STREAM_MODULES)
2433
2434AC_CHECK_HEADERS(dnl
2435	fcntl.h dnl
2436	inttypes.h dnl
2437	libc.h dnl
2438	limits.h dnl
2439	malloc.h dnl
2440	memory.h dnl
2441	signal.h dnl
2442	stdint.h dnl
2443	string.h dnl
2444	sys/fcntl.h dnl
2445	sys/file.h dnl
2446	sys/filio.h dnl
2447	sys/inttypes.h dnl
2448	sys/ioctl.h dnl
2449	sys/signal.h dnl
2450	sys/stropts.h dnl
2451	sys/wait.h dnl
2452	unistd.h dnl
2453	utime.h dnl
2454        stdlib.h dnl
2455	)
2456
2457if test $ac_cv_header_inttypes_h = yes; then
2458INCLUDE_INTTYPES="#include <inttypes.h>"
2459elif test $ac_cv_header_sys_inttypes_h = yes; then
2460INCLUDE_INTTYPES="#include <sys/inttypes.h>"
2461elif test $ac_cv_header_stdint_h = yes; then
2462INCLUDE_INTTYPES="#include <stdint.h>"
2463else
2464INCLUDE_INTTYPES="no"
2465fi
2466
2467if test "$INCLUDE_INTTYPES" = "no"; then
2468INCLUDE_INTTYPES=""
2469DEFINE_INT8_T="#define int8_t gss8"
2470DEFINE_UINT8_T="#define uint8_t gsu8"
2471DEFINE_INT16_T="#define int16_t gss16"
2472DEFINE_UINT16_T="#define uint16_t gsu16"
2473DEFINE_INT32_T="#define int32_t gss32"
2474DEFINE_UINT32_T="#define uint32_t gsu32"
2475DEFINE_INT64_T="#define int64_t gss64"
2476DEFINE_UINT64_T="#define uint64_t gsu64"
2477DEFINE_INTPTR_T="#define intptr_t gssaddr"
2478DEFINE_UINTPTR_T="#define uintptr_t gsuaddr"
2479else
2480DEFINE_INT8_T=""
2481DEFINE_UINT8_T=""
2482DEFINE_INT16_T=""
2483DEFINE_UINT16_T=""
2484DEFINE_INT32_T=""
2485DEFINE_UINT32_T=""
2486DEFINE_INT64_T=""
2487DEFINE_UINT64_T=""
2488DEFINE_INTPTR_T=""
2489DEFINE_UINTPTR_T=""
2490fi
2491
2492AC_SUBST(INCLUDE_INTTYPES)
2493AC_SUBST(DEFINE_INT8_T)
2494AC_SUBST(DEFINE_UINT8_T)
2495AC_SUBST(DEFINE_INT16_T)
2496AC_SUBST(DEFINE_UINT16_T)
2497AC_SUBST(DEFINE_INT32_T)
2498AC_SUBST(DEFINE_UINT32_T)
2499AC_SUBST(DEFINE_INT64_T)
2500AC_SUBST(DEFINE_UINT64_T)
2501AC_SUBST(DEFINE_INTPTR_T)
2502AC_SUBST(DEFINE_UINTPTR_T)
2503
2504#--------------------------------------------------------------------
2505# These used by GSFileHandle.m and distributed objects
2506# On some systems we need -lnsl ... so check for that case.
2507#--------------------------------------------------------------------
2508AC_SEARCH_LIBS([inet_ntop],[nsl])
2509AC_CHECK_FUNCS(gethostbyaddr_r inet_aton inet_pton inet_ntop sigaction)
2510
2511USE_ZLIB=0
2512AC_CHECK_HEADERS(zlib.h)
2513if test $ac_cv_header_zlib_h = yes; then
2514  AC_CHECK_LIB(z, gzseek, zlib_ok=yes, zlib_ok=no)
2515  if test "$zlib_ok" = yes; then
2516    LIBS="$LIBS -lz"
2517    USE_ZLIB=1
2518  fi
2519fi
2520AC_SUBST(USE_ZLIB)
2521
2522HAVE_INET_PTON=no
2523if test $ac_cv_func_inet_pton = yes ; then
2524  HAVE_INET_PTON=yes
2525fi
2526AC_SUBST(HAVE_INET_PTON)
2527
2528HAVE_INET_NTOP=no
2529if test $ac_cv_func_inet_ntop = yes ; then
2530  HAVE_INET_NTOP=yes
2531fi
2532AC_SUBST(HAVE_INET_NTOP)
2533
2534#--------------------------------------------------------------------
2535# For setting thread stack size
2536#--------------------------------------------------------------------
2537AC_CHECK_HEADERS(sys/resource.h)
2538AC_CHECK_FUNCS(setrlimit)
2539
2540#--------------------------------------------------------------------
2541# One of these functions needed by NSDebug.m and NSProcessInfo.m
2542#--------------------------------------------------------------------
2543AC_CHECK_FUNCS(strerror)
2544AC_FUNC_STRERROR_R
2545
2546#--------------------------------------------------------------------
2547# Needed by NSDebug.m
2548#--------------------------------------------------------------------
2549AC_CHECK_FUNCS(sigsetjmp)
2550
2551#--------------------------------------------------------------------
2552# This type needed by GSFormat
2553#--------------------------------------------------------------------
2554AC_CHECK_TYPES([uintmax_t])
2555AC_CHECK_HEADERS(wchar.h)
2556
2557#--------------------------------------------------------------------
2558# Check if short and int values need to be word aligned
2559#--------------------------------------------------------------------
2560saved_CFLAGS="$CFLAGS"
2561CFLAGS="$CFLAGS -O0"
2562AC_MSG_CHECKING(short/int needs to be word aligned)
2563AC_TRY_RUN([#include "$srcdir/config/config.align.c"],
2564	NEED_WORD_ALIGNMENT=0,
2565	NEED_WORD_ALIGNMENT=1,
2566	NEED_WORD_ALIGNMENT="$cross_NEED_WORD_ALIGNMENT")
2567CFLAGS="$saved_CFLAGS"
2568AC_DEFINE_UNQUOTED(NEED_WORD_ALIGNMENT, $NEED_WORD_ALIGNMENT,
2569                   [Define if your system needs to have short/int word aligned])
2570if test $NEED_WORD_ALIGNMENT = 1; then
2571  AC_MSG_RESULT(yes)
2572else
2573  AC_MSG_RESULT(no)
2574fi
2575
2576#--------------------------------------------------------------------
2577# This needed by NSString for handling of %@ printf directive.
2578#--------------------------------------------------------------------
2579AC_CHECK_FUNCS(register_printf_specifier)
2580AC_CHECK_FUNC(register_printf_function, register_printf=1,
2581register_printf=0)
2582if test $register_printf = 1; then
2583  AC_TRY_RUN([#include "$srcdir/config/config.printf.c"],
2584	       working_register_printf=1, working_register_printf=0,
2585               working_register_printf="$cross_working_register_printf")
2586  if test $working_register_printf = 1; then
2587    AC_DEFINE(HAVE_REGISTER_PRINTF_FUNCTION,1,
2588              [Define if you have the register_printf_function function])
2589    AC_TRY_RUN([#include "$srcdir/config/config.wprintf.c"],
2590	       wide_register_printf=1, wide_register_printf=0,
2591               wide_register_printf="$cross_wide_register_printf")
2592    if test $wide_register_printf = 1; then
2593      AC_DEFINE(HAVE_WIDE_PRINTF_FUNCTION,1,
2594              [Define if register_printf_function supports wide characters])
2595    fi
2596  fi
2597fi
2598
2599
2600#--------------------------------------------------------------------
2601# This function needed by NSString.
2602#--------------------------------------------------------------------
2603AC_CHECK_FUNCS(realpath)
2604
2605#--------------------------------------------------------------------
2606# Check if the C Library defines extern char *program_invocation_name
2607# Used in critical cases by NSProcessInfo.m
2608#--------------------------------------------------------------------
2609AC_MSG_CHECKING(program_invocation_name in C Library)
2610AC_CACHE_VAL(gs_cv_program_invocation_name_worked,
2611[AC_TRY_RUN([
2612#include <string.h>
2613int
2614main (int argc, char *argv[])
2615{
2616  extern char *program_invocation_name;
2617  return (strcmp (program_invocation_name, argv[0]));
2618}
2619], gs_cv_program_invocation_name_worked=yes, gs_cv_program_invocation_name_worked=no,
2620 gs_cv_program_invocation_name_worked="$cross_gs_cv_program_invocation_name_worked")])
2621if test $gs_cv_program_invocation_name_worked = yes; then
2622  AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME,1,
2623            [Define if your Lib C defines program_invocation_name])
2624  AC_MSG_RESULT(yes)
2625else
2626  AC_MSG_RESULT(no)
2627fi
2628
2629#--------------------------------------------------------------------
2630# Check for uname header used by NSProcessInfo.m
2631#--------------------------------------------------------------------
2632AC_CHECK_HEADERS(sys/utsname.h)
2633
2634#--------------------------------------------------------------------
2635# Check for sysctlbyname used by NSProcessInfo.m
2636#--------------------------------------------------------------------
2637AC_CHECK_HEADERS(sys/sysctl.h)
2638AC_CHECK_FUNCS(sysctlbyname)
2639
2640#--------------------------------------------------------------------
2641# Defines HAVE_PROCFS if the kernel supports the /proc filesystem.
2642# Needed by NSProcessInfo.m
2643#--------------------------------------------------------------------
2644AC_CHECK_HEADERS(procfs.h)
2645AC_SYS_PROCFS
2646AC_SYS_PROCFS_PSINFO
2647AC_SYS_PROCFS_EXE_LINK
2648
2649#--------------------------------------------------------------------
2650# Check if /proc/$$/cmdline terminates the last argument with a nul
2651#--------------------------------------------------------------------
2652AC_MSG_CHECKING(/proc/$$/cmdline terminated by nul)
2653AC_TRY_RUN([#include "$srcdir/config/config.proccmd.c"],
2654	CMDLINE_TERMINATED=1,
2655	CMDLINE_TERMINATED=0,
2656	CMDLINE_TERMINATED="$cross_CMDLINE_TERMINATED")
2657AC_DEFINE_UNQUOTED(CMDLINE_TERMINATED, $CMDLINE_TERMINATED,
2658		   [Define if your system terminates the final argument in /proc/$$/cmdline])
2659if test $CMDLINE_TERMINATED = 1; then
2660  AC_MSG_RESULT(yes)
2661else
2662  AC_MSG_RESULT(no)
2663fi
2664
2665#--------------------------------------------------------------------
2666# If /proc doesn't work, try kvm (on FreeBSD, for instance)
2667#--------------------------------------------------------------------
2668have_kvm_env=0
2669save_LIBS="$LIBS"
2670AC_CHECK_LIB(kvm, kvm_getenvv)
2671if test "$ac_cv_lib_kvm_kvm_getenvv" = yes; then
2672  AC_MSG_CHECKING(if we can access kernel memory)
2673  AC_TRY_RUN([#include "$srcdir/config/config.kvmopen.c"],
2674	have_kvm_env=1,
2675	have_kvm_env=0,
2676	have_kvm_env="$cross_have_kvm_env")
2677  if test $have_kvm_env = 1; then
2678    AC_MSG_RESULT(yes)
2679    AC_DEFINE(HAVE_KVM_ENV, 1,
2680    			    [Define if you can access the kernel via kvm_open])
2681  else
2682    AC_MSG_RESULT(no)
2683    # Reset LIBS since we don't need kvm
2684    LIBS="$save_LIBS"
2685  fi
2686fi
2687
2688#--------------------------------------------------------------------
2689# Include redefinition of main () only if needed.
2690# On some systems - force redefinition to be used as the /proc stuff
2691# doesn't work. Allow NSProcessInfo initialization method also.
2692#--------------------------------------------------------------------
2693PASS_ARG=no
2694case "$target_os" in
2695  cygwin*)	PASS_ARG=yes;;
2696esac
2697
2698AC_MSG_CHECKING(use of pass-through arguments)
2699AC_ARG_ENABLE(pass-arguments,
2700  [  --enable-pass-arguments	Force user main call to NSProcessInfo initialize],,
2701  enable_pass_arguments=$PASS_ARG)
2702
2703if test "$enable_pass_arguments" = "yes"; then
2704  GS_PASS_ARGUMENTS=1
2705else
2706  GS_PASS_ARGUMENTS=0
2707fi
2708AC_SUBST(GS_PASS_ARGUMENTS)
2709AC_MSG_RESULT($enable_pass_arguments)
2710
2711AC_MSG_CHECKING(use of fake-main definition)
2712AC_ARG_ENABLE(fake-main,
2713  [  --enable-fake-main  		Force redefine of user main function],,
2714  enable_fake_main=no)
2715
2716if test "$enable_pass_arguments" = "no"; then
2717  case "$target_os" in
2718    freebsd2*)	enable_fake_main=yes;;
2719    freebsd*)	;;
2720    kfreebsd*)	enable_fake_main=yes;;
2721    netbsd*)	enable_fake_main=yes;;
2722    openbsd*)	enable_fake_main=yes;;
2723    *sysv*)	enable_fake_main=yes;;
2724  esac
2725fi
2726
2727GS_FAKE_MAIN=0
2728if test "$enable_fake_main" = "yes"; then
2729  GS_FAKE_MAIN=1
2730elif test "$enable_pass_arguments" = "no"; then
2731  if test "$gs_cv_objc_load_method_worked" = yes -a \( "$ac_cv_sys_procfs" = yes -o "$have_kvm_env" = 1 -o "$ac_cv_sys_procfs_psinfo" = yes \); then
2732    GS_FAKE_MAIN=0
2733    if test "$have_kvm_env" = "1"; then
2734      AC_MSG_WARN([Using libkvm which is known to be buggy on some systems consider configuring with --enable-fake-main instead.])
2735    fi
2736  else
2737    case "$target_os" in
2738      darwin* ) ;;
2739      * )
2740       GS_FAKE_MAIN=1
2741       enable_fake_main=yes
2742    esac
2743  fi
2744fi
2745case "$target_os" in
2746    mingw*)	enable_fake_main=no; GS_FAKE_MAIN=0;;
2747esac
2748AC_SUBST(GS_FAKE_MAIN)
2749AC_MSG_RESULT($enable_fake_main)
2750
2751#--------------------------------------------------------------------
2752# Simple way to add a bunch of paths to the flags
2753#--------------------------------------------------------------------
2754AC_ARG_WITH(include-flags,
2755    [  --with-include-flags=FLAGS    Specify all include flags at once],
2756    include_flags="$withval", include_flags="no")
2757if test ${include_flags} != "no"; then
2758    CPPFLAGS="$CPPFLAGS ${include_flags}"
2759    INCLUDE_FLAGS="$INCLUDE_FLAGS ${include_flags}"
2760fi
2761
2762AC_ARG_WITH(library-flags,
2763    [  --with-library-flags=FLAGS    Specify all library flags at once],
2764    library_flags="$withval", library_flags="no")
2765if test ${library_flags} != "no"; then
2766    LDFLAGS="$LDFLAGS ${library_flags}"
2767    LDIR_FLAGS="$LDIR_FLAGS ${library_flags}"
2768fi
2769
2770#--------------------------------------------------------------------
2771# Check for FFI interface libraries for invocations
2772# We enable ffi by default now, as it's the only well supported
2773# library nowadays.
2774#--------------------------------------------------------------------
2775do_broken_libffi=no
2776do_broken_libffcall=no
2777do_enable_libffi=yes
2778do_enable_libffcall=no
2779case "$target_cpu" in
2780  sparc64*)
2781    case "$target_os" in
2782      solaris*)
2783        do_broken_libffcall=yes;
2784        do_enable_libffi=yes;
2785        do_enable_libffcall=no;;
2786      *) ;;
2787    esac ;;
2788  *) ;;
2789esac
2790
2791if test "$exceptions" = "yes"; then
2792  # ffcall will mess up native exceptions, so we must disable it.
2793  do_broken_libffcall=yes
2794  do_enable_libffcall=no
2795fi
2796
2797AC_ARG_ENABLE(libffi,
2798  [  --disable-libffi  		Disable use of libffi library],,
2799  enable_libffi=$do_enable_libffi)
2800
2801AC_ARG_ENABLE(ffcall,
2802  [  --enable-ffcall  		Enable use of the deprecated ffcall library],,
2803  enable_ffcall=$do_enable_libffcall)
2804
2805if test $enable_ffcall = yes; then
2806  AC_MSG_WARN([ffcall has been enabled ... this is deprecated ... please install and use a recent libffi if possible])
2807fi
2808
2809AC_ARG_ENABLE(invocations,
2810  [  --disable-invocations		Build even if invocation-dependencies are not met],,
2811  enable_invocations=yes)
2812
2813# DO isn't used on apple-apple-apple
2814if test $LIBRARY_COMBO = apple-apple-apple; then
2815  enable_invocations=no
2816fi
2817
2818AC_ARG_WITH(ffi-include,
2819[  --with-ffi-include=PATH       Include path for ffi headers],
2820    ffi_incdir="$withval", ffi_incdir="no")
2821if test ${ffi_incdir} != "no"; then
2822    CPPFLAGS="$CPPFLAGS -I${ffi_incdir}"
2823    INCLUDE_FLAGS="$INCLUDE_FLAGS -I${ffi_incdir}"
2824fi
2825
2826AC_ARG_WITH(ffi-library,
2827[  --with-ffi-library=PATH       Library path for ffi libs],
2828    ffi_libdir="$withval", ffi_libdir="no")
2829if test ${ffi_libdir} != "no"; then
2830GS_ADD_LIBRARY_PATH([${ffi_libdir}])
2831fi
2832
2833if test "$do_broken_libffi" = "no"; then
2834  if test -n "$PKG_CONFIG"; then
2835    if $PKG_CONFIG --exists libffi; then
2836      pkg_config_libffi=yes
2837      ffi_CFLAGS=`$PKG_CONFIG --cflags libffi`;
2838      CPPFLAGS="$CPPFLAGS $ffi_CFLAGS"
2839      INCLUDE_FLAGS="$INCLUDE_FLAGS $ffi_CFLAGS"
2840    fi
2841  fi
2842  AC_CHECK_HEADER(ffi.h, have_libffi=yes, have_libffi=no)
2843else
2844  have_libffi=no
2845fi
2846if test "$do_broken_libffcall" = "no"; then
2847  AC_CHECK_HEADERS(callback.h, have_ffcall=yes, have_ffcall=no)
2848else
2849  have_ffcall=no
2850fi
2851if test $have_ffcall = no; then
2852  enable_ffcall=no
2853  # If we don't have ffcall but do have libffi, use libffi
2854  if test $have_libffi = yes; then
2855    enable_libffi=yes
2856  fi
2857fi
2858if test $have_libffi = no; then
2859  enable_libffi=no
2860  # If we don't have libffi but do have ffcall, use ffcall
2861  if test $have_ffcall = yes; then
2862    if test $enable_ffcall = no; then
2863      AC_MSG_WARN([ffi support seems to be missing on this system ... please install a recent libffi])
2864    fi
2865  fi
2866fi
2867
2868have_forward_hook=yes
2869saved_CPPFLAGS="$CPPFLAGS"
2870CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
2871AC_MSG_CHECKING(for forwarding callback in runtime)
2872AC_COMPILE_IFELSE(
2873  [AC_LANG_SOURCE([[#include "$srcdir/config/config.forward2.m"]])],
2874	have_forward_hook=yes, have_forward_hook=no)
2875if test $have_forward_hook = yes; then
2876  AC_DEFINE(HAVE_FORWARD2,1,
2877            [Define if libobjc has the __objc_msg_forward2 function])
2878else
2879  AC_COMPILE_IFELSE(
2880    [AC_LANG_SOURCE([[#include "$srcdir/config/config.forward.m"]])],
2881	have_forward_hook=yes, have_forward_hook=no)
2882fi
2883AC_MSG_RESULT($have_forward_hook)
2884if test $have_forward_hook = no; then
2885  enable_libffi=no
2886  enable_ffcall=no
2887fi
2888CPPFLAGS="$saved_CPPFLAGS"
2889
2890AC_MSG_CHECKING(FFI library usage)
2891WITH_FFI=none
2892if test $enable_libffi = yes; then
2893  AC_DEFINE(USE_LIBFFI,1,
2894            [Define if using the libffi library for invocations])
2895  WITH_FFI=libffi
2896  if test "$pkg_config_libffi" = "yes"; then
2897    ffi_LIBS=`pkg-config --libs libffi`
2898  else
2899    ffi_LIBS=-lffi
2900  fi
2901  LIBS="$ffi_LIBS $LIBS"
2902  AC_TRY_RUN([#include "$srcdir/config/config.ffi.c"],
2903             ffi_ok="yes",ffi_ok="no",ffi_ok="$cross_ffi_ok")
2904  if test $ffi_ok = yes; then
2905    AC_MSG_RESULT(libffi)
2906    if test $do_broken_libffi = yes; then
2907      AC_MSG_WARN([ffi may be broken on this system ... try enabling ffcall])
2908    fi
2909    AC_CHECK_FUNCS(ffi_prep_closure_loc)
2910  else
2911    AC_MSG_ERROR([The ffi library (libffi) does not appear to be working.  Perhaps it's missing or you need a more recent version.  Version 3.0.9 or later should work, and you can find a link to it n the list of packages for download at http://www.gnustep.org/resources/sources.html])
2912  fi
2913elif test $enable_ffcall = yes; then
2914  AC_DEFINE(USE_FFCALL,1,
2915            [Define if using the ffcall library for invocations])
2916  WITH_FFI=ffcall
2917  LIBS="-lcallback -lavcall $LIBS"
2918  AC_TRY_LINK([#include <callback.h>], , ffi_ok="yes", ffi_ok="no")
2919  if test $ffi_ok = yes; then
2920    AC_MSG_RESULT(ffcall)
2921  fi
2922  AC_MSG_WARN([ffcall is broken on some systems and is deprecated ... try enabling ffi])
2923else
2924  ffi_ok=no
2925fi
2926
2927if test $enable_ffcall = yes -a $ffi_ok = yes; then
2928  AC_MSG_CHECKING(if ffcall trampolines work)
2929  AC_RUN_IFELSE(
2930    [AC_LANG_SOURCE([[#include "$srcdir/config/config.trampoline.c"]])],
2931	  have_working_trampoline=yes, have_working_trampoline=no,
2932	  have_working_trampoline=yes)
2933  AC_MSG_RESULT($have_working_trampoline)
2934fi
2935
2936if test $ffi_ok = no; then
2937  AC_MSG_RESULT(none)
2938  echo
2939  if test $have_forward_hook = no; then
2940    echo "You do not have an up-to-date libobjc library installed"
2941  elif test "$have_working_trampoline" = no; then
2942    echo "You have ffcall, but it does not work properly. Most likely because"
2943    echo "your system's security policy is blocking some parts of ffcall"
2944    echo "we recommend installing libffi instead."
2945  else
2946    echo "You do not have either ffcall or libffi installed/enabled, or configure needs"
2947    echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them,"
2948    echo "or you have ffcall but gnustep-make is configured to use native exceptions"
2949    echo "(native exceptions are not compatible with ffcall)."
2950  fi
2951  echo "GNUstep requires libffi (or ffcall) and proper libobjc hooks to do"
2952  echo "invocations and DO."
2953  echo "(This does not apply on apple-apple-apple systems where DO is"
2954  echo "not compatible with other GNUstep systems.)"
2955  if test $enable_invocations = yes; then
2956    echo
2957    echo "You most likely do not want to build base without invocation support."
2958    echo "Many things (including Distributed Objects and undo/redo), won't work"
2959    echo "at all without invocations."
2960    echo "If you really want to build -base without invocation support,"
2961    echo "add --disable-invocations to the configure arguments."
2962    echo "For more information, read the GNUstep build guide, ffcall section:"
2963    echo "http://gnustep.made-it.com/BuildGuide/index.html"
2964    AC_MSG_ERROR([Incomplete support for ffi functionality.])
2965  fi
2966  AC_MSG_WARN([Incomplete support for ffi funtionality.])
2967fi
2968AC_SUBST(WITH_FFI)
2969
2970
2971#--------------------------------------------------------------------
2972# Check for iconv support (for Unicode conversion).
2973#--------------------------------------------------------------------
2974# Do this before checking for xml2,  as xml2 may require iconv.
2975#
2976# We need to find an iconv library that matches the installed iconv.h header
2977# (if any). It is important to check header/library compatibility. It's
2978# fairly common to have iconv support both in libc and from libiconv. In that
2979# case, a naive check that iconv() is in libc will succeed, but if we use
2980# libiconv's iconv.h, it will redefine iconv() to functions that exist
2981# only in libiconv, and we'll get link errors.
2982#
2983# Some versions of iconv don't support the '//TRANSLIT' option, which is
2984# needed for a lossy conversion (where we pick the closest equivalent for
2985# any character present in the source string which does not exist in the
2986# destination characterset), so we check for support of that first.
2987
2988# First, check if there's a working iconv in libc (ie. if the test program
2989# runs without any extra flags).
2990AC_ARG_ENABLE(iconv,
2991  [  --disable-iconv		Build even if iconv is not available],,
2992  enable_iconv=yes)
2993
2994if test $enable_iconv = yes; then
2995AC_MSG_CHECKING(iconv support)
2996AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
2997int main(int argc,char **argv)
2998{ return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
2999,
3000  # libc has a working iconv.
3001  AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3002  AC_MSG_RESULT([[yes, in libc]])
3003  found_iconv=yes
3004,
3005  found_iconv=no
3006,
3007  found_iconv="$cross_found_iconv_libc",
3008)
3009
3010if test $found_iconv = no ; then
3011  # libc doesn't have a working iconv with translit.
3012  # Try adding -liconv and any user supplied directory.
3013  AC_ARG_WITH(libiconv-library,
3014    [  --with-libiconv-library=PATH  Library path for libiconv libraries],
3015    libiconv_libdir="$withval", libiconv_libdir="no")
3016
3017  if test "$libiconv_libdir" != "no"; then
3018    GS_ADD_LIBRARY_PATH([${libiconv_libdir}])
3019  fi
3020
3021  old_LIBS="$LIBS"
3022  LIBS="-liconv $LIBS"
3023  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
3024  int main(int argc,char **argv)
3025  { return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
3026  ,
3027    # -liconv works.
3028    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3029    AC_MSG_RESULT([[yes, -liconv]])
3030    found_iconv=yes
3031  ,
3032    found_iconv=no
3033    LIBS="$old_LIBS"
3034  ,
3035    found_iconv="$cross_found_iconv_liconv";
3036    if test "$found_iconv" = "no"; then
3037      LIBS="$old_LIBS"
3038    fi
3039  )
3040fi
3041
3042if test $found_iconv = no ; then
3043  # -liconv with translit didn't work. Try giconv.h and -lgiconv.
3044  # BSDs install this lib as libgiconv.
3045  old_LIBS="$LIBS"
3046  LIBS="-lgiconv $LIBS"
3047  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <giconv.h>
3048  int main(int argc,char **argv)
3049  { return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
3050  ,
3051    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3052    AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
3053    AC_MSG_RESULT([[yes, -lgiconv]])
3054    found_iconv=yes
3055  ,
3056    found_iconv=no
3057    LIBS="$old_LIBS"
3058  ,
3059    found_iconv="$cross_found_iconv_lgiconv";
3060    if test "$found_iconv" = "no"; then
3061      LIBS="$old_LIBS"
3062    fi
3063  )
3064fi
3065
3066AC_ARG_ENABLE(stricticonv,
3067  [  --enable-stricticonv		Build even if iconv is strict],,
3068  enable_stricticonv=no)
3069if test $enable_stricticonv = yes; then
3070AC_MSG_CHECKING(non-lossy iconv support)
3071AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
3072int main(int argc,char **argv)
3073{ return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
3074,
3075  # libc has a working iconv.
3076  AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3077  AC_MSG_RESULT([[yes, in libc]])
3078  found_iconv=yes
3079,
3080  found_iconv=no
3081)
3082
3083if test $found_iconv = no ; then
3084  # libc doesn't have a working iconv. Try adding -liconv and any user
3085  # supplied directory.
3086  AC_ARG_WITH(libiconv-library,
3087    [  --with-libiconv-library=PATH  Library path for libiconv libraries],
3088    libiconv_libdir="$withval", libiconv_libdir="no")
3089
3090  if test "$libiconv_libdir" != "no"; then
3091    GS_ADD_LIBRARY_PATH([${libiconv_libdir}])
3092  fi
3093
3094  old_LIBS="$LIBS"
3095  LIBS="-liconv $LIBS"
3096  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
3097  int main(int argc,char **argv)
3098  { return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
3099  ,
3100    # -liconv works.
3101    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3102    AC_MSG_RESULT([[yes, -liconv]])
3103    found_iconv=yes
3104  ,
3105    found_iconv=no
3106    LIBS="$old_LIBS"
3107  )
3108fi
3109
3110if test $found_iconv = no ; then
3111  # -liconv didn't work. Try giconv.h and -lgiconv.
3112  # BSDs install this lib as libgiconv.
3113  old_LIBS="$LIBS"
3114  LIBS="-lgiconv $LIBS"
3115  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <giconv.h>
3116  int main(int argc,char **argv)
3117  { return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
3118  ,
3119    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
3120    AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
3121    AC_MSG_RESULT([[yes, -lgiconv]])
3122    found_iconv=yes
3123  ,
3124    found_iconv=no
3125    LIBS="$old_LIBS"
3126  )
3127fi
3128fi
3129
3130if test $found_iconv = no ; then
3131  AC_MSG_RESULT([[no]])
3132  echo
3133  echo "You do not appear to have usable iconv header/library."
3134  echo "Building without them will disable much characterset support."
3135  echo "If you really want to build gnustep-base without character conversion"
3136  echo " support, please add --disable-iconv to the configure arguments."
3137  AC_MSG_ERROR([Missing support for character conversion functionality.])
3138fi
3139fi
3140
3141#--------------------------------------------------------------------
3142# Check recent libxml2 for GSXML and NSXMLNode
3143# See DEPENDENCIES POLICY at the start of this file.
3144#--------------------------------------------------------------------
3145AC_ARG_ENABLE(xml,
3146  [  --disable-xml			Build even if XML-dependencies are not met],,
3147  enable_xml=yes)
3148
3149HAVE_LIBXML=0
3150
3151if test $enable_xml = yes; then
3152  PKG_CHECK_MODULES([XML], [libxml-2.0 >= 2.3.0], [enable_libxml=yes], [
3153    AM_PATH_XML(2.3.0, enable_libxml=yes, enable_libxml=no)
3154  ])
3155
3156  if test $enable_libxml = yes; then
3157    CPPFLAGS="$CPPFLAGS $XML_CFLAGS"
3158    INCLUDE_FLAGS="$INCLUDE_FLAGS $XML_CFLAGS"
3159    LIBS="$XML_LIBS $LIBS"
3160    HAVE_LIBXML=1
3161    AC_DEFINE(HAVE_LIBXML,1,[Define if libxml available])
3162    AC_CHECK_HEADERS(libxml/SAX2.h)
3163
3164    #--------------------------------------------------------------------
3165    # Check for (optional) libxslt
3166    #--------------------------------------------------------------------
3167    AC_ARG_ENABLE(xslt,
3168      [  --disable-xslt		Build even if XSLT-dependency is not met],,
3169      enable_xslt=yes)
3170
3171    if test $enable_xslt = yes; then
3172      AC_CHECK_LIB(xslt, xsltApplyStylesheet, xslt_ok=yes, xslt_ok=no)
3173      if test "$xslt_ok" = "yes"; then
3174	AC_CHECK_HEADER(libxslt/xslt.h, xslthdr_ok=yes, xslthdr_ok=no)
3175	if test "$xslthdr_ok" = "no"; then
3176	  xslt_ok=no
3177	fi
3178      fi
3179      if test "$xslt_ok" = "yes"; then
3180	HAVE_LIBXSLT=1
3181	AC_DEFINE(HAVE_LIBXSLT,1,[Define if libxslt available])
3182	LIBS="-lxslt $LIBS"
3183      else
3184	echo
3185	echo "You do not appear to have usable libxslt headers/library."
3186	echo "Building without them will disable the XSLT extensions."
3187	echo "If you really want to build gnustep-base without XSLT support,"
3188	echo "add --disable-xslt to the configure arguments to avoid warning."
3189	AC_MSG_WARN([Missing support for XSLT functionality.])
3190      fi
3191    else
3192      HAVE_LIBXSLT=0
3193      AC_MSG_WARN([Disabled support for XSLT funtionality.])
3194    fi
3195    AC_SUBST(HAVE_LIBXSLT)
3196  else
3197    echo
3198    echo "You do not appear to have usable libxml2 headers/library."
3199    echo "Building without them will disable the GSXML and NSXMLNode."
3200    echo "If you really want to build gnustep-base without XML DOM support"
3201    echo " (though NSXMLParser is unaffected),  please"
3202    echo "add --disable-xml to the configure arguments."
3203    AC_MSG_ERROR([Missing support for XML DOM functionality.])
3204  fi
3205else
3206  AC_MSG_WARN([XML functionality disabled.])
3207fi
3208AC_SUBST(HAVE_LIBXML)
3209
3210#--------------------------------------------------------------------
3211# Check recent libgnutls for SSL streams.
3212# See DEPENDENCIES POLICY at the start of this file.
3213#--------------------------------------------------------------------
3214AC_ARG_ENABLE(tls,
3215  [  --disable-tls			Disable use of GNUTLS],,
3216  enable_tls=yes)
3217
3218if test $enable_tls = yes; then
3219  HAVE_GNUTLS=0
3220  # Save CFLAGS and LIBS as AM_PATH_TLS clobbers these variables regardless
3221  # of the success of the macro.
3222  saved_LIBS="$LIBS"
3223  saved_CFLAGS="$CFLAGS"
3224
3225  if test -n "$PKG_CONFIG"; then
3226    if pkg-config --exists gnutls; then
3227      AC_MSG_CHECKING(gnutls support)
3228      HAVE_GNUTLS=1
3229      TLS_CFLAGS=`$PKG_CONFIG --cflags gnutls`
3230      TLS_LIBS=`$PKG_CONFIG --libs gnutls`
3231    fi
3232  fi
3233
3234  if test $HAVE_GNUTLS = 0; then
3235    #  AM_PATH_TLS(2.0.1, enable_libgnutls=yes, enable_libgnutls=no)
3236    AM_PATH_TLS(1.4.0, enable_libgnutls=yes, enable_libgnutls=no)
3237    if test $enable_libgnutls = yes; then
3238      HAVE_GNUTLS=1
3239    else
3240      HAVE_GNUTLS=0
3241    fi
3242  fi
3243  if test $HAVE_GNUTLS = 1; then
3244    if ! pkg-config --atleast-version=2.12 gnutls; then
3245      AC_CHECK_LIB(gcrypt, gcry_control, have_gcrypt=yes, have_gcrypt=no)
3246      if test "$have_gcrypt" = "no"; then
3247        HAVE_GNUTLS=0
3248      else
3249        TLS_LIBS="$TLS_LIBS -lgcrypt"
3250      fi
3251    fi
3252  fi
3253  if test $HAVE_GNUTLS = 0; then
3254    # Restore the CFLAGS and LIBS because AM_PATH_TLS messes them
3255    LIBS="$saved_LIBS"
3256    CFLAGS="$saved_CFLAGS"
3257    AC_MSG_RESULT(no)
3258    echo
3259    echo "You do not appear to have usable libgnutls headers/library."
3260    echo "Building without them will disable SSL/TLS/HTTPS in NSStream,"
3261    echo "NSFileHandle, NSURLHandle and NSURLConnection."
3262    echo "If you really want to build gnustep-base without TLS support,"
3263    echo "add --disable-tls to the configure arguments."
3264    AC_MSG_ERROR([Missing support for TLS functionality.])
3265  else
3266    AC_MSG_RESULT(yes)
3267    CPPFLAGS="$CPPFLAGS $TLS_CFLAGS"
3268    INCLUDE_FLAGS="$INCLUDE_FLAGS $TLS_CFLAGS"
3269    LIBS="$TLS_LIBS $LIBS"
3270    AC_CHECK_FUNCS(gnutls_transport_set_errno)
3271    if test "$ac_cv_func_gnutls_transport_set_errno" = "no"; then
3272      AC_MSG_WARN([Missing support for thread-safe error handling in GNUTLS.  Please check that you have the most recent version installed (2.0 or later chould be fine).])
3273    fi
3274    AC_CHECK_FUNCS(gnutls_x509_privkey_import2)
3275  fi
3276else
3277  AC_MSG_WARN([Disabled support for TLS funtionality.])
3278  HAVE_GNUTLS=0
3279fi
3280if test $HAVE_GNUTLS = 1; then
3281  AC_DEFINE_UNQUOTED(HAVE_GNUTLS,$HAVE_GNUTLS,[Define if libgnutls available])
3282fi
3283AC_SUBST(HAVE_GNUTLS)
3284
3285#--------------------------------------------------------------------
3286# Check for NSNetServices
3287# See DEPENDENCIES POLICY at the start of this file.
3288#--------------------------------------------------------------------
3289HAVE_MDNS=0
3290HAVE_AVAHI=0
3291AC_ARG_ENABLE(zeroconf,
3292  [  --disable-zeroconf		Disable NSNetServices support],,
3293  enable_zeroconf=yes)
3294AC_ARG_WITH(zeroconf-api,
3295  [  --with-zeroconf-api=API  force use of a specific zeroconf API (mdns or avahi)],
3296  zeroconf_api="$withval", zeroconf_api="any")
3297if test $enable_zeroconf = yes; then
3298  if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "mdns"; then
3299    AC_CHECK_HEADERS(dns_sd.h, have_mdns=yes, have_mdns=no)
3300    if test "$have_mdns" = "yes"; then
3301      AC_CHECK_LIB(dns_sd, DNSServiceBrowse, have_mdns=yes, have_mdns=no)
3302      if test "$have_mdns" = "yes"; then
3303        MDNS_LIBS="-ldns_sd"
3304        HAVE_MDNS=1
3305      fi
3306    fi
3307  fi
3308  if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "avahi"; then
3309    AC_CHECK_HEADERS(avahi-client/client.h, have_avahi=yes, have_avahi=no)
3310    if test "$have_avahi" = "yes"; then
3311      AC_CHECK_LIB(avahi-client, avahi_client_new, have_avahi=yes, have_avahi=no)
3312      if test "$have_avahi" = "yes"; then
3313        AVAHI_LIBS="-lavahi-common -lavahi-client"
3314        HAVE_AVAHI=1
3315      fi
3316    fi
3317  fi
3318  # If we have both APIs, prefer Avahi, because the mDNS API
3319  # is most certainly the compatability one
3320  if test "$have_avahi" = "yes" && test "$have_mdns" = "yes"; then
3321    LIBS="$AVAHI_LIBS $LIBS"
3322    HAVE_MDNS=0
3323  else
3324    # One of those will be empty.
3325    LIBS="$AVAHI_LIBS $MDNS_LIBS $LIBS"
3326  fi
3327fi
3328AC_SUBST(HAVE_MDNS)
3329AC_SUBST(HAVE_AVAHI)
3330#--------------------------------------------------------------------
3331# Check for International Components for Unicode
3332# See DEPENDENCIES POLICY at the start of this file.
3333#--------------------------------------------------------------------
3334HAVE_ICU=0
3335AC_ARG_ENABLE(icu,
3336  [  --disable-icu			Disable International Components for Unicode],,
3337  enable_icu=yes)
3338
3339if test "$enable_icu" = "yes"; then
3340  PKG_CHECK_MODULES([ICU], [icu-i18n > 49.0])
3341  AC_CHECK_HEADERS(unicode/uloc.h unicode/ulocdata.h unicode/ucol.h unicode/ucurr.h unicode/uregex.h unicode/ucal.h unicode/unorm2.h unicode/unum.h unicode/udat.h unicode/udatpg.h unicode/ustring.h unicode/usearch.h unicode/ucnv.h)
3342  LIBS="$LIBS $ICU_LIBS"
3343  HAVE_ICU=1
3344fi
3345AC_SUBST(HAVE_ICU)
3346
3347#--------------------------------------------------------------------
3348# Check for libdispatch
3349# See DEPENDENCIES POLICY at the start of this file.
3350#--------------------------------------------------------------------
3351HAVE_LIBDISPATCH=0
3352AC_ARG_ENABLE(libdispatch,
3353  [  --disable-libdispatch		Disable dispatching blocks via libdispatch],
3354  enable_libdispatch=$enableval,
3355  enable_libdispatch=yes)
3356
3357if test $enable_libdispatch = yes; then
3358  AC_CHECK_HEADERS(dispatch.h, have_dispatch=yes, have_dispatch=no)
3359  if test "$have_dispatch" = "no"; then
3360    AC_CHECK_HEADERS(dispatch/dispatch.h, have_dispatch=yes, have_dispatch=no)
3361    # check for private header which includes runloop integration functions in
3362    # the Swift corelibs libdispatch release
3363    AC_CHECK_HEADERS(dispatch/private.h)
3364  fi
3365  if test "$have_dispatch" = "yes"; then
3366    AC_CHECK_LIB(dispatch, dispatch_queue_create, have_dispatch=yes, have_dispatch=no)
3367    if test "$have_dispatch" = "yes"; then
3368      saveLIBS="$LIBS"
3369      LIBS="-lobjc -ldispatch";
3370      # This check is needed because libdispatch might be linked against a
3371      # version of libBlocksRuntime that defines symbols conflicting with libobjc
3372      AC_MSG_CHECKING(whether we can link libdispatch and libobjc at the same time)
3373      AC_TRY_LINK(,,have_dispatch=yes, have_dispatch=no)
3374      if test "$have_dispatch" = "yes"; then
3375	LIBS="$saveLIBS -ldispatch";
3376	AC_MSG_RESULT(yes);
3377	HAVE_LIBDISPATCH=1;
3378      else
3379	LIBS="$saveLIBS";
3380	AC_MSG_RESULT(no);
3381      fi
3382    fi
3383  else
3384  HAVE_LIBDISPATCH=0;
3385  # just ignore libdispatch if it's not there
3386  fi
3387fi
3388AC_SUBST(HAVE_LIBDISPATCH)
3389
3390HAVE_LIBDISPATCH_RUNLOOP=0
3391if test $HAVE_LIBDISPATCH = 1; then
3392  # We check whether we have a variant of libdispatch that allows runloop
3393  # integration
3394  AC_CHECK_FUNCS(dispatch_main_queue_drain_np dispatch_get_main_queue_handle_np)
3395  if test "$ac_cv_func_dispatch_main_queue_drain_np" = "yes" && test "$ac_cv_func_dispatch_get_main_queue_handle_np" = "yes"; then
3396    HAVE_LIBDISPATCH_RUNLOOP=1
3397  fi
3398  # Check for "_4CF" variants of runloop integration functions provided by the
3399  # Swift corelibs libdispatch release
3400  AC_CHECK_FUNCS(_dispatch_main_queue_callback_4CF _dispatch_get_main_queue_handle_4CF)
3401  if test "$ac_cv_func__dispatch_main_queue_callback_4CF" = "yes" && test "$ac_cv_func__dispatch_get_main_queue_handle_4CF" = "yes"; then
3402    HAVE_LIBDISPATCH_RUNLOOP=1
3403  fi
3404fi
3405AC_SUBST(HAVE_LIBDISPATCH_RUNLOOP)
3406
3407#--------------------------------------------------------------------
3408# Check GMP for NSDecimal
3409#--------------------------------------------------------------------
3410AC_ARG_WITH(gmp-include,
3411  [  --with-gmp-include=PATH  include path for gmp headers],
3412  gmp_incdir="$withval", gmp_incdir="no")
3413
3414AC_ARG_WITH(gmp-library,
3415  [  --with-gmp-library=PATH  library path for gmp libraries],
3416  gmp_libdir="$withval", gmp_libdir="no")
3417
3418libs_temp=$LIBS
3419
3420if test "$gmp_incdir" != "no"; then
3421  CPPFLAGS="$CPPFLAGS -I$gmp_incdir"
3422  INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gmp_incdir"
3423fi
3424if test "$gmp_libdir" != "no"; then
3425  GS_ADD_LIBRARY_PATH([${gmp_libdir}])
3426fi
3427
3428USE_GMP=0
3429AC_CHECK_HEADERS(gmp.h)
3430if test $ac_cv_header_gmp_h = yes; then
3431  AC_CHECK_LIB(gmp, mpf_abs, gmp_ok=yes, gmp_ok=no)
3432  if test "$gmp_ok" = no; then
3433    AC_CHECK_LIB(gmp, __gmpf_abs, gmp_ok=yes, gmp_ok=no)
3434  fi
3435  if test "$gmp_ok" = yes; then
3436    LIBS="-lgmp $LIBS"
3437    USE_GMP=1
3438  fi
3439fi
3440
3441AC_SUBST(USE_GMP)
3442
3443
3444#--------------------------------------------------------------------
3445# Check whether nl_langinfo(CODESET) is supported, needed by Unicode.m.
3446#--------------------------------------------------------------------
3447AM_LANGINFO_CODESET
3448
3449
3450AC_SUBST(INCLUDE_FLAGS)
3451AC_SUBST(LDIR_FLAGS)
3452
3453#--------------------------------------------------------------------
3454# Check for -Wdeclaration-after-statement
3455#--------------------------------------------------------------------
3456AC_MSG_CHECKING(whether the compiler supports -Wdeclaration-after-statement)
3457
3458saved_CFLAGS="$CFLAGS"
3459CFLAGS="$CFLAGS -Wdeclaration-after-statement"
3460AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],HAS_W_DECL_AFTER_STATEMENT=yes,HAS_W_DECL_AFTER_STATEMENT=no)
3461CFLAGS="$saved_CFLAGS"
3462
3463AC_MSG_RESULT($HAS_W_DECL_AFTER_STATEMENT)
3464
3465if test x"$HAS_W_DECL_AFTER_STATEMENT" = x"yes"; then
3466  WARN_FLAGS="-Wall -Wdeclaration-after-statement"
3467else
3468  WARN_FLAGS=-Wall
3469fi
3470
3471AC_SUBST(WARN_FLAGS)
3472
3473#--------------------------------------------------------------------
3474# Check if we should use an alternative gdomap port
3475#--------------------------------------------------------------------
3476AC_ARG_WITH(gdomap-port,
3477  [  --with-gdomap-port=PORT  alternative port for gdomap],
3478  gdomap_port="$withval", gdomap_port="no")
3479
3480if test "$gdomap_port" = "no"; then
3481  GNUSTEP_GDOMAP_PORT_OVERRIDE="$gdomap_port"
3482else
3483  GNUSTEP_GDOMAP_PORT_OVERRIDE="$gdomap_port"
3484fi
3485AC_SUBST(GNUSTEP_GDOMAP_PORT_OVERRIDE)
3486
3487#--------------------------------------------------------------------
3488# Check if we should install gdomap as setuid
3489#--------------------------------------------------------------------
3490AC_MSG_CHECKING([if we should install gdomap as setuid])
3491AC_ARG_ENABLE(setuid-gdomap,[
3492  --enable-setuid-gdomap        Enable installing gdomap as a setuid
3493                                executable.  By default, it is installed
3494                                as a normal program intended to be started
3495				by root at system boot time, but it can
3496                                also be started up automatically
3497                                by any user at any time.  Use this
3498                                option if you are happy having the program
3499                                started automatically on demand.
3500],
3501  ac_cv_setuid_gdomap=$enableval,
3502  ac_cv_setuid_gdomap="no")
3503
3504if test "$ac_cv_setuid_gdomap" = "yes"; then
3505  AC_MSG_RESULT(yes);
3506  GNUSTEP_INSTALL_GDOMAP_AS_SETUID="yes"
3507else
3508  AC_MSG_RESULT(no);
3509  GNUSTEP_INSTALL_GDOMAP_AS_SETUID="no"
3510fi
3511
3512AC_SUBST(GNUSTEP_INSTALL_GDOMAP_AS_SETUID)
3513
3514#--------------------------------------------------------------------
3515# Record the version
3516#--------------------------------------------------------------------
3517AC_MSG_CHECKING(for the version of gnustep-base we are compiling)
3518if test -f "Version"; then
3519  . ./Version
3520fi
3521AC_MSG_RESULT($VERSION)
3522AC_SUBST(VERSION)
3523AC_SUBST(MAJOR_VERSION)
3524AC_SUBST(MINOR_VERSION)
3525AC_SUBST(SUBMINOR_VERSION)
3526AC_SUBST(GCC_VERSION)
3527
3528#--------------------------------------------------------------------
3529# Write the Makefiles
3530#--------------------------------------------------------------------
3531AC_CONFIG_FILES([config.mak base.make Headers/GNUstepBase/GSConfig.h])
3532AC_OUTPUT
3533