Source: gnucobol Version: 2.2-5 Tags: patch upstream User: debian-cr...@lists.debian.org Usertags: ftcbfs
gnucobol fails to cross build from source, because it uses AC_RUN_IFELSE a lot. Running a compiled program is what doesn't work during cross compilation, so the use of this macro needs to be minimized and the remaining uses need workarounds. In many occasions (checking macro existence, computing sizeof something, calculating integer values), one doesn't actually need AC_RUN_IFELSE (AC_COMPILE_IFELSE, AC_CHECK_SIZEOF, and AC_COMPUTE_INT may suffice). The attached patch replaced a large chunk of AC_RUN_IFELSE with alternatives that better support cross compilation. It doesn't make gnucobol cross buildable just yet. Please consider applying it and close this bug when doing so. Even partially applying the patch helps a little. You'll also notice that it poses a noticeable reduction in complexity. Helmut
--- gnucobol-2.2.orig/configure.ac +++ gnucobol-2.2/configure.ac @@ -248,12 +248,11 @@ # Checks for UTC offset (init) COB_HAS_UTC_OFFSET="no" -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef _BSD_SOURCE - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef _BSD_SOURCE + #error _BSD_SOURCE is not defined + #endif + return 0;]])], [COB_HAS_UTC_OFFSET="yes"], [], []) @@ -286,62 +285,52 @@ COB_USES_XLC_ONLY=no COB_USES_WATCOMC_ONLY=no -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef __GNUC__ - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef __GNUC__ + #error __GNUC__ is not defined + #endif + return 0;]])], [COB_USES_GCC=yes], [], []) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #if defined(__GNUC__) && !defined(__INTEL_COMPILER) - return 0; - #else - return 1; - #endif]])], - [COB_USES_GCC_NO_ICC=yes], - [], - []) - -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef __INTEL_COMPILER - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef __INTEL_COMPILER + #error __INTEL_COMPILER not defined + #endif + return 0;]])], [COB_USES_ICC_ONLY=yes], [], []) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef __clang__ - return 0; - #else - return 1; - #endif]])], +AS_IF([test "x$COB_USES_GCC" = xyes -a "x$COB_USES_ICC_ONLY" != xyes],[ + COB_USES_GCC_NO_ICC=yes +]) + + +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef __clang__ + #error __clang__ not defined + #endif + return 0;]])], [COB_USES_CLANG_ONLY=yes], [], []) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef __xlc__ - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef __xlc__ + #error __xlc__ not defined + #endif + return 0;]])], [COB_USES_XLC_ONLY=yes], [], []) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef __WATCOMC__ - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef __WATCOMC__ + #error __WATCOMC__ not defined + #endif + return 0;]])], [COB_USES_WATCOMC_ONLY=yes], [], []) @@ -501,23 +490,13 @@ # Check just major/minor levels between header and library # get GMP version from header -AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include <stdio.h> - #include <gmp.h> - int main (int argc, char **argv) - { - (void)argv; - if (argc > 1) - printf ("%d.%d\n", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR); - return 0; - } - ]])], - [COB_GMP_HEADER=`./conftest$ac_exeext x`], - [AC_MSG_ERROR([Unable to extract GMP version information from gmp.h])], - []) -if test "x$COB_GMP_HEADER" = "x"; then +AC_COMPUTE_INT(COB_GMP_HEADER_MAJOR,__GNU_MP_VERSION,[#include <gmp.h>],[ AC_MSG_ERROR([Unable to extract GMP version information (header)]) -fi +]) +AC_COMPUTE_INT(COB_GMP_HEADER_MINOR,__GNU_MP_VERSION_MINOR,[#include <gmp.h>],[ + AC_MSG_ERROR([Unable to extract GMP version information (header)]) +]) +COB_GMP_HEADER="$COB_GMP_HEADER_MAJOR.$COB_GMP_HEADER_MINOR" MYOLDLIBS=$LIBS LIBS="$MYOLDLIBS -lgmp" @@ -535,21 +514,25 @@ ]])], [COB_GMP_LIB=`./conftest$ac_exeext x`], [AC_MSG_ERROR([Unable to extract GMP version information from gmp_version])], - []) + [COB_GMP_LIB=cross]) if test "x$COB_GMP_LIB" = "x"; then AC_MSG_ERROR([Unable to extract GMP version information (library)]) fi AC_MSG_CHECKING([matching GMP version]) -COB_GMP_LIB_MAJOR=$(echo "$COB_GMP_LIB" | cut -d. -f1) -COB_GMP_LIB_MINOR=$(echo "$COB_GMP_LIB" | cut -d. -f2) +AS_IF([test "x$COB_GMP_LIB" != xcross],[ + COB_GMP_LIB_MAJOR=$(echo "$COB_GMP_LIB" | cut -d. -f1) + COB_GMP_LIB_MINOR=$(echo "$COB_GMP_LIB" | cut -d. -f2) -if test "$COB_GMP_HEADER" = "$COB_GMP_LIB_MAJOR.$COB_GMP_LIB_MINOR"; then - AC_MSG_RESULT([yes ($COB_GMP_HEADER)]) -else - AC_MSG_RESULT([no (header: $COB_GMP_HEADER / library: $COB_GMP_LIB)]) - AC_MSG_ERROR([Unable to use GMP - Please check config.log]) -fi + if test "$COB_GMP_HEADER" = "$COB_GMP_LIB_MAJOR.$COB_GMP_LIB_MINOR"; then + AC_MSG_RESULT([yes ($COB_GMP_HEADER)]) + else + AC_MSG_RESULT([no (header: $COB_GMP_HEADER / library: $COB_GMP_LIB)]) + AC_MSG_ERROR([Unable to use GMP - Please check config.log]) + fi +],[ + AC_MSG_RESULT([yes assumed during cross compilation ($COB_GMP_HEADER)]) +]) LIBS=$MYOLDLIBS @@ -798,36 +781,17 @@ # BDB header exists. Extract major/minor number pair COB_BDB_HEADER='' - COB_BDB_HEADER_STR='' - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include <stdio.h> - #include <db.h> - int main (int argc, char **argv) - { - (void)argv; - if (argc == 2) - printf ("%d.%d\n", DB_VERSION_MAJOR, DB_VERSION_MINOR); - if (argc == 3) - printf ("-%s-\n", DB_VERSION_STRING); - return 0; - } - ]])], - [COB_BDB_HEADER=`./conftest$ac_exeext x`] - [COB_BDB_HEADER_STR=`./conftest$ac_exeext x y`], - [AC_MSG_ERROR([Unable to extract Berkeley DB version information from db.h])], - []) - if test "x$COB_BDB_HEADER" = "x"; then - AC_MSG_ERROR([Unable to extract Berkeley DB version information]) - fi - if test "x$COB_BDB_HEADER_STR" != "x"; then - AC_MSG_NOTICE([db.h reports version "$COB_BDB_HEADER_STR"]) - fi + AC_COMPUTE_INT([COB_BDB_HEADER_MAJOR],[DB_VERSION_MAJOR],[#include <db.h>],[ + AC_MSG_ERROR([Unable to extract Berkeley DB version information from db.h]) + ]) + AC_COMPUTE_INT([COB_BDB_HEADER_MINOR],[DB_VERSION_MINOR],[#include <db.h>],[ + AC_MSG_ERROR([Unable to extract Berkeley DB version information from db.h]) + ]) + COB_BDB_HEADER="$COB_BDB_HEADER_MAJOR.$COB_BDB_HEADER_MINOR" AC_MSG_CHECKING([for Berkeley DB db.h version >= 4.1]) - COB_BDB_HEADER_MAJOR=$(echo "$COB_BDB_HEADER" | cut -d. -f1) if test $COB_BDB_HEADER_MAJOR -gt 4; then AC_MSG_RESULT([yes ($COB_BDB_HEADER)]) else - COB_BDB_HEADER_MINOR=$(echo "$COB_BDB_HEADER" | cut -d. -f2) if test $COB_BDB_HEADER_MAJOR -eq 4 -a $COB_BDB_HEADER_MINOR -ge 1; then AC_MSG_RESULT([yes ($COB_BDB_HEADER)]) else @@ -874,12 +838,11 @@ # Checks for dl/ltdl. DEFINE_DL="no" -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - #ifdef _WIN32 - return 0; - #else - return 1; - #endif]])], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + #ifndef _WIN32 + #error _WIN32 not defined + #endif + return 0;]])], [DEFINE_DL="yes"], [], []) @@ -938,39 +901,28 @@ []) # Checks for size of long +AC_CHECK_SIZEOF(long int) +AC_CHECK_SIZEOF(long long) AC_MSG_CHECKING([if size of long int = size of long long]) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - if (sizeof(long int) == sizeof(long long)) - return 0; - return 1; - ]])], +AS_IF([test "x$ac_cv_sizeof_long_int" = "x$ac_cv_sizeof_long_long"], [AC_DEFINE([COB_LI_IS_LL], [1]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])], - []) + [AC_MSG_RESULT([no])]) +AC_CHECK_SIZEOF(long) AC_MSG_CHECKING([if long is 32 bits]) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - if (sizeof (long) == 4) - return 0; - return 1; - ]])], +AS_IF([test "x$ac_cv_sizeof_long" = x4], [AC_DEFINE([COB_32_BIT_LONG], [1]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])], - []) + [AC_MSG_RESULT([no])]) +AC_CHECK_SIZEOF(void *) COB_HAS_64_BIT_POINTER="no" AC_MSG_CHECKING([if pointer is longer than 32 bits]) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[ - if (sizeof (void *) > 4U) - return 0; - return 1; - ]])], +AS_IF([test "$ac_cv_sizeof_void_p" -gt 4], [COB_HAS_64_BIT_POINTER="yes" AC_DEFINE([COB_64_BIT_POINTER], [1]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])], - []) + [AC_MSG_RESULT([no])]) #if test "$enable_debug" != "yes" -a "$COB_USES_GCC_NO_ICC" = "yes"; then # MYOLDCFLAGS="$CFLAGS"