Stripped much crap out of configure system; should now build on MacOS X
[fw/sdcc] / support / cpp2 / configure.in
1 # configure.in for GNU CC
2 # Process this file with autoconf to generate a configuration script.
3
4 # Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5
6 #This file is part of GNU CC.
7
8 #GNU CC is free software; you can redistribute it and/or modify
9 #it under the terms of the GNU General Public License as published by
10 #the Free Software Foundation; either version 2, or (at your option)
11 #any later version.
12
13 #GNU CC is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #GNU General Public License for more details.
17
18 #You should have received a copy of the GNU General Public License
19 #along with GNU CC; see the file COPYING.  If not, write to
20 #the Free Software Foundation, 59 Temple Place - Suite 330,
21 #Boston, MA 02111-1307, USA.
22
23 # Initialization and defaults
24 AC_PREREQ(2.13)
25 AC_INIT(cppmain.c)
26 AC_CONFIG_HEADER(auto-host.h:config.in)
27
28 remove=rm
29 hard_link=ln
30 symbolic_link='ln -s'
31 copy=cp
32
33 # Check for additional parameters
34
35 # With GNU ld
36 AC_ARG_WITH(gnu-ld,
37 [  --with-gnu-ld           arrange to work with GNU ld.],
38 gnu_ld_flag="$with_gnu_ld",
39 gnu_ld_flag=no)
40
41 # With pre-defined ld
42 AC_ARG_WITH(ld,
43 [  --with-ld               arrange to use the specified ld (full pathname)],
44 DEFAULT_LINKER="$with_ld")
45 if test x"${DEFAULT_LINKER+set}" = x"set"; then
46   if test ! -x "$DEFAULT_LINKER"; then
47     AC_MSG_WARN([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
48   elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
49     gnu_ld_flag=yes
50   fi
51   AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
52         [Define to enable the use of a default linker.])
53 fi
54
55 # With GNU as
56 AC_ARG_WITH(gnu-as,
57 [  --with-gnu-as           arrange to work with GNU as],
58 gas_flag="$with_gnu_as",
59 gas_flag=no)
60
61 AC_ARG_WITH(as,
62 [  --with-as               arrange to use the specified as (full pathname)],
63 DEFAULT_ASSEMBLER="$with_as")
64 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
65   if test ! -x "$DEFAULT_ASSEMBLER"; then
66     AC_MSG_WARN([cannot execute: $DEFAULT_ASSEMBLER: check --with-as or env. var. DEFAULT_ASSEMBLER])
67   elif $DEFAULT_ASSEMBLER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
68     gas_flag=yes
69   fi
70   AC_DEFINE_UNQUOTED(DEFAULT_ASSEMBLER,"$DEFAULT_ASSEMBLER",
71         [Define to enable the use of a default assembler.])
72 fi
73
74 # With stabs
75 AC_ARG_WITH(stabs,
76 [  --with-stabs            arrange to use stabs instead of host debug format],
77 stabs="$with_stabs",
78 stabs=no)
79
80 # With ELF
81 AC_ARG_WITH(elf,
82 [  --with-elf              arrange to use ELF instead of host debug format],
83 elf="$with_elf",
84 elf=no)
85
86 # Specify the local prefix
87 local_prefix=
88 AC_ARG_WITH(local-prefix,
89 [  --with-local-prefix=DIR specifies directory to put local include],
90 [case "${withval}" in
91 yes)    AC_MSG_ERROR(bad value ${withval} given for local include directory prefix) ;;
92 no)     ;;
93 *)      local_prefix=$with_local_prefix ;;
94 esac])
95
96 # Default local prefix if it is empty
97 if test x$local_prefix = x; then
98         local_prefix=/usr/local
99 fi
100
101 AC_ARG_PROGRAM
102
103 # Enable Multibyte Characters for C/C++
104 AC_ARG_ENABLE(c-mbchar,
105 [  --enable-c-mbchar       enable multibyte characters for C and C++],
106 if test x$enable_c_mbchar != xno; then
107   AC_DEFINE(MULTIBYTE_CHARS, 1,
108   [Define if you want the C and C++ compilers to support multibyte
109    character sets for source code.])
110 fi)
111   
112 # Find the native compiler
113 AC_PROG_CC
114 AC_PROG_CC_C_O
115 # autoconf is lame and doesn't give us any substitution variable for this.
116 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
117   NO_MINUS_C_MINUS_O=yes
118 else
119   OUTPUT_OPTION='-o $@'
120 fi
121 AC_SUBST(NO_MINUS_C_MINUS_O)
122 AC_SUBST(OUTPUT_OPTION)
123
124 AC_PROG_CPP
125 AC_C_INLINE
126
127 # sizeof(char) is 1 by definition.
128 gcc_AC_COMPILE_CHECK_SIZEOF(short)
129 gcc_AC_COMPILE_CHECK_SIZEOF(int)
130 gcc_AC_COMPILE_CHECK_SIZEOF(long)
131
132 gcc_AC_C_CHARSET
133
134 # If the native compiler is GCC, we can enable warnings even in stage1.  
135 # That's useful for people building cross-compilers, or just running a
136 # quick `make'.
137 warn_cflags=
138 if test "x$GCC" = "xyes"; then
139   warn_cflags='$(GCC_WARN_CFLAGS)'
140 fi
141 AC_SUBST(warn_cflags)
142
143 AC_PROG_MAKE_SET
144
145 AC_MSG_CHECKING([whether a default assembler was specified])
146 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then
147     if test x"$gas_flag" = x"no"; then
148         AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER)])
149     else
150         AC_MSG_RESULT([yes ($DEFAULT_ASSEMBLER - GNU as)])
151     fi
152 else
153     AC_MSG_RESULT(no)
154 fi
155
156 AC_MSG_CHECKING([whether a default linker was specified])
157 if test x"${DEFAULT_LINKER+set}" = x"set"; then
158     if test x"$gnu_ld_flag" = x"no"; then
159         AC_MSG_RESULT([yes ($DEFAULT_LINKER)])
160     else
161         AC_MSG_RESULT([yes ($DEFAULT_LINKER - GNU ld)])
162     fi
163 else
164     AC_MSG_RESULT(no)
165 fi
166
167 # Find some useful tools
168 gcc_AC_PROG_LN
169 gcc_AC_PROG_LN_S
170 AC_PROG_RANLIB
171 gcc_AC_PROG_INSTALL
172
173 AC_HEADER_STDC
174 AC_HEADER_TIME
175 gcc_AC_HEADER_STRING
176 AC_HEADER_SYS_WAIT
177 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
178                  fcntl.h unistd.h sys/file.h sys/time.h \
179                  sys/param.h sys/stat.h \
180                  direct.h malloc.h)
181
182 # Check for thread headers.
183
184 # These tests can't be done till we know if we have limits.h.
185 gcc_AC_C_CHAR_BIT
186 gcc_AC_C_COMPILE_ENDIAN
187
188 # See if we have the mktemp command.
189 AC_CHECK_PROG(have_mktemp_command, mktemp, yes, no)
190
191 AC_CHECK_PROG(STRIP, strip, strip, :)
192
193 # See if the stage1 system preprocessor understands the ANSI C
194 # preprocessor stringification operator.  (Used by symcat.h.)
195 AC_C_STRINGIZE
196
197 dnl Disabled until we have a complete test for buggy enum bitfields.
198 dnl gcc_AC_C_ENUM_BF_UNSIGNED
199
200 AC_CHECK_FUNCS(clock strchr strrchr lstat)
201
202 AC_CHECK_TYPE(ssize_t, int)
203
204 AC_FUNC_MMAP_ANYWHERE
205 AC_FUNC_MMAP_FILE
206
207 # We will need to find libiberty.h and ansidecl.h
208 saved_CFLAGS="$CFLAGS"
209 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
210 gcc_AC_CHECK_DECLS(getenv abort errno \
211         malloc realloc calloc free clock, , ,[
212 #include "ansidecl.h"
213 #include "system.h"])
214
215 # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests.
216 CFLAGS="$saved_CFLAGS"
217
218 # mkdir takes a single argument on some systems. 
219 gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG
220
221 # File extensions
222 manext='.1'
223 objext='.o'
224 AC_SUBST(manext)
225 AC_SUBST(objext)
226
227 build_xm_file=
228 build_xm_defines=
229 build_install_headers_dir=install-headers-tar
230 build_exeext=
231 host_xm_file=
232 host_xm_defines=
233 host_xmake_file=
234 host_truncate_target=
235 host_exeext=
236
237 # Decode the host machine, then the target machine.
238 # For the host machine, we save the xm_file variable as host_xm_file;
239 # then we decode the target machine and forget everything else
240 # that came from the host machine.
241 #for machine in $build $host $target; do
242 #       . ${srcdir}/config.gcc
243 #done
244
245 extra_objs="${host_extra_objs} ${extra_objs}"
246
247 # Default the target-machine variables that were not explicitly set.
248 if test x"$tm_file" = x
249 then tm_file=$cpu_type/$cpu_type.h; fi
250
251 if test x"$extra_headers" = x
252 then extra_headers=; fi
253
254 if test x$md_file = x
255 then md_file=$cpu_type/$cpu_type.md; fi
256
257 if test x$out_file = x
258 then out_file=$cpu_type/$cpu_type.c; fi
259
260 if test x"$tmake_file" = x
261 then tmake_file=$cpu_type/t-$cpu_type
262 fi
263
264 if test x"$dwarf2" = xyes
265 then tm_file="$tm_file tm-dwarf2.h"
266 fi
267
268 # Handle cpp installation.
269 if test x$enable_cpp != xno
270 then
271   tmake_file="$tmake_file t-install-cpp"
272 fi
273
274 # auto-host.h is the file containing items generated by autoconf and is
275 # the first file included by config.h.
276 # If host=build, it is correct to have hconfig include auto-host.h
277 # as well.  If host!=build, we are in error and need to do more 
278 # work to find out the build config parameters.
279 if test x$host = x$build
280 then
281         build_auto=auto-host.h
282 else
283         # We create a subdir, then run autoconf in the subdir.
284         # To prevent recursion we set host and build for the new
285         # invocation of configure to the build for this invocation
286         # of configure. 
287         tempdir=build.$$
288         rm -rf $tempdir
289         mkdir $tempdir
290         cd $tempdir
291         case ${srcdir} in
292         /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
293         *) realsrcdir=../${srcdir};;
294         esac
295         CC=${CC_FOR_BUILD} ${realsrcdir}/configure \
296                 --target=$target --host=$build --build=$build
297
298         # We just finished tests for the build machine, so rename
299         # the file auto-build.h in the gcc directory.
300         mv auto-host.h ../auto-build.h
301         cd ..
302         rm -rf $tempdir
303         build_auto=auto-build.h
304 fi
305
306 tm_file="${tm_file} defaults.h"
307 host_xm_file="auto-host.h ansidecl.h ${host_xm_file} ${tm_file}"
308 build_xm_file="${build_auto} ansidecl.h ${build_xm_file} ${tm_file}"
309 xm_file="ansidecl.h ${xm_file} ${tm_file}"
310
311 # Truncate the target if necessary
312 if test x$host_truncate_target != x; then
313         target=`echo $target | sed -e 's/\(..............\).*/\1/'`
314 fi
315
316 # Get the version trigger filename from the toplevel
317 if test "${with_gcc_version_trigger+set}" = set; then
318         gcc_version_trigger=$with_gcc_version_trigger
319 else
320         gcc_version_trigger=${srcdir}/version.c
321 fi
322 changequote(,)dnl
323 gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*"\([^"]*\)".*/\1/'`
324 gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
325
326 # Compile in configure arguments.
327 if test -f configargs.h ; then
328         # Being re-configured.
329         gcc_config_arguments=`grep configuration_arguments configargs.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
330         gcc_config_arguments="$gcc_config_arguments : (reconfigured) $TOPLEVEL_CONFIGURE_ARGUMENTS"
331 else
332         gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS"
333 fi
334 cat > configargs.h <<EOF
335 /* Generated automatically. */
336 static const char configuration_arguments[] = "$gcc_config_arguments";
337 static const char thread_model[] = "$thread_file";
338 EOF
339 changequote([,])dnl
340
341 # Internationalization
342 PACKAGE=sdcc
343 VERSION="$gcc_version"
344 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",
345         [Define to the name of the distribution.])
346 AC_DEFINE_UNQUOTED(VERSION, "$VERSION",
347         [Define to the version of the distribution.])
348 AC_SUBST(PACKAGE)
349 AC_SUBST(VERSION)
350
351 ALL_LINGUAS="sv"
352
353 # Get an absolute path to the GCC top-level source directory
354 holddir=`pwd`
355 cd $srcdir
356 topdir=`pwd`
357 cd $holddir
358
359 out_object_file=`basename $out_file .c`.o
360
361 # Figure out what assembler we will be using.
362 AC_MSG_CHECKING(what assembler to use)
363 gcc_cv_as=
364 gcc_cv_gas_major_version=
365 gcc_cv_gas_minor_version=
366 gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
367 if test -x "$DEFAULT_ASSEMBLER"; then
368         gcc_cv_as="$DEFAULT_ASSEMBLER"
369 elif test -x "$AS"; then
370         gcc_cv_as="$AS"
371 elif test -x as$host_exeext; then
372         # Build using assembler in the current directory.
373         gcc_cv_as=./as$host_exeext
374 elif test -f $gcc_cv_as_gas_srcdir/configure.in -a -f ../gas/Makefile; then
375         # Single tree build which includes gas.
376         for f in $gcc_cv_as_gas_srcdir/configure $gcc_cv_as_gas_srcdir/configure.in $gcc_cv_as_gas_srcdir/Makefile.in
377         do
378 changequote(,)dnl
379                 gcc_cv_gas_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f`
380 changequote([,])dnl
381                 if test x$gcc_cv_gas_version != x; then
382                         break
383                 fi
384         done
385 changequote(,)dnl
386         gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([0-9]*\)"`
387         gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
388 changequote([,])dnl
389 fi
390
391 if test "x$gcc_cv_as" = x -a x$host = x$target; then
392         # Native build.
393         # Search the same directories that the installed compiler will
394         # search.  Else we may find the wrong assembler and lose.  If we
395         # do not find a suitable assembler binary, then try the user's
396         # path.
397         #
398         # Also note we have to check MD_EXEC_PREFIX before checking the
399         # user's path.  Unfortunately, there is no good way to get at the
400         # value of MD_EXEC_PREFIX here.  So we do a brute force search
401         # through all the known MD_EXEC_PREFIX values.  Ugh.  This needs
402         # to be fixed as part of the make/configure rewrite too.
403
404         if test "x$exec_prefix" = xNONE; then
405                 if test "x$prefix" = xNONE; then
406                         test_prefix=/usr/local
407                 else
408                         test_prefix=$prefix
409                 fi
410         else
411                 test_prefix=$exec_prefix
412         fi
413
414         # If the loop below does not find an assembler, then use whatever
415         # one we can find in the users's path.
416         # user's path.
417         gcc_cv_as=as$host_exeext
418
419         test_dirs="$test_prefix/lib/gcc-lib/$target/$gcc_version \
420                    $test_prefix/lib/gcc-lib/$target \
421                    /usr/lib/gcc/$target/$gcc_version \
422                    /usr/lib/gcc/$target \
423                    $test_prefix/$target/bin/$target/$gcc_version \
424                    $test_prefix/$target/bin \
425                    /usr/libexec \
426                    /usr/ccs/gcc \
427                    /usr/ccs/bin \
428                    /udk/usr/ccs/bin \
429                    /bsd43/usr/lib/cmplrs/cc \
430                    /usr/cross64/usr/bin \
431                    /usr/lib/cmplrs/cc \
432                    /sysv/usr/lib/cmplrs/cc \
433                    /svr4/usr/lib/cmplrs/cc \
434                    /usr/bin"
435
436         for dir in $test_dirs; do
437                 if test -f $dir/as$host_exeext; then
438                         gcc_cv_as=$dir/as$host_exeext
439                         break;
440                 fi
441         done
442 fi
443 if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
444   AC_MSG_RESULT("newly built gas")
445 else
446   AC_MSG_RESULT($gcc_cv_as)
447 fi
448
449 # Figure out what nm we will be using.
450 AC_MSG_CHECKING(what nm to use)
451 if test -x nm$host_exeext; then
452         gcc_cv_nm=./nm$host_exeext
453 elif test x$host = x$target; then
454         # Native build.
455         gcc_cv_nm=nm$host_exeext
456 fi
457 AC_MSG_RESULT($gcc_cv_nm)
458
459 dnl Very limited version of automake's enable-maintainer-mode
460
461 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
462   dnl maintainer-mode is disabled by default
463   AC_ARG_ENABLE(maintainer-mode,
464 [  --enable-maintainer-mode
465                           enable make rules and dependencies not useful
466                           (and sometimes confusing) to the casual installer],
467       maintainer_mode=$enableval,
468       maintainer_mode=no)
469
470 AC_MSG_RESULT($maintainer_mode)
471
472 if test "$maintainer_mode" = "yes"; then
473   MAINT=''
474 else
475   MAINT='#'
476 fi
477 AC_SUBST(MAINT)dnl
478
479 # These (without "all_") are set in each config-lang.in.
480 # `language' must be a single word so is spelled singularly.
481 all_stagestuff=
482 all_outputs='Makefile'
483 # List of language makefile fragments.
484
485 # Add the language fragments.
486 # Languages are added via two mechanisms.  Some information must be
487 # recorded in makefile variables, these are defined in config-lang.in.
488 # We accumulate them and plug them into the main Makefile.
489 # The other mechanism is a set of hooks for each of the main targets
490 # like `clean', `install', etc.
491
492 language_fragments="Make-lang"
493
494 # Define variables host_canonical and build_canonical
495 # because some Cygnus local changes in the Makefile depend on them.
496 build_canonical=${build}
497 host_canonical=${host}
498 target_subdir=
499 if test "${host}" != "${target}" ; then
500     target_subdir=${target_alias}/
501 fi
502 AC_SUBST(build_canonical)
503 AC_SUBST(host_canonical)
504 AC_SUBST(target_subdir)
505         
506 # Nothing to do for FLOAT_H, float_format already handled.
507 objdir=`pwd`
508 AC_SUBST(objdir)
509
510 # Substitute configuration variables
511 AC_SUBST(all_stagestuff)
512 AC_SUBST(build_exeext)
513 AC_SUBST(build_install_headers_dir)
514 AC_SUBST(build_xm_file_list)
515 AC_SUBST(build_xm_file)
516 AC_SUBST(build_xm_defines)
517 AC_SUBST(check_languages)
518 AC_SUBST(dep_host_xmake_file)
519 AC_SUBST(dep_tmake_file)
520 AC_SUBST(extra_c_flags)
521 AC_SUBST(extra_headers_list)
522 AC_SUBST(extra_objs)
523 AC_SUBST(extra_parts)
524 AC_SUBST(extra_passes)
525 AC_SUBST(extra_programs)
526 AC_SUBST(gcc_config_arguments)
527 AC_SUBST(gcc_version)
528 AC_SUBST(gcc_version_full)
529 AC_SUBST(gcc_version_trigger)
530 AC_SUBST(host_exeext)
531 AC_SUBST(host_extra_gcc_objs)
532 AC_SUBST(install)
533 AC_SUBST(lang_tree_files)
534 AC_SUBST(local_prefix)
535 AC_SUBST(md_file)
536 AC_SUBST(out_file)
537 AC_SUBST(out_object_file)
538 AC_SUBST(symbolic_link)
539 AC_SUBST(thread_file)
540 AC_SUBST(c_target_objs)
541
542 #AC_SUBST_FILE(target_overrides)
543 #AC_SUBST_FILE(host_overrides)
544 #AC_SUBST(cross_defines)
545 #AC_SUBST_FILE(cross_overrides)
546 #AC_SUBST_FILE(build_overrides)
547
548 # Create the Makefile
549 # and configure language subdirectories
550 AC_OUTPUT($all_outputs,
551 [
552 case x$CONFIG_HEADERS in
553 xauto-host.h:config.in)
554 echo > cstamp-h ;;
555 esac
556
557 # Avoid having to add intl to our include paths.
558 if test -f intl/libintl.h; then
559   echo creating libintl.h
560   echo '#include "intl/libintl.h"' >libintl.h
561 fi
562 ],
563 [
564 host='${host}'
565 build='${build}'
566 target='${target}'
567 target_alias='${target_alias}'
568 srcdir='${srcdir}'
569 symbolic_link='${symbolic_link}'
570 program_transform_set='${program_transform_set}'
571 program_transform_name='${program_transform_name}'
572 dep_host_xmake_file='${dep_host_xmake_file}'
573 host_xmake_file='${host_xmake_file}'
574 dep_tmake_file='${dep_tmake_file}'
575 tmake_file='${tmake_file}'
576 thread_file='${thread_file}'
577 gcc_config_arguments='${gcc_config_arguments}'
578 gcc_version='${gcc_version}'
579 gcc_version_full='${gcc_version_full}'
580 gcc_version_trigger='${gcc_version_trigger}'
581 local_prefix='${local_prefix}'
582 build_install_headers_dir='${build_install_headers_dir}'
583 build_exeext='${build_exeext}'
584 host_exeext='${host_exeext}'
585 out_file='${out_file}'
586 gdb_needs_out_file_path='${gdb_needs_out_file_path}'
587 SET_MAKE='${SET_MAKE}'
588 target_list='${target_list}'
589 target_overrides='${target_overrides}'
590 host_overrides='${host_overrides}'
591 cross_defines='${cross_defines}'
592 cross_overrides='${cross_overrides}'
593 build_overrides='${build_overrides}'
594 cpp_install_dir='${cpp_install_dir}'
595 ])