monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[monit-dev] [PATCH] configure.ac: support cross-compilation


From: Thomas Petazzoni
Subject: [monit-dev] [PATCH] configure.ac: support cross-compilation
Date: Wed, 21 Mar 2012 15:42:57 +0100

configure.ac: support cross-compilation

The libmonit/configure.ac file does two checks using the AC_RUN_IFELSE
autoconf macro. Unfortunately, this macro requires *executing* a
program, which is not possible when doing cross-compilation (since the
machine on which the program will run is not the same as the build
machine).

Therefore, we enclose those AC_RUN_IFELSE tests into a AC_CACHE_CHECK
so that people doing cross-compilation can pass
libmonit_cv_setjmp_available=yes and
libmonit_cv_vsnprintf_c99_conformant=yes if they know their target
machine has support for those features.

If no value is passed and we're cross-compiling, the configure script
aborts with an error. If no value is passed and we're not
cross-compiling, then the normal AC_RUN_IFELSE test is conducted,
which aborts the configure script if the feature is not available.

Signed-off-by: Thomas Petazzoni <address@hidden>

Index: monit-5.3.2/libmonit/configure.ac
===================================================================
--- monit-5.3.2.orig/libmonit/configure.ac
+++ monit-5.3.2/libmonit/configure.ac
@@ -100,16 +100,33 @@
 # ------------------------------------------------------------------------
 
 # Require a working setjmp
-AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]],
-        [[jmp_buf env; setjmp(env);]])], 
-        [], [AC_MSG_FAILURE([setjmp is required])])
+AC_CACHE_CHECK([setjmp is available],[libmonit_cv_setjmp_available],
+  [
+  AC_RUN_IFELSE(
+  [AC_LANG_PROGRAM([[#include <setjmp.h>]],
+     [[jmp_buf env; setjmp(env);]])],
+     [
+     AC_MSG_RESULT(yes)
+  ],[
+     AC_MSG_FAILURE([setjmp is required])
+  ],[
+     AC_MSG_ERROR(cross-compiling: please set 'libmonit_cv_setjmp_available')
+  ])])
 
 # Require that we have vsnprintf that conforms to c99. I.e. does bounds check
-AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> 
+AC_CACHE_CHECK([vsnprintf is c99 
conformant],[libmonit_cv_vsnprintf_c99_conformant],
+  [
+  AC_RUN_IFELSE(
+  [AC_LANG_PROGRAM([[#include <stdarg.h>
         #include <stdio.h>]],
-[[char t[1]; va_list ap; int n = vsnprintf(t, 1, "hello", ap); if(n == 5) 
return 0;return 1;]])], 
-[], [AC_MSG_FAILURE([vsnprintf does not conform to c99])])
-
+     [[char t[1]; va_list ap; int n = vsnprintf(t, 1, "hello", ap); if(n == 5) 
return 0;return 1;]])],
+   [
+    AC_MSG_RESULT(yes)
+  ],[
+    AC_MSG_FAILURE([vsnprintf does not conform to c99])
+  ],[
+    AC_MSG_ERROR(cross-compiling: please set 
'libmonit_cv_vsnprintf_c99_conformant')
+  ])])
 
 # ------------------------------------------------------------------------
 # Architecture/OS


-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]