2 # Process this file with autoconf to produce a configure script.
5 AC_INIT([Portable C Compiler], [1.2.0.DEVEL], [pcc@lists.ludd.ltu.se], [pcc], [http://pcc.ludd.ltu.se/])
6 AC_CONFIG_HEADER([config.h])
21 # allowed: UNSIGNED (4-char u_int), INT (4-char int), SHORT (2-char u_short)
31 m68k) targmach=m68k endian=big ;;
39 pdp11) targmach=pdp11 ;;
40 nova) targmach=nova ;;
50 *10.*) targosver=10 ;;
56 i?86) targmach=i386 ;;
57 powerpc) targmach=powerpc endian=big ;;
58 x86_64) targmach=amd64 ;;
68 i?86) targmach=i386 ;;
69 x86_64) targmach=amd64 ;;
78 *13.*) targosver=13 ;;
79 *12.*) targosver=12 ;;
80 *11.*) targosver=11 ;;
81 *10.*) targosver=10 ;;
90 i?86) targmach=i386 ;;
91 sparc64) targmach=sparc64 endian=big ;;
92 x86_64) targmach=amd64 ;;
100 case "$target_cpu" in
101 arm*) targmach=arm ;;
102 i?86) targmach=i386 ;;
103 mips64el) targmach=mips64 ;;
104 mips64) targmach=mips64 endian=big ;;
105 mipseb) targmach=mips endian=big ;;
106 mips*) targmach=mips ;;
107 x86_64) targmach=amd64 ;;
115 case "$target_cpu" in
116 aarch64) targmach=aarch64 ;;
117 arm*) targmach=arm ;;
118 i?86) targmach=i386 ;;
119 m68k) targmach=m68k endian=big target_alias=m68k-linux-gnu ;;
120 mips64el) targmach=mips64 ;;
121 mips64) targmach=mips64 endian=big ;;
122 mipseb) targmach=mips endian=big ;;
123 mips*) targmach=mips ;;
124 powerpc*) targmach=powerpc endian=big ;;
125 x86_64) targmach=amd64 ;;
128 *-musl*) ADD_CPPFLAGS="$ADD_CPPFLAGS -DUSE_MUSL" ;;
135 case "$target_cpu" in
136 mips*) targmach=mips ;;
144 case "$target_cpu" in
145 i?86) targmach=i386 ;;
146 sparc64) targmach=sparc64 endian=big ;;
155 altincdir="c:/mingw/include"
156 altlibdir="c:/mingw/lib"
166 # pcc works for 3.1.6
167 # not tested for 3.1.7 and 3.1.8
171 # Minix switched to ELF with 3.2
179 case "$target_cpu" in
181 i?86) targmach=i386 ;;
182 arm*) targmach=arm ;;
183 x86_64) targmach=amd64 ;;
192 case "$target_cpu" in
193 i?86) targmach=i386 ;;
210 case "$target_cpu" in
211 armeb) targmach=arm endian=big ;;
212 arm*) targmach=arm ;;
213 i?86) targmach=i386 ;;
214 m68k*) targmach=m68k endian=big ;;
215 mips64el) targmach=mips64 ;;
216 mips64) targmach=mips64 endian=big ;;
217 mipseb) targmach=mips endian=big ;;
218 mips*) targmach=mips ;;
219 pdp10) targmach=pdp10 ;;
220 powerpc) targmach=powerpc endian=big ;;
221 riscv32) targmach=riscv32 targmachdir=riscv ;;
222 riscv64) targmach=riscv64 targmachdir=riscv ;;
223 sparc64) targmach=sparc64 endian=big ;;
225 x86_64) targmach=amd64 ;;
233 case "$target_cpu" in
234 i?86) targmach=i386 ;;
235 sparc) targmach=sparc endian=big ;;
236 hppa) targmach=hppa endian=big ;;
244 case "$target_cpu" in
245 i?86) targmach=i386 ;;
247 mips64el) targmach=mips64 ;;
248 mips64) targmach=mips64 endian=big ;;
249 powerpc) targmach=powerpc endian=big ;;
250 sparc64) targmach=sparc64 endian=big ;;
251 m68k) targmach=m68k endian=big ;;
252 x86_64) targmach=amd64 ;;
259 case "$target_cpu" in
260 i?86) targmach=i386 ;;
268 case "$target_cpu" in
269 i?86) targmach=i386 ;;
270 sparc*) targmach=sparc64 endian=big ;;
271 x86_64) targmach=amd64 ;;
285 case "$target_cpu" in
286 arm) targmach=arm targos=none abi=$target_os ;;
288 m16c) targmach=m16c ;;
289 m68k) targmach=m68k endian=big targos=none abi=$target_os ;;
290 nova) targmach=nova ;;
291 pdp7) targmach=pdp7 ;;
296 if test "X$targos" = X -o "X$targmach" = X ; then
297 AC_MSG_ERROR(['$target' is not (yet) supported by pcc.])
300 if test "X$targmachdir" = X ; then
301 targmachdir=$targmach
322 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_DEFAULT_SOURCE"
350 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_XOPEN_SOURCE=600"
354 # quick hack for cross-build to win32 host
356 if "$prefix" = NONE; then
358 assembler="yasm.exe -p gnu -f win32"
359 linker="link.exe /nologo"
360 ADD_CPPFLAGS="$ADD_CPPFLAGS -DMSLINKER"
366 if test "X$endian" = "Xbig" ; then
367 AC_DEFINE(TARGET_BIG_ENDIAN, 1,
368 [Define if target defaults to BIG endian])
370 AC_DEFINE(TARGET_LITTLE_ENDIAN, 1,
371 [Define if target defaults to LITTLE endian])
375 elf*) AC_DEFINE(ELFABI, 1, [Using ELF ABI]) ;;
376 aout) AC_DEFINE(AOUTABI, 1, [Using a.out ABI]) ;;
377 macho) AC_DEFINE(MACHOABI, 1, [Using Mach-O ABI]) ;;
378 coff) AC_DEFINE(COFFABI, 1, [Using COFF ABI]) ;;
379 ecoff) AC_DEFINE(ECOFFABI, 1, [Using ECOFF ABI]) ;;
380 pecoff) AC_DEFINE(PECOFFABI, 1, [Using PE/COFF ABI]) ;;
381 classic68k) AC_DEFINE(CLASSIC68K, 1, [Using Classic 68k ABI]) ;;
384 if test "$stabs" = "yes"; then
385 AC_DEFINE(STABS, 1, [Enable STABS debugging output])
388 if test "$dwarf" = "yes"; then
389 AC_DEFINE(DWARF, 1, [Enable DWARF debugging output])
392 # Specify alternate assembler, linker, include and lib paths
393 AC_ARG_ENABLE(multiarch,
394 AS_HELP_STRING([--enable-multiarch=yes/no/auto/<triplet>],
395 [Enable use of Linux Multi-Arch paths (default: auto)]),
396 [multiarch=$enableval], [multiarch=auto])
398 AS_HELP_STRING([--with-incdir=<path>],
399 [Specify the default include path.]),
403 AS_HELP_STRING([--with-libdir=<path>],
404 [Specify the default library path.]),
407 AC_ARG_WITH(assembler,
408 AS_HELP_STRING([--with-assembler=<path>],
409 [Specify alternate assember.]),
413 AS_HELP_STRING([--with-linker=<path>],
414 [Specify alternate linker.]),
418 AS_HELP_STRING([--with-libvmf=<path>],
423 AS_HELP_STRING([--enable-tls],
424 [Enable Thread-local storage (TLS).]),
425 [tls=$enableval], [])
426 if test "$tls" = "yes"; then
427 AC_DEFINE(TLS, 1, [Enable thread-local storage (TLS).])
429 AC_ARG_ENABLE(Werror,
430 AS_HELP_STRING([--enable-Werror],
431 [Enable use of compiler -Werror flag]),
432 [werror=$enableval], [])
433 if test "$werror" = "yes"; then
434 ADD_CFLAGS="$ADD_CFLAGS -Werror"
436 AC_ARG_ENABLE(gcc-compat,
437 AS_HELP_STRING([--disable-gcc-compat],
438 [Disable GCC compatibility]),
439 [gcccompat=$enableval], [])
440 if test "$gcccompat" = "yes"; then
441 ADD_CPPFLAGS="$ADD_CPPFLAGS -DGCC_COMPAT";
443 AC_ARG_ENABLE(pcc-debug,
444 AS_HELP_STRING([--disable-pcc-debug],
445 [Disable PCC debugging]),
446 [pccdebug=$enableval], [])
447 if test "$pccdebug" = "yes"; then
448 ADD_CPPFLAGS="$ADD_CPPFLAGS -DPCC_DEBUG";
450 AC_ARG_ENABLE(twopass,
451 AS_HELP_STRING([--enable-twopass],
452 [Link PCC as a two-pass compiler]),
453 [twopass=$enableval], [])
454 if test "$twopass" = "yes"; then
455 ADD_CPPFLAGS="$ADD_CPPFLAGS -DTWOPASS";
456 CCNAMES='$(BINPREFIX)cc0$(EXEEXT) $(BINPREFIX)cc1$(EXEEXT)'
460 CCNAMES='$(BINPREFIX)ccom$(EXEEXT)'
463 if test "$targmach" = "nova"; then
464 CCNAMES="`echo $CCNAMES` \$(BINPREFIX)cc2\$(EXEEXT)"
467 AC_ARG_ENABLE(stripping,
468 AS_HELP_STRING([--disable-stripping],
469 [Disable stripping of symbols in installed binaries]),
470 [stripping=$enableval], [])
471 if test "$stripping" = "yes"; then
472 if test -z "$INSTALL_PROGRAM"; then
473 INSTALL_PROGRAM='${INSTALL} -s'
475 AC_MSG_WARN([Installed binaries may be unstripped])
480 AS_HELP_STRING([--with-yasm], [Use yasm assembler]),
483 if test "$useyasm" = "yes"; then
485 ADD_CPPFLAGS="$ADD_CPPFLAGS -DUSE_YASM"
487 AC_ARG_ENABLE(native,
488 AS_HELP_STRING([--enable-native],
489 [Build the compiler as a native rather than cross-build compiler]),
490 [native=$enableval], [])
492 # Setup for ubuntu multiarch
498 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path=
499 case $multiarch_path in
502 AC_MSG_ERROR([Cannot determine Multi-Arch path '$multiarch_path'!])
507 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path=
508 case x$multiarch_path in
512 AC_MSG_WARN([Ignoring unrecognised Multi-Arch path '$multiarch_path'!])
518 multiarch_path=$multiarch
521 AC_MSG_ERROR([Ignoring unrecognised Multi-Arch path '$multiarch_path'!])
524 if test -n "$multiarch_path"; then
525 AC_DEFINE_UNQUOTED([MULTIARCH_PATH], ["$multiarch_path"],
526 [Define target Multi-Arch path])
527 multiarch="\"$multiarch_path\""
531 # setup for building a cross-compiler
532 if test "X$native" = "Xyes" -o "X$target_alias" = "X$host_alias" -o "X$target_alias" = "X"; then
535 BINPREFIX="${target_alias}-"
536 test "X$prefix" = XNONE && prefix="$ac_default_prefix"
537 test "X$exec_prefix" = XNONE && exec_prefix="${prefix}"
538 if test -z "$altincdir"; then
539 altincdir=${exec_prefix}/${target_alias}/include
541 if test -z "$altlibdir"; then
542 altlibdir=${exec_prefix}/${target_alias}/lib
544 if test -z "$assembler"; then
545 assembler=${BINPREFIX}as
547 if test -z "$linker"; then
548 linker=${BINPREFIX}ld
550 preprocessor="${BINPREFIX}cpp"
551 compiler="${BINPREFIX}ccom"
552 cc2="${BINPREFIX}cc2"
553 AC_DEFINE(CROSS_COMPILING, 1, [Cross-compiling.])
557 if test -n "$altincdir"; then
558 AC_DEFINE_UNQUOTED(STDINC, "$altincdir",
559 [Define alternate standard include directory])
561 if test -n "$altlibdir"; then
562 AC_DEFINE_UNQUOTED(LIBDIR, "${altlibdir}/",
563 [Define alternate standard lib directory])
565 if test -n "$assembler"; then
566 AC_DEFINE_UNQUOTED(ASSEMBLER, "$assembler",
567 [Define path to alternate assembler])
569 if test -n "$linker"; then
570 AC_DEFINE_UNQUOTED(LINKER, "$linker",
571 [Define path to alternate linker])
573 if test -n "$preprocessor"; then
574 AC_DEFINE_UNQUOTED(PREPROCESSOR, "$preprocessor",
575 [Define path to alternate preprocessor])
577 if test -n "$compiler"; then
578 AC_DEFINE_UNQUOTED(COMPILER, "$compiler",
579 [Define path to alternate compiler])
581 if test -n "$cc2"; then
582 AC_DEFINE_UNQUOTED(CC2, "$cc2",
583 [Define path to alternate cc2])
587 USHORT) wchar_size=2 ;;
588 UNSIGNED|INT) wchar_size=4 ;;
589 *) AC_MSG_ERROR([Unknown wchar_t '$wchar_type'.]) ;;
592 AC_DEFINE_UNQUOTED(WCHAR_TYPE, $wchar_type, [Type to use for wide characters])
593 AC_DEFINE_UNQUOTED(WCHAR_SIZE, $wchar_size, [Size of wide-character type in chars])
595 # check for additional compiler flags
597 DESIRED_FLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wtruncate"
598 for flag in $DESIRED_FLAGS
600 AC_MSG_CHECKING([whether $CC accepts $flag])
602 CFLAGS="$CFLAGS $flag -Werror"
604 AC_LANG_PROGRAM([[]], [[]])
612 AC_MSG_RESULT([$use_flag])
613 if test $use_flag = yes; then
614 ADD_CFLAGS="$ADD_CFLAGS $flag"
618 # setup for cross-compiling mkext
619 AC_MSG_CHECKING([for a C compiler for mkext])
620 if test $cross_compiling = yes; then
621 AC_MSG_RESULT([cross compiling])
622 AC_CHECK_PROGS(CC_FOR_BUILD, [pcc clang gcc cc])
624 AC_MSG_RESULT([not cross compiling])
625 CC_FOR_BUILD=${CC-cc}
626 AC_SUBST(CC_FOR_BUILD)
629 AC_CACHE_CHECK([for C99 printf size specifiers], ac_cv_have_c99_format, [
631 AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
633 if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
635 else if (strcmp(buf, "12345"))
638 [ ac_cv_have_c99_format=yes ],
639 [ ac_cv_have_c99_format=no ],
640 [ ac_cv_have_c99_format=yes ])
642 if test $ac_cv_have_c99_format = yes; then
643 AC_DEFINE([HAVE_C99_FORMAT], 1,
644 [Define to 1 if printf supports C99 size specifiers])
647 AC_CHECK_SIZEOF([int *])
650 AC_C_BIGENDIAN([AC_DEFINE(HOST_BIG_ENDIAN, 1, [Define if host is BIG endian])],
651 [AC_DEFINE(HOST_LITTLE_ENDIAN, 1, [Define if host is LITTLE endian])],
654 # Checks for programs.
660 # Checks for libraries.
661 if test $libvmf != no ; then
663 AC_DEFINE(LIBVMF, 1, [Use libvmf.])
664 if test $libvmf != yes ; then
669 # Checks for header files.
670 # AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
671 AC_CHECK_HEADERS([string.h])
674 # Checks for library functions.
677 # AC_CHECK_FUNCS([memset strchr strdup strrchr strtol])
678 AC_CHECK_FUNCS([strtold vsnprintf snprintf mkstemp strlcat strlcpy getopt ffs vfork])
686 AC_SUBST(targmachdir)
689 AC_SUBST(exec_prefix)
692 AC_SUBST(PACKAGE_VERSION)
694 AC_SUBST(ADD_CPPFLAGS)
701 pcc_major=`echo $PACKAGE_VERSION | awk -F. '{print $1}'`
702 pcc_minor=`echo $PACKAGE_VERSION | awk -F. '{print $2}'`
703 pcc_minorminor=`echo $PACKAGE_VERSION | awk -F. '{print $3}'`
704 test -n "$MPVERSION" && MPVERSION=", $MPVERSION"
705 versstr="\"$PACKAGE_STRING `cat $srcdir/DATESTAMP` for $target$MPVERSION\""
706 targstr="\"$target$MPVERSION\""
708 AC_DEFINE_UNQUOTED(PCC_MAJOR, $pcc_major, [Major version no])
709 AC_DEFINE_UNQUOTED(PCC_MINOR, $pcc_minor, [Minor version no])
710 AC_DEFINE_UNQUOTED(PCC_MINORMINOR, $pcc_minorminor, [Minor minor version no])
711 AC_DEFINE_UNQUOTED(VERSSTR, $versstr, [Version string])
712 AC_DEFINE_UNQUOTED(TARGSTR, $targstr, [Target string])
714 AC_CONFIG_FILES([Makefile
727 eval "exec_prefix=$exec_prefix"
728 eval "bindir=$bindir"
729 eval "libexecdir=$libexecdir"
732 echo "Target CPU is .................... ${targmach}"
733 echo "Target ABI is .................... ${abi}"
734 echo "Target OS is ..................... ${targos}"
735 echo "Compiler is called ............... ${BINPREFIX}pcc${EXEEXT}"
736 echo "Installing compiler into ......... ${bindir}"
737 echo "Installing pre-processor into .... ${libexecdir}"
738 echo "Using assembler .................. ${assembler-<default>}"
739 echo "Using linker ..................... ${linker-<default>}"
740 echo "Using Multi-Arch path ............ ${multiarch}"
741 echo "Using include path ............... ${altincdir-<default>}"
742 echo "Using library path ............... ${altlibdir-<default>}"
743 echo "Use libvmf ....................... $libvmf"
744 echo "Has TLS support .................. $tls"
745 echo "Has GCC compatibility ............ $gcccompat"
746 echo "Has PCC debugging ................ $pccdebug"
747 echo "Type of wchar_t is ............... ${wchar_type} (${wchar_size} chars)"
749 echo "Configure finished. Do 'make && make install' to compile and install.