1 -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ(2.59) 5AC_INIT([Portable C Compiler], [1.2.0.DEVEL], [pcc@lists.ludd.ltu.se], [pcc], [http://pcc.ludd.ltu.se/]) 6AC_CONFIG_HEADER([config.h]) 7 8AC_CANONICAL_TARGET 9 10abi=unknown 11endian=little 12targosver=0 13tls=no 14gcccompat=yes 15pccdebug=yes 16stripping=yes 17native=no 18useyasm=no 19stabs=no 20# allowed: UNSIGNED (4-char u_int), INT (4-char int), SHORT (2-char u_short) 21wchar_type=INT 22 23case "$target_os" in 24 25 apple) 26 targos=apple 27 abi=classic68k 28 stabs=yes 29 case "$target_cpu" in 30 m68k) targmach=m68k endian=big ;; 31 esac 32 ;; 33 34 bsd) 35 targos=bsd 36 abi=aout 37 case "$target_cpu" in 38 pdp11) targmach=pdp11 ;; 39 nova) targmach=nova ;; 40 esac 41 wchar_type=USHORT 42 ;; 43 44 darwin*) 45 targos=darwin 46 abi=macho 47 stabs=yes 48 case "$target_os" in 49 *10.*) targosver=10 ;; 50 *9.*) targosver=9 ;; 51 *8.*) targosver=8 ;; 52 *7.*) targosver=7 ;; 53 esac 54 case "$target_cpu" in 55 i?86) targmach=i386 ;; 56 powerpc) targmach=powerpc endian=big ;; 57 x86_64) targmach=amd64 ;; 58 esac 59 ;; 60 61 dragonfly*) 62 targos=dragonfly 63 abi=elf 64 stabs=yes 65 tls=yes 66 case "$target_cpu" in 67 i?86) targmach=i386 ;; 68 x86_64) targmach=amd64 ;; 69 esac 70 ;; 71 72 freebsd*) 73 targos=freebsd 74 abi=elf 75 stabs=yes 76 case "$target_os" in 77 *10.*) targosver=10 ;; 78 *9.*) targosver=9 ;; 79 *8.*) targosver=8 ;; 80 *7.*) targosver=7 ;; 81 *6.*) targosver=6 ;; 82 *5.*) targosver=5 ;; 83 *4.*) targosver=4 ;; 84 esac 85 case "$target_cpu" in 86 i386) targmach=i386 ;; 87 sparc64) targmach=sparc64 endian=big ;; 88 x86_64) targmach=amd64 ;; 89 esac 90 ;; 91 92 linux-android*) 93 targos=android 94 abi=elf 95 stabs=yes 96 case "$target_cpu" in 97 arm*) targmach=arm ;; 98 i?86) targmach=i386 ;; 99 x86_64) targmach=amd64 ;; 100 mipseb) targmach=mips endian=big ;; 101 mips*) targmach=mips ;; 102 esac 103 ;; 104 105 linux*) 106 targos=linux 107 abi=elf 108 stabs=yes 109 case "$target_cpu" in 110 arm*) targmach=arm ;; 111 i?86) targmach=i386 ;; 112 powerpc*) targmach=powerpc endian=big ;; 113 x86_64) targmach=amd64 ;; 114 mipseb) targmach=mips endian=big ;; 115 mips*) targmach=mips ;; 116 esac 117 case "$target_os" in 118 *-musl*) ADD_CPPFLAGS="$ADD_CPPFLAGS -DUSE_MUSL" ;; 119 esac 120 ;; 121 122 litebsd*) 123 targos=litebsd 124 abi=elf 125 wchar_type=USHORT 126 case "$target_cpu" in 127 mips*) targmach=mips ;; 128 esac 129 ;; 130 131 midnightbsd*) 132 targos=midnightbsd 133 abi=elf 134 stabs=yes 135 case "$target_cpu" in 136 i?86) targmach=i386 ;; 137 sparc64) targmach=sparc64 endian=big ;; 138 esac 139 ;; 140 141 mingw*) 142 targos=win32 143 abi=pecoff 144 wchar_type=USHORT 145 targmach=i386 146 altincdir="c:/mingw/include" 147 altlibdir="c:/mingw/lib" 148 ;; 149 150 minix*) 151 targos=minix 152 stabs=yes 153 case "$target_os" in 154 # explicit setting 155 minixaout|minix2|*aout) abi=aout ;; 156 minixelf|minix3|*elf) abi=elf ;; 157 # default to ELF 158 *) abi=elf ;; 159 esac 160 case "$target_cpu" in 161 i86) targmach=i86 ;; 162 i?86) targmach=i386 ;; 163 arm*) targmach=arm ;; 164 x86_64) targmach=amd64 ;; 165 esac 166 ;; 167 168 mirbsd*) 169 targos=mirbsd 170 abi=elf 171 stabs=yes 172 wchar_type=USHORT 173 case "$target_cpu" in 174 i?86) targmach=i386 ;; 175 esac 176 ;; 177 178 netbsd*) 179 targos=netbsd 180 abi=elf 181 stabs=yes 182 case "$target_os" in 183 *7.*) targosver=7 ;; 184 *6.*) targosver=6 ;; 185 *5.*) targosver=5 ;; 186 *4.*) targosver=4 ;; 187 *3.*) targosver=3 ;; 188 *2.*) targosver=2 ;; 189 *1.*) targosver=1 ;; 190 esac 191 case "$target_cpu" in 192 armeb) targmach=arm endian=big ;; 193 arm*) targmach=arm ;; 194 i?86) targmach=i386 ;; 195 m68k*) targmach=m68k endian=big ;; 196 mipseb) targmach=mips endian=big ;; 197 mips*) targmach=mips ;; 198 pdp10) targmach=pdp10 ;; 199 powerpc) targmach=powerpc endian=big ;; 200 riscv32) targmach=riscv32 ;; 201 riscv64) targmach=riscv64 ;; 202 sparc64) targmach=sparc64 endian=big ;; 203 vax) targmach=vax ;; 204 x86_64) targmach=amd64 ;; 205 esac 206 ;; 207 208 nextstep*) 209 targos=nextstep 210 abi=macho 211 stabs=yes 212 case "$target_cpu" in 213 i?86) targmach=i386 ;; 214 sparc) targmach=sparc endian=big ;; 215 hppa) targmach=hppa endian=big ;; 216 esac 217 ;; 218 219 openbsd*) 220 targos=openbsd 221 abi=elf 222 stabs=yes 223 case "$target_cpu" in 224 i?86) targmach=i386 ;; 225 vax) targmach=vax ;; 226 powerpc) targmach=powerpc endian=big ;; 227 sparc64) targmach=sparc64 endian=big ;; 228 m68k) targmach=m68k endian=big ;; 229 x86_64) targmach=amd64 ;; 230 esac 231 ;; 232 233 sysv4*) 234 targos=sysv4 235 abi=elf 236 case "$target_cpu" in 237 i?86) targmach=i386 ;; 238 esac 239 ;; 240 241 sunos*|solaris*) 242 targos=sunos 243 abi=elf 244 stabs=yes 245 case "$target_cpu" in 246 i?86) targmach=i386 ;; 247 sparc*) targmach=sparc64 endian=big ;; 248 esac 249 ;; 250 251 windows*|pe*) 252 target_alias=i386-pe 253 targos=win32 254 abi=pecoff 255 wchar_type=USHORT 256 targmach=i386 257 ;; 258 259 *) 260 targos="$target_os" 261 case "$target_cpu" in 262 m16c) targmach=m16c ;; 263 nova) targmach=nova ;; 264 i86) targmach=i86 ;; 265 esac 266 ;; 267esac 268 269if test "X$targos" = X -o "X$targmach" = X ; then 270 AC_MSG_ERROR(['$target' is not (yet) supported by pcc.]) 271fi 272 273case "$host_os" in 274 275 apple) 276 hostos=apple 277 ;; 278 bsd) 279 hostos=bsd 280 ;; 281 darwin*) 282 hostos=darwin 283 ;; 284 dragonfly*) 285 hostos=dragonfly 286 ;; 287 freebsd*) 288 hostos=freebsd 289 ;; 290 linux*) 291 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_BSD_SOURCE" 292 hostos=linux 293 ;; 294 litebsd*) 295 hostos=litebsd 296 ;; 297 midnightbsd*) 298 hostos=midnightbsd 299 ;; 300 mingw*) 301 hostos=win32 302 ;; 303 minix*) 304 hostos=minix 305 ;; 306 mirbsd*) 307 hostos=mirbsd 308 ;; 309 netbsd*) 310 hostos=netbsd 311 ;; 312 nextstep*) 313 hostos=nextstep 314 ;; 315 openbsd*) 316 hostos=openbsd 317 ;; 318 sunos*|solaris*) 319 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_XOPEN_SOURCE=600" 320 hostos=sunos 321 ;; 322 pe*|windows*) 323 # quick hack for cross-build to win32 host 324 hostos=win32 325 if "$prefix" = NONE; then 326 prefix="c:/pcc" 327 assembler="yasm.exe -p gnu -f win32" 328 linker="link.exe /nologo" 329 ADD_CPPFLAGS="$ADD_CPPFLAGS -DMSLINKER" 330 fi 331 ;; 332 333esac 334 335if test "X$endian" = "Xbig" ; then 336 AC_DEFINE(TARGET_BIG_ENDIAN, 1, 337 [Define if target defaults to BIG endian]) 338else 339 AC_DEFINE(TARGET_LITTLE_ENDIAN, 1, 340 [Define if target defaults to LITTLE endian]) 341fi 342 343case "$abi" in 344 elf*) AC_DEFINE(ELFABI, 1, [Using ELF ABI]) ;; 345 aout) AC_DEFINE(AOUTABI, 1, [Using a.out ABI]) ;; 346 macho) AC_DEFINE(MACHOABI, 1, [Using Mach-O ABI]) ;; 347 coff) AC_DEFINE(COFFABI, 1, [Using COFF ABI]) ;; 348 ecoff) AC_DEFINE(ECOFFABI, 1, [Using ECOFF ABI]) ;; 349 pecoff) AC_DEFINE(PECOFFABI, 1, [Using PE/COFF ABI]) ;; 350 classic68k) AC_DEFINE(CLASSIC68K, 1, [Using Classic 68k ABI]) ;; 351esac 352 353if test "$stabs" = "yes"; then 354 AC_DEFINE(STABS, 1, [Enable STABS debugging output]) 355fi 356 357# Specify alternate assembler, linker, include and lib paths 358AC_ARG_ENABLE(multiarch, 359 AS_HELP_STRING([--enable-multiarch=yes/no/auto/<triplet>], 360 [Enable use of Linux Multi-Arch paths (default: auto)]), 361 [multiarch=$enableval], [multiarch=auto]) 362AC_ARG_WITH(incdir, 363 AS_HELP_STRING([--with-incdir=<path>], 364 [Specify the default include path.]), 365 altincdir=$withval, 366 []) 367AC_ARG_WITH(libdir, 368 AS_HELP_STRING([--with-libdir=<path>], 369 [Specify the default library path.]), 370 altlibdir=$withval, 371 []) 372AC_ARG_WITH(assembler, 373 AS_HELP_STRING([--with-assembler=<path>], 374 [Specify alternate assember.]), 375 assembler=$withval, 376 []) 377AC_ARG_WITH(linker, 378 AS_HELP_STRING([--with-linker=<path>], 379 [Specify alternate linker.]), 380 linker=$withval, 381 []) 382AC_ARG_ENABLE(tls, 383 AS_HELP_STRING([--enable-tls], 384 [Enable Thread-local storage (TLS).]), 385 [tls=$enableval], []) 386if test "$tls" = "yes"; then 387 AC_DEFINE(TLS, 1, [Enable thread-local storage (TLS).]) 388fi 389AC_ARG_ENABLE(Werror, 390 AS_HELP_STRING([--enable-Werror], 391 [Enable use of compiler -Werror flag]), 392 [werror=$enableval], []) 393if test "$werror" = "yes"; then 394 ADD_CFLAGS="$ADD_CFLAGS -Werror" 395fi 396AC_ARG_ENABLE(gcc-compat, 397 AS_HELP_STRING([--disable-gcc-compat], 398 [Disable GCC compatibility]), 399 [gcccompat=$enableval], []) 400if test "$gcccompat" = "yes"; then 401 ADD_CPPFLAGS="$ADD_CPPFLAGS -DGCC_COMPAT"; 402fi 403AC_ARG_ENABLE(pcc-debug, 404 AS_HELP_STRING([--disable-pcc-debug], 405 [Disable PCC debugging]), 406 [pccdebug=$enableval], []) 407if test "$pccdebug" = "yes"; then 408 ADD_CPPFLAGS="$ADD_CPPFLAGS -DPCC_DEBUG"; 409fi 410AC_ARG_ENABLE(twopass, 411 AS_HELP_STRING([--enable-twopass], 412 [Link PCC as a two-pass compiler]), 413 [twopass=$enableval], []) 414if test "$twopass" = "yes"; then 415 ADD_CPPFLAGS="$ADD_CPPFLAGS -DTWOPASS"; 416 CCNAMES='$(BINPREFIX)cc0$(EXEEXT) $(BINPREFIX)cc1$(EXEEXT)' 417 CF0='-DPASS1' 418 CF1='-DPASS2' 419else 420 CCNAMES='$(BINPREFIX)ccom$(EXEEXT)' 421fi 422 423AC_ARG_ENABLE(stripping, 424 AS_HELP_STRING([--disable-stripping], 425 [Disable stripping of symbols in installed binaries]), 426 [stripping=$enableval], []) 427if test "$stripping" = "yes"; then 428 if test -z "$INSTALL_PROGRAM"; then 429 INSTALL_PROGRAM='${INSTALL} -s' 430 else 431 AC_MSG_WARN([Installed binaries may be unstripped]) 432 fi 433fi 434 435AC_ARG_WITH(yasm, 436 AS_HELP_STRING([--use-yasm], [Use yasm assembler]), 437 useyasm=$withval, 438 []) 439if test "$useyasm" = "yes"; then 440 assembler="yasm" 441 ADD_CPPFLAGS="$ADD_CPPFLAGS -DUSE_YASM" 442fi 443AC_ARG_ENABLE(native, 444 AS_HELP_STRING([--enable-native], 445 [Build the compiler as a native rather than cross-build compiler]), 446 [native=$enableval], []) 447 448# Setup for ubuntu multiarch 449multiarch_path= 450case x$multiarch in 451xno) 452 ;; 453xyes) 454 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path= 455 case $multiarch_path in 456 *-*-*) ;; 457 *) 458 AC_MSG_ERROR([Cannot determine Multi-Arch path '$multiarch_path'!]) 459 ;; 460 esac 461 ;; 462xauto|x) 463 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path= 464 case x$multiarch_path in 465 x*-*-*) ;; 466 x) ;; 467 *) 468 AC_MSG_WARN([Ignoring unrecognised Multi-Arch path '$multiarch_path'!]) 469 multiarch_path= 470 ;; 471 esac 472 ;; 473x*-*-*) 474 multiarch_path=$multiarch 475 ;; 476*) 477 AC_MSG_ERROR([Ignoring unrecognised Multi-Arch path '$multiarch_path'!]) 478 ;; 479esac 480if test -n "$multiarch_path"; then 481 AC_DEFINE_UNQUOTED([MULTIARCH_PATH], ["$multiarch_path"], 482 [Define target Multi-Arch path]) 483 multiarch="\"$multiarch_path\"" 484else 485 multiarch="(no)" 486fi 487# setup for building a cross-compiler 488if test "X$native" = "Xyes" -o "X$target_alias" = "X$host_alias" -o "X$target_alias" = "X"; then 489 BINPREFIX="" 490else 491 BINPREFIX="${target_alias}-" 492 test "X$prefix" = XNONE && prefix="$ac_default_prefix" 493 test "X$exec_prefix" = XNONE && exec_prefix="${prefix}" 494 if test -z "$altincdir"; then 495 altincdir=${exec_prefix}/${target_alias}/include 496 fi 497 if test -z "$altlibdir"; then 498 altlibdir=${exec_prefix}/${target_alias}/lib 499 fi 500 if test -z "$assembler"; then 501 assembler=${BINPREFIX}as 502 fi 503 if test -z "$linker"; then 504 linker=${BINPREFIX}ld 505 fi 506 preprocessor="${BINPREFIX}cpp" 507 compiler="${BINPREFIX}ccom" 508fi 509AC_SUBST(BINPREFIX) 510 511if test -n "$altincdir"; then 512 AC_DEFINE_UNQUOTED(STDINC, "$altincdir", 513 [Define alternate standard include directory]) 514fi 515if test -n "$altlibdir"; then 516 AC_DEFINE_UNQUOTED(LIBDIR, "${altlibdir}/", 517 [Define alternate standard lib directory]) 518fi 519if test -n "$assembler"; then 520 AC_DEFINE_UNQUOTED(ASSEMBLER, "$assembler", 521 [Define path to alternate assembler]) 522fi 523if test -n "$linker"; then 524 AC_DEFINE_UNQUOTED(LINKER, "$linker", 525 [Define path to alternate linker]) 526fi 527if test -n "$preprocessor"; then 528 AC_DEFINE_UNQUOTED(PREPROCESSOR, "$preprocessor", 529 [Define path to alternate preprocessor]) 530fi 531if test -n "$compiler"; then 532 AC_DEFINE_UNQUOTED(COMPILER, "$compiler", 533 [Define path to alternate compiler]) 534fi 535 536case $wchar_type in 537USHORT) wchar_size=2 ;; 538UNSIGNED|INT) wchar_size=4 ;; 539*) AC_MSG_ERROR([Unknown wchar_t '$wchar_type'.]) ;; 540esac 541 542AC_DEFINE_UNQUOTED(WCHAR_TYPE, $wchar_type, [Type to use for wide characters]) 543AC_DEFINE_UNQUOTED(WCHAR_SIZE, $wchar_size, [Size of wide-character type in chars]) 544 545# check for additional compiler flags 546AC_PROG_CC 547DESIRED_FLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wtruncate" 548for flag in $DESIRED_FLAGS 549do 550 AC_MSG_CHECKING([whether $CC accepts $flag]) 551 cflags="$CFLAGS" 552 CFLAGS="$CFLAGS $flag -Werror" 553 AC_COMPILE_IFELSE([ 554 AC_LANG_PROGRAM([[]], [[]]) 555 ], [ 556 use_flag=yes 557 ], [ 558 use_flag=no 559 ]) 560 CFLAGS="$cflags" 561 562 AC_MSG_RESULT([$use_flag]) 563 if test $use_flag = yes; then 564 ADD_CFLAGS="$ADD_CFLAGS $flag" 565 fi 566done 567 568# setup for cross-compiling mkext 569AC_MSG_CHECKING([for a C compiler for mkext]) 570if test $cross_compiling = yes; then 571 AC_MSG_RESULT([cross compiling]) 572 AC_CHECK_PROGS(CC_FOR_BUILD, [pcc gcc cc]) 573else 574 AC_MSG_RESULT([not cross compiling]) 575 CC_FOR_BUILD=${CC-cc} 576 AC_SUBST(CC_FOR_BUILD) 577fi 578 579AC_CACHE_CHECK([for C99 printf size specifiers], ac_cv_have_c99_format, [ 580 AC_RUN_IFELSE([ 581 AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ 582 char buf[64]; 583 if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5) 584 exit(1); 585 else if (strcmp(buf, "12345")) 586 exit(2); 587 ]])], 588 [ ac_cv_have_c99_format=yes ], 589 [ ac_cv_have_c99_format=no ], 590 [ ac_cv_have_c99_format=yes ]) 591]) 592if test $ac_cv_have_c99_format = yes; then 593 AC_DEFINE([HAVE_C99_FORMAT], 1, 594 [Define to 1 if printf supports C99 size specifiers]) 595fi 596 597# Byteorder of host 598AC_C_BIGENDIAN([AC_DEFINE(HOST_BIG_ENDIAN, 1, [Define if host is BIG endian])], 599 [AC_DEFINE(HOST_LITTLE_ENDIAN, 1, [Define if host is LITTLE endian])], 600 []) 601 602# Checks for programs. 603AC_PROG_MAKE_SET 604AC_PROG_INSTALL 605AC_PROG_YACC 606AC_PROG_LEX 607 608# Checks for libraries. 609 610# Checks for header files. 611# AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) 612AC_CHECK_HEADERS([string.h malloc.h libgen.h]) 613AC_HEADER_SYS_WAIT 614 615# Checks for library functions. 616## AC_FUNC_STRTOD 617# AC_FUNC_VPRINTF 618# AC_CHECK_FUNCS([memset strchr strdup strrchr strtol]) 619AC_CHECK_FUNCS([strtold vsnprintf snprintf mkstemp strlcat strlcpy getopt ffs vfork]) 620AC_FUNC_ALLOCA 621 622AC_EXEEXT 623 624AC_SUBST(targos) 625AC_SUBST(targosver) 626AC_SUBST(targmach) 627AC_SUBST(hostos) 628AC_SUBST(prefix) 629AC_SUBST(exec_prefix) 630AC_SUBST(libexecdir) 631AC_SUBST(includedir) 632AC_SUBST(PACKAGE_VERSION) 633AC_SUBST(ADD_CFLAGS) 634AC_SUBST(ADD_CPPFLAGS) 635AC_SUBST(CCNAMES) 636AC_SUBST(CF0) 637AC_SUBST(CF1) 638 639pcc_major=`echo $PACKAGE_VERSION | awk -F. '{print $1}'` 640pcc_minor=`echo $PACKAGE_VERSION | awk -F. '{print $2}'` 641pcc_minorminor=`echo $PACKAGE_VERSION | awk -F. '{print $3}'` 642test -n "$MPVERSION" && MPVERSION=", $MPVERSION" 643versstr="\"$PACKAGE_STRING `cat $srcdir/DATESTAMP` for $target$MPVERSION\"" 644 645AC_DEFINE_UNQUOTED(PCC_MAJOR, $pcc_major, [Major version no]) 646AC_DEFINE_UNQUOTED(PCC_MINOR, $pcc_minor, [Minor version no]) 647AC_DEFINE_UNQUOTED(PCC_MINORMINOR, $pcc_minorminor, [Minor minor version no]) 648AC_DEFINE_UNQUOTED(VERSSTR, $versstr, [Version string]) 649 650AC_CONFIG_FILES([Makefile 651 cc/Makefile 652 cc/cc/Makefile 653 cc/cpp/Makefile 654 cc/ccom/Makefile 655 cc/cxxcom/Makefile 656 cc/driver/Makefile 657 f77/Makefile 658 f77/f77/Makefile 659 f77/fcom/Makefile 660]) 661AC_OUTPUT 662 663eval "exec_prefix=$exec_prefix" 664eval "bindir=$bindir" 665eval "libexecdir=$libexecdir" 666 667echo 668echo "Target CPU is .................... ${targmach}" 669echo "Target ABI is .................... ${abi}" 670echo "Target OS is ..................... ${targos}" 671echo "Compiler is called ............... ${BINPREFIX}pcc${EXEEXT}" 672echo "Installing compiler into ......... ${bindir}" 673echo "Installing pre-processor into .... ${libexecdir}" 674echo "Using assembler .................. ${assembler-<default>}" 675echo "Using linker ..................... ${linker-<default>}" 676echo "Using Multi-Arch path ............ ${multiarch}" 677echo "Using include path ............... ${altincdir-<default>}" 678echo "Using library path ............... ${altlibdir-<default>}" 679echo "Has TLS support .................. $tls" 680echo "Has GCC compatibility ............ $gcccompat" 681echo "Has PCC debugging ................ $pccdebug" 682echo "Type of wchar_t is ............... ${wchar_type} (${wchar_size} chars)" 683echo 684echo "Configure finished. Do 'make && make install' to compile and install. 685" 686