Two patches which fix issues on cross compiling/building
[samba.git] / source4 / build / m4 / check_cc.m4
index a1dfc45404648ced4cd4bb32c71f9d10dd2fd4f0..32e4b5083ddddce13a03c3658e5955bd7adf721f 100644 (file)
@@ -7,12 +7,6 @@ dnl
 
 AC_LIBREPLACE_CC_CHECKS
 
-if test x"$GCC" = x"yes" ; then
-       AC_MSG_CHECKING([for version of gcc])
-       GCC_VERSION=`$CC -dumpversion`
-       AC_MSG_RESULT(${GCC_VERSION})
-fi
-
 #
 # Set the debug symbol option if we have
 # --enable-*developer or --enable-debug
@@ -36,35 +30,30 @@ fi
 # check if the compiler can handle negative enum values
 # and don't truncate the values to INT_MAX
 # a runtime test is needed here
-AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
+AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
     AC_TRY_RUN(
 [
        #include <stdio.h>
        enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
        int main(void) {
                enum negative_values v1 = NEGATIVE_VALUE;
-               unsigned v2 = NEGATIVE_VALUE;
-
-               if (v1 != 0xFFFFFFFF) {
-                       printf("%u != 0xFFFFFFFF\n", v1);
-                       return 1;
-               }
-               if (v2 != 0xFFFFFFFF) {
-                       printf("%u != 0xFFFFFFFF\n", v2);
+               unsigned v2 = 0xFFFFFFFF;
+               if (v1 != v2) {
+                       printf("v1=0x%08x v2=0x%08x\n", v1, v2);
                        return 1;
                }
-
                return 0;
        }
 ],
-       SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
-if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
-       AC_MSG_WARN([using --unit-enums for pidl])
-       PIDL_ARGS="$PIDL_ARGS --uint-enums"
+       samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,
+       samba_cv_CC_NEGATIVE_ENUM_VALUES=no,
+       samba_cv_CC_NEGATIVE_ENUM_VALUES=yes)])
+if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
+       AC_DEFINE(USE_UINT_ENUMS, 1, [Whether the compiler has uint enum support])
 fi
 
 AC_MSG_CHECKING([for test routines])
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
            AC_MSG_RESULT(yes),
            AC_MSG_ERROR([cant find test code. Aborting config]),
            AC_MSG_WARN([cannot run when cross-compiling]))
@@ -84,10 +73,10 @@ if test -n "$VISIBILITY_CFLAGS"; then
        OLD_CFLAGS="$CFLAGS"
 
        CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
-       AC_TRY_RUN([
+       AC_TRY_LINK([
                void vis_foo1(void) {}
                __attribute__((visibility("default"))) void vis_foo2(void) {}
-               #include "${srcdir-.}/build/tests/trivial.c"
+       ],[
        ],[
                AC_MSG_RESULT(yes)
                AC_DEFINE(HAVE_VISIBILITY_ATTR,1,[Whether the C compiler supports the visibility attribute])
@@ -135,6 +124,13 @@ if test x$developer = xyes; then
            #
            AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
            AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS)
+           #
+           # warnings we don't want just for some files e.g. swig bindings
+           #
+           AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL)
+           AC_SUBST(CFLAG_NO_CAST_QUAL)
+           AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS)
+           AC_SUBST(CFLAG_NO_UNUSED_MACROS)
        else
            AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS)
        fi
@@ -152,7 +148,7 @@ if test -n "$DEVELOPER_CFLAGS"; then
 fi
 
 # allow for --with-hostcc=gcc
-AC_ARG_WITH(hostcc,[  --with-hostcc=compiler    choose host compiler],
+AC_ARG_WITH(hostcc,[  --with-hostcc=compiler  choose host compiler],
 [HOSTCC=$withval],
 [
 if test z"$cross_compiling" = "yes"; then