Page 1 of 1

AC_CHECK_FILE vs Cross Compilation

Posted: Sat Sep 17, 2011 1:21 am
by mazilo
According to GNU Autoconf online manual, the AC_CHECK_FILE (file, [action-if-found], [action-if-not-found]) is used to check whether file file exists on the native system. In other words, the use of AC_CHECK_FILE function under a cross compilation will terminate configure process with a warning: Cannot check for file existence when cross compiling message. This happens if I tried to cross compile H323Plus package for OpenWRT platform because the configure.ac scripts file uses the AC_CHECK_FILE function to check for the ${PTLIBDIR}/version.h and ${OPENH323DIR}/../ptlib/version.h files. The work around to this is either to replace the AC_CHECK_FILE function with a test -f or other autoconf supported function. If you see the patch I included below, you will notice I have replaced the AC_CHECK_FILE function with the AC_CHECK_HEADER function.

Code: Select all

+++ b/configure.ac
@@ -66,11 +66,11 @@ dnl look for ptlib, use a preference ord
 dnl at same level, home directory, /usr/local or /usr.
 
 if test "${PTLIBDIR:-unset}" != "unset" ; then 	 
-  AC_CHECK_FILE(${PTLIBDIR}/version.h, HAS_PTLIB=1) 	 
+  AC_CHECK_HEADER(${PTLIBDIR}/version.h, HAS_PTLIB=1) 	 
 fi
 
 if test "${HAS_PTLIB:-unset}" = "unset" ; then
-  AC_CHECK_FILE(${OPENH323DIR}/../ptlib/version.h, HAS_PTLIB=1) 	 
+  AC_CHECK_HEADER(${OPENH323DIR}/../ptlib/version.h, HAS_PTLIB=1) 	 
   if test "${HAS_PTLIB:-unset}" != "unset" ; then
     PTLIBDIR="${OPENH323DIR}/../ptlib"
   else
Honestly, I don't know if the above substitution is appropriate or not; however, it gets the job done and configure process is now capable of verifying the existence of both version.h files as shown below. At any rate, if this substitution deemed to be properly done, please feel free to apply the patch to the H323Plus configure.ac file.

Code: Select all

checking for unistd.h... yes
checking /opt/openwrt-svn-trunk/build_dir/target-mipsel_uClibc-0.9.32/ptlib2_svn/version.h usability... yes
checking /opt/openwrt-svn-trunk/build_dir/target-mipsel_uClibc-0.9.32/ptlib2_svn/version.h presence... yes
checking for /opt/openwrt-svn-trunk/build_dir/target-mipsel_uClibc-0.9.32/ptlib2_svn/version.h... yes
PTLib prefix set to.... /opt/openwrt-svn-trunk/build_dir/target-mipsel_uClibc-0.9.32/ptlib2_svn
checking Checking PTLib version 2.11.0... ok
configure: Disabling H.235.6

Re: AC_CHECK_FILE vs Cross Compilation

Posted: Sat Sep 17, 2011 6:42 am
by willamowius
Thanks, I've applied the fix to the CVS.

Re: AC_CHECK_FILE vs Cross Compilation

Posted: Sat Sep 17, 2011 12:54 pm
by mazilo
willamowius wrote:Thanks, I've applied the fix to the CVS.
I have checkout the source and now the cross-compilation works without my own patch. Thank you.