]> err.no Git - sope/blob - gnustep-make/configure.ac
bumped dyld version
[sope] / gnustep-make / configure.ac
1 #
2 #   configure.ac
3 #
4 #   Copyright (C) 1997-2004 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 2
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.LIB.
20 #   If not, write to the Free Software Foundation,
21 #   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 AC_INIT
23 AC_PREREQ(2.57)
24 AC_CONFIG_SRCDIR([application.make])
25 AC_CONFIG_HEADER(config.h)
26
27 #--------------------------------------------------------------------
28 # Setup the library combination
29 #--------------------------------------------------------------------
30 targetArgument=${target}
31 AC_PROG_CC
32 AC_PROG_CPP
33 AC_CANONICAL_TARGET([])
34
35 AC_MSG_CHECKING(for library combo)
36 AC_ARG_WITH(library-combo,[
37 --with-library-combo
38    Define the default "library combo".  The library combo is a string
39    of the form aaa-bbb-ccc where 'aaa' is the Objective-C runtime
40    library to use (examples are 'gnu' and 'apple'), 
41    'bbb' is the Foundation library to use (examples are 'gnu' for
42    gnustep-base, and 'apple' for Apple Cocoa FoundationKit),
43    and 'ccc' is the ApplicationKit to use (examples are 'gnu'
44    for gnustep-gui and 'apple' for Apple Cocoa AppKit).  Use this 
45    option if you want to force a different default library combo than 
46    the one that would be used by default.  For example, on Darwin GNUstep
47    will automatically use the Apple Objective-C frameworks by
48    default (library-combo=apple-apple-apple); if you are planning 
49    on installing and using gnustep-base on there, you would need 
50    to use --with-library-combo=gnu-gnu-gnu instead.  Please notice
51    that if --disable-flattened is used, gnustep-make can have fat
52    binaries that support multiple library combos.  In that case,
53    this flag will only configure the default one, but you can still
54    use other ones at run-time.
55 ],
56 ac_cv_library_combo=$withval,
57 ac_cv_library_combo=$ac_cv_library_combo
58 )
59
60 if test "$ac_cv_library_combo" = "" -o "$ac_cv_library_combo" = "no"; then
61   case "$host_os" in
62     darwin*)   ac_cv_library_combo=apple-apple-apple ;;
63     nextstep4) ac_cv_library_combo=nx-nx-nx          ;;
64     openstep4) ac_cv_library_combo=nx-nx-nx          ;;
65     *)         ac_cv_library_combo=gnu-gnu-gnu       ;;
66   esac
67 fi
68
69 case "$ac_cv_library_combo" in
70   apple) ac_cv_library_combo=apple-apple-apple ;;
71   gnu)   ac_cv_library_combo=gnu-gnu-gnu ;;
72   nx)    ac_cv_library_combo=nx-nx-nx ;;
73 esac
74
75 AC_SUBST(ac_cv_library_combo)
76 AC_MSG_RESULT($ac_cv_library_combo)
77
78 OBJC_RUNTIME_LIB=`echo $ac_cv_library_combo | awk -F- '{print $1}'`
79
80 #--------------------------------------------------------------------
81 # Check if we are using Apple cc
82 #--------------------------------------------------------------------
83 cc_cppprecomp=0
84 cc_byndle=0
85 AC_MSG_CHECKING([for apple compiler flags])
86 cc_cppprecomp=`${CC} -no-cpp-precomp 2>&1 | grep -c "unrecognized"`
87 cc_bundle=`${CC} -bundle 2>&1 | grep -c "couldn"`
88 # 0 means we have the flag
89 if test $cc_cppprecomp = 0; then
90   cc_cppprecomp=yes
91 else
92   cc_cppprecomp=no
93 fi
94 if test $cc_bundle = 0; then
95   cc_bundle=yes
96 else
97   cc_bundle=no
98 fi
99 AC_MSG_RESULT($cc_bundle)
100 AC_SUBST(cc_cppprecomp)
101 AC_SUBST(cc_bundle)
102
103 #--------------------------------------------------------------------
104 # specific target_os options
105 #--------------------------------------------------------------------
106 case "$target_os" in
107   freebsd* | openbsd* ) 
108                 INCLUDES="$INCLUDES -I/usr/local/include"
109                 LIB_DIR="$LIB_DIR -L/usr/local/lib";;
110   netbsd*)      INCLUDES="$INCLUDES -I/usr/pkg/include"
111                 LIB_DIR="$LIB_DIR -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
112 esac
113
114 #--------------------------------------------------------------------
115 # Determine the host, build, and target systems
116 #--------------------------------------------------------------------
117 case $host_os in
118   *cygwin*  )
119         MINGW32=no
120         CYGWIN=yes
121         MSWIND=yes;;
122   *mingw32* )
123         MINGW32=yes
124         CYGWIN=yes
125         MSWIND=yes;;
126           * )
127         MINGW32=no
128         CYGWIN=no
129         MSWIND=no;;
130 esac
131 AC_SUBST(CYGWIN)
132
133 AC_EXEEXT
134 AC_OBJEXT
135 if test "$MINGW32" = yes; then
136   echo "hosted on mingw32 .."
137   export INSTALL="install -p"
138   export SHELL=sh
139   export CC=${CC:-gcc}
140   export AR=${AR:-ar}
141   export RANLIB=${RANLIB:-ranlib}
142   export DLLTOOL=${DLLTOOL:-dlltool}
143 elif test "$CYGWIN" = yes; then
144   echo "hosted on cygwin .."
145   export CC=${CC:-gcc}
146   export AR=${AR:-ar}
147   export RANLIB=${RANLIB:-ranlib}
148   export DLLTOOL=${DLLTOOL:-dlltool}
149 fi
150
151 #--------------------------------------------------------------------
152 # Find the binary and compile tools
153 #--------------------------------------------------------------------
154 if test "x$target" != "x$host"; then
155   echo "cross compiling from $host to $target .."
156   cross_compiling="yes"
157   AC_CHECK_PROG(CC,      "${targetArgument}-gcc",     dnl
158                          "${targetArgument}-gcc",     gcc)
159   AC_CHECK_PROG(RANLIB,  "${targetArgument}-ranlib",  dnl
160                          "${targetArgument}-ranlib",  ranlib)
161   AC_CHECK_PROG(AR,      "${targetArgument}-ar",      dnl
162                          "${targetArgument}-ar",      ar)
163   AC_CHECK_PROG(DLLTOOL, "${targetArgument}-dlltool", dnl
164                          "${targetArgument}-dlltool", dlltool)
165 else
166   AC_CHECK_PROG(AR,      ar,      ar)
167   AC_CHECK_PROG(DLLTOOL, dlltool, dlltool)
168   AC_PROG_RANLIB
169 fi
170
171 AC_PROG_INSTALL
172 AC_PROG_LN_S([])
173
174 AC_CHECK_PROGS(TAR, gnutar gtar, tar)
175 AC_ARG_WITH(tar,[
176 --with-tar
177    Set the name of the tar program to use.  Use this option if the
178    default choice does not work for you.
179 ],
180   TAR="$withval",)
181
182 AC_CHECK_PROG(CHOWN, chown, chown, none)
183 if test "$MINGW32" = no; then
184   if test "$CHOWN" = "none"; then
185     AC_MSG_ERROR("Could not find chown.");
186   fi
187 fi
188
189 #-------------------------------------------------------------------
190 # GNUstep specific options follow
191 #-------------------------------------------------------------------
192
193 #---------------------------------------------------------------------
194 # Location of the GNUstep.conf config file (--with-config-file)
195 #---------------------------------------------------------------------
196 AC_MSG_CHECKING([for GNUstep configuration file to use])
197 AC_ARG_WITH(config-file,[
198 --with-config-file=PATH
199    Set the path of the system GNUstep config file.  Use this option 
200    if you want to have the GNUstep config file in a non-standard place.
201    Example: --with-config-file=/usr/GNUstep/GNUstep.conf
202 ],
203   GNUSTEP_CONFIG_FILE="$withval",)
204 if test "$GNUSTEP_CONFIG_FILE" = "" -o "$GNUSTEP_CONFIG_FILE" = "no"; then
205   case "$target_os" in
206     freebsd* | openbsd* ) GNUSTEP_CONFIG_FILE=/usr/etc/GNUstep.conf ;;
207     netbsd* )             GNUSTEP_CONFIG_FILE=/usr/pkg/etc/GNUstep.conf ;;
208     mingw32* )      GNUSTEP_CONFIG_FILE=/c/GNUstep/GNUstep.conf-dev ;;
209     *)              GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf ;;
210   esac
211 fi
212 if echo "$GNUSTEP_CONFIG_FILE" | grep -q '[[    \\]]'
213 then
214   echo "found a backslash or space (illegal) in '$GNUSTEP_CONFIG_FILE'"
215   echo "Please try again using --with-config-file= to specify a valid path."
216   if test "$MSWIND" = "yes"
217   then
218     echo "Please note that on windows you must use unix-style paths within"
219     echo "the make package even though gnustep programs built in the mingw32"
220     echo "environment use native paths throughout."
221   fi
222   exit 1
223 fi
224 AC_MSG_RESULT($GNUSTEP_CONFIG_FILE)
225 AC_SUBST(GNUSTEP_CONFIG_FILE)
226
227 #---------------------------------------------------------------------
228 # Now read/import the existing configuration file, if any
229 #---------------------------------------------------------------------
230
231 # Reading/importing the existing configuration file is good as a
232 # default because it means that you don't have to type in your
233 # GNUSTEP_SYSTEM_ROOT, GNUSTEP_LOCAL_ROOT, etc. settings every time
234 # you configure gnustep-make. (please note we only read the
235 # system-wide one, not the user one.  Reason being that the settings
236 # we read will be used to generate the new system-wide one, while the
237 # user one will be left untouched).
238
239 # It can be annoying in certain cases though; this option lets you
240 # turn it off
241 AC_MSG_CHECKING([if we should import an existing configuration file])
242 AC_ARG_ENABLE(importing-config-file, [
243 --disable-importing-config-file
244    Disable importing the existing system GNUstep configuration file.
245    Use this option to prevent an existing configuration file from being
246    parsed and used when configure is being run.
247 ], 
248   ac_cv_importing_config_file=$enableval,
249   ac_cv_importing_config_file="yes")
250
251 # If importing the file is disabled, don't import it.
252 if test "$ac_cv_importing_config_file" = "no"; then
253   AC_MSG_RESULT([no: disabled from the command-line])
254 else
255
256  # Check that the file exists
257  if test ! -f "$GNUSTEP_CONFIG_FILE"; then
258   AC_MSG_RESULT([no: file "$GNUSTEP_CONFIG_FILE" does not exist])
259  else
260   AC_MSG_RESULT([yes: trying to import "$GNUSTEP_CONFIG_FILE"])
261   AC_MSG_NOTICE([If this fails, please run configure again with the --disable-importing-config-file option])
262   . "$GNUSTEP_CONFIG_FILE"
263  fi
264 fi
265
266 #--------------------------------------------------------------------
267 # Important - from now on, any variable that is set in the
268 # configuration file (eg, GNUSTEP_SYSTEM_ROOT) could already have a
269 # value that we have imported from the previous file.  ./configure
270 # command line options should override those values, but otherwise we
271 # should keep them!
272 #
273 # Those could also be env variables, which is really a backwards
274 # compatibility hack that won't necessarily be kept in the future!
275 #--------------------------------------------------------------------
276
277
278 #--------------------------------------------------------------------
279 # Process --prefix
280 #--------------------------------------------------------------------
281
282 #
283 # In practice,
284 #
285 # ./configure --prefix=/usr/GNUstep
286 #
287 # is equivalent to:
288 #
289 # ./configure --with-system-root=/usr/GNUstep/System
290 #             --with-local-root=/usr/GNUstep/Local
291 #
292 # plus it has the side-effect that a config.site will be loaded by
293 # ./configure from $prefix/share/config.site, if it exists.  Our
294 # config.site is in $prefix/System/share/config.site though, so it
295 # won't be found.  It doesn't really matter though, as the config.site
296 # is irrelevant for us in this context.
297 #
298
299 # Please note that AC_PREFIX_DEFAULT will not appear in this position
300 # in the generated configure file; it will appear at the very
301 # beginning.  So we can't check for GNUSTEP_SYSTEM_ROOT or anything
302 # similar in the implementation of AC_PREFIX_DEFAULT because we will
303 # not have read GNUstep.conf yet ...  
304
305 # PS: This is the default GNUSTEP_ROOT that is used when installing
306 # GNUstep with no other indication.  Test for the C: directory, which
307 # means we're on Windows
308 AC_PREFIX_DEFAULT(`if test -d C: ; then
309     echo C:/GNUstep;
310   else
311     echo /usr/GNUstep ;
312   fi`)
313
314 #
315 # GNUSTEP_ROOT is only used to set default values for
316 # GNUSTEP_SYSTEM_ROOT and GNUSTEP_LOCAL_ROOT if they are not set in
317 # config file or as a command-line argument.
318 #
319 if test "x$prefix" = "xNONE"; then
320   GNUSTEP_ROOT="$ac_default_prefix" ;
321 else
322   GNUSTEP_ROOT="$prefix";
323
324   # Set the values for all those variables ovverriding anything read
325   # from the configuration file or inherited from the environment.
326   # The --prefix=xxx option should overwrite those.  Please notice
327   # that the --with-system-root=xxx (and similar) options are
328   # processed later as overwrite --prefix=xxx in their specific area.
329   GNUSTEP_SYSTEM_ROOT="$GNUSTEP_ROOT/System";
330   GNUSTEP_LOCAL_ROOT="$GNUSTEP_ROOT/Local";
331   GNUSTEP_NETWORK_ROOT="$GNUSTEP_LOCAL_ROOT";
332 fi
333
334 #--------------------------------------------------------------------
335 # Process --with-system-root
336 #--------------------------------------------------------------------
337 AC_MSG_CHECKING(for GNUSTEP_SYSTEM_ROOT to use)
338 AC_ARG_WITH(system-root,[
339 --with-system-root
340    Set the GNUSTEP_SYSTEM_ROOT directory.  Use this option if you want 
341    to have the GNUSTEP_SYSTEM_ROOT directory in a non-standard place.
342    Example: --with-system-root=/usr/GNUstep/System
343 ],
344 GNUSTEP_SYSTEM_ROOT="$withval",)
345 if test "$GNUSTEP_SYSTEM_ROOT" = "" -o "$GNUSTEP_SYSTEM_ROOT" = "no"; then 
346   GNUSTEP_SYSTEM_ROOT="$GNUSTEP_ROOT/System"
347 fi
348 if echo "$GNUSTEP_SYSTEM_ROOT" | grep -q '[[    \\]]'
349 then
350   echo "found a backslash or space (illegal) in '$GNUSTEP_SYSTEM_ROOT'"
351   echo "Please try again using --with-system-root= to specify a valid path."
352   if test "$MSWIND" = "yes"
353   then
354     echo "Please note that on windows you must use unix-style paths within"
355     echo "the make package even though gnustep programs built in the mingw32"
356     echo "environment use native paths throughout."
357   fi
358   exit 1
359 fi
360 AC_MSG_RESULT($GNUSTEP_SYSTEM_ROOT)
361 AC_SUBST(GNUSTEP_SYSTEM_ROOT)
362
363 #--------------------------------------------------------------------
364 # Process --with-local-root
365 #--------------------------------------------------------------------
366 AC_MSG_CHECKING(for GNUSTEP_LOCAL_ROOT to use)
367 AC_ARG_WITH(local-root,[
368 --with-local-root
369    Set the GNUSTEP_LOCAL_ROOT directory.  Use this option if you want 
370    to have the GNUSTEP_LOCAL_ROOT directory in a non-standard place.
371    Example: --with-local-root=/usr/local/GNUstep/Local
372 ],
373 GNUSTEP_LOCAL_ROOT="$withval",)
374 # If GNUSTEP_LOCAL_ROOT is explicitly set to 'no', we effectively disable it
375 # by setting it to be the same as GNUSTEP_SYSTEM_ROOT
376 if test "$GNUSTEP_LOCAL_ROOT" = "no"; then 
377   GNUSTEP_LOCAL_ROOT="$GNUSTEP_SYSTEM_ROOT"
378 fi
379 if test "$GNUSTEP_LOCAL_ROOT" = ""; then 
380   GNUSTEP_LOCAL_ROOT="$GNUSTEP_ROOT/Local"
381 fi
382 if echo "$GNUSTEP_LOCAL_ROOT" | grep -q '[[     \\]]'
383 then
384   echo "found a backslash or space (illegal) in '$GNUSTEP_LOCAL_ROOT'"
385   echo "Please try again using --with-local-root= to specify a valid path."
386   if test "$MSWIND" = "yes"
387   then
388     echo "Please note that on windows you must use unix-style paths within"
389     echo "the make package even though gnustep programs built in the mingw32"
390     echo "environment use native paths throughout."
391   fi
392   exit 1
393 fi
394 AC_MSG_RESULT($GNUSTEP_LOCAL_ROOT)
395 AC_SUBST(GNUSTEP_LOCAL_ROOT)
396
397 #--------------------------------------------------------------------
398 # Process --with-network-root
399 #--------------------------------------------------------------------
400 AC_MSG_CHECKING(for GNUSTEP_NETWORK_ROOT to use)
401 AC_ARG_WITH(network-root,[
402 --with-network-root
403    Set the GNUSTEP_NETWORK_ROOT directory.  Use this option if you 
404    want to have the GNUSTEP_NETWORK_ROOT directory.  
405    Example: --with-network-root=/usr/local/GNUstep/Network
406 ],
407 GNUSTEP_NETWORK_ROOT="$withval",)
408 # By default we disable network root, by setting GNUSTEP_NETWORK_ROOT
409 # to be the same as GNUSTEP_LOCAL_ROOT.  GNUSTEP_NETWORK_ROOT is very
410 # rarely used, and most users prefer simpler systems with shorter
411 # paths and shorter command lines.  To turn on GNUSTEP_NETWORK_ROOT
412 # again, you can use the --with-network-root=xxx option; pass
413 # something like --with-network-root=/usr/GNUstep/Network on the
414 # configure command line.
415 if test "$GNUSTEP_NETWORK_ROOT" = "" -o "$GNUSTEP_NETWORK_ROOT" = "no"; then 
416   GNUSTEP_NETWORK_ROOT="$GNUSTEP_LOCAL_ROOT"
417 fi
418 if echo "$GNUSTEP_NETWORK_ROOT" | grep -q '[[   \\]]'
419 then
420   echo "found a backslash or space (illegal) in '$GNUSTEP_NETWORK_ROOT'"
421   echo "Please try again using --with-network-root= to specify a valid path."
422   if test "$MSWIND" = "yes"
423   then
424     echo "Please note that on windows you must use unix-style paths within"
425     echo "the make package even though gnustep programs built in the mingw32"
426     echo "environment use native paths throughout."
427   fi
428   exit 1
429 fi
430 AC_MSG_RESULT($GNUSTEP_NETWORK_ROOT)
431 AC_SUBST(GNUSTEP_NETWORK_ROOT)
432
433 #--------------------------------------------------------------------
434 # Process --with-user-config-file
435 #--------------------------------------------------------------------
436 AC_MSG_CHECKING(for user config file to use)
437 AC_ARG_WITH(user-config-file,[
438 --with-user-config-file
439    Set the name of the user config file to use.  This can be 
440    relative to the user's home directory if it is a relative path,
441    or an absolute directory (the same for all users) if it is an
442    absolute path.  Use '' if you want to disable user config files.
443    The default is .GNUstep.conf if not specified.
444    Example: --with-user-config-file=GNUstep/GNUstep.conf
445 ],
446 GNUSTEP_USER_CONFIG_FILE="$withval",)
447 if test "$GNUSTEP_USER_CONFIG_FILE" = "" -o "$GNUSTEP_USER_CONFIG_FILE" = "no"; then 
448   GNUSTEP_USER_CONFIG_FILE=".GNUstep.conf"
449 fi
450 if echo "$GNUSTEP_USER_CONFIG_FILE" | grep -q '[[       \\]]'
451 then
452   echo "found a backslash or space (illegal) in '$GNUSTEP_USER_CONFIG_FILE'"
453   echo "Please try again using --with-user-config-file= to specify a value."
454   if test "$MSWIND" = "yes"
455   then
456     echo "Please note that on windows you must use unix-style paths within"
457     echo "the make package even though gnustep programs built in the mingw32"
458     echo "environment use native paths throughout."
459   fi
460   exit 1
461 fi
462 AC_MSG_RESULT($GNUSTEP_NETWORK_ROOT)
463 AC_MSG_RESULT($GNUSTEP_USER_CONFIG_FILE)
464 AC_SUBST(GNUSTEP_USER_CONFIG_FILE)
465
466 #--------------------------------------------------------------------
467 # Process --with-user-dir
468 #--------------------------------------------------------------------
469 AC_MSG_CHECKING(for user dir to use)
470 AC_ARG_WITH(user-dir,[
471 --with-user-dir
472    Set the GNUSTEP_USER_DIR directory for all users.  This can be
473    relative to the user's home directory if it is a relative path,
474    or an absolute directory (the same for all users) if it is an
475    absolute path.  Use this option if you want to have the 
476    GNUSTEP_USER_DIR directory in a non default place for all users.
477    The default is 'GNUstep'.
478    Example: --with-user-dir='gnustep'
479 ],
480 GNUSTEP_USER_DIR="$withval",)
481 if test "$GNUSTEP_USER_DIR" = "" -o "$GNUSTEP_USER_DIR" = "no"; then 
482   GNUSTEP_USER_DIR="GNUstep"
483 fi
484 if echo "$GNUSTEP_USER_DIR" | grep -q '[[       \\]]'
485 then
486   echo "found a backslash or space (illegal) in '$GNUSTEP_USER_DIR'"
487   echo "Please try again using --with-user-dir= to specify a value."
488   if test "$MSWIND" = "yes"
489   then
490     echo "Please note that on windows you must use unix-style paths within"
491     echo "the make package even though gnustep programs built in the mingw32"
492     echo "environment use native paths throughout."
493   fi
494   exit 1
495 fi
496 AC_MSG_RESULT($GNUSTEP_USER_DIR)
497 AC_SUBST(GNUSTEP_USER_DIR)
498
499 #--------------------------------------------------------------------
500 # Process --with-user-defaults-dir
501 #--------------------------------------------------------------------
502 AC_MSG_CHECKING(for user defaults dir to use)
503 AC_ARG_WITH(user-defaults-dir,[
504 --with-user-defaults-dir
505    Set the GNUstep user defaults directory for all users.  This can be
506    relative to the user's home directory if it is a relative path,
507    or an absolute directory (the same for all users) if it is an
508    absolute path.  Use this option if you want to have the 
509    GNUSTEP_USER_DEFAULTS_DIR directory in a non default place for
510    all users.  The default is 'GNUstep/Defaults'
511    Example: --with-user-defaults-dir='GNUstep/Library/Defaults'
512 ],
513 GNUSTEP_USER_DEFAULTS_DIR="$withval",)
514 if test "$GNUSTEP_USER_DEFAULTS_DIR" = "" -o "$GNUSTEP_USER_DEFAULTS_DIR" = "no"; then 
515   GNUSTEP_USER_DEFAULTS_DIR="GNUstep/Defaults"
516 fi
517 if echo "$GNUSTEP_USER_DEFAULTS_DIR" | grep -q '[[      \\]]'
518 then
519   echo "found a backslash or space (illegal) in '$GNUSTEP_USER_DEFAULTS_DIR'"
520   echo "Please try again using --with-user-defaults-dir= to specify a value."
521   if test "$MSWIND" = "yes"
522   then
523     echo "Please note that on windows you must use unix-style paths within"
524     echo "the make package even though gnustep programs built in the mingw32"
525     echo "environment use native paths throughout."
526   fi
527   exit 1
528 fi
529 AC_MSG_RESULT($GNUSTEP_USER_DEFAULTS_DIR)
530 AC_SUBST(GNUSTEP_USER_DEFAULTS_DIR)
531
532 #--------------------------------------------------------------------
533 # Setting up GNUSTEP_MAKEFILES
534 #--------------------------------------------------------------------
535 #
536 # Please note that we do an explicit check in preparation for the (not
537 # so far) future when this directory (like any other GNUstep
538 # directory, eg, Applications or Tools or Libraries) will be
539 # relocatable to anywhere you like.
540 #
541 AC_MSG_CHECKING(for GNUSTEP_MAKEFILES to use)
542 GNUSTEP_MAKEFILES="$GNUSTEP_SYSTEM_ROOT/Library/Makefiles"
543 AC_SUBST(GNUSTEP_MAKEFILES)
544 AC_MSG_RESULT($GNUSTEP_MAKEFILES)
545
546 #--------------------------------------------------------------------
547 # Setting up the install-sh script
548 #--------------------------------------------------------------------
549
550 # HOST_INSTALL is the name of the install program in config.make so set it up
551 # to point to the install-sh script in the GNUstep tree if no system install is
552 # found.
553 AC_SUBST(HOST_INSTALL)
554 if test "$INSTALL" = "$ac_install_sh"; then
555   HOST_INSTALL="$GNUSTEP_MAKEFILES/$INSTALL"
556 else
557   HOST_INSTALL="$INSTALL"
558 fi
559
560 #--------------------------------------------------------------------
561 # Is the system flattened?
562 #--------------------------------------------------------------------
563 AC_MSG_CHECKING(for flattened directory structure)
564 AC_ARG_ENABLE(flattened, [
565 --disable-flattened
566    Disable flattened directory structure.  Use this option if you want
567    to have support for multiple library combos and fat binaries.  A
568    library combo specifies the Objective-C frameworks to use to compile
569    a program, so having multiple library combos is only useful if you 
570    have (or plan to have) multiple OpenStep-like Objective-C frameworks 
571    installed on your machine, for example both the Apple Cocoa Objective-C 
572    frameworks and the GNUstep frameworks.  Fat binaries allow you to
573    have multiple versions for different CPUs and Operating Systems.  
574    Please note that using the fat directory structure will not blend 
575    easily with native filesystems and so if you want the non-flattened
576    directory structure you probably want to install GNUstep using its 
577    own default filesystem layout.  To switch between different 
578    library-combos, you also need to source GNUstep.sh after
579    setting the LIBRARY_COMBO environment variable.  Please refer to
580    the documentation for more information on library-combos and fat
581    binaries.
582 ], 
583   ac_cv_flattened=$enableval,
584   ac_cv_flattened="undefined")
585
586 if test "$ac_cv_flattened" = "no"; then
587   GNUSTEP_FLATTENED=;
588 else
589   GNUSTEP_FLATTENED=yes;
590 fi
591 AC_SUBST(GNUSTEP_FLATTENED)
592
593 if test "$GNUSTEP_FLATTENED" = "yes"; then
594   AC_MSG_RESULT(yes);
595 else
596   AC_MSG_RESULT(no);
597 fi
598
599
600 #--------------------------------------------------------------------
601 # Is the system multi-platform?
602 #--------------------------------------------------------------------
603 #
604 # Multi-platform means that GNUstep.sh will determine the host
605 # platform (by running config.guess) each time that it is sourced.
606 # This is good if you are sharing your GNUstep.sh across your network
607 # (for example, mounting the makefiles via NFS), but it requires you
608 # to be able to run config.guess on your machine(s), which usually
609 # requires a development environment (compiler, libc etc).
610 #
611 # The default instead is not using multi-platform, which means the
612 # local host os, cpu and version is hardcoded in GNUstep.sh.  This
613 # works nicely for a single machine using this gnustep-make
614 # installation, and it works even if you don't have development
615 # packages (gcc, binutils, libc-dev etc) installed.  We had to make
616 # this the default after end-users (with no development packages
617 # installed) complained that binary packages wouldn't work (and the
618 # reason turned out to be that GNUstep.sh was running config.guess
619 # which was returning the wrong platform because the development
620 # tools needed/used to determine the platform were not available).
621 #
622 # Unless you know what you are doing, stick with the default, which is
623 # also much faster when sourcing GNUstep.sh.
624 #
625 AC_ARG_ENABLE(multi-platform, [
626 --enable-multi-platform
627    Enable run-time multi-platform support.  If this option is enabled,
628    then every time GNUstep.sh is run it will determine/guess the type
629    of local host machine instead of using the hardcoded value.  Use
630    this together with --disable-flattened if you have a single GNUstep
631    installation with fat binaries that is being shared over the network
632    by a variety of machines with different hardware and o/s.
633 ], 
634   ac_cv_multi_platform=$enableval,
635   ac_cv_multi_platform="undefined")
636
637 if test "$ac_cv_multi_platform" = "yes"; then
638   GNUSTEP_MULTI_PLATFORM=yes;
639 else
640   GNUSTEP_MULTI_PLATFORM=;
641 fi
642 AC_SUBST(GNUSTEP_MULTI_PLATFORM)
643
644 #--------------------------------------------------------------------
645 # Build backend bundles (on by default)
646 #--------------------------------------------------------------------
647 AC_ARG_ENABLE(backend-bundle, [
648 --disable-backend-bundle
649    Compile GUI backend as a library.  Use this option if the default
650    compilation of the GUI backend as a bundle (loadable module) is
651    not supported / does not work on your machine.
652 ], 
653   ac_cv_backend=$enableval,  
654   ac_cv_backend="yes")
655
656 if test "$ac_cv_backend" = "yes"; then
657   BACKEND_BUNDLE=yes;
658 else
659   BACKEND_BUNDLE=;
660 fi
661 AC_SUBST(BACKEND_BUNDLE)
662
663 #--------------------------------------------------------------------
664 # Miscellaneous flags and setup
665 #--------------------------------------------------------------------
666
667 # Set location of GNUstep dirs for later use
668 if test "$GNUSTEP_FLATTENED" = yes; then
669   GNUSTEP_LDIR="$GNUSTEP_SYSTEM_ROOT/Library/Libraries"
670   GNUSTEP_HDIR="$GNUSTEP_SYSTEM_ROOT/Library/Headers"
671 else
672   clean_target_os=`$srcdir/clean_os.sh $target_os`
673   clean_target_cpu=`$srcdir/clean_cpu.sh $target_cpu`
674   obj_dir="$clean_target_cpu/$clean_target_os"
675   GNUSTEP_LDIR="$GNUSTEP_SYSTEM_ROOT/Library/Libraries/$obj_dir"
676   GNUSTEP_HDIR="$GNUSTEP_SYSTEM_ROOT/Library/Headers/${ac_cv_library_combo}"
677 fi
678
679 # Check to see if the libobjc library is in our GNUSTEP_SYSTEM_ROOT.
680 # If so, there are probably other libraries that we want there also, so
681 # leave the proper includes in CPPFLAGS and LDFLAGS
682 AC_MSG_CHECKING(for custom shared objc library)
683 AC_CACHE_VAL(gs_cv_objc_libdir,
684 [dnl
685 gs_cv_objc_libdir=NONE
686 if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
687   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"; then
688     gs_cv_objc_libdir="$GNUSTEP_LDIR"
689   else
690     gs_cv_objc_libdir=NONE
691   fi
692 fi
693 #gcc_shared_libobjc=`gcc -print-file-name=libobjc.so`
694 #if test -f "$gcc_shared_libobjc"; then
695 #  gs_cv_objc_libdir=`dirname $gcc_shared_libobjc`
696 #fi
697 ])
698 AC_MSG_RESULT($gs_cv_objc_libdir)
699
700 # The following are needed to compile the test programs
701 if test "$gs_cv_objc_libdir" = "$GNUSTEP_LDIR"; then
702   if test "$GNUSTEP_FLATTENED" = yes; then
703     OBJC_CPPFLAGS="$CPPFLAGS $INCLUDES -I$GNUSTEP_SYSTEM_ROOT/Library/Headers"
704   else
705     OBJC_CPPFLAGS="$CPPFLAGS $INCLUDES -I$GNUSTEP_SYSTEM_ROOT/Library/Headers/${ac_cv_library_combo}"
706   fi
707   OBJC_LDFLAGS="$LDFLAGS $LIB_DIR -L$gs_cv_objc_libdir"
708 fi
709
710 # And the following to execute them
711 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$gs_cv_objc_libdir"
712 export LD_LIBRARY_PATH
713
714 #--------------------------------------------------------------------
715 # Miscellaneous headers (only used for compiling which_lib.c and user_home.c)
716 #--------------------------------------------------------------------
717 AC_HEADER_DIRENT
718 AC_CHECK_HEADERS(sys/param.h sys/file.h dir.h string.h stdlib.h sys/types.h dnl
719                 fcntl.h limits.h utime.h sys/stat.h pwd.h unistd.h ctype.h)
720 AC_CHECK_FUNCS(getpwnam getpwuid geteuid getlogin strchr)
721
722 #--------------------------------------------------------------------
723 # Check if libobjc was compiled with thread support.
724 #--------------------------------------------------------------------
725 OBJC_THREAD=
726 AC_ARG_WITH(thread-lib,[
727 --with-thread-lib
728    Specify alternate thread library.  Use this flag if configure can
729    not properly determine the thread library used by your libobjc.
730 ],
731 OBJC_THREAD=$withval,
732 OBJC_THREAD=
733 )
734 if test "$OBJC_THREAD" = no; then
735 OBJC_THREAD=
736 fi
737
738
739 AC_MSG_CHECKING(whether objc has thread support)
740 saved_CFLAGS="$CFLAGS"
741 saved_LIBS="$LIBS"
742 CFLAGS="$CFLAGS -x objective-c -I$srcdir $OBJC_CPPFLAGS $OBJC_LDFLAGS"
743 if test "$OBJC_RUNTIME_LIB" = "gnu"; then
744   CFLAGS="$CFLAGS -fgnu-runtime"
745 fi
746 if test "$OBJC_RUNTIME_LIB" = "nx"; then
747   CFLAGS="$CFLAGS -DNeXT_RUNTIME"
748 fi
749 if test "$OBJC_RUNTIME_LIB" = "apple"; then
750   CFLAGS="$CFLAGS -DNeXT_RUNTIME"
751 fi
752 if test "$OBJC_THREAD" != ""; then
753   LIBS="-lobjc $LIBS $OBJC_THREAD"
754   AC_TRY_RUN([#include "config_thread.m"], 
755         objc_threaded="$OBJC_THREAD",
756         objc_threaded="", objc_threaded="")
757 elif test "$host_os" = linux-gnu; then
758   LIBS="-lobjc -lpthread"
759   AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpthread",
760         objc_threaded="", objc_threaded="-lpthread")
761 elif test "`echo $host_os|sed 's/[[0-9]].*//'|sed s/elf//`" = freebsd; then
762   LIBS="-pthread -lobjc"
763   AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-pthread",
764        objc_threaded="", objc_threaded="-pthread")
765   if test x"$objc_threaded" = x""; then
766     LIBS="-lpthread -lobjc"
767     AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpthread",
768         objc_threaded="", objc_threaded="-lpthread")
769   fi
770   if test x"$objc_threaded" = x""; then
771     LIBS="-lobjc -lpcthread"
772     AC_TRY_RUN([#include "config_thread.m"], objc_threaded="-lpcthread",
773         objc_threaded="", objc_threaded="-lpcthread")
774   fi
775 elif test "$MINGW32" = yes; then
776   # Mingw doesn't need anything extra for threads
777   LIBS="-lobjc $LIBS"
778   AC_TRY_RUN([#include "config_thread.m"], 
779         objc_threaded="works",
780         objc_threaded="", objc_threaded="works")
781 else
782   LIBS="-lobjc $LIBS"
783   AC_TRY_RUN([#include "config_thread.m"], 
784         objc_threaded="works",
785         objc_threaded="", objc_threaded="")
786   if test x"$objc_threaded" = x""; then
787     LIBS="-lobjc $saved_LIBS -lpthread "
788     AC_TRY_RUN([#include "config_thread.m"], 
789         objc_threaded="-lpthread", 
790         objc_threaded="", objc_threaded="")
791   fi
792   if test x"$objc_threaded" = x""; then
793     # Solaris, OpenBSD/sparc
794     LIBS="-lobjc $saved_LIBS -lpthread -lposix4"
795     AC_TRY_RUN([#include "config_thread.m"], 
796         objc_threaded="-lpthread -lposix4", 
797         objc_threaded="", objc_threaded="")
798   fi
799   if test x"$objc_threaded" = x""; then
800     LIBS="-lobjc $saved_LIBS -lthread "
801     AC_TRY_RUN([#include "config_thread.m"], 
802         objc_threaded="-lthread", 
803         objc_threaded="", objc_threaded="")
804   fi
805 fi
806 if test x"$objc_threaded" = x""; then
807   AC_MSG_RESULT(no)
808 else
809   if test x"$objc_threaded" = x"works"; then
810     objc_threaded=""
811   fi
812   AC_MSG_RESULT(yes: $objc_threaded)
813 fi
814 ac_cv_objc_threaded="$objc_threaded"
815 AC_SUBST(objc_threaded)
816 AC_SUBST(ac_cv_objc_threaded)
817
818 # Do not restore LIBS and CFLAGS yet as we need to test if the
819 # compiler supports native exceptions.
820
821 #--------------------------------------------------------------------
822 # Check if GCC supports -fobjc-exceptions, and if so, turn it on!
823 #--------------------------------------------------------------------
824
825 AC_ARG_ENABLE(native-objc-exceptions, [
826 --enable-native-objc-exceptions
827    Use native Objective-C exceptions.  Use this option if you want
828    to use the native Objective-C exception support (@try/@catch/@finally)
829    provided by newer GCC compilers.
830 ], 
831 USE_OBJC_EXCEPTIONS=$enableval,
832 USE_OBJC_EXCEPTIONS=no)
833
834 AC_MSG_CHECKING(whether we should use native ObjC exceptions)
835 if test x"$USE_OBJC_EXCEPTIONS" = x"yes"; then
836   # What we want to do: set USE_OBJC_EXCEPTIONS to yes if we can compile
837   # something with @try/@catch/@finally in it.
838   if test ! ${GCC} = "yes" ; then
839     USE_OBJC_EXCEPTIONS=no
840     AC_MSG_RESULT(no: compiler isn't gcc)
841   else
842     CFLAGS="$CFLAGS -fobjc-exceptions"
843     AC_RUN_IFELSE([[
844 #include <stdlib.h>
845 #include <objc/Object.h>
846
847 int main(int argc, char **argv)
848 {
849         Object *o=nil;
850         @try
851         {
852                 o=[Object new];
853                 @throw o;
854         }
855         @catch (id foo)
856         {
857                 if (o!=foo)
858                         return 1;
859         }
860         return 0;
861 }
862   ]], USE_OBJC_EXCEPTIONS=yes, USE_OBJC_EXCEPTIONS=no)
863     AC_MSG_RESULT($USE_OBJC_EXCEPTIONS)
864   fi
865   if test x$USE_OBJC_EXCEPTIONS = xno; then
866     AC_MSG_NOTICE([Native objective-c exceptions were requested, but the compiler])
867     AC_MSG_NOTICE([doesn't support them.])
868     AC_MSG_ERROR([compiler doesn't support native objective-c exceptions])
869   fi
870 else
871   AC_MSG_RESULT(not requested by user)
872 fi
873
874 AC_SUBST(USE_OBJC_EXCEPTIONS)
875
876 # Restore LIBS and CFLAGS - we are going to compile C code in the next
877 # test.
878 LIBS="$saved_LIBS"
879 CFLAGS="$saved_CFLAGS"
880
881 #--------------------------------------------------------------------
882 # Check if compiler supports -MMD -MP to generate %.d files ...
883 #--------------------------------------------------------------------
884
885 AC_MSG_CHECKING(if the compiler supports autodependencies)
886
887 # What we want to do: set AUTO_DEPENDENCIES to yes if gcc => 3.x
888
889 if test ! ${GCC} = "yes" ; then
890   AUTO_DEPENDENCIES=""
891   PRECOMPILED_HEADERS=""
892   AC_MSG_RESULT(no: it's not gcc)
893 else
894   # Running gcc -dumpversion we get something like 2.95.4 or
895   #  egcs-2.91.66 or 3.0.2 or 3.1 20011211
896   # We want to discard anything but the major number.
897   # Explanation of the regexp -
898   # \(^[^0-9]*\) matches beginning of line and following non numeric chars
899   # \([0-9][0-9]*\) matches 1 or more numeric chars (this is the 2^nd
900   #  subpattern)
901   # \([^0-9].*\) matches a non numeric char followed by anything
902   # /\2/ replace the whole lot with the 2^nd subpattern
903   gs_cv_gcc_major_version=`${CC} -dumpversion | sed "s/\([[^0-9]]*\)\([[0-9]][[0-9]]*\)\([[^0-9]].*\)/\2/"`;
904
905   if test "${gs_cv_gcc_major_version}" -ge "3" ; then
906     AUTO_DEPENDENCIES=yes
907     AC_MSG_RESULT(yes: gcc major version is ${gs_cv_gcc_major_version})
908   else
909     AUTO_DEPENDENCIES=""
910     PRECOMPILED_HEADERS=""
911     AC_MSG_RESULT(no: gcc major version is ${gs_cv_gcc_major_version})
912   fi
913 fi
914
915 AC_SUBST(AUTO_DEPENDENCIES)
916 AC_SUBST(PRECOMPILED_HEADERS)
917 AC_SUBST(INCLUDES)
918 AC_SUBST(LIB_DIR)
919 AC_SUBST(OBJCFLAGS)
920
921 #--------------------------------------------------------------------
922 # Shall we strip makefiles upon installation ?
923 #--------------------------------------------------------------------
924
925 # Stripping makefiles removes comments and newlines from them.  The
926 # resulting stripped makefiles execute around 5% faster on average.
927 # Too little for it to be worth for the common user who's more
928 # interested in the comments :-) so it's disabled by default.
929 AC_MSG_CHECKING(if we should strip makefiles after installation)
930 AC_ARG_ENABLE(strip-makefiles, [
931 --enable-strip-makefiles
932    Enable stripping system makefiles after installation.  This will 
933    speed up gnustep-make by about 5% (average), but will remove all 
934    comments from the installed makefiles.  Those comments are quite
935    useful if you are trying to find some information on how gnustep-make
936    works (eg, if you're trying to locate a bug), and the performance
937    gain is quite small, so you probably don't want to strip makefiles.
938 ],
939   ac_cv_strip_makefiles=$enableval,
940   ac_cv_strip_makefiles="undefined")
941
942 if test "$ac_cv_strip_makefiles" = "yes"; then
943   GNUSTEP_STRIP_MAKEFILES=strip;
944   AC_MSG_RESULT(yes);
945 else
946   GNUSTEP_STRIP_MAKEFILES=;
947   AC_MSG_RESULT(no);
948 fi
949 AC_SUBST(GNUSTEP_STRIP_MAKEFILES)
950
951 #--------------------------------------------------------------------
952 # Disable updating the obsolete directory structure
953 #--------------------------------------------------------------------
954 gs_move_obsolete=yes
955 AC_ARG_ENABLE(move-obsolete,[
956 --disable-move-obsolete
957    Disable moving obsolete dir structure.  This option will be 
958    removed SOON as the dir structure was change more than 2 years ago! :-)
959 ],
960   gs_move_obsolete=$enableval,
961   gs_move_obsolete=yes)
962
963 if test "$gs_move_obsolete" = "yes"; then
964   GNUSTEP_MOVE_OBSOLETE=move_obsolete;
965 else
966   GNUSTEP_MOVE_OBSOLETE=
967   AC_MSG_NOTICE(Old GNUstep directories will not be moved)
968 fi
969 AC_SUBST(GNUSTEP_MOVE_OBSOLETE)
970
971 #--------------------------------------------------------------------
972 # Enable/disable precompiled headers
973 #--------------------------------------------------------------------
974 # TODO: replace with / add a check whether PCH works with the
975 #       compiler
976 gs_enable_pch=no
977 AC_MSG_CHECKING(if we should enable precompiled headers (pch))
978 AC_ARG_ENABLE(pch, 
979 [--enable-pch                   Enable precompiled headers], 
980   gs_enable_pch=$enableval,
981   gs_enable_pch=no)
982
983 if test "$gs_enable_pch" = "yes"; then
984   PRECOMPILED_HEADERS=yes
985   AC_MSG_RESULT(yes);
986 else
987   PRECOMPILED_HEADERS=
988   AC_MSG_RESULT(no);
989 fi
990 AC_SUBST(PRECOMPILED_HEADERS)
991
992 #--------------------------------------------------------------------
993 # Record the version
994 #--------------------------------------------------------------------
995 AC_MSG_CHECKING(for the version of gnustep-make we are compiling)
996 . "$srcdir/Version"
997 AC_MSG_RESULT($GNUSTEP_MAKE_VERSION)
998 AC_SUBST(GNUSTEP_MAKE_VERSION)
999 AC_SUBST(GNUSTEP_MAKE_MAJOR_VERSION)
1000 AC_SUBST(GNUSTEP_MAKE_MINOR_VERSION)
1001 AC_SUBST(GNUSTEP_MAKE_SUBMINOR_VERSION)
1002
1003 #-------------------------------------------------------------------
1004 # Record the 'clean' target_os, target_cpu and target_vendor
1005 #-------------------------------------------------------------------
1006 # This is just for efficiency, so that core/make/GNUmakefile does not
1007 # have to compute clean_target_os from target_os (and similar) by
1008 # running shell scripts each time you 'make' something inside
1009 # gnustep-make.  We basically compute them once now, and cache them
1010 # forever.  It is also used by GNUstep.sh when multi-platform is
1011 # disabled.
1012 clean_target_os=`$srcdir/clean_os.sh $target_os`
1013 clean_target_cpu=`$srcdir/clean_cpu.sh $target_cpu`
1014 clean_target_vendor=`$srcdir/clean_cpu.sh $target_vendor`
1015 AC_SUBST(clean_target_os)
1016 AC_SUBST(clean_target_cpu)
1017 AC_SUBST(clean_target_vendor)
1018 AC_SUBST(target)
1019
1020 #--------------------------------------------------------------------
1021 # Produce the output files
1022 #--------------------------------------------------------------------
1023 AC_CONFIG_FILES([config.make openapp debugapp opentool 
1024 executable.template GNUmakefile GNUstep.conf GNUstep.sh GNUstep.csh fixpath.sh
1025 gnustep-make.spec])
1026 AC_CONFIG_COMMANDS([default],
1027         [[chmod a+x openapp debugapp opentool fixpath.sh executable.template]],
1028         [[]])
1029 AC_OUTPUT