1#
2#   configure.ac
3#
4#   Copyright (C) 1997-2007 Free Software Foundation, Inc.
5#
6#   Author:  Scott Christley <scottc@net-community.com>
7#	     Ovidiu Predescu <ovidiu@net-community.com>
8#   Rewrite: Adam Fedor <fedor@gnu.org>
9#            Nicola Pero <n.pero@mi.flashnet.it>
10#
11#   This file is part of the GNUstep Makefile Package.
12#
13#   This library is free software; you can redistribute it and/or
14#   modify it under the terms of the GNU General Public License
15#   as published by the Free Software Foundation; either version 3
16#   of the License, or (at your option) any later version.
17#
18#   You should have received a copy of the GNU General Public
19#   License along with this library; see the file COPYING.
20#   If not, write to the Free Software Foundation,
21#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23AC_INIT
24AC_PREREQ(2.57)
25AC_CONFIG_SRCDIR([application.make])
26AC_CONFIG_MACRO_DIRS([m4])
27
28#
29# TODO: This configure file should not contain any checks that depend on the
30# Objective-C runtime being used or available.  This is because on
31# some platforms the Objective-C runtime itself is compiled using
32# gnustep-make!
33#
34# All the runtime-dependent checks should go in gnustep-base.
35#
36# We still need compiler checks, because if we are compiling the
37# Objective-C runtime itself, we need to know what compiler we have
38# and what flags we can use.  But these checks should test
39# compilation, not linking or execution, because we don't necessarily
40# have an Objective-C runtime available yet.
41#
42
43targetArgument=${target}
44
45AC_CANONICAL_TARGET([])
46
47AC_PATH_PROG(GNUSTEP_HAS_PKGCONFIG, pkgconfig, yes, no)
48AC_CHECK_PROG([HAVE_GNUSTEP_CONFIG], [gnustep-config], yes, no)
49#--------------------------------------------------------------------
50# Setup the library combination
51#--------------------------------------------------------------------
52GS_LIBRARY_COMBO()
53
54# The ng runtime library setting requires clang rather than gcc
55if test "$OBJC_RUNTIME_LIB" = "ng"; then
56  defaultng=yes;
57  if test "$OBJCC" = ""; then
58    OBJCC=clang
59  fi
60  if test "$CC" = ""; then
61    CC=clang
62  fi
63  if test "$OBJCXX" = ""; then
64    OBJCXX=clang++
65  fi
66  if test "$CXX" = ""; then
67    CXX=clang++
68  fi
69else
70  defaultng=no;
71fi
72
73AC_PROG_CC
74AC_PROG_CPP
75
76# We also look for a C++ compiler.  While not strictly needed, some
77# people use gnustep-make to compile C++ code.  It's nice to detect a
78# C++ compiler, if we have one, and automatically use it to
79# compile/link C++ code. :-)
80AC_PROG_CXX
81
82# Similarly for the ObjC++ compiler ... but only new versions of autoconf
83# support it, so we pretend by using the C++ compiler
84#AC_PROG_OBJCXX
85OBJCXX="${CXX}"
86
87# We may use egrep for some tests further down below
88AC_PROG_EGREP
89
90#--------------------------------------------------------------------
91# Check if we are using Apple cc
92#--------------------------------------------------------------------
93cc_cppprecomp=0
94cc_byndle=0
95AC_MSG_CHECKING([for apple compiler flags])
96cc_cppprecomp=`${CC} -no-cpp-precomp 2>&1 | grep -c "unrecognized"`
97cc_bundle=`${CC} -bundle 2>&1 | grep -c "couldn"`
98# 0 means we have the flag
99if test $cc_cppprecomp = 0; then
100  cc_cppprecomp=yes
101else
102  cc_cppprecomp=no
103fi
104if test $cc_bundle = 0; then
105  cc_bundle=yes
106else
107  cc_bundle=no
108fi
109AC_MSG_RESULT($cc_bundle)
110AC_SUBST(cc_cppprecomp)
111AC_SUBST(cc_bundle)
112
113#--------------------------------------------------------------------
114# specific target_os options
115#--------------------------------------------------------------------
116case "$target_os" in
117  freebsd* | openbsd* )
118	        INCLUDES="$INCLUDES -I/usr/local/include"
119		LIB_DIR="$LIB_DIR -L/usr/local/lib";;
120  netbsd*)	INCLUDES="$INCLUDES -I/usr/pkg/include"
121		LIB_DIR="$LIB_DIR -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
122esac
123
124#--------------------------------------------------------------------
125# Determine the host, build, and target systems
126#--------------------------------------------------------------------
127case $host_os in
128  *cygwin*  )
129	MINGW32=no
130	MINGW64=no
131	CYGWIN=yes
132	MSWIND=yes;;
133  *mingw32* )
134	MINGW32=yes
135	MINGW64=no
136	CYGWIN=no
137	MSWIND=yes;;
138  *mingw64* )
139	MINGW32=no
140	MINGW64=yes
141	CYGWIN=no
142	MSWIND=yes;;
143          * )
144	MINGW32=no
145	MINGW64=no
146	CYGWIN=no
147	MSWIND=no;;
148esac
149AC_SUBST(CYGWIN)
150
151AC_EXEEXT
152AC_OBJEXT
153if test "$MINGW32" = yes; then
154  echo "hosted on mingw32 .."
155  export SHELL=sh
156  if test "$OBJC_RUNTIME_LIB" = ng; then
157    export CC=${CC:-clang}
158  else
159    export CC=${CC:-gcc}
160  fi
161  export AR=${AR:-ar}
162  export RANLIB=${RANLIB:-ranlib}
163  export DLLTOOL=${DLLTOOL:-dlltool}
164elif test "$MINGW64" = yes; then
165  echo "hosted on mingw64 .."
166  export SHELL=sh
167  if test "$OBJC_RUNTIME_LIB" = ng; then
168    export CC=${CC:-clang}
169  else
170    export CC=${CC:-gcc}
171  fi
172  export AR=${AR:-ar}
173  export RANLIB=${RANLIB:-ranlib}
174  export DLLTOOL=${DLLTOOL:-dlltool}
175elif test "$CYGWIN" = yes; then
176  echo "hosted on cygwin .."
177  if test "$OBJC_RUNTIME_LIB" = ng; then
178    export CC=${CC:-clang}
179  else
180    export CC=${CC:-gcc}
181  fi
182  export AR=${AR:-ar}
183  export RANLIB=${RANLIB:-ranlib}
184  export DLLTOOL=${DLLTOOL:-dlltool}
185fi
186
187GS_CHECK_CC_IS_CLANG()
188
189#--------------------------------------------------------------------
190# Find the binary and compile tools
191#--------------------------------------------------------------------
192if test "x$target" != "x$host"; then
193  echo "cross compiling from $host to $target .."
194  cross_compiling="yes"
195  if test "$OBJC_RUNTIME_LIB" = ng -o x"$gs_cv_cc_is_clang" = x"yes"; then
196    AC_CHECK_PROG(CC,    "${targetArgument}-clang",   dnl
197                         "${targetArgument}-clang",   clang)
198  else
199    AC_CHECK_PROG(CC,    "${targetArgument}-gcc",     dnl
200                         "${targetArgument}-gcc",     gcc)
201  fi
202  AC_CHECK_PROG(RANLIB,  "${targetArgument}-ranlib",  dnl
203                         "${targetArgument}-ranlib",  ranlib)
204  AC_CHECK_PROG(AR,      "${targetArgument}-ar",      dnl
205                         "${targetArgument}-ar",      ar)
206  AC_CHECK_PROG(DLLTOOL, "${targetArgument}-dlltool", dnl
207                         "${targetArgument}-dlltool", dlltool)
208else
209  if test "$OBJC_RUNTIME_LIB" = ng; then
210    #
211    # Detect compiler support for Blocks; perhaps someday -fblocks won't be
212    # required, in which case we'll need to change this.
213    #
214    saveCFLAGS="$CFLAGS"
215    CFLAGS="$CFLAGS -fblocks"
216    AC_LANG_PUSH(C)
217    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [
218      ac_cv_blocks="yes"
219    ], [
220      ac_cv_blocks="no"
221    ])
222    CFLAGS="$saveCFLAGS"
223    AC_LANG_POP(C)
224    if test "$ac_cv_blocks" = no; then
225      AC_MSG_ERROR([Your compiler doesn't appear to support blocks. To fix this use the CC environment varibale to specify a different compiler (or use a different library-combo)]);
226    fi
227  fi
228  AC_CHECK_PROG(AR,      ar,      ar)
229  AC_CHECK_PROG(DLLTOOL, dlltool, dlltool)
230  AC_PROG_RANLIB
231fi
232
233AC_PROG_INSTALL
234
235AC_MSG_CHECKING([if 'install -p' works])
236gs_install_p_test_builddir="`pwd`"
237gs_install_p_test_results=`(INSTALL="$INSTALL"; export INSTALL; cd "$srcdir/config-install-p-test/"; ./run-test.sh "$gs_install_p_test_builddir"; echo $?) 2>&5`
238if test "$gs_install_p_test_results" = "0"; then
239  AC_MSG_RESULT(yes);
240else
241  AC_MSG_RESULT(no);
242fi
243
244AC_MSG_CHECKING([if we should use 'install -p' when installing files])
245AC_ARG_ENABLE(install-p, [
246--disable-install-p
247  Disable using 'install -p' when installing files.  By default,
248  assuming that 'install -p' works, when installing files such as header files or libraries,
249  gnustep-make uses 'install -p', which preserves the original timestamp of the header file or
250  library.  If you do not want the timestamp to be preserved, use this option
251  to have gnustep-make use 'install' instead of 'install -p'.
252  Unless you have a specific reason for not liking the default behaviour
253  this option is most likely irrelevant for you.
254],
255  ac_cv_install_p=$enableval,
256  ac_cv_install_p="yes")
257
258if test "$ac_cv_install_p" = "yes"; then
259  if test "$gs_install_p_test_results" = "0"; then
260    AC_MSG_RESULT(yes);
261    INSTALL="${INSTALL} -p"
262  else
263    AC_MSG_RESULT(no: install -p does not work);
264  fi
265else
266  AC_MSG_RESULT(no);
267fi
268
269AC_PROG_LN_S([])
270
271AC_CHECK_PROGS(NM, gnm, nm)
272
273
274AC_CHECK_PROGS(TAR, gnutar gtar, tar)
275AC_ARG_WITH(tar,[
276--with-tar
277   Set the name of the tar program to use.  Use this option if the
278   default choice does not work for you.
279],
280  TAR="$withval",)
281
282AC_CHECK_PROG(CHOWN, chown, chown, none)
283if test "$MINGW32" = no; then
284  if test "$MINGW64" = no; then
285    if test "$CHOWN" = "none"; then
286      AC_MSG_ERROR("Could not find chown.");
287    fi
288  fi
289fi
290
291#-------------------------------------------------------------------
292# GNUstep specific options follow
293#-------------------------------------------------------------------
294
295#-------------------------------------------------------------------
296# Determine if we should enable strict gnustep-make v2 mode by default
297#-------------------------------------------------------------------
298
299AC_MSG_CHECKING([if we should enable strict gnustep-make version 2 mode by default])
300AC_ARG_ENABLE(strict-v2-mode, [
301--enable-strict-v2-mode
302  Enable strict gnustep-make version 2 mode by default.  Use this
303  option to have gnustep-make be aggressively backwards-incompatible
304  with gnustep-make version 1.  You should use it to help upgrade old
305  makefiles.  Packegers should make sure that old makefiles have been
306  upgraded before releasing builds using this option.
307],
308  ac_cv_strict_v2_mode=$enableval,
309  ac_cv_strict_v2_mode="yes")
310
311if test "$ac_cv_strict_v2_mode" = "yes"; then
312  AC_MSG_RESULT(yes);
313  GNUSTEP_MAKE_STRICT_V2_MODE="yes"
314  AC_MSG_WARN(Useing strict version 2 mode; ancient makefiles may need to be updated)
315else
316  AC_MSG_RESULT(no);
317  GNUSTEP_MAKE_STRICT_V2_MODE="no"
318  AC_MSG_WARN(Disable strict version 2 mode at your own risk; it may allow faulty makefiles to go unnoticed)
319fi
320
321AC_SUBST(GNUSTEP_MAKE_STRICT_V2_MODE)
322
323#-------------------------------------------------------------------
324# Determine filesystem layout to use
325#-------------------------------------------------------------------
326
327AC_MSG_CHECKING([for GNUstep filesystem layout to use])
328AC_ARG_WITH(layout,[
329--with-layout=FILE
330   Set the type of filesystem layout that you want your GNUstep
331   installation to use.  The layout described by FILE will be
332   read from the FilesystemLayouts directory.  Check the
333   FilesystemLayouts subdirectory for a list of layouts and how
334   to choose which one you want (or create your own).
335   If you do not specify a layout then 'fhs' is used except
336   when the library-combo is apple-apple-apple, in which case it is 'apple'.
337   Example: --with-layout=fhs
338],
339  GNUSTEP_FILESYSTEM_LAYOUT="$withval",)
340
341# The variable GNUSTEP_FILESYSTEM_LAYOUT is empty if no layout was
342# specified on the command line.
343if test ! x"$GNUSTEP_FILESYSTEM_LAYOUT" = x""; then
344  AC_MSG_RESULT($GNUSTEP_FILESYSTEM_LAYOUT)
345  GNUSTEP_FILESYSTEM_LAYOUT_FILE="$GNUSTEP_FILESYSTEM_LAYOUT"
346else
347  # This is the default layout that is used when installing
348  # GNUstep with no other indication.  We normally use 'fhs'.
349  # However, if the library-combo is apple-apple-apple we use
350  # 'apple' irrespective of the target OS.
351  if test "$ac_cv_library_combo" = "apple-apple-apple"; then
352    AC_MSG_RESULT(default layout: 'apple' since we're on apple-apple-apple)
353    GNUSTEP_FILESYSTEM_LAYOUT_FILE=apple
354  else
355    GNUSTEP_FILESYSTEM_LAYOUT_FILE=fhs
356    AC_MSG_RESULT(default layout: '$GNUSTEP_FILESYSTEM_LAYOUT_FILE')
357  fi
358fi
359
360if test ! -f "$srcdir/FilesystemLayouts/$GNUSTEP_FILESYSTEM_LAYOUT_FILE" >&5 2>&5; then
361  echo "Can not find $srcdir/FilesystemLayouts/$GNUSTEP_FILESYSTEM_LAYOUT_FILE"
362  echo "Please check your --with-layout=xxx argument and try again."
363  echo "Valid arguments for --with-layout= are:"
364  echo `ls "$srcdir/FilesystemLayouts/" | grep -v README`
365  exit 1
366fi
367
368# Need to do some checks related to building dylibs on darwin.
369GNUSTEP_ABSOLUTE_INSTALL_PATHS=;
370
371case "$target_os" in
372  darwin*)
373    AC_MSG_CHECKING([if we should build dynamic libraries with an absolute install_name])
374    AC_ARG_ENABLE(absolute-install-paths, [
375--enable-absolute-install-paths
376  Enable the use of absolute paths for the install_name of dynamic
377  libraries on Darwin.  This option is specific to Darwin and is
378  ignored on all other platforms.  Any code that links against a
379  dynamic library with an absolute install_name will tell dyld to
380  find the library at that location.  Enabling this option allows
381  one to place libraries in non-standard locations without having
382  to set DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH in the shell
383  and ~/.MacOSX/environment.plist, but libraries built with an
384  absolute install_name are not relocatable.  By default, this
385  setting is disabled unless the gnu-gnu-gnu library combo is
386  used, in which case it is enabled.
387    ],
388      ac_cv_absolute_install_paths=$enableval,
389      ac_cv_absolute_install_paths="undefined")
390
391    if test "$ac_cv_absolute_install_paths" = "yes"; then
392      AC_MSG_RESULT(yes)
393      GNUSTEP_ABSOLUTE_INSTALL_PATHS=yes;
394    else
395      if test "$ac_cv_absolute_install_paths" = "undefined"; then
396        # gnu-gnu-gnu on darwin is difficult because of the risk of
397        # conflicts between the GNU Objective-C runtime and the Apple
398        # one.  absolute-install-paths makes this slightly easier
399        # by hardcoding the absolute path of dynamic libraries into the
400        # programs that link them so that it's less likely that the
401        # wrong dynamic libraries will be pulled in.  So we enable it
402        # by default in that case.
403        if test "$ac_cv_library_combo" = "gnu-gnu-gnu"; then
404           GNUSTEP_ABSOLUTE_INSTALL_PATHS=yes;
405           AC_MSG_RESULT(yes)
406        else
407           AC_MSG_RESULT(no)
408        fi
409      else
410        AC_MSG_RESULT(no)
411      fi
412    fi
413
414    ;;
415esac
416
417AC_SUBST(GNUSTEP_ABSOLUTE_INSTALL_PATHS)
418
419#-------------------------------------------------------------------
420# Read filesystem layout from file
421#-------------------------------------------------------------------
422AC_MSG_CHECKING([if we manage to import the filesystem layout configuration])
423
424. "$srcdir/FilesystemLayouts/$GNUSTEP_FILESYSTEM_LAYOUT_FILE"
425
426if test ! x"$GNUSTEP_DEFAULT_PREFIX" = x""; then
427  AC_MSG_RESULT(ok)
428else
429  AC_MSG_RESULT(failed)
430  echo "Please check your $srcdir/FilesystemLayouts/$GNUSTEP_FILESYSTEM_LAYOUT_FILE"
431  echo "layout file, as it can not be loaded (GNUSTEP_DEFAULT_PREFIX missing)"
432  exit 1
433fi
434
435# Now, all MAKEFILES/SYSTEM/LOCAL/NETWORK paths in the filesystem
436# layout file will be relative to prefix.  So we need to immediately
437# determine prefix, and use it.
438
439#--------------------------------------------------------------------
440# Process --prefix
441#--------------------------------------------------------------------
442
443# We use this to make sure we know if the user has passed a
444# --prefix=xxx option or not.  We use it if it was passed.
445#
446# If it wasn't passed, then we want to know because in that case we
447# want to use the specified default prefix for that filesystem.  For
448# example, the 'gnustep' filesystem will install by default in
449# /usr/GNUstep, while the 'fhs' filesystem will install by default in
450# /usr/local.  Please note that AC_PREFIX_DEFAULT will actually be
451# done at the very beginning of ./configure, not here.  So we wouldn't
452# have access to all the filesystem layout information yet, which is
453# why we only use the macro to know if a --prefix=xxx was passed or
454# not.
455AC_PREFIX_DEFAULT(NONE)
456
457AC_MSG_CHECKING([for prefix])
458if test "x$prefix" = "xNONE"; then
459  # Use the default prefix for this filesystem layout
460  GNUSTEP_PREFIX="$GNUSTEP_DEFAULT_PREFIX";
461else
462  # Use the prefix that the user specified
463  GNUSTEP_PREFIX="$prefix";
464fi
465
466# Remove any '/' at the end of prefix.  All system/network/local paths
467# from layout files must start with a '/'.  We don't want a '/' at the
468# end of the prefix to generate a '//' mostly because common.make will
469# try to double-check that GNUSTEP_SYSTEM_TOOLS is in your PATH.  Any
470# '//' in GNUSTEP_SYSTEM_TOOLS will have been normalized to '/' in
471# PATH (on some systems at least) and so comparing them won't find a
472# match and the check will fail even if GNUSTEP_SYSTEM_TOOLS is in
473# PATH and a spurious warning will be produced.
474GNUSTEP_PREFIX=`echo "$GNUSTEP_PREFIX" | sed 's%/*$%%'`
475
476AC_MSG_RESULT($GNUSTEP_PREFIX)
477AC_SUBST(GNUSTEP_PREFIX)
478
479# Now we apply the prefix (we don't need to apply it to
480# GNUSTEP_SYSTEM_USERS_DIR and similar, which are something like
481# '/home' - we never install anything in there).
482GNUSTEP_MAKEFILES="$GNUSTEP_PREFIX$GNUSTEP_MAKEFILES"
483
484GNUSTEP_SYSTEM_APPS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_APPS"
485GNUSTEP_SYSTEM_ADMIN_APPS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_ADMIN_APPS"
486GNUSTEP_SYSTEM_WEB_APPS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_WEB_APPS"
487GNUSTEP_SYSTEM_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_TOOLS"
488GNUSTEP_SYSTEM_ADMIN_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_ADMIN_TOOLS"
489GNUSTEP_SYSTEM_LIBRARY="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_LIBRARY"
490GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_HEADERS"
491GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_LIBRARIES"
492GNUSTEP_SYSTEM_DOC="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_DOC"
493GNUSTEP_SYSTEM_DOC_MAN="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_DOC_MAN"
494GNUSTEP_SYSTEM_DOC_INFO="$GNUSTEP_PREFIX$GNUSTEP_SYSTEM_DOC_INFO"
495
496GNUSTEP_NETWORK_APPS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_APPS"
497GNUSTEP_NETWORK_ADMIN_APPS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_ADMIN_APPS"
498GNUSTEP_NETWORK_WEB_APPS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_WEB_APPS"
499GNUSTEP_NETWORK_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_TOOLS"
500GNUSTEP_NETWORK_ADMIN_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_ADMIN_TOOLS"
501GNUSTEP_NETWORK_LIBRARY="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_LIBRARY"
502GNUSTEP_NETWORK_HEADERS="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_HEADERS"
503GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_LIBRARIES"
504GNUSTEP_NETWORK_DOC="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_DOC"
505GNUSTEP_NETWORK_DOC_MAN="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_DOC_MAN"
506GNUSTEP_NETWORK_DOC_INFO="$GNUSTEP_PREFIX$GNUSTEP_NETWORK_DOC_INFO"
507
508GNUSTEP_LOCAL_APPS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_APPS"
509GNUSTEP_LOCAL_ADMIN_APPS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_ADMIN_APPS"
510GNUSTEP_LOCAL_WEB_APPS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_WEB_APPS"
511GNUSTEP_LOCAL_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_TOOLS"
512GNUSTEP_LOCAL_ADMIN_TOOLS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_ADMIN_TOOLS"
513GNUSTEP_LOCAL_LIBRARY="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_LIBRARY"
514GNUSTEP_LOCAL_HEADERS="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_HEADERS"
515GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_LIBRARIES"
516GNUSTEP_LOCAL_DOC="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_DOC"
517GNUSTEP_LOCAL_DOC_MAN="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_DOC_MAN"
518GNUSTEP_LOCAL_DOC_INFO="$GNUSTEP_PREFIX$GNUSTEP_LOCAL_DOC_INFO"
519
520#---------------------------------------------------------------------
521# Location of the GNUstep.conf config file (--with-config-file)
522#---------------------------------------------------------------------
523AC_MSG_CHECKING([for GNUstep configuration file to use])
524AC_ARG_WITH(config-file,[
525--with-config-file=PATH
526   Set the path of the system GNUstep config file.  Use this option
527   if you want to have the GNUstep config file in a non-standard
528   place.
529   Example: --with-config-file=/usr/GNUstep/GNUstep.conf
530   By default, if this option is not specified, the config file is
531   /etc/GNUstep/GNUstep.conf if the prefix is /, /usr or /usr/GNUstep
532   and $prefix/etc/GNUstep/GNUstep.conf otherwise.  On Apple, it is
533   always /Library/GNUstep/GNUstep.conf regardless of prefix.
534],
535  GNUSTEP_CONFIG_FILE="$withval",)
536if test "$GNUSTEP_CONFIG_FILE" = "" -o "$GNUSTEP_CONFIG_FILE" = "no"; then
537  case "$target_os" in
538    darwin*)              GNUSTEP_CONFIG_FILE=/Library/GNUstep/GNUstep.conf ;;
539    *)  case x"$GNUSTEP_PREFIX" in
540          x)             GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf;;
541          x/usr)         GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf;;
542          x/usr/GNUstep) GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf;;
543          *)             GNUSTEP_CONFIG_FILE="$GNUSTEP_PREFIX/etc/GNUstep/GNUstep.conf";;
544        esac ;;
545  esac
546fi
547if echo "$GNUSTEP_CONFIG_FILE" | grep '[[ 	\\]] > /dev/null'
548then
549  echo "found a backslash or space (illegal) in '$GNUSTEP_CONFIG_FILE'"
550  echo "Please try again using --with-config-file= to specify a valid path."
551  if test "$MSWIND" = "yes"
552  then
553    echo "Please note that on windows you must use unix-style paths within"
554    echo "the make package even though gnustep programs built in the mingw"
555    echo "environment use native paths throughout."
556  fi
557  exit 1
558fi
559AC_MSG_RESULT($GNUSTEP_CONFIG_FILE)
560AC_SUBST(GNUSTEP_CONFIG_FILE)
561
562#---------------------------------------------------------------------
563# Now read/import the existing configuration file, if any
564#---------------------------------------------------------------------
565
566# Reading/importing the existing configuration file might be good as a
567# default because it means that you don't have to type in your
568# layout/prefix settings every time you configure
569# gnustep-make. (please note we only read the system-wide one, not the
570# user one.  Reason being that the settings we read will be used to
571# generate the new system-wide one, while the user one will be left
572# untouched).
573
574# Please note that this option will override any --with-layout=xxx and
575# --prefix=yyy options.
576
577AC_MSG_CHECKING([if we should import an existing configuration file])
578AC_ARG_ENABLE(importing-config-file, [
579--enable-importing-config-file
580   Enable importing the existing system GNUstep configuration file.
581   Use this option to use an existing configuration file for
582   setting up the filesystem layout and prefix.  If you specify this
583   option, all the configuration will be read from the existing
584   system GNUstep configuration file and any --with-layout=xxx
585   and --prefix=yyy options will be ignored.
586],
587  ac_cv_importing_config_file=$enableval,
588  ac_cv_importing_config_file="no")
589
590if test "$ac_cv_importing_config_file" = "yes"; then
591 if test ! -f "$GNUSTEP_CONFIG_FILE"; then
592   AC_MSG_RESULT([no: file "$GNUSTEP_CONFIG_FILE" does not exist])
593   AC_MSG_ERROR([asked to import non-existing configuration file.  To fix this problem, make sure you have a config file to import, or remove the --enable-importing-config-file option.])
594 else
595   AC_MSG_RESULT([yes: trying to import "$GNUSTEP_CONFIG_FILE"])
596   AC_MSG_NOTICE([If this fails, run configure again with --disable-importing-config-file])
597   . "$GNUSTEP_CONFIG_FILE"
598 fi
599else
600  AC_MSG_RESULT([no])
601fi
602
603
604#--------------------------------------------------------------------
605# Important - from now on, any variable that is set in the filesystem
606# layout and/or configuration file (eg, GNUSTEP_SYSTEM_TOOLS) could
607# already have a value that we have imported from the files.
608# ./configure command line options should override those values, but
609# otherwise we should keep them!
610#--------------------------------------------------------------------
611
612#--------------------------------------------------------------------
613# Process --with-user-config-file
614#--------------------------------------------------------------------
615AC_MSG_CHECKING(for user config file to use)
616AC_ARG_WITH(user-config-file,[
617--with-user-config-file
618   Set the name of the user config file to use.  This can be
619   relative to the user's home directory if it is a relative path,
620   or an absolute directory (the same for all users) if it is an
621   absolute path.  Use '' if you want to disable user config files.
622   The default is .GNUstep.conf if not specified.
623   Example: --with-user-config-file=GNUstep/GNUstep.conf
624],
625GNUSTEP_USER_CONFIG_FILE="$withval",)
626# Keep in mind we already have a default value set by the filesystem
627# layout, so it should never be empty.
628if echo "$GNUSTEP_USER_CONFIG_FILE" | grep '[[ 	\\]] > /dev/null'
629then
630  echo "found a backslash or space (illegal) in '$GNUSTEP_USER_CONFIG_FILE'"
631  echo "Please try again using --with-user-config-file= to specify a value."
632  if test "$MSWIND" = "yes"
633  then
634    echo "Please note that on windows you must use unix-style paths within"
635    echo "the make package even though gnustep programs built in the mingw"
636    echo "environment use native paths throughout."
637  fi
638  exit 1
639fi
640AC_MSG_RESULT($GNUSTEP_USER_CONFIG_FILE)
641AC_SUBST(GNUSTEP_USER_CONFIG_FILE)
642
643#--------------------------------------------------------------------
644# Process --with-user-dir
645#--------------------------------------------------------------------
646AC_MSG_CHECKING(if the obsolete --with-user-dir option was used)
647AC_ARG_WITH(user-dir,[
648--with-user-dir
649   This is an obsolete option.  It used to determine the location of
650   the USER domain directory (inside of each user's home directory)
651   under the 'gnustep' layout.  We ignore this option so that you can
652   write ./configure commands that work with both old and new
653   gnustep-makes.  To get the effect of this option with this version
654   of gnustep-make, please create your own layout file and use
655   --with-layout=xxx to use it.
656],
657OBSOLETE_GNUSTEP_USER_DIR="$withval",)
658if test ! x"$OBSOLETE_GNUSTEP_USER_DIR" = x"" && test ! x"$OBSOLETE_GNUSTEP_USER_DIR" = x"no"; then
659  AC_MSG_RESULT([$OBSOLETE_GNUSTEP_USER_DIR: ignored])
660  AC_MSG_WARN([ignoring --with-user-dir=$OBSOLETE_GNUSTEP_USER_DIR option])
661else
662  AC_MSG_RESULT(no: good)
663fi
664
665#--------------------------------------------------------------------
666# Process --with-user-defaults-dir
667#--------------------------------------------------------------------
668AC_MSG_CHECKING(for user defaults dir to use)
669AC_ARG_WITH(user-defaults-dir,[
670--with-user-defaults-dir
671   Set the GNUstep user defaults directory for all users.  This can be
672   relative to the user's home directory if it is a relative path,
673   or an absolute directory (the same for all users) if it is an
674   absolute path.  Use this option if you want to have the
675   GNUSTEP_USER_DEFAULTS_DIR directory in a non default place for
676   all users.  The default is 'GNUstep/Defaults'
677   Example: --with-user-defaults-dir='GNUstep/Library/Defaults'
678],
679GNUSTEP_USER_DEFAULTS_DIR="$withval",)
680# Keep in mind we already have a default value set by the filesystem
681# layout, so it should never be empty.
682if echo "$GNUSTEP_USER_DEFAULTS_DIR" | grep '[[ 	\\]] > /dev/null'
683then
684  echo "found a backslash or space (illegal) in '$GNUSTEP_USER_DEFAULTS_DIR'"
685  echo "Please try again using --with-user-defaults-dir= to specify a value."
686  if test "$MSWIND" = "yes"
687  then
688    echo "Please note that on windows you must use unix-style paths within"
689    echo "the make package even though gnustep programs built in the mingw"
690    echo "environment use native paths throughout."
691  fi
692  exit 1
693fi
694AC_MSG_RESULT($GNUSTEP_USER_DEFAULTS_DIR)
695AC_SUBST(GNUSTEP_USER_DEFAULTS_DIR)
696
697#--------------------------------------------------------------------
698# Setting up GNUSTEP_MAKEFILES
699#--------------------------------------------------------------------
700#
701# This is where you install gnustep-make.  We just print it out.
702#
703AC_MSG_CHECKING(for GNUSTEP_MAKEFILES to use)
704AC_SUBST(GNUSTEP_MAKEFILES)
705AC_MSG_RESULT($GNUSTEP_MAKEFILES)
706# If GNUSTEP_MAKEFILES contains a space, we may have problems later
707# because make does not really support having spaces in filenames
708if echo "$GNUSTEP_MAKEFILES" | grep " " >/dev/null 2>&1; then
709  AC_MSG_WARN([GNUSTEP_MAKEFILES ($GNUSTEP_MAKEFILES) contains spaces: this may not work])
710fi
711
712#--------------------------------------------------------------------
713# Setting up the install-sh script
714#--------------------------------------------------------------------
715
716# HOST_INSTALL is the name of the install program in config.make so set it up
717# to point to the install-sh script in the GNUstep tree if no system install is
718# found.
719AC_SUBST(HOST_INSTALL)
720if test "$INSTALL" = "$ac_install_sh"; then
721  HOST_INSTALL="$GNUSTEP_MAKEFILES/$INSTALL"
722else
723  HOST_INSTALL="$INSTALL"
724fi
725
726#--------------------------------------------------------------------
727# Is the system flattened?
728#--------------------------------------------------------------------
729AC_MSG_CHECKING(for flattened directory structure)
730AC_ARG_ENABLE(flattened, [
731--disable-flattened
732   Disable flattened directory structure.  Use this option if you want
733   to have support for multiple library combos and fat binaries.  A
734   library combo specifies the Objective-C frameworks to use to compile
735   a program, so having multiple library combos is only useful if you
736   have (or plan to have) multiple OpenStep-like Objective-C frameworks
737   installed on your machine, for example both the Apple Cocoa Objective-C
738   frameworks and the GNUstep frameworks.  Fat binaries allow you to
739   have multiple versions for different CPUs and Operating Systems.
740   Please note that using the fat directory structure will not blend
741   easily with native filesystems and so if you want the non-flattened
742   directory structure you probably want to install GNUstep using its
743   own default filesystem layout.  To switch between different
744   library-combos, you also need to source GNUstep.sh after
745   setting the LIBRARY_COMBO environment variable.  Please refer to
746   the documentation for more information on library-combos and fat
747   binaries.
748],
749  ac_cv_flattened=$enableval,
750  ac_cv_flattened="undefined")
751
752if test "$ac_cv_flattened" = "no"; then
753
754  # GNUSTEP_FLATTENED is here for backwards compatibility only and
755  # should be removed at some point.  It has the problem that it
756  # defaults to 'no' while we want the default to be 'yes'!
757  # The new GNUSTEP_IS_FLATTENED variable defaults to 'yes'. :-)
758
759  GNUSTEP_FLATTENED=;
760  GNUSTEP_IS_FLATTENED=no;
761
762  # FIXME - maybe we should have a warning here if you try to
763  # use 'fhs' or 'fhs-system' layout with non-flattened!
764else
765  GNUSTEP_FLATTENED=yes;
766  GNUSTEP_IS_FLATTENED=yes;
767fi
768AC_SUBST(GNUSTEP_FLATTENED)
769AC_SUBST(GNUSTEP_IS_FLATTENED)
770
771if test "$GNUSTEP_IS_FLATTENED" = "yes"; then
772  AC_MSG_RESULT(yes);
773else
774  AC_MSG_RESULT(no);
775fi
776
777#--------------------------------------------------------------------
778# Output the full filesystem layout
779#--------------------------------------------------------------------
780
781# Note: We print out the entire filesystem layout so that people can
782# see with their eyes the result of the configuration options that
783# they used.  This is good to immediately spot mistakes.
784AC_MSG_NOTICE([Now printing the filesystem layout configuration.])
785
786AC_MSG_CHECKING([for System Applications directory])
787AC_MSG_RESULT($GNUSTEP_SYSTEM_APPS)
788AC_SUBST(GNUSTEP_SYSTEM_APPS)
789AC_MSG_CHECKING([for System Admin Applications directory])
790AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_APPS)
791AC_SUBST(GNUSTEP_SYSTEM_ADMIN_APPS)
792AC_MSG_CHECKING([for System Web Applications directory])
793AC_MSG_RESULT($GNUSTEP_SYSTEM_WEB_APPS)
794AC_SUBST(GNUSTEP_SYSTEM_WEB_APPS)
795AC_MSG_CHECKING([for System Tools directory])
796AC_MSG_RESULT($GNUSTEP_SYSTEM_TOOLS)
797AC_SUBST(GNUSTEP_SYSTEM_TOOLS)
798AC_MSG_CHECKING([for System Admin Tools directory])
799AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_TOOLS)
800AC_SUBST(GNUSTEP_SYSTEM_ADMIN_TOOLS)
801AC_MSG_CHECKING([for System Library directory])
802AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARY)
803AC_SUBST(GNUSTEP_SYSTEM_LIBRARY)
804AC_MSG_CHECKING([for System Headers directory])
805AC_MSG_RESULT($GNUSTEP_SYSTEM_HEADERS)
806AC_SUBST(GNUSTEP_SYSTEM_HEADERS)
807AC_MSG_CHECKING([for System Libraries directory])
808AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARIES)
809AC_SUBST(GNUSTEP_SYSTEM_LIBRARIES)
810AC_MSG_CHECKING([for System Documentation directory])
811AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC)
812AC_SUBST(GNUSTEP_SYSTEM_DOC)
813AC_MSG_CHECKING([for System Info Documentation directory])
814AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_INFO)
815AC_SUBST(GNUSTEP_SYSTEM_DOC_INFO)
816AC_MSG_CHECKING([for System Man Documentation directory])
817AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_MAN)
818AC_SUBST(GNUSTEP_SYSTEM_DOC_MAN)
819
820AC_MSG_CHECKING([for Network Applications directory])
821AC_MSG_RESULT($GNUSTEP_NETWORK_APPS)
822AC_SUBST(GNUSTEP_NETWORK_APPS)
823AC_MSG_CHECKING([for Network Admin Applications directory])
824AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_APPS)
825AC_SUBST(GNUSTEP_NETWORK_ADMIN_APPS)
826AC_MSG_CHECKING([for Network Web Applications directory])
827AC_MSG_RESULT($GNUSTEP_NETWORK_WEB_APPS)
828AC_SUBST(GNUSTEP_NETWORK_WEB_APPS)
829AC_MSG_CHECKING([for Network Tools directory])
830AC_MSG_RESULT($GNUSTEP_NETWORK_TOOLS)
831AC_SUBST(GNUSTEP_NETWORK_TOOLS)
832AC_MSG_CHECKING([for Network Admin Tools directory])
833AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_TOOLS)
834AC_SUBST(GNUSTEP_NETWORK_ADMIN_TOOLS)
835AC_MSG_CHECKING([for Network Library directory])
836AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARY)
837AC_SUBST(GNUSTEP_NETWORK_LIBRARY)
838AC_MSG_CHECKING([for Network Headers directory])
839AC_MSG_RESULT($GNUSTEP_NETWORK_HEADERS)
840AC_SUBST(GNUSTEP_NETWORK_HEADERS)
841AC_MSG_CHECKING([for Network Libraries directory])
842AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARIES)
843AC_SUBST(GNUSTEP_NETWORK_LIBRARIES)
844AC_MSG_CHECKING([for Network Documentation directory])
845AC_MSG_RESULT($GNUSTEP_NETWORK_DOC)
846AC_SUBST(GNUSTEP_NETWORK_DOC)
847AC_MSG_CHECKING([for Network Info Documentation directory])
848AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_INFO)
849AC_SUBST(GNUSTEP_NETWORK_DOC_INFO)
850AC_MSG_CHECKING([for Network Man Documentation directory])
851AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_MAN)
852AC_SUBST(GNUSTEP_NETWORK_DOC_MAN)
853
854AC_MSG_CHECKING([for Local Applications directory])
855AC_MSG_RESULT($GNUSTEP_LOCAL_APPS)
856AC_SUBST(GNUSTEP_LOCAL_APPS)
857AC_MSG_CHECKING([for Local Admin Applications directory])
858AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_APPS)
859AC_SUBST(GNUSTEP_LOCAL_ADMIN_APPS)
860AC_MSG_CHECKING([for Local Web Applications directory])
861AC_MSG_RESULT($GNUSTEP_LOCAL_WEB_APPS)
862AC_SUBST(GNUSTEP_LOCAL_WEB_APPS)
863AC_MSG_CHECKING([for Local Tools directory])
864AC_MSG_RESULT($GNUSTEP_LOCAL_TOOLS)
865AC_SUBST(GNUSTEP_LOCAL_TOOLS)
866AC_MSG_CHECKING([for Local Admin Tools directory])
867AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_TOOLS)
868AC_SUBST(GNUSTEP_LOCAL_ADMIN_TOOLS)
869AC_MSG_CHECKING([for Local Library directory])
870AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARY)
871AC_SUBST(GNUSTEP_LOCAL_LIBRARY)
872AC_MSG_CHECKING([for Local Headers directory])
873AC_MSG_RESULT($GNUSTEP_LOCAL_HEADERS)
874AC_SUBST(GNUSTEP_LOCAL_HEADERS)
875AC_MSG_CHECKING([for Local Libraries directory])
876AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARIES)
877AC_SUBST(GNUSTEP_LOCAL_LIBRARIES)
878AC_MSG_CHECKING([for Local Documentation directory])
879AC_MSG_RESULT($GNUSTEP_LOCAL_DOC)
880AC_SUBST(GNUSTEP_LOCAL_DOC)
881AC_MSG_CHECKING([for Local Info Documentation directory])
882AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_INFO)
883AC_SUBST(GNUSTEP_LOCAL_DOC_INFO)
884AC_MSG_CHECKING([for Local Man Documentation directory])
885AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_MAN)
886AC_SUBST(GNUSTEP_LOCAL_DOC_MAN)
887
888AC_MSG_CHECKING([for User Applications directory])
889AC_MSG_RESULT($GNUSTEP_USER_DIR_APPS)
890AC_SUBST(GNUSTEP_USER_DIR_APPS)
891AC_MSG_CHECKING([for User Admin Applications directory])
892AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_APPS)
893AC_SUBST(GNUSTEP_USER_DIR_ADMIN_APPS)
894AC_MSG_CHECKING([for User Web Applications directory])
895AC_MSG_RESULT($GNUSTEP_USER_DIR_WEB_APPS)
896AC_SUBST(GNUSTEP_USER_DIR_WEB_APPS)
897AC_MSG_CHECKING([for User Tools directory])
898AC_MSG_RESULT($GNUSTEP_USER_DIR_TOOLS)
899AC_SUBST(GNUSTEP_USER_DIR_TOOLS)
900AC_MSG_CHECKING([for User Admin Tools directory])
901AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_TOOLS)
902AC_SUBST(GNUSTEP_USER_DIR_ADMIN_TOOLS)
903AC_MSG_CHECKING([for User Library directory])
904AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARY)
905AC_SUBST(GNUSTEP_USER_DIR_LIBRARY)
906AC_MSG_CHECKING([for User Headers directory])
907AC_MSG_RESULT($GNUSTEP_USER_DIR_HEADERS)
908AC_SUBST(GNUSTEP_USER_DIR_HEADERS)
909AC_MSG_CHECKING([for User Libraries directory])
910AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARIES)
911AC_SUBST(GNUSTEP_USER_DIR_LIBRARIES)
912AC_MSG_CHECKING([for User Documentation directory])
913AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC)
914AC_SUBST(GNUSTEP_USER_DIR_DOC)
915AC_MSG_CHECKING([for User Info Documentation directory])
916AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_INFO)
917AC_SUBST(GNUSTEP_USER_DIR_DOC_INFO)
918AC_MSG_CHECKING([for User Man Documentation directory])
919AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_MAN)
920AC_SUBST(GNUSTEP_USER_DIR_DOC_MAN)
921
922AC_MSG_CHECKING([for System User directory])
923AC_MSG_RESULT($GNUSTEP_SYSTEM_USERS_DIR)
924AC_SUBST(GNUSTEP_SYSTEM_USERS_DIR)
925AC_MSG_CHECKING([for Network User directory])
926AC_MSG_RESULT($GNUSTEP_NETWORK_USERS_DIR)
927AC_SUBST(GNUSTEP_NETWORK_USERS_DIR)
928AC_MSG_CHECKING([for Local User directory])
929AC_MSG_RESULT($GNUSTEP_LOCAL_USERS_DIR)
930AC_SUBST(GNUSTEP_LOCAL_USERS_DIR)
931
932#--------------------------------------------------------------------
933# These variables no longer exist!  We try to set some compatibility
934# values for them that should work with the old 'gnustep' layout.
935# So things using the old 'gnustep' layout should keep working.
936# These variables won't have any meaning with the new layouts.
937# They are deprecated and they *will* be removed.
938#--------------------------------------------------------------------
939GNUSTEP_SYSTEM_ROOT="$GNUSTEP_PREFIX/System"
940GNUSTEP_NETWORK_ROOT="$GNUSTEP_PREFIX/Network"
941GNUSTEP_LOCAL_ROOT="$GNUSTEP_PREFIX/Local"
942GNUSTEP_USER_DIR="GNUstep"
943AC_SUBST(GNUSTEP_SYSTEM_ROOT)
944AC_SUBST(GNUSTEP_NETWORK_ROOT)
945AC_SUBST(GNUSTEP_LOCAL_ROOT)
946AC_SUBST(GNUSTEP_USER_DIR)
947
948#--------------------------------------------------------------------
949# Is the system multi-platform?
950#--------------------------------------------------------------------
951#
952# Multi-platform means that GNUstep.sh will determine the host
953# platform (by running config.guess) each time that it is sourced.
954# This is good if you are sharing your GNUstep.sh across your network
955# (for example, mounting the makefiles via NFS), but it requires you
956# to be able to run config.guess on your machine(s), which usually
957# requires a development environment (compiler, libc etc).
958#
959# The default instead is not using multi-platform, which means the
960# local host os, cpu and version is hardcoded in GNUstep.sh.  This
961# works nicely for a single machine using this gnustep-make
962# installation, and it works even if you don't have development
963# packages (gcc, binutils, libc-dev etc) installed.  We had to make
964# this the default after end-users (with no development packages
965# installed) complained that binary packages wouldn't work (and the
966# reason turned out to be that GNUstep.sh was running config.guess
967# which was returning the wrong platform because the development
968# tools needed/used to determine the platform were not available).
969#
970# Unless you know what you are doing, stick with the default, which is
971# also much faster when sourcing GNUstep.sh.
972#
973AC_ARG_ENABLE(multi-platform, [
974--enable-multi-platform
975   Enable run-time multi-platform support.  If this option is enabled,
976   then every time GNUstep.sh is run it will determine/guess the type
977   of local host machine instead of using the hardcoded value.  Use
978   this together with --disable-flattened if you have a single GNUstep
979   installation with fat binaries that is being shared over the network
980   by a variety of machines with different hardware and o/s.
981],
982  ac_cv_multi_platform=$enableval,
983  ac_cv_multi_platform="undefined")
984
985if test "$ac_cv_multi_platform" = "yes"; then
986  GNUSTEP_MULTI_PLATFORM=yes;
987else
988  GNUSTEP_MULTI_PLATFORM=;
989fi
990AC_SUBST(GNUSTEP_MULTI_PLATFORM)
991
992#--------------------------------------------------------------------
993# Build backend bundles (on by default)
994#--------------------------------------------------------------------
995AC_ARG_ENABLE(backend-bundle, [
996--disable-backend-bundle
997   Compile GUI backend as a library.  Use this option if the default
998   compilation of the GUI backend as a bundle (loadable module) is
999   not supported / does not work on your machine.
1000],
1001  ac_cv_backend=$enableval,
1002  ac_cv_backend="yes")
1003
1004if test "$ac_cv_backend" = "yes"; then
1005  BACKEND_BUNDLE=yes;
1006else
1007  BACKEND_BUNDLE=;
1008fi
1009AC_SUBST(BACKEND_BUNDLE)
1010
1011#--------------------------------------------------------------------
1012# Enable installation of ld.so.conf.d/gnustep-make.conf
1013#--------------------------------------------------------------------
1014AC_ARG_ENABLE(install-ld-so-conf, [
1015--enable-install-ld-so-conf
1016   Enable installation of ld.so.conf/gnustep-make.conf. This is useful
1017   if you are installing in a non-standard prefix, and a component of
1018   the build system needs to be able to find libraries even without
1019   GNUstep.sh or equivalent providing environment. Some packaging
1020   systems clear out the environment at certain points during the
1021   packaging build process, hence making LD_LIBRARY_PATH set by
1022   gnustep-make.conf ineffective.
1023],
1024  ac_cv_install_ld_so_conf=$enableval,
1025  ac_cv_install_ld_so_conf="undefined")
1026
1027if test "$ac_cv_install_ld_so_conf" = "yes"; then
1028  GNUSTEP_INSTALL_LD_SO_CONF=yes;
1029else
1030  GNUSTEP_INSTALL_LD_SO_CONF=;
1031fi
1032AC_SUBST(GNUSTEP_INSTALL_LD_SO_CONF)
1033
1034#--------------------------------------------------------------------
1035# Miscellaneous flags and setup
1036#--------------------------------------------------------------------
1037
1038# TODO: This check for a custom ObjC library needs to be moved to
1039# gnustep-base since it concerns the runtime library (see explanations
1040# at the beginning of this file).
1041
1042# Special case for Apple systems: When compiling plain C source files that
1043# include Objective-C runtime headers we must make sure that the correct
1044# header files are used with a gnu-*-* combo. The -fobjc-runtime=gcc compiler
1045# option should take care of this when compiling Objective-C source files, but
1046# has no effect when compiling plain C (or C++) source files.
1047cc_gnuruntime=
1048case $target_os-$ac_cv_library_combo in
1049  darwin*-gnu-*-* )
1050    if test "$gs_cv_objc_libdir" = "NONE"; then
1051      AC_MSG_CHECKING(GNU Objective-C runtime header directory)
1052      install_dir="`$CC -print-search-dirs | sed -n 's/install: //p'`"
1053      if test -n "${install_dir}" && \
1054        test -d "${install_dir}"include-gnu-runtime; then
1055        cc_gnuruntime="${install_dir}"include-gnu-runtime
1056        AC_MSG_RESULT($cc_gnuruntime)
1057      else
1058        AC_MSG_RESULT(NONE)
1059      fi
1060    fi
1061    ;;
1062esac
1063AC_SUBST(cc_gnuruntime)
1064
1065dnl these macros are required by GS_CHECK_OBJC_RUNTIME, but we need to explicitly execute them here because we wrap this initial use of the macro in an
1066dnl conditional
1067AC_PROG_SED()
1068GS_OBJ_DIR()
1069GS_OBJC_LIB_FLAG()
1070GS_LIBOBJC_PKG()
1071
1072if test "$OBJC_RUNTIME_LIB" = "gnu" -a x"$gs_cv_cc_is_clang" = x"yes" -a  x"$gs_cv_library_combo_implicit" = x"yes"; then
1073  dnl in order to determine whether the installed runtime library supports the `ng' library combo,
1074  dnl we need to detect the runtime with that combo specifically. Unfortunately,
1075  dnl GS_CHECK_OBJC_RUNTIME is a very invasive macro that sets up lots of variables needed later on.
1076  dnl For that reason, we need to save the state of  all variables that are changed by this and
1077  dnl restore them afterwards
1078  m4_define([rt_save_variables], [[OBJC_CPPFLAGS],dnl
1079                                  [OBJC_LDFLAGS],dnl
1080                                  [OBJC_FINAL_LIB_FLAG],dnl
1081                                  [CFLAGS],dnl
1082                                  [LIBS],dnl
1083                                  [saved_CFLAGS],dnl
1084                                  [saved_LDFLAGS],dnl
1085                                  [OBJCRT],dnl
1086                                  [LD_LIBRARY_PATH],dnl
1087                                  [PATH]])
1088
1089  m4_foreach([to_save], [rt_save_variables], [dnl
1090      AS_VAR_SET([m4_join([_], [gs_cv_ng_rt_saved], m4_strip(to_save))], m4_join([], [$], m4_strip(to_save)))
1091  ])dnl
1092  GS_CHECK_OBJC_RUNTIME([NG], [ng-gnu-gnu])
1093
1094  dnl The gnustep runtime library has objc_test_capability -- the GCC runtime doesn't, so we can use  this
1095  dnl to distinguish between them
1096  AC_CHECK_FUNC([objc_test_capability], [
1097    GS_LIBRARY_COMBO([ng-gnu-gnu],[yes])
1098    LIBRARY_COMBO=ng-gnu-gnu
1099    AC_MSG_NOTICE([library combo has been upgraded to `ng-gnu-gnu' because compiler/runtime support is available. To prevent this, pass --with-library-combo explicitly.])
1100  ])
1101
1102  dnl restare state
1103  m4_foreach([saved_var], [rt_save_variables], [dnl
1104    AS_VAR_SET([m4_strip(saved_var)], m4_join([], [$gs_cv_ng_rt_saved_], m4_strip(saved_var)))
1105    AS_UNSET(m4_join([_], [gs_cv_ng_rt_saved], m4_strip(saved_var)))
1106  ])dnl
1107   m4_undefine([rt_save_variables])
1108fi
1109
1110
1111GS_CHECK_OBJC_RUNTIME()
1112
1113#--------------------------------------------------------------------
1114# Check if libobjc was compiled with thread support.
1115#--------------------------------------------------------------------
1116# TODO: This check needs to be moved to gnustep-base since it concerns
1117# the runtime library (see explanations at the beginning of this
1118# file).
1119OBJC_THREAD=
1120AC_ARG_WITH(thread-lib,[
1121--with-thread-lib
1122   Specify alternate thread library.  Use this flag if configure can
1123   not properly determine the thread library used by your libobjc.
1124],
1125OBJC_THREAD=$withval,
1126OBJC_THREAD=
1127)
1128if test "$OBJC_THREAD" = no; then
1129OBJC_THREAD=
1130fi
1131
1132
1133AC_MSG_CHECKING(whether objc has thread support)
1134if test "$OBJC_THREAD" != ""; then
1135  LIBS="$OBJCRT $LIBS $OBJC_THREAD"
1136  AC_TRY_RUN([#include "config_thread.m"],
1137	objc_threaded="$OBJC_THREAD",
1138	objc_threaded="", objc_threaded="")
1139elif test "$host_os" = linux-gnu; then
1140  LIBS="$OBJCRT -lpthread"
1141  AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpthread",
1142	objc_threaded="", objc_threaded="-lpthread")
1143  if test x"$objc_threaded" = x""; then
1144    LIBS="$OBJCRT"
1145    AC_TRY_RUN([#include "config_thread.m"],
1146          objc_threaded="works",
1147	  objc_threaded="", objc_threaded="works")
1148  fi
1149elif test "`echo $host_os|sed 's/[[0-9]].*//'|sed s/elf//`" = freebsd; then
1150  LIBS="-pthread $OBJCRT"
1151  AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-pthread",
1152       objc_threaded="", objc_threaded="-pthread")
1153  if test x"$objc_threaded" = x""; then
1154    LIBS="-lpthread $OBJCRT"
1155    AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpthread",
1156	objc_threaded="", objc_threaded="-lpthread")
1157  fi
1158  if test x"$objc_threaded" = x""; then
1159    LIBS="$OBJCRT -lpcthread"
1160    AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpcthread",
1161	objc_threaded="", objc_threaded="-lpcthread")
1162  fi
1163  if test x"$objc_threaded" = x""; then
1164    LIBS="$OBJCRT"
1165    AC_TRY_RUN([#include "config_thread.m"],
1166          objc_threaded="works",
1167	  objc_threaded="", objc_threaded="works")
1168  fi
1169elif test "$MINGW32" = yes; then
1170  # Mingw doesn't need anything extra for threads
1171  LIBS="$OBJCRT $LIBS"
1172  AC_TRY_RUN([#include "config_thread.m"],
1173	objc_threaded="works",
1174	objc_threaded="", objc_threaded="works")
1175elif test "$MINGW64" = yes; then
1176  # Mingw doesn't need anything extra for threads
1177  LIBS="$OBJCRT $LIBS"
1178  AC_TRY_RUN([#include "config_thread.m"],
1179	objc_threaded="works",
1180	objc_threaded="", objc_threaded="works")
1181elif test "$OBJC_RUNTIME_LIB" = "apple"; then
1182  # Apple doesn't need anything extra for threads
1183  LIBS="$OBJCRT $LIBS"
1184  AC_TRY_RUN([#include "config_thread.m"],
1185	objc_threaded="works",
1186	objc_threaded="", objc_threaded="works")
1187else
1188  LIBS="$OBJCRT $LIBS"
1189  AC_TRY_RUN([#include "config_thread.m"],
1190	objc_threaded="works",
1191	objc_threaded="", objc_threaded="")
1192  if test x"$objc_threaded" = x""; then
1193    LIBS="$OBJCRT $saved_LIBS -lpthread "
1194    AC_TRY_RUN([#include "config_thread.m"],
1195    	objc_threaded="-lpthread",
1196	objc_threaded="", objc_threaded="")
1197  fi
1198  if test x"$objc_threaded" = x""; then
1199    # Solaris, OpenBSD/sparc
1200    LIBS="$OBJCRT $saved_LIBS -lpthread -lposix4"
1201    AC_TRY_RUN([#include "config_thread.m"],
1202    	objc_threaded="-lpthread -lposix4",
1203	objc_threaded="", objc_threaded="")
1204  fi
1205  if test x"$objc_threaded" = x""; then
1206    LIBS="$OBJCRT $saved_LIBS -lthread "
1207    AC_TRY_RUN([#include "config_thread.m"],
1208    	objc_threaded="-lthread",
1209	objc_threaded="", objc_threaded="")
1210  fi
1211  if test x"$objc_threaded" = x""; then
1212    LIBS="$OBJCRT"
1213    AC_TRY_RUN([#include "config_thread.m"],
1214          objc_threaded="works",
1215	  objc_threaded="", objc_threaded="works")
1216  fi
1217fi
1218if test x"$objc_threaded" = x""; then
1219  AC_MSG_RESULT(no)
1220else
1221  if test x"$objc_threaded" = x"works"; then
1222    objc_threaded=""
1223  fi
1224  AC_MSG_RESULT(yes: $objc_threaded)
1225fi
1226ac_cv_objc_threaded="$objc_threaded"
1227AC_SUBST(objc_threaded)
1228AC_SUBST(ac_cv_objc_threaded)
1229
1230AC_MSG_CHECKING(whether Objective-C++ is supported)
1231
1232# Only new autoconf supports ObjC++ so we use C++ instead for now
1233#AC_LANG_PUSH(Objective C++)
1234#OBJCXXFLAGS_saved="$OBJCXXFLAGS"
1235#OBJCXXFLAGS="$OBJCXXFLAGS -x objective-c++"
1236#OBJCXXPPFLAGS_saved="$OBJCXXPPFLAGS"
1237#OBJCXXPPFLAGS="$OBJCXXPPFLAGS -x objective-c++"
1238AC_LANG_PUSH(C++)
1239CXXFLAGS_saved="$CXXFLAGS"
1240CXXFLAGS="$CXXFLAGS -x objective-c++"
1241CXXPPFLAGS_saved="$CXXPPFLAGS"
1242CXXPPFLAGS="$CXXPPFLAGS -x objective-c++"
1243
1244AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1245
1246@interface	ObjCClass
1247{
1248  int x;
1249}
1250@end
1251
1252class CppClass
1253{
1254  int x;
1255};
1256
1257int
1258main()
1259{
1260  return 0;
1261}
1262]])], objcc=yes, objcc=no)
1263AC_MSG_RESULT($objcc)
1264if test x"$objcc" = x"no"; then
1265  OBJCXX=
1266fi
1267AC_SUBST(OBJCXX)
1268# Only new autoconf supports ObjC++ so we use C++ instead for now
1269#OBJCXXFLAGS="$OBJCXXFLAGS_saved"
1270#OBJCXXPPFLAGS="$OBJCXXPPFLAGS_saved"
1271#AC_LANG_POP(Objective C++)
1272CXXFLAGS="$CXXFLAGS_saved"
1273CXXPPFLAGS="$CXXPPFLAGS_saved"
1274AC_LANG_POP(C++)
1275
1276#--------------------------------------------------------------------
1277# Check if compiler supports -fobjc-arc, and if so, turn it on!
1278#--------------------------------------------------------------------
1279
1280AC_ARG_ENABLE(objc-arc, [
1281--enable-objc-arc
1282   Use automatic retain counts for Objective-C.  Use this option if you want
1283   to use the ARC mechanism of the Objective-C compiler and runtime.
1284],
1285USE_ARC=$enableval,
1286USE_ARC=$defaultng)
1287
1288AC_MSG_CHECKING(whether we should use ARC)
1289if test x"$USE_ARC" = x"yes"; then
1290  # What we want to do: set USE_ARC to yes if we can compile
1291  # something with -fobjc-arc.
1292  CFLAGS_no_arc="$CFLAGS"
1293  CFLAGS="$CFLAGS -fobjc-runtime=gnustep-1.8 -fobjc-arc"
1294  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1295/* Note that we never execute this code so it does not really matter
1296   what it is.  We are testing that the compiler accepts the
1297   '-fobjc-arc' flag.  */
1298int
1299main()
1300{
1301#ifndef __has_feature
1302#define __has_feature(x) 0
1303#endif
1304return __has_feature(objc_arc) ? 0 : 1;
1305}
1306]])], USE_ARC=yes, USE_ARC=no)
1307  AC_MSG_RESULT($USE_ARC)
1308  CFLAGS="$CFLAGS_no_arc"
1309
1310  if test x"$USE_ARC" = x"no"; then
1311    AC_MSG_NOTICE([Building ARC code was requested, but the compiler])
1312    AC_MSG_NOTICE([doesn't support it.])
1313    AC_MSG_ERROR([compiler doesn't support ARC])
1314  fi
1315else
1316  if test x"$USE_ARC" != x"no"; then
1317    saved_CPPFLAGS=$CPPFLAGS
1318    CPPFLAGS="$CPPFLAGS -x objective-c"
1319    AC_EGREP_CPP([^1$], [
1320#ifndef __has_feature
1321#define __has_feature(x) 0
1322#endif
1323__has_feature(objc_arc)
1324], USE_ARC=yes, USE_ARC=no)
1325    CPPFLAGS=$saved_CPPFLAGS
1326  fi
1327  if test x"$USE_ARC" = x"yes"; then
1328    AC_MSG_RESULT([yes (compiler default)])
1329  else
1330    AC_MSG_RESULT(not requested by user)
1331  fi
1332fi
1333
1334AC_SUBST(USE_ARC)
1335
1336
1337# Keep LIBS and CFLAGS as they are for a while - we need them in
1338# the following Objective-C tests!
1339
1340#--------------------------------------------------------------------
1341# Check if we should use -r or -Wl,-r when doing partial linking
1342#--------------------------------------------------------------------
1343
1344# Ideally, we'd use -r or -Wl,-r everywhere and that would work with
1345# both GCC and clang.  But -r doesn't work with clang on some
1346# platforms, while using -Wl,-r is a problem with GCC on some Sparc
1347# systems, where GCC automatically passes --relax to the linker unless
1348# you specify -r.  If you specify -Wl,-r, it still passes --relax,
1349# producing the error
1350#
1351#   ld: --relax and -r may not be used together
1352#
1353# To work around this, we use -Wl,-r with clang, and -r with GCC.
1354AC_MSG_CHECKING(for the flag to use to do partial linking)
1355gs_cv_using_clang=`${CC} --version 2>&5 | grep -c "clang"`
1356if test x"${gs_cv_using_clang}" = x"0" ; then
1357  OBJ_MERGE_CMD_FLAG=-r
1358  AC_MSG_RESULT([-r])
1359else
1360  OBJ_MERGE_CMD_FLAG=-Wl,-r
1361  AC_MSG_RESULT([-Wl,-r])
1362fi
1363
1364AC_SUBST(OBJ_MERGE_CMD_FLAG)
1365
1366#--------------------------------------------------------------------
1367# Check for the GCC version - this is used in the following tests
1368#--------------------------------------------------------------------
1369
1370GS_CHECK_GCC_VERSION()
1371
1372
1373GS_RUNTIME_ABI()
1374# If we determined that the user wants the gnustep-2.0 ABI, check for potential linker problems.
1375if test $gs_cv_runtime_abi = 'gnustep-2.0'; then
1376  GS_CHECK_ABI20_LINKER()
1377fi
1378# Do not restore LIBS and CFLAGS yet as we need to test if the
1379# compiler supports native exceptions.
1380
1381#--------------------------------------------------------------------
1382# Check if GCC supports -fobjc-exceptions, and if so, turn it on!
1383#--------------------------------------------------------------------
1384
1385AC_ARG_ENABLE(native-objc-exceptions, [
1386--disable-native-objc-exceptions
1387   Disable native Objective-C exception support (@try / @catch /
1388   @finally / @synchronized).  If unspecified, Objective-C exception
1389   support is enabled if the compiler can compile Objective-C code
1390   containing @try / @catch / @finally / @synchronized.  Please note
1391   that native exceptions also require support in the Objective-C
1392   runtime; GNUstep-base will check for that support and may still
1393   disable native exceptions if such support is not available.
1394   Use this option if you do not want to use the native Objective-C
1395   exception support provided by newer compilers.
1396],
1397USE_OBJC_EXCEPTIONS=$enableval,
1398USE_OBJC_EXCEPTIONS=maybe)
1399
1400if test x"$USE_OBJC_EXCEPTIONS" = x"maybe"; then
1401  if test x"$MSWIND" = x"yes"; then
1402    USE_OBJC_EXCEPTIONS=no
1403  fi
1404fi
1405
1406# Please note that -fobjc-exceptions should automatically enable
1407# -fexceptions.
1408AC_MSG_CHECKING(whether the compiler supports native ObjC exceptions)
1409if test x"$USE_OBJC_EXCEPTIONS" = x"maybe"; then
1410  # What we want to do: set USE_OBJC_EXCEPTIONS to yes if we can compile
1411  # something with @try/@catch/@finally in it.
1412  CFLAGS_no_exceptions="$CFLAGS"
1413  CFLAGS="$CFLAGS -fexceptions -fobjc-exceptions"
1414  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1415#include <objc/objc.h>
1416@interface Test { id isa; } @end
1417
1418int test (Test *o)
1419{
1420  @try
1421    {
1422      @throw o;
1423    }
1424   @catch (id foo)
1425    {
1426      if (o != foo)
1427	return 1;
1428    }
1429  return 0;
1430}
1431  ]])], USE_OBJC_EXCEPTIONS=yes, USE_OBJC_EXCEPTIONS=no)
1432    if test x"$USE_OBJC_EXCEPTIONS" = x"no"; then
1433      AC_MSG_RESULT(no)
1434    else
1435      AC_MSG_RESULT(yes)
1436    fi
1437    CFLAGS="$CFLAGS_no_exceptions"
1438else
1439  AC_MSG_RESULT($USE_OBJC_EXCEPTIONS)
1440fi
1441AC_SUBST(USE_OBJC_EXCEPTIONS)
1442
1443# Check if we need -shared-libgcc linker flags
1444if test x"$USE_OBJC_EXCEPTIONS" = x"yes" -a x"${GCC}" = x"yes"; then
1445  if test x"$CLANG_CC" = x"no"; then
1446    LDFLAGS="$LDFLAGS -shared-libgcc"
1447  fi
1448fi
1449
1450#--------------------------------------------------------------------
1451# Check if compiler supports -MMD -MP to generate %.d files ...
1452#--------------------------------------------------------------------
1453
1454AC_MSG_CHECKING(if the compiler supports autodependencies)
1455
1456# What we want to do: set AUTO_DEPENDENCIES to yes if gcc => 3.x.  As
1457# an exception, we disabled them on cygwin because the compiler
1458# generates autodependencies files containing filenames such as
1459# G:/GNUstep/mingw/include/stdlib.h which can't really work with GNU
1460# make because of the ':'.
1461
1462AUTO_DEPENDENCIES=""
1463if test "$CYGWIN" = yes; then
1464  AC_MSG_RESULT(no: autodependencies do not work on cygwin)
1465elif test ! ${GCC} = "yes" ; then
1466  AC_MSG_RESULT(no: it's not gcc)
1467else
1468  if test "${gs_cv_gcc_major_version}" -ge "3" >&5 2>&5; then
1469    AUTO_DEPENDENCIES=yes
1470    AC_MSG_RESULT(yes: gcc version is ${gs_cv_gcc_parsed_version} >= 3.0)
1471  else
1472    AC_MSG_RESULT(no: gcc version is ${gs_cv_gcc_parsed_version} < 3.0)
1473  fi
1474fi
1475
1476AC_SUBST(AUTO_DEPENDENCIES)
1477
1478#--------------------------------------------------------------------
1479# Check if compiler supports precompiled headers
1480#--------------------------------------------------------------------
1481
1482AC_MSG_CHECKING(if the compiler supports precompiled headers)
1483
1484# We used to check the compiler version here; this is not that
1485# reliable because precompiled headers were added in 3.4, then they
1486# were broken in 4.1, then fixed again.
1487
1488# So we prefer to actually try them out! ;-)
1489
1490# (Unfortunately, even that is not enough since we have reports of
1491# 4.1.1 GCC prereleases that pass this simple test, but where any
1492# serious usage of precompiled headers (ie, including
1493# Foundation/Foundation.h and AppKit/AppKit.h) doesn't work.  So in
1494# addition to doing this test, we also forcefully disable precompiled
1495# headers in 4.1)
1496
1497# What we want to do: set GCC_WITH_PRECOMPILED_HEADERS to yes if gcc
1498# can compile and use a precompiled header.
1499
1500GCC_WITH_PRECOMPILED_HEADERS="no"
1501
1502# First, a preliminary test.  If this is not gcc, precompiled headers
1503# are not supported.
1504if test ! "${GCC}" = "yes" ; then
1505  AC_MSG_RESULT(no: it's not gcc)
1506else
1507  if test "${gs_cv_gcc_parsed_version}" = "4.1" >&5 2>&5; then
1508    AC_MSG_RESULT(no: gcc 4.1 is often shipped with broken precompiled headers)
1509  else
1510    gs_precomp_test_builddir="`pwd`"
1511    gs_precomp_test_results=`(CC="$CC"; export CC; CFLAGS="$CFLAGS"; export CFLAGS; CPPLAGS="$CPPFLAGS"; export CPPFLAGS; LDFLAGS="$LDFLAGS"; export LDFLAGS; LIBS="$LIBS"; export LIBS; cd "$srcdir/config-precomp-test/"; ./run-test.sh "$gs_precomp_test_builddir"; echo $?) 2>&5`
1512    if test "$gs_precomp_test_results" = "0"; then
1513      GCC_WITH_PRECOMPILED_HEADERS="yes"
1514      AC_MSG_RESULT(yes)
1515    else
1516      # Please check the config-precomp-test.log log file for more info
1517      AC_MSG_RESULT(no: old or buggy gcc)
1518    fi
1519  fi
1520fi
1521
1522# Important - if you think there is a problem with precompiled
1523# headers, try adding ADDITIONAL_OBJC_FLAGS = -Winvalid-pch to your
1524# GNUmakefile to check that they are used.
1525AC_SUBST(GCC_WITH_PRECOMPILED_HEADERS)
1526
1527# Restore LIBS and CFLAGS - we used to compile C code after this
1528# point.  Useful to keep this in case we need to compile C code again.
1529LIBS="$saved_LIBS"
1530CFLAGS="$saved_CFLAGS"
1531
1532#--------------------------------------------------------------------
1533# Check if compiler requires -shared flag on Solaris ...
1534#--------------------------------------------------------------------
1535
1536AC_MSG_CHECKING(if the compiler requires -shared flag to build for Solaris)
1537
1538# set SOLARIS_SHARED to yes if gcc => 4.x
1539
1540SOLARIS_SHARED=""
1541if test ! ${GCC} = "yes" ; then
1542  AC_MSG_RESULT(no: it's not gcc)
1543else
1544  if test "${gs_cv_gcc_major_version}" -ge "4" >&5 2>&5; then
1545    if test "$host_os" = "solaris2.7" -o $"host_os" = "solaris2.6"; then
1546      AC_MSG_RESULT(no: solaris 2.6 or 2.7)
1547    else
1548      SOLARIS_SHARED=yes
1549      AC_MSG_RESULT(yes: gcc version is ${gs_cv_gcc_parsed_version} >= 4.0)
1550    fi
1551  else
1552    AC_MSG_RESULT(no: gcc version is ${gs_cv_gcc_parsed_version} < 4.0)
1553  fi
1554fi
1555
1556AC_SUBST(SOLARIS_SHARED)
1557
1558AC_SUBST(INCLUDES)
1559AC_SUBST(LIB_DIR)
1560AC_SUBST(OBJCFLAGS)
1561
1562#--------------------------------------------------------------------
1563# Check if we need to enable debug=yes builds by default
1564#--------------------------------------------------------------------
1565
1566AC_MSG_CHECKING(if we should enable 'make debug=yes' by default)
1567AC_ARG_ENABLE(debug-by-default, [
1568--enable-debug-by-default
1569   Enable building with 'make debug=yes' by default.  When you use
1570   gnustep-make to build software, you have a choice of using
1571   debug=yes or debug=no.  The debug=no will use the default compiler
1572   flags determined when gnustep-make was configured (usually -g -O2),
1573   while debug=yes will remove the optimization flags and add a
1574   number of debugging compiler flags.  If you do not specify the
1575   --enable-debug-by-default option, gnustep-make will default to
1576   building with debug=no when nothing is specified.  If you
1577   specify the --enable-debug-by-default option, gnustep-make will
1578   default to building with debug=yes instead, which can be handy if you
1579   always want to compile software with debug=yes and want to avoid
1580   having to type debug=yes each time you compile (an alternative
1581   is to define the variable debug=yes in your shell).  If you are
1582   unsure, you should stick with the default and ignore this option.
1583],
1584  ac_cv_debug_by_default=$enableval,
1585  ac_cv_debug_by_default="undefined")
1586
1587if test "$ac_cv_debug_by_default" = "yes"; then
1588  GNUSTEP_DEFAULT_DEBUG=yes;
1589  AC_MSG_RESULT(yes);
1590else
1591  GNUSTEP_DEFAULT_DEBUG=no;
1592  AC_MSG_RESULT(no);
1593fi
1594AC_SUBST(GNUSTEP_DEFAULT_DEBUG)
1595
1596#--------------------------------------------------------------------
1597# Check for GNU make
1598#--------------------------------------------------------------------
1599
1600# Search for GNU make.  We try 'gmake' then 'gnumake' then 'make'.  If
1601# we can't find it, we set it to 'make', even if that will fail later
1602# on.
1603AC_CHECK_PROGS(GNUMAKE, [gmake gnumake make], make)
1604
1605# Used by gnustep-config to launch gnustep-make to compute
1606# compilation/link flags
1607AC_SUBST(GNUMAKE)
1608
1609# If GNU make supports $(info ...), gnustep-make can use it to print
1610# out a help message at the beginning of each compilation.  This
1611# feature was introduced in GNU make 3.81, so we check GNU make's
1612# version number (alternatively, we could try executing a makefile
1613# that contains an info command).
1614AC_MSG_CHECKING(for the GNU Make version)
1615
1616# To get the make version, take the output of 'make --version', read
1617# only the first line (that we expect to be something like "GNU Make
1618# 3.81"), and ignore everything up to the first numeric character.
1619gs_cv_make_version=`($GNUMAKE --version | head -1 | sed -e 's/^[[^0-9]]*//') 2>&5`
1620
1621# Now check for the major/minor version numbers.
1622gs_cv_make_major_version=`(echo ${gs_cv_make_version} | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]]\([[0-9]][[0-9]]*\).*/\1/') 2>&5`
1623gs_cv_make_minor_version=`(echo ${gs_cv_make_version} | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]]\([[0-9]][[0-9]]*\).*/\2/') 2>&5`
1624AC_MSG_RESULT(version: ${gs_cv_make_major_version}.${gs_cv_make_minor_version})
1625
1626#--------------------------------------------------------------------
1627# Check for GNU Make >= 3.79
1628#--------------------------------------------------------------------
1629# We want to emit a warning if they are using GNU make < 3.79 as it's
1630# no longer supported.  We let them install everything at their own
1631# risk though.
1632AC_MSG_CHECKING(for GNU Make >= 3.79)
1633SUPPORTED_MAKE=no
1634if test "${gs_cv_make_major_version}" = "3" >&5 2>&5; then
1635  if test "${gs_cv_make_minor_version}" -ge "79" >&5 2>&5; then
1636    SUPPORTED_MAKE=yes
1637  fi
1638fi
1639
1640if test "${gs_cv_make_major_version}" -ge "4" >&5 2>&5; then
1641  SUPPORTED_MAKE=yes
1642fi
1643
1644if test "${SUPPORTED_MAKE}" = "yes" >&5 2>&5; then
1645  AC_MSG_RESULT(yes)
1646else
1647  # We do not abort mostly because the checks for GNU make might have
1648  # gone wrong and returned the wrong version, and because GNU make <
1649  # 3.79.1 probably works anyway (with the exception of parallel
1650  # building).
1651  AC_MSG_RESULT(no)
1652  AC_MSG_WARN(GNU Make >= 3.79.1 is recommended!  Older versions are no longer supported.  Continue at your own risk.)
1653fi
1654
1655#--------------------------------------------------------------------
1656# Check for $(info ...) function in GNU make
1657#--------------------------------------------------------------------
1658AC_MSG_CHECKING(if GNU Make has the info function)
1659
1660# Things may go wrong (eg, make couldn't be found in one of the
1661# previous steps), so by default we assume 'no' here.  If things go
1662# wrong, you'll lost some non-essential features.
1663MAKE_WITH_INFO_FUNCTION=no
1664if test "${gs_cv_make_major_version}" = "3" >&5 2>&5; then
1665  if test "${gs_cv_make_minor_version}" -ge "81" >&5 2>&5; then
1666    MAKE_WITH_INFO_FUNCTION=yes
1667  fi
1668fi
1669
1670if test "${gs_cv_make_major_version}" -ge "4" >&5 2>&5; then
1671  MAKE_WITH_INFO_FUNCTION=yes
1672fi
1673
1674AC_MSG_RESULT(${MAKE_WITH_INFO_FUNCTION})
1675AC_SUBST(MAKE_WITH_INFO_FUNCTION)
1676
1677#--------------------------------------------------------------------
1678# Shall we strip makefiles upon installation ?
1679#--------------------------------------------------------------------
1680
1681# Stripping makefiles removes comments and newlines from them.  The
1682# resulting stripped makefiles execute around 5% faster on average.
1683# Too little for it to be worth for the common user who's more
1684# interested in the comments :-) so it's disabled by default.
1685AC_MSG_CHECKING(if we should strip makefiles after installation)
1686AC_ARG_ENABLE(strip-makefiles, [
1687--enable-strip-makefiles
1688   Enable stripping system makefiles after installation.  This will
1689   speed up gnustep-make by about 5% (average), but will remove all
1690   comments from the installed makefiles.  Those comments are quite
1691   useful if you are trying to find some information on how gnustep-make
1692   works (eg, if you're trying to locate a bug), and the performance
1693   gain is quite small, so you probably don't want to strip makefiles.
1694],
1695  ac_cv_strip_makefiles=$enableval,
1696  ac_cv_strip_makefiles="undefined")
1697
1698if test "$ac_cv_strip_makefiles" = "yes"; then
1699  GNUSTEP_STRIP_MAKEFILES=strip;
1700  AC_MSG_RESULT(yes);
1701else
1702  GNUSTEP_STRIP_MAKEFILES=;
1703  AC_MSG_RESULT(no);
1704fi
1705AC_SUBST(GNUSTEP_STRIP_MAKEFILES)
1706
1707#-------------------------------------------------
1708# Determine if we should enable parallel building
1709#-------------------------------------------------
1710
1711AC_MSG_CHECKING([if we should enable support for parallel building])
1712AC_ARG_ENABLE(parallel-building, [
1713--disable-parallel-building
1714  Disable support for parallel building.  Normally this is enabled
1715  and you can request parallel building of a project by using the '-j N'
1716  flag for make (where N is a number, eg, '-j 4').  If you know that
1717  you are never going to be using parallel building, you can disable
1718  parallel building here - which will ignore all '-j N' flags, and
1719  also avoid executing a 'compile' submake invocation - resulting
1720  in slightly faster non-parallel builds, but making it impossible
1721  to do parallel builds.
1722],
1723  ac_cv_parallel_building=$enableval,
1724  ac_cv_parallel_building="yes")
1725
1726if test "$ac_cv_parallel_building" = "yes"; then
1727  AC_MSG_RESULT(yes);
1728  GNUSTEP_MAKE_PARALLEL_BUILDING="yes"
1729else
1730  AC_MSG_RESULT(no);
1731  GNUSTEP_MAKE_PARALLEL_BUILDING="no"
1732fi
1733
1734AC_SUBST(GNUSTEP_MAKE_PARALLEL_BUILDING)
1735
1736
1737#--------------------------------------------------------------------
1738# Record the version
1739#--------------------------------------------------------------------
1740AC_MSG_CHECKING(for the version of gnustep-make we are compiling)
1741. "$srcdir/Version"
1742AC_MSG_RESULT($GNUSTEP_MAKE_VERSION)
1743AC_SUBST(GNUSTEP_MAKE_VERSION)
1744AC_SUBST(GNUSTEP_MAKE_MAJOR_VERSION)
1745AC_SUBST(GNUSTEP_MAKE_MINOR_VERSION)
1746AC_SUBST(GNUSTEP_MAKE_SUBMINOR_VERSION)
1747
1748#-------------------------------------------------------------------
1749# Record the 'clean' target_os, target_cpu and target_vendor
1750#-------------------------------------------------------------------
1751# This is just for efficiency, so that core/make/GNUmakefile does not
1752# have to compute clean_target_os from target_os (and similar) by
1753# running shell scripts each time you 'make' something inside
1754# gnustep-make.  We basically compute them once now, and cache them
1755# forever.  It is also used by GNUstep.sh when multi-platform is
1756# disabled.
1757clean_target_os=`$srcdir/clean_os.sh $target_os`
1758clean_target_cpu=`$srcdir/clean_cpu.sh $target_cpu`
1759clean_target_vendor=`$srcdir/clean_cpu.sh $target_vendor`
1760AC_SUBST(clean_target_os)
1761AC_SUBST(clean_target_cpu)
1762AC_SUBST(clean_target_vendor)
1763AC_SUBST(target)
1764
1765#--------------------------------------------------------------------
1766# For documentation
1767#--------------------------------------------------------------------
1768AC_CHECK_PROGS(LATEX2HTML, latex2html)
1769
1770#--------------------------------------------------------------------
1771# For test framework
1772#--------------------------------------------------------------------
1773AC_PATH_PROG(SHELLPROG,bash,/bin/sh)
1774AC_PATH_PROG(TESTPROG, test)
1775
1776#--------------------------------------------------------------------
1777# Produce the output files
1778#--------------------------------------------------------------------
1779AC_CONFIG_FILES([config-noarch.make config.make openapp opentool
1780executable.template GNUmakefile GNUstep.conf GNUstep-strict-v2.conf
1781GNUstep.sh GNUstep.csh fixpath.sh
1782gnustep-make.spec gnustep-config TestFramework/gnustep-tests
1783filesystem.make filesystem.sh filesystem.csh gnustep-make-ld.so.conf])
1784AC_CONFIG_FILES([runtime/$OBJC_RUNTIME_LIB.make:config.make.in])
1785AC_CONFIG_COMMANDS([default],
1786	[[chmod a+x openapp opentool fixpath.sh executable.template]],
1787	[[]])
1788AC_OUTPUT
1789