[hkl] remove a bunch of warnings.
[hkl.git] / configure.ac
blob27b6fdebea102619a50aeee3fe6752f9bb090e75
1 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
2 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
3 m4_define([v_maj], [4])
4 m4_define([v_min], [99])
5 m4_define([v_mic], [99])
6 m4_define([v_rev], m4_esyscmd([(git rev-list --count HEAD 2>/dev/null || echo 0) | tr -d '\n']))dnl
7 ##--   When released, remove the dnl on the below line
8 dnl m4_undefine([v_rev])
9 ##--   When doing snapshots - change soname. remove dnl on below line
10 dnl m4_define([relname], [ver-pre-svn-07])
11 dnl m4_define([v_rel], [-release relname])
12 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
13 m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic.v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])])
14 m4_define([lt_cur], m4_eval(v_maj + v_min))
15 m4_define([lt_rev], v_mic)
16 m4_define([lt_age], v_min)
17 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
18 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
20 AC_PREREQ([2.69])
21 AC_INIT([hkl],[v_ver],[picca@synchrotron-soleil.fr])
22 AC_CONFIG_SRCDIR([config.h.in])
23 AC_CONFIG_HEADERS([config.h])
24 AC_CONFIG_MACRO_DIR([m4])
25 AC_CONFIG_AUX_DIR(config)
27 AM_INIT_AUTOMAKE([silent-rules tar-ustar -Wno-portability subdir-objects])
29 # Checks for programs.
30 AC_PROG_AWK
31 AC_PROG_CC_C99
32 AC_PROG_CXX
33 AC_PROG_CPP
34 AC_PROG_INSTALL
35 AC_PROG_LN_S
36 AC_PROG_MAKE_SET
37 LT_INIT
38 AM_SILENT_RULES
40 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
41 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
42 m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
43 m4_ifdef([v_rel], , [m4_define([v_rel], [])])
44 AC_DEFINE_UNQUOTED(VMAJ, [v_maj], [Major version])
45 AC_DEFINE_UNQUOTED(VMIN, [v_min], [Minor version])
46 AC_DEFINE_UNQUOTED(VMIC, [v_mic], [Micro version])
47 AC_DEFINE_UNQUOTED(VREV, [v_rev], [Revison])
48 version_info="lt_cur:lt_rev:lt_age"
49 release_info="v_rel"
50 AC_SUBST(version_info)
51 AC_SUBST(release_info)
52 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
53 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
54 VMAJ=v_maj
55 AC_SUBST(VMAJ)
57 # activate all the warnings
58 AX_CFLAGS_WARN_ALL
59 AX_CXXFLAGS_WARN_ALL
61 # Checks for libraries.
62 AX_PATH_GSL
63 AM_PATH_GLIB_2_0
65 # Checks for header files.
66 AC_HEADER_STDC
67 AC_HEADER_TIME
68 AC_FUNC_ALLOCA
69 AC_CHECK_HEADERS([float.h limits.h malloc.h memory.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
71 # Checks for typedefs, structures, and compiler characteristics.
72 AC_C_CONST
73 AC_C_INLINE
74 AC_TYPE_INT16_T
75 AC_TYPE_INT32_T
76 AC_TYPE_INT64_T
77 AC_TYPE_INT8_T
78 AC_TYPE_SIZE_T
79 AC_TYPE_UINT16_T
80 AC_TYPE_UINT32_T
81 AC_TYPE_UINT64_T
82 AC_TYPE_UINT8_T
84 # Checks for library functions.
85 AC_FUNC_ERROR_AT_LINE
86 AC_FUNC_MALLOC
87 AC_FUNC_REALLOC
88 AC_FUNC_VPRINTF
89 AC_CHECK_FUNCS([floor getcwd gettimeofday memmove memset pow select sqrt strchr strdup strstr])
91 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
92 dnl Create a new --enable option that defaults to being disabled.
93 dnl NAME is the base name of the option.  The shell variable enable_NAME
94 dnl   will be set to either the user's value (if the option is
95 dnl   specified; 'yes' for a plain --enable-NAME) or to 'no' (if the
96 dnl   option is not specified).  Note that the shell variable name is
97 dnl   constructed as autoconf does, by replacing non-alphanumeric
98 dnl   characters with "_".
99 dnl HELP-STRING is the help text for the option.
100 AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
101   AC_ARG_ENABLE([$1],[AS_HELP_STRING([--enable-$1],[$2])],[],[dnl
102     m4_bpatsubst([enable_$1], [[^0-9a-z]], [_])=no])dnl
103 ])dnl
105 dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
106 dnl Create a new --enable option that defaults to being enabled.
107 dnl NAME is the base name of the option.  The shell variable enable_NAME
108 dnl   will be set to either the user's value (if the option is
109 dnl   specified; 'no' for a plain --enable-NAME) or to 'yes' (if the
110 dnl   option is not specified).  Note that the shell variable name is
111 dnl   constructed as autoconf does, by replacing non-alphanumeric
112 dnl   characters with "_".
113 dnl HELP-STRING is the help text for the option.
114 AC_DEFUN([OPTION_DEFAULT_ON], [dnl
115   AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])],[],[dnl
116     m4_bpatsubst([enable_$1], [[^0-9a-z]], [_])=yes])dnl
117 ])dnl
119 dnl ***************
120 dnl *** logging ***
121 dnl ***************
123 OPTION_DEFAULT_OFF([logging], [enable the glib logging])
124 AM_CONDITIONAL([LOGGING], [test x$enable_logging != xno])
125 AM_COND_IF([LOGGING],
126         AC_DEFINE([LOGGING], [1], [activate the logging or not])
127         )
129 dnl ***********
130 dnl *** doc ***
131 dnl ***********
133 OPTION_DEFAULT_ON([hkl-doc], [build documentation])
134 AM_CONDITIONAL([HKL_DOC], [test x$enable_hkl_doc = xyes])
135 AM_COND_IF([HKL_DOC],
136            [dnl *** asymptote ***
137             AC_PATH_PROG([ASY], [asy], [echo])
138             dnl *** emacs ***
139             AC_PATH_PROG([EMACS], [emacs], [no])
140            ])
142 dnl *** gtk-doc ***
143 GTK_DOC_CHECK([1.9],[--flavour no-tmpl])
145 dnl *******************************
146 dnl *** add an option for hkl3d ***
147 dnl *******************************
149 OPTION_DEFAULT_OFF([hkl3d], [compile the hkl3d library])
151 AM_CONDITIONAL([HKL3D], [test x$enable_hkl3d != xno])
152 AM_COND_IF([HKL3D],
153            [PKG_CHECK_MODULES([G3D], [libg3d >= 0.0.8])
154             PKG_CHECK_MODULES([BULLET], [bullet >= 2.82])
155            dnl check for yaml
156            AC_SEARCH_LIBS([yaml_get_version], [yaml],
157                           [AC_CHECK_HEADERS([yaml.h], [],
158                                             [AC_MSG_ERROR([Could not find the yaml headers, please install yaml developement files])]
159                           )],
160                           [AC_MSG_ERROR([Could not find the libyaml runtime, please install yaml])]
161            )
162            YAML_CFLAGS=""
163            AC_SUBST(YAML_CFLAGS)
164            YAML_LIBS="-lyaml"
165            AC_SUBST(YAML_LIBS)
168 dnl ****************************************
169 dnl *** add an option for the ghkl build ***
170 dnl ****************************************
172 OPTION_DEFAULT_ON([gui], [do not compile the gui interface])
174 AM_CONDITIONAL([GUI], [test x$enable_gui = xyes])
175 AM_COND_IF([GUI],
176         [PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.0])
177         AM_COND_IF([HKL3D],
178                    [PKG_CHECK_MODULES([GLU], [glu >= 7.7.1])
179                     PKG_CHECK_MODULES([GTKGLEXT], [gtkglext-1.0 >= 1.2.0])
180         ])
183 dnl ************************************
184 dnl *** Enable lcov coverage reports ***
185 dnl ************************************
187 AC_ARG_ENABLE(gcov,
188         AS_HELP_STRING([--enable-gcov],
189                 [Enable gcov]),
190         [use_gcov=$enableval],
191         [use_gcov=no])
193 if test "x$use_gcov" = "xyes"; then
194    dnl we need gcc:
195    if test "$GCC" != "yes"; then
196       AC_MSG_ERROR([GCC is required for --enable-gcov])
197    fi
199   dnl Check if ccache is being used
200   AC_CHECK_PROG(SHTOOL, shtool, shtool)
201   case `$SHTOOL path $CC` in
202     *ccache*[)] gcc_ccache=yes;;
203     *[)] gcc_ccache=no;;
204   esac
206   if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
207     AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
208   fi
210   ltp_version_list="1.6 1.7 1.8 1.9"
211   AC_CHECK_PROG(LTP, lcov, lcov)
212   AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
214   if test "$LTP"; then
215     AC_CACHE_CHECK([for ltp version], glib_cv_ltp_version, [
216       glib_cv_ltp_version=invalid
217       ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
218       for ltp_check_version in $ltp_version_list; do
219         if test "$ltp_version" = "$ltp_check_version"; then
220           glib_cv_ltp_version="$ltp_check_version (ok)"
221         fi
222       done
223     ])
224   else
225     ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
226     AC_MSG_ERROR([$ltp_msg])
227   fi
229   case $glib_cv_ltp_version in
230     ""|invalid[)]
231       ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
232       AC_MSG_ERROR([$ltp_msg])
233       LTP="exit 0;"
234       ;;
235   esac
237   if test -z "$LTP_GENHTML"; then
238     AC_MSG_ERROR([Could not find genhtml from the LTP package])
239   fi
241   AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
243   dnl Remove all optimization flags from CFLAGS
244   changequote({,})
245   CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
246   CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9]*//g'`
247   changequote([,])
249   dnl Add the special gcc flags
250   CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
251   CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
252   LDFLAGS="$LDFLAGS -lgcov"
255 dnl *********************
256 dnl *** introspection ***
257 dnl *********************
259 GOBJECT_INTROSPECTION_CHECK([0.6.7])
261 AM_COND_IF([HAVE_INTROSPECTION],
262         [PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])])
265 dnl ************
266 dnl *** ccan ***
267 dnl ************
269 AC_DEFINE([HAVE_SECTION_START_STOP], [1], ["do we support section or not"])
270 AC_DEFINE([HAVE_TYPEOF], [1], ["do we have typeof"])
271 AC_DEFINE([HAVE_STATEMENT_EXPR], [1], ["do we have typeof"])
272 AC_DEFINE([HAVE_ATTRIBUTE_COLD], [1], ["do we have typeof"])
273 AC_DEFINE([HAVE_ATTRIBUTE_PRINTF], [1], ["do we have typeof"])
274 AC_DEFINE([HAVE_ATTRIBUTE_CONST], [1], ["do we have typeof"])
275 AC_DEFINE([HAVE_ATTRIBUTE_UNUSED], [1], ["do we have typeof"])
276 AC_DEFINE([HAVE_BUILTIN_CONSTANT_P], [1], ["do we have typeof"])
277 AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1], ["do we have typeof"])
278 AC_DEFINE([HAVE_ATTRIBUTE_NORETURN], [1], ["do we have typeof"])
279 AC_DEFINE([HAVE_ATTRIBUTE_USED], [1], ["do we have typeof"])
280 AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P], [1], ["do we have typeof"])
282 AC_CONFIG_FILES([Makefile
283                  hkl/Makefile
284                  hkl/ccan/Makefile
285                  hkl.pc
286                  hkl3d/Makefile
287                  hkl3d.pc
288                  tests/Makefile
289                  tests/bindings/Makefile
290                  tests/tap/Makefile
291                  Documentation/Makefile
292                  Documentation/hkl.org
293                  Documentation/api/Makefile
294                  Documentation/figures/Makefile
295                  Documentation/sphinx/Makefile
296                  Documentation/sphinx/source/conf.py
297                  gui/Makefile
298                  data/Makefile
301 AC_OUTPUT