1 | dnl SMB Build Environment CC Checks
|
---|
2 | dnl -------------------------------------------------------
|
---|
3 | dnl Copyright (C) Stefan (metze) Metzmacher 2004
|
---|
4 | dnl Released under the GNU GPL
|
---|
5 | dnl -------------------------------------------------------
|
---|
6 | dnl
|
---|
7 |
|
---|
8 | AC_LIBREPLACE_CC_CHECKS
|
---|
9 |
|
---|
10 | #
|
---|
11 | # Set the debug symbol option if we have
|
---|
12 | # --enable-*developer or --enable-debug
|
---|
13 | # and the compiler supports it
|
---|
14 | #
|
---|
15 | if test x$ac_cv_prog_cc_g = xyes -a x$debug = xyes; then
|
---|
16 | CFLAGS="${CFLAGS} -g"
|
---|
17 | fi
|
---|
18 |
|
---|
19 | ############################################
|
---|
20 | # check if the compiler handles c99 struct initialization
|
---|
21 | LIBREPLACE_C99_STRUCT_INIT(samba_cv_c99_struct_initialization=yes,
|
---|
22 | samba_cv_c99_struct_initialization=no)
|
---|
23 |
|
---|
24 | if test x"$samba_cv_c99_struct_initialization" != x"yes"; then
|
---|
25 | AC_MSG_WARN([C compiler does not support c99 struct initialization!])
|
---|
26 | AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
|
---|
27 | fi
|
---|
28 |
|
---|
29 | ############################################
|
---|
30 | # check if the compiler can handle negative enum values
|
---|
31 | # and don't truncate the values to INT_MAX
|
---|
32 | # a runtime test is needed here
|
---|
33 | AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
|
---|
34 | AC_TRY_RUN(
|
---|
35 | [
|
---|
36 | #include <stdio.h>
|
---|
37 | enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
|
---|
38 | int main(void) {
|
---|
39 | enum negative_values v1 = NEGATIVE_VALUE;
|
---|
40 | unsigned v2 = 0xFFFFFFFF;
|
---|
41 | if (v1 != v2) {
|
---|
42 | printf("v1=0x%08x v2=0x%08x\n", v1, v2);
|
---|
43 | return 1;
|
---|
44 | }
|
---|
45 | return 0;
|
---|
46 | }
|
---|
47 | ],
|
---|
48 | samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,
|
---|
49 | samba_cv_CC_NEGATIVE_ENUM_VALUES=no,
|
---|
50 | samba_cv_CC_NEGATIVE_ENUM_VALUES=yes)])
|
---|
51 | if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
|
---|
52 | AC_DEFINE(USE_UINT_ENUMS, 1, [Whether the compiler has uint enum support])
|
---|
53 | fi
|
---|
54 |
|
---|
55 | AC_MSG_CHECKING([for test routines])
|
---|
56 | AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
|
---|
57 | AC_MSG_RESULT(yes),
|
---|
58 | AC_MSG_ERROR([cant find test code. Aborting config]),
|
---|
59 | AC_MSG_WARN([cannot run when cross-compiling]))
|
---|
60 |
|
---|
61 | #
|
---|
62 | # Check if the compiler support ELF visibility for symbols
|
---|
63 | #
|
---|
64 |
|
---|
65 | visibility_attribute=no
|
---|
66 | VISIBILITY_CFLAGS=""
|
---|
67 | if test x"$GCC" = x"yes" ; then
|
---|
68 | AX_CFLAGS_GCC_OPTION([-fvisibility=hidden], VISIBILITY_CFLAGS)
|
---|
69 | fi
|
---|
70 |
|
---|
71 | if test -n "$VISIBILITY_CFLAGS"; then
|
---|
72 | AC_MSG_CHECKING([whether the C compiler supports the visibility attribute])
|
---|
73 | OLD_CFLAGS="$CFLAGS"
|
---|
74 |
|
---|
75 | CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
|
---|
76 | AC_TRY_LINK([
|
---|
77 | void vis_foo1(void) {}
|
---|
78 | __attribute__((visibility("default"))) void vis_foo2(void) {}
|
---|
79 | ],[
|
---|
80 | ],[
|
---|
81 | AC_MSG_RESULT(yes)
|
---|
82 | AC_DEFINE(HAVE_VISIBILITY_ATTR,1,[Whether the C compiler supports the visibility attribute])
|
---|
83 | visibility_attribute=yes
|
---|
84 | ],[
|
---|
85 | AC_MSG_RESULT(no)
|
---|
86 | ])
|
---|
87 | CFLAGS="$OLD_CFLAGS"
|
---|
88 | fi
|
---|
89 | AC_SUBST(visibility_attribute)
|
---|
90 |
|
---|
91 | #
|
---|
92 | # Check if the compiler can handle the options we selected by
|
---|
93 | # --enable-*developer
|
---|
94 | #
|
---|
95 | DEVELOPER_CFLAGS=""
|
---|
96 | if test x$developer = xyes; then
|
---|
97 | OLD_CFLAGS="${CFLAGS}"
|
---|
98 |
|
---|
99 | CFLAGS="${CFLAGS} -D_SAMBA_DEVELOPER_DONNOT_USE_O2_"
|
---|
100 | DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
|
---|
101 | if test x"$GCC" = x"yes" ; then
|
---|
102 | #
|
---|
103 | # warnings we want...
|
---|
104 | #
|
---|
105 | AX_CFLAGS_GCC_OPTION(-Wall, DEVELOPER_CFLAGS)
|
---|
106 | AX_CFLAGS_GCC_OPTION(-Wshadow, DEVELOPER_CFLAGS)
|
---|
107 | AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DEVELOPER_CFLAGS)
|
---|
108 | AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes, DEVELOPER_CFLAGS)
|
---|
109 | AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DEVELOPER_CFLAGS)
|
---|
110 | AX_CFLAGS_GCC_OPTION(-Wcast-qual, DEVELOPER_CFLAGS)
|
---|
111 | AX_CFLAGS_GCC_OPTION(-Wcast-align, DEVELOPER_CFLAGS)
|
---|
112 | AX_CFLAGS_GCC_OPTION(-Wwrite-strings, DEVELOPER_CFLAGS)
|
---|
113 | AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute, DEVELOPER_CFLAGS)
|
---|
114 | AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS)
|
---|
115 | AX_CFLAGS_GCC_OPTION(-Wdeclaration-after-statement, DEVELOPER_CFLAGS)
|
---|
116 | AX_CFLAGS_GCC_OPTION(-Wunused-macros, DEVELOPER_CFLAGS)
|
---|
117 | # AX_CFLAGS_GCC_OPTION(-Wextra, DEVELOPER_CFLAGS)
|
---|
118 | # AX_CFLAGS_GCC_OPTION(-Wc++-compat, DEVELOPER_CFLAGS)
|
---|
119 | # AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes, DEVELOPER_CFLAGS)
|
---|
120 | # AX_CFLAGS_GCC_OPTION(-Wmissing-declarations, DEVELOPER_CFLAGS)
|
---|
121 | # AX_CFLAGS_GCC_OPTION(-Wmissing-field-initializers, DEVELOPER_CFLAGS)
|
---|
122 | #
|
---|
123 | # warnings we don't want...
|
---|
124 | #
|
---|
125 | AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
|
---|
126 | AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS)
|
---|
127 | #
|
---|
128 | # warnings we don't want just for some files e.g. swig bindings
|
---|
129 | #
|
---|
130 | AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL)
|
---|
131 | AC_SUBST(CFLAG_NO_CAST_QUAL)
|
---|
132 | AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS)
|
---|
133 | AC_SUBST(CFLAG_NO_UNUSED_MACROS)
|
---|
134 | else
|
---|
135 | AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS)
|
---|
136 | fi
|
---|
137 |
|
---|
138 | CFLAGS="${OLD_CFLAGS}"
|
---|
139 | fi
|
---|
140 | if test -n "$DEVELOPER_CFLAGS"; then
|
---|
141 | OLD_CFLAGS="${CFLAGS}"
|
---|
142 | CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
|
---|
143 | AC_MSG_CHECKING([that the C compiler can use the DEVELOPER_CFLAGS])
|
---|
144 | AC_TRY_COMPILE([],[],
|
---|
145 | AC_MSG_RESULT(yes),
|
---|
146 | DEVELOPER_CFLAGS=""; AC_MSG_RESULT(no))
|
---|
147 | CFLAGS="${OLD_CFLAGS}"
|
---|
148 | fi
|
---|
149 |
|
---|
150 | # allow for --with-hostcc=gcc
|
---|
151 | AC_ARG_WITH(hostcc,[ --with-hostcc=compiler choose host compiler],
|
---|
152 | [HOSTCC=$withval],
|
---|
153 | [
|
---|
154 | if test z"$cross_compiling" = "yes"; then
|
---|
155 | HOSTCC=cc
|
---|
156 | else
|
---|
157 | HOSTCC=$CC
|
---|
158 | fi
|
---|
159 | ])
|
---|
160 | AC_SUBST(HOSTCC)
|
---|
161 |
|
---|
162 | AC_PATH_PROG(GCOV,gcov)
|
---|