Source: gnucobol
Version: 4.0~early~20200606-3
Tags: patch upstream
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

gnucobol fails to cross build from source. The immediate reason is abuse
of AC_CHECK_FILE. The macro should be used to check for files on the
host system, but it is being used to check for files on the build
system. Please use plain test -e for that. The other issue is use of
AC_RUN_IFELSE. gnucobol exclusively uses the form with an extra cross
compilation argument, but a few of the uses are unnecessary and yield
wrong results. A number can be removed in favour of cross-compatible
macros AC_CHECK_SIZEOF or AC_COMPUTE_INT. While these used to fail
during cross compilation, they use compiler bisection since more than
ten years now and work for cross compilation. As such a pile of code
becomes unnecessary. Please consider applying the attached patch. It
does not make gnucobol cross buildable, because it still fails via
help2man. Please close this bug anyway when fixing the AC_CHECK_FILE
aspects.

Helmut
--- gnucobol-4.0~early~20200606.orig/configure.ac
+++ gnucobol-4.0~early~20200606/configure.ac
@@ -590,7 +590,7 @@
 	AC_MSG_NOTICE([Checks for local cJSON ...])
 	curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS"
 	with_cjson_local=no
-	AC_CHECK_FILE([./libcob/cJSON.c],
+	AS_IF([test -e ./libcob/cJSON.c],
 	  [AC_MSG_CHECKING([if linking of ./libcob/cJSON.c works])
 	   CPPFLAGS="$curr_cppflags -I./libcob"
 	   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cJSON.c"]],
@@ -601,7 +601,7 @@
 	   )]
 	)
 	if test "$with_cjson_local" = "no"; then
-	  AC_CHECK_FILE([$srcdir/libcob/cJSON.c],
+	  AS_IF([test -e "$srcdir/libcob/cJSON.c"],
 	    [AC_MSG_CHECKING([if linking of $srcdir/libcob/cJSON.c works])
 	     CPPFLAGS="$curr_cppflags -I$srcdir/libcob"
 	     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "cJSON.c"]],
@@ -1545,78 +1545,27 @@
 	[AC_MSG_RESULT([no])])
 
 # 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 "$ac_cv_sizeof_long_int" = "$ac_cv_sizeof_long_long"],
 	[AC_DEFINE([COB_LI_IS_LL], [1]) AC_MSG_RESULT([yes])],
-	[AC_MSG_RESULT([no])],
-	[if test "$COB_LI_IS_LL" = "0"; then
-		AC_MSG_RESULT([specified "no" on configure line])
-	 else
-		if test "$COB_LI_IS_LL" = "1"; then
-			AC_MSG_RESULT([specified "yes" on configure line])
-		else
-			COB_LI_IS_LL=1
-			AC_MSG_RESULT([assumed - cross-compilation])
-		fi
-	 fi
-	 AC_DEFINE([COB_LI_IS_LL], [$COB_LI_IS_LL])
-	 AC_MSG_WARN([cannot run test program while cross-compiling])])
+	[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 "$ac_cv_sizeof_long" = 4],
 	[AC_DEFINE([COB_32_BIT_LONG], [1]) AC_MSG_RESULT([yes])],
-	[AC_MSG_RESULT([no])],
-	[if test "$COB_32_BIT_LONG" = "0"; then
-		AC_MSG_RESULT([specified "no" on configure line])
-	 else
-		if test "$COB_32_BIT_LONG" = "1"; then
-			AC_MSG_RESULT([specified "yes" on configure line])
-		else
-			COB_32_BIT_LONG=1
-			AC_MSG_RESULT([assumed - cross-compilation])
-		fi
-	 fi
-	 AC_DEFINE([COB_32_BIT_LONG], [$COB_32_BIT_LONG])
-	 AC_MSG_WARN([cannot run test program while cross-compiling])])
+	[AC_MSG_RESULT([no])])
 
 
-if test "cross_compiling" != "yes"; then
-	COB_HAS_64_BIT_POINTER="no"
-fi
+AC_CHECK_SIZEOF(void *)
 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])],
-	[if test "$COB_HAS_64_BIT_POINTER" = "0"; then
-		COB_HAS_64_BIT_POINTER="no"
-		AC_DEFINE([COB_64_BIT_POINTER], [0])
-		AC_MSG_RESULT([specified "no" on configure line])
-	 else
-		if test "$COB_HAS_64_BIT_POINTER" = "1"; then
-			COB_HAS_64_BIT_POINTER="yes"
-			AC_DEFINE([COB_64_BIT_POINTER], [1])
-			AC_MSG_RESULT([specified "yes" on configure line])
-		else
-			COB_HAS_64_BIT_POINTER="no"
-			AC_DEFINE([COB_64_BIT_POINTER], [0])
-			AC_MSG_RESULT([assumed "no" - cross-compilation])
-		fi
-	 fi
-	 AC_MSG_WARN([cannot run test program while cross-compiling])])
+	[AC_MSG_RESULT([no])])
 
 #if test "$enable_debug" != "yes" -a "$COB_USES_GCC_NO_ICC" = "yes"; then
 #	MYOLDCFLAGS="$CFLAGS"

Reply via email to