1 dnl --------------------------------
2 dnl Initialization macros.
3 dnl --------------------------------
5 AC_INIT(encoder/encmain.cpp)
7 dnl -----------------------------------------------
8 dnl Package name and version number (user defined)
9 dnl -----------------------------------------------
11 GENERIC_LIBRARY_NAME=dirac
14 GENERIC_MAJOR_VERSION=1
15 GENERIC_MINOR_VERSION=0
16 GENERIC_MICRO_VERSION=0
18 #shared library versioning
19 GENERIC_LIBRARY_VERSION=0:0:0
23 # current:revision:age
25 # | | +- increment if interfaces have been added
26 # | | set to zero if interfaces have been removed
28 # | +- increment if source code has changed
29 # | set to zero if current is incremented
30 # +- increment if interfaces have been added, removed or changed
33 dnl --------------------------------
34 dnl Package name and version number
35 dnl --------------------------------
37 AC_SUBST(GENERIC_LIBRARY_VERSION)
39 PACKAGE=$GENERIC_LIBRARY_NAME
40 AC_SUBST(GENERIC_LIBRARY_NAME)
42 GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
43 GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
44 AC_SUBST(GENERIC_RELEASE)
45 AC_SUBST(GENERIC_VERSION)
47 VERSION=$GENERIC_VERSION
49 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
51 dnl -----------------------------------------------
52 dnl Checks for required programs.
53 dnl -----------------------------------------------
60 ACLOCAL_AMFLAGS="-I m4 $ACLOCAL_AMFLAGS"
61 AC_SUBST(ACLOCAL_AMFLAGS)
64 dnl -------------------------------------------------------------------------
65 dnl Check if compiling using MS VC++ compiler in msys environment on Windows
66 dnl -------------------------------------------------------------------------
68 AC_SUBST([LIBFLAGS],[])
72 CXXFLAGS="-nologo -W1 -EHsc -DWIN32"
73 if test x"$enable_shared" = "xyes"; then
75 LIBFLAGS="-DLL -INCREMENTAL:NO"
76 CXXFLAGS="$CXXFLAGS -D_WINDLL"
87 AM_CONDITIONAL(USE_MSVC, test x"$use_msvc" = "xyes")
89 dnl -----------------------------------------------
90 dnl Checks for required headers
91 dnl -----------------------------------------------
96 dnl -------------------------------------------------------------------------
97 dnl Indirectly checking if the compiler is useable
98 dnl -------------------------------------------------------------------------
100 AC_CHECK_HEADER(streambuf,[], [AC_MSG_ERROR(["Unsupported Compiler version"])])
102 dnl ** We probably need this line, but not now
103 dnl AC_CHECK_HEADERS(stdint.h unistd.h fcntl.h)
105 AX_CREATE_STDINT_H([libdirac_common/dirac-stdint.h])
107 dnl -----------------------------------------------
108 dnl Checks for libraries.
109 dnl -----------------------------------------------
111 dnl -----------------------------------------------
112 dnl Checks for optional programs.
113 dnl -----------------------------------------------
114 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
115 if test $HAVE_DOXYGEN = "false"; then
116 AC_MSG_WARN([*** doxygen not found, code documentation will not be built])
118 AM_CONDITIONAL(HAVE_DOXYGEN, $HAVE_DOXYGEN)
120 AC_CHECK_PROG(HAVE_DOT, dot, true, false)
121 if test $HAVE_DOT = "false"; then
122 AC_MSG_WARN([*** dot not found, inheritance diagrams will not be generated in code documentation])
124 AM_CONDITIONAL(HAVE_DOT, $HAVE_DOT)
126 AC_CHECK_PROG(HAVE_LATEX, latex, true, false)
127 if test $HAVE_LATEX = "false"; then
128 AC_MSG_WARN([*** latex not found, algorithm documentation will not be built])
130 AM_CONDITIONAL(HAVE_LATEX, $HAVE_LATEX)
132 AC_CHECK_PROG(HAVE_DVIPDFM, dvipdfm, true, false)
133 if test $HAVE_DVIPDFM = "false"; then
134 AC_MSG_WARN([*** dvipdfm not found, programmer documentation will not be built])
136 AM_CONDITIONAL(HAVE_DVIPDFM, $HAVE_DVIPDFM)
138 AC_ARG_ENABLE(overlay,
139 [ --enable-overlay Turns onDirectory instrumentation],
140 [case "${enableval}" in
143 *) AC_MSG_ERROR(bad value ${enableval} for --enable-overlay) ;;
144 esac],[overlay=false])
145 AM_CONDITIONAL(OVERLAY, test x$overlay = xtrue)
147 dnl -----------------------------------------------
148 dnl Setup for the testsuite
149 dnl -----------------------------------------------
150 AC_CONFIG_TESTDIR([tests], [tests:encoder:decoder:unit_tests:util/instrumentation])
151 AC_CONFIG_FILES([tests/Makefile])
152 AC_CONFIG_FILES([tests/at_wrap], [chmod +x tests/at_wrap])
153 AM_MISSING_PROG([AUTOM4TE], [autom4te])
155 dnl ----------------------------------------------
156 dnl enable profiling flags
157 dnl -----------------------------------------------
158 AC_MSG_CHECKING([whether gprof flags are to be used when compiling])
159 AC_ARG_ENABLE(profile, AC_HELP_STRING([--enable-profile], [enable profile flags (no)]),
161 if test x"${enableval}" = x"yes" ; then
165 CXXFLAGS="$CXXFLAGS -pg"
173 fi], [AC_MSG_RESULT(no)]
180 TRY_CFLAGS="$OPT_CFLAGS -g"
181 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
182 TRY_CFLAGS="$OPT_CFLAGS -pedantic"
183 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
184 TRY_CFLAGS="$OPT_CFLAGS -Wall"
185 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
186 TRY_CFLAGS="$OPT_CFLAGS -Werror"
187 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
188 TRY_CFLAGS="$OPT_CFLAGS -W"
189 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
190 TRY_CFLAGS="$OPT_CFLAGS -Woverloaded-virtual"
191 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
192 #TRY_CFLAGS="-Wno-long-double"
193 #AC_TRY_CXXFLAGS([#include <math.h>],[long double lw;], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$OPT_CFLAGS $TRY_CFLAGS"])
194 TRY_CFLAGS="$OPT_CFLAGS -Wextra"
195 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
196 CXXFLAGS="$OPT_CFLAGS $CXXFLAGS"
199 # do nothing at the moment
202 dnl ----------------------------------------------
203 dnl enable debug flags
204 dnl -----------------------------------------------
205 AC_MSG_CHECKING([whether extra debug flags are to be used when compiling])
206 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable extra debug flags (no)]),
208 if test x"${enableval}" = x"yes" ; then
212 CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
215 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
216 CXXFLAGS="$OPT_CFLAGS $CXXFLAGS -DDIRAC_DEBUG"
219 CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
220 CXXFLAGS="-DDIRAC_DEBUG -g -O0 $CXXFLAGS"
221 # report only errors and warnings as errors
222 CXXFLAGS="$CXXFLAGS -w1 -Werror -wr964 -wr963"
225 # -Od turn off optimisation, -Z7 turn on debugging info
226 CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
227 CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[a-z]]*//g'`
228 CXXFLAGS=`echo $CXXFLAGS | sed 's/-W[[0-9]]*//g'`
229 CXXFLAGS="$CXXFLAGS -Od -Z7 -W2"
230 if test x"$enable_shared" = "xyes"; then
231 LIBFLAGS="$LIBFLAGS -DEBUG";
235 # do nothing at the moment
247 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
248 TRY_CFLAGS="$OPT_CFLAGS -Wuninitialized"
249 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
250 dnl arch specific flags
252 i386-*) TRY_CFLAGS="$OPT_CFLAGS -march=i386";;
253 i486-*) TRY_CFLAGS="$OPT_CFLAGS -march=i486";;
254 i586-*) TRY_CFLAGS="$OPT_CFLAGS -march=pentium";;
255 i686-*) TRY_CFLAGS="$OPT_CFLAGS -march=pentiumpro";;
256 k6-*) TRY_CFLAGS="$OPT_CFLAGS -march=k6";;
258 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
264 #Try more optimising flags if supported
267 dnl TRY_CFLAGS="$OPT_CFLAGS -fprefetch-loop-arrays"
268 dnl AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
269 TRY_CFLAGS="$OPT_CFLAGS -fexpensive-optimizations"
270 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
271 TRY_CFLAGS="$OPT_CFLAGS -frerun-cse-after-loop"
272 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
273 TRY_CFLAGS="$OPT_CFLAGS -frerun-loop-opt"
274 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
275 TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer"
276 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
277 TRY_CFLAGS="$OPT_CFLAGS -minline-all-stringops"
278 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
279 TRY_CFLAGS="$OPT_CFLAGS -fschedule-insns2"
280 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
281 TRY_CFLAGS="$OPT_CFLAGS -falign-functions=4"
282 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
283 dnl TRY_CFLAGS="$OPT_CFLAGS -preferred-stack-boundary=4"
284 dnl AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
285 TRY_CFLAGS="$OPT_CFLAGS -fforce-addr"
286 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
287 TRY_CFLAGS="$OPT_CFLAGS -pipe"
288 AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
291 # do nothing at the moment
294 CXXFLAGS="$OPT_CFLAGS $CXXFLAGS"
299 dnl ----------------------------------------------
300 dnl enable MMX optimization flag
301 dnl TODO: need to fix this test
302 dnl -----------------------------------------------
303 AC_MSG_CHECKING([whether optimizations using MMX instructions are enabled])
304 AC_ARG_ENABLE(mmx, AC_HELP_STRING([--enable-mmx], [enable MMX optimization (default=yes)]), [enable_mmx="${enableval}"], [enable_mmx="yes"])
306 if test x"${enable_mmx}" = x"yes" ; then
311 AC_TRY_CXXFLAGS([#include <mmintrin.h>],[], [$TRY_CFLAGS $CXXFLAGS],[CXXFLAGS="$CXXFLAGS $TRY_CFLAGS -DHAVE_MMX"])
316 AC_CHECK_HEADER(mmintrin.h,[AC_MSG_RESULT(yes); CXXFLAGS="$CXXFLAGS -DHAVE_MMX=1"], [AC_MSG_RESULT(["no"])])
321 AC_MSG_RESULT(["no"])
328 dnl -----------------------------------------------
329 dnl Setup for the cppunit testsuite
330 dnl -----------------------------------------------
332 dnl need to determine how to run AC_CHECK_LIB on a c++ library
333 dnl Until then just use AC_CHECK_HEADER by itself
334 dnl AC_CHECK_HEADER([cppunit/TestRunner.h],
335 dnl [AC_CHECK_LIB([cppunit], [main], [HAVE_CPPUNIT="true"], [HAVE_CPPUNIT="false"], [ -ldl ])], [HAVE_CPPUNIT="false"])
336 AC_CHECK_HEADER([cppunit/TestRunner.h],[HAVE_CPPUNIT="true"], [HAVE_CPPUNIT="false"])
337 if test $HAVE_CPPUNIT = "true"; then
338 AC_MSG_CHECKING([whether unit tests code will compile and link])
340 SAVE_CXXFLAGS=$CXXFLAGS
341 LIBS="$LIBS -lcppunit -ldl"
342 case `$LD -v 2>&1 < /dev/null` in
343 *GNU* | *'with BFD'*)
344 CXXFLAGS="$CXXFLAGS -Wl,--fatal-warnings"
347 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <string>
348 #include <cppunit/TestResult.h>
349 #include <cppunit/TestRunner.h>]], [[CPPUNIT_NS::TestResult controller; CPPUNIT_NS::TestRunner runner;]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); HAVE_CPPUNIT="false"])
351 CXXFLAGS=$SAVE_CXXFLAGS
353 AM_CONDITIONAL(HAVE_CPPUNIT, $HAVE_CPPUNIT)
356 dnl -----------------------------------------------
357 dnl Check if static libraries to be used on non-Windows platforms
358 dnl -----------------------------------------------
359 AM_CONDITIONAL(USE_STATIC, test x"$enable_static" = "xyes")
361 dnl -----------------------------------------------
362 dnl Setup valgrind and necessary args for memcheck
363 dnl -----------------------------------------------
364 dnl Using -q --leak-check on valgrind pre-2.2 gives stderr output when
365 dnl no leaks are found so only use --leak-check with recent valgrind.
366 dnl valgrind is used during the make valgrind-check target.
367 AC_CHECK_PROGS(VALGRIND, valgrind)
368 if test x"$VALGRIND" != "x" ; then
369 if $VALGRIND -q --tool=memcheck true 2>/dev/null; then
370 VALGRIND="valgrind --tool=memcheck --leak-check=yes"
374 dnl -----------------------------------------------
375 dnl Check if we need mathlib
376 dnl -----------------------------------------------
378 AC_SUBST([CONFIG_MATH_LIB],[])
379 AC_MSG_CHECKING([whether we need to link math lib])
380 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cmath>]], [[double lw = std::pow(2.0, 2.0);]])],[AC_MSG_RESULT(no)], [CONFIG_MATH_LIB="-lm";AC_MSG_RESULT(yes)])
382 dnl -----------------------------------------------
383 dnl Generates Makefile's, configuration files and scripts
384 dnl -----------------------------------------------
386 AC_OUTPUT(Makefile dirac.pc \
388 libdirac_byteio/Makefile \
389 libdirac_common/Makefile \
390 libdirac_motionest/Makefile \
391 libdirac_encoder/Makefile \
392 libdirac_decoder/Makefile \
395 unit_tests/Makefile \
397 util/conversion/Makefile \
398 util/conversion/common/Makefile \
399 util/instrumentation/Makefile \
400 util/instrumentation/libdirac_instrument/Makefile \
402 win32/VisualStudio/Makefile )