* remove a valgrind warning
[hkl.git] / configure.ac
bloba6e62eae07039bd0279e771d1c293bdbdb64dacc
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ([2.67])
5 AC_INIT([hkl],[5.0.0],[picca@synchrotron-soleil.fr])
6 AC_CONFIG_SRCDIR([config.h.in])
7 AC_CONFIG_HEADERS([config.h])
8 AC_CONFIG_MACRO_DIR([m4])
9 AC_CONFIG_AUX_DIR(config)
11 AM_INIT_AUTOMAKE([silent-rules tar-ustar])
13 # Checks for programs.
14 AC_PROG_CXX
15 AC_PROG_AWK
16 AC_PROG_CC
17 AC_PROG_CPP
18 AC_PROG_INSTALL
19 AC_PROG_LN_S
20 AC_PROG_MAKE_SET
21 LT_INIT
22 AC_PROG_RANLIB
23 AM_SILENT_RULES
25 # Checks for libraries.
26 AX_PATH_GSL
27 AC_CHECK_LIB([glut], [glutMainLoop])
29 # Checks for header files.
30 AC_HEADER_STDBOOL
31 AC_HEADER_STDC
32 AC_HEADER_TIME
33 AC_FUNC_ALLOCA
34 AC_CHECK_HEADERS([float.h limits.h malloc.h memory.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
36 # Checks for typedefs, structures, and compiler characteristics.
37 AC_C_CONST
38 AC_C_INLINE
39 AC_TYPE_INT16_T
40 AC_TYPE_INT32_T
41 AC_TYPE_INT64_T
42 AC_TYPE_INT8_T
43 AC_TYPE_SIZE_T
44 AC_TYPE_UINT16_T
45 AC_TYPE_UINT32_T
46 AC_TYPE_UINT64_T
47 AC_TYPE_UINT8_T
49 # Checks for library functions.
50 AC_FUNC_ERROR_AT_LINE
51 AC_FUNC_MALLOC
52 AC_FUNC_REALLOC
53 AC_FUNC_VPRINTF
54 AC_CHECK_FUNCS([floor getcwd gettimeofday memmove memset pow select sqrt strchr strdup strstr])
56 dnl ***************
57 dnl *** gtk-doc ***
58 dnl ***************
60 GTK_DOC_CHECK(1.9)
62 dnl **************
63 dnl *** povray ***
64 dnl **************
66 AC_PATH_PROG([POVRAY], [povray])
68 dnl *********************************************
69 dnl *** took from the bullet configure script ***
70 dnl *********************************************
72 AC_CANONICAL_HOST
73 case "$host" in
74         *-*-mingw*|*-*-cygwin*)
75                 AC_DEFINE(PLATFORM_WIN32, 1, [Platform is Win32])
76                 opengl_LIBS="-lunsupported_platform"
77                 PLATFORM_STRING="Win32"
78                 ;;
79         *-*-linux*)
80                 AC_DEFINE(PLATFORM_LINUX, 1, [Platform is Linux])
81                 opengl_LIBS="-lGL -lGLU -lglut"
82                 PLATFORM_STRING="Linux"
83                 ;;
84         *-*-darwin*)
85                 AC_DEFINE(PLATFORM_APPLE, 1, [Platform is Apple])
86                 opengl_LIBS="-framework AGL -framework OpenGL -framework GLUT"
87                 PLATFORM_STRING="Apple"
88                 ;;
89         *)
90                 AC_MSG_WARN([*** Please add $host to configure.ac checks!])
91                 ;;
92 esac
93 AC_SUBST(opengl_LIBS)
95 case "$host" in
96         i?86-* | k?-* | athlon-* | pentium*-)
97                 AC_DEFINE(ARCH_X86, 1, [Architecture is x86])
98                 ARCH_SPECIFIC_CFLAGS=""
99                 ARCH_STRING="X86"
100                 ;;
101         x86_64-*)
102                 AC_DEFINE(ARCH_X86_64, 1, [Architecture is x86-64])
103                 ARCH_SPECIFIC_CFLAGS="-DUSE_ADDR64"
104                 ARCH_STRING="X86-64"
105                 ;;
106         ppc-* | powerpc-*)
107                 AC_DEFINE(ARCH_PPC, 1, [Architecture is PowerPC])
108                 ARCH_SPECIFIC_CFLAGS=""
109                 ARCH_STRING="PowerPC"
110                 ;;
111         *)
112                 AC_MSG_ERROR([Unknown Architecture])
113                 ;;
114 esac
115 AC_C_BIGENDIAN
117 #----------------------------------------------------------------------------
118 # Package configuration switches.
119 #----------------------------------------------------------------------------
120 AC_ARG_ENABLE([multithreaded],
121         [AS_HELP_STRING([--enable-multithreaded],[build BulletMultiThreaded (default NO)])],
122         [disable_multithreaded=no], [disable_multithreaded=yes])
123 AC_MSG_CHECKING([BulletMultiThreaded])
124 AS_IF([test "$disable_multithreaded" = yes], [build_multithreaded=no], [build_multithreaded=yes])
125 AC_MSG_RESULT([$build_multithreaded])
126 AM_CONDITIONAL([CONDITIONAL_BUILD_MULTITHREADED], [test "$build_multithreaded" = yes])
128 AC_ARG_ENABLE([demos],
129     [AS_HELP_STRING([--disable-demos],
130             [disable Bullet demos])],
131     [],
132     [enable_demos=yes])
133 AM_CONDITIONAL([CONDITIONAL_BUILD_DEMOS], [false])
134 if test "x$enable_demos" != xno; then
135     AC_MSG_NOTICE([Building Bullet demos])
136     AM_CONDITIONAL([CONDITIONAL_BUILD_DEMOS],[true])
141 AC_ARG_ENABLE([debug],
142     [AS_HELP_STRING([--enable-debug],[build with debugging information (default NO)])],
143     [], [enable_debug=no])
145 AC_MSG_CHECKING([build mode])
146 AS_IF([test $enable_debug = yes], [build_mode=debug], [build_mode=optimize])
147 AC_MSG_RESULT([$build_mode])
149 CFLAGS="$ARCH_SPECIFIC_CFLAGS $CFLAGS"
150 CXXFLAGS="$ARCH_SPECIFIC_CFLAGS $CXXFLAGS $CFLAGS"
152 ### end bullet configure script
154 dnl *******************************
155 dnl *** add an option for hkl3d ***
156 dnl *******************************
158 AC_ARG_ENABLE([hkl3d],
159         AS_HELP_STRING([--disable-hkl3d],
160                 [turn off the hkl3d library [[default=yes]]]),
161         [],
162         [enable_hkl3d=yes])
163 AM_CONDITIONAL([HKL3D], [test x$enable_hkl3d = xyes])
164 AM_COND_IF([HKL3D],
165            [PKG_CHECK_MODULES([G3D], [libg3d >= 0.0.8])
166            dnl check for yaml
167            AC_CHECK_LIB(yaml, yaml_get_version,
168                         [AC_CHECK_HEADERS(yaml.h, , yaml_found=no)])
169            if test x$yaml_found = xno; then
170               AC_MSG_ERROR([Could not find yaml.h])
171            fi
172            YAML_CFLAGS=""
173            AC_SUBST(YAML_CFLAGS)
174            YAML_LIBS="-lyaml"
175            AC_SUBST(YAML_LIBS)
178 dnl ****************************************
179 dnl *** add an option for the ghkl build ***
180 dnl ****************************************
182 AC_ARG_ENABLE([ghkl],
183         AS_HELP_STRING([--disable-ghkl],
184                 [do not compile the ghkl gui [[default=yes]]]),
185         [],
186         [enable_ghkl=yes])
187 AM_CONDITIONAL([GHKL], [test x$enable_ghkl = xyes])
188 AM_COND_IF([GHKL],
189         [PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.18])
190         AM_COND_IF([HKL3D],
191                    [PKG_CHECK_MODULES([GLU], [glu >= 7.7.1])
192                     PKG_CHECK_MODULES([GTKGLEXTMM], [gtkglextmm-1.2])
193         ])
196 dnl ************************************
197 dnl *** Enable lcov coverage reports ***
198 dnl ************************************
200 AC_ARG_ENABLE(gcov,
201         AS_HELP_STRING([--enable-gcov],
202                 [Enable gcov]),
203         [use_gcov=$enableval],
204         [use_gcov=no])
206 if test "x$use_gcov" = "xyes"; then
207    dnl we need gcc:
208    if test "$GCC" != "yes"; then
209       AC_MSG_ERROR([GCC is required for --enable-gcov])
210    fi
212   dnl Check if ccache is being used
213   AC_CHECK_PROG(SHTOOL, shtool, shtool)
214   case `$SHTOOL path $CC` in
215     *ccache*[)] gcc_ccache=yes;;
216     *[)] gcc_ccache=no;;
217   esac
219   if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
220     AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
221   fi
223   ltp_version_list="1.6 1.7 1.8"
224   AC_CHECK_PROG(LTP, lcov, lcov)
225   AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
227   if test "$LTP"; then
228     AC_CACHE_CHECK([for ltp version], glib_cv_ltp_version, [
229       glib_cv_ltp_version=invalid
230       ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
231       for ltp_check_version in $ltp_version_list; do
232         if test "$ltp_version" = "$ltp_check_version"; then
233           glib_cv_ltp_version="$ltp_check_version (ok)"
234         fi
235       done
236     ])
237   else
238     ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
239     AC_MSG_ERROR([$ltp_msg])
240   fi
242   case $glib_cv_ltp_version in
243     ""|invalid[)]
244       ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
245       AC_MSG_ERROR([$ltp_msg])
246       LTP="exit 0;"
247       ;;
248   esac
250   if test -z "$LTP_GENHTML"; then
251     AC_MSG_ERROR([Could not find genhtml from the LTP package])
252   fi
254   AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
256   dnl Remove all optimization flags from CFLAGS
257   changequote({,})
258   CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
259   CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9]*//g'`
260   changequote([,])
262   dnl Add the special gcc flags
263   CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
264   CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
265   LDFLAGS="$LDFLAGS -lgcov"
268 AC_CONFIG_FILES([Makefile
269                  hkl/Makefile
270                  hkl.pc
271                  hkl3d/Makefile
272                  hkl3d/bullet/Makefile
273                  hkl3d/bullet/src/Makefile
274                  hkl3d.pc
275                  test/Makefile
276                  test/hkl/Makefile
277                  test/hkl3d/Makefile
278                  test/tap/Makefile
279                  Documentation/Makefile
280                  Documentation/api/Makefile
281                  Documentation/figures/Makefile
282                  gui/Makefile
283                  gui/hkl3d/Makefile
284                  data/Makefile
287 AC_OUTPUT