File: configure.ac

package info (click to toggle)
dirac 1.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,664 kB
  • ctags: 3,041
  • sloc: cpp: 28,139; sh: 13,225; makefile: 449; perl: 87
file content (402 lines) | stat: -rw-r--r-- 14,121 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
dnl --------------------------------
dnl Initialization macros.
dnl --------------------------------

AC_INIT(encoder/encmain.cpp)

dnl -----------------------------------------------
dnl Package name and version number (user defined)
dnl -----------------------------------------------

GENERIC_LIBRARY_NAME=dirac

#release versioning
GENERIC_MAJOR_VERSION=1
GENERIC_MINOR_VERSION=0
GENERIC_MICRO_VERSION=2

#shared library versioning
GENERIC_LIBRARY_VERSION=1:0:1
#                       | | |
#                +------+ | +---+
#                |        |     |
#             current:revision:age
#                |        |     |
#                |        |     +- increment if interfaces have been added
#                |        |        set to zero if interfaces have been removed
#                                  or changed
#                |        +- increment if source code has changed
#                |           set to zero if current is incremented
#                +- increment if interfaces have been added, removed or changed


dnl --------------------------------
dnl Package name and version number
dnl --------------------------------

AC_SUBST(GENERIC_LIBRARY_VERSION)

PACKAGE=$GENERIC_LIBRARY_NAME
AC_SUBST(GENERIC_LIBRARY_NAME)

GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
AC_SUBST(GENERIC_RELEASE)
AC_SUBST(GENERIC_VERSION)

VERSION=$GENERIC_VERSION

AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)

dnl -----------------------------------------------
dnl Checks for required programs.
dnl -----------------------------------------------
AC_PROG_CXX
AM_SANITY_CHECK
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_SYS_LARGEFILE

ACLOCAL_AMFLAGS="-I m4 $ACLOCAL_AMFLAGS"
AC_SUBST(ACLOCAL_AMFLAGS)


dnl -------------------------------------------------------------------------
dnl Check if compiling using MS VC++ compiler in msys environment on Windows
dnl -------------------------------------------------------------------------
use_msvc=no
AC_SUBST([LIBFLAGS],[])
AC_SUBST([LIBEXT],[])
case "$CXX" in
		cl*|CL*)
		CXXFLAGS="-nologo -W1 -EHsc -DWIN32"
		if test x"$enable_shared" = "xyes"; then
		    LIBEXT=".dll";
		    LIBFLAGS="-DLL -INCREMENTAL:NO"
			CXXFLAGS="$CXXFLAGS -D_WINDLL"
		else
		    LIBEXT=".lib";
		    LIBFLAGS="-lib"
		fi
		RANLIB="echo"
		use_msvc=yes
		;;
	*)
		;;
esac
AM_CONDITIONAL(USE_MSVC, test x"$use_msvc" = "xyes")

dnl -----------------------------------------------
dnl Checks for required headers
dnl -----------------------------------------------

AC_HEADER_STDC
AC_HEADER_STDBOOL

dnl -------------------------------------------------------------------------
dnl Indirectly checking if the compiler is useable
dnl -------------------------------------------------------------------------
AC_LANG_PUSH(C++)
AC_CHECK_HEADER(streambuf,[], [AC_MSG_ERROR(["Unsupported Compiler version"])])
AC_LANG_POP(C++)
dnl ** We probably need this line, but not now
dnl AC_CHECK_HEADERS(stdint.h unistd.h fcntl.h)

AX_CREATE_STDINT_H([libdirac_common/dirac-stdint.h])

dnl -----------------------------------------------
dnl Checks for libraries.
dnl -----------------------------------------------

dnl -----------------------------------------------
dnl Checks for optional programs.
dnl -----------------------------------------------
AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
	if test $HAVE_DOXYGEN = "false"; then
		AC_MSG_WARN([*** doxygen not found, code documentation will not be built])
	fi
AM_CONDITIONAL(HAVE_DOXYGEN, $HAVE_DOXYGEN)

AC_CHECK_PROG(HAVE_DOT, dot, true, false)
	if test $HAVE_DOT = "false"; then
		AC_MSG_WARN([*** dot not found, inheritance diagrams will not be generated in code documentation])
	fi
AM_CONDITIONAL(HAVE_DOT, $HAVE_DOT)

AC_CHECK_PROG(HAVE_LATEX, latex, true, false)
	if test $HAVE_LATEX = "false"; then
		AC_MSG_WARN([*** latex not found, algorithm documentation will not be built])
	fi
AM_CONDITIONAL(HAVE_LATEX, $HAVE_LATEX)

AC_CHECK_PROG(HAVE_DVIPDFM, dvipdfm, true, false)
	if test $HAVE_DVIPDFM = "false"; then
	    AC_MSG_WARN([*** dvipdfm not found, programmer documentation will not be built])
    fi
AM_CONDITIONAL(HAVE_DVIPDFM, $HAVE_DVIPDFM)

AC_ARG_ENABLE(overlay,
[ --enable-overlay Turns onDirectory instrumentation],
[case "${enableval}" in
	yes) overlay=true ;;
	no) overlay=false ;;
	*) AC_MSG_ERROR(bad value ${enableval} for --enable-overlay) ;;
esac],[overlay=false])
AM_CONDITIONAL(OVERLAY, test x$overlay = xtrue)

dnl -----------------------------------------------
dnl Setup for the testsuite
dnl -----------------------------------------------
AC_CONFIG_TESTDIR([tests], [tests:encoder:decoder:unit_tests:util/instrumentation])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/at_wrap], [chmod +x tests/at_wrap])
AM_MISSING_PROG([AUTOM4TE], [autom4te])

dnl ----------------------------------------------
dnl enable profiling flags
dnl -----------------------------------------------
AC_MSG_CHECKING([whether gprof flags are to be used when compiling])
AC_ARG_ENABLE(profile, AC_HELP_STRING([--enable-profile], [enable profile flags (no)]),
[
if test x"${enableval}" = x"yes" ; then
	AC_MSG_RESULT(yes)
	case "$CXX" in
	    g++*|icc)
	        CXXFLAGS="$CXXFLAGS -pg"
			;;
        *)
		    # do nothing
			;;
    esac
else
	AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(no)]
)

AC_LANG_PUSH(C++)
OPT_CFLAGS=""
case "$CXX" in
   g++*)
		TRY_CFLAGS="$OPT_CFLAGS -g"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -pedantic"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -Wall"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -Werror"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -W"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -Woverloaded-virtual"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		#TRY_CFLAGS="-Wno-long-double"
		#AC_TRY_CXXFLAGS([#include <math.h>],[long double lw;], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$OPT_CFLAGS $TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -Wextra"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
        CXXFLAGS="$OPT_CFLAGS $CXXFLAGS"
		   ;;
    *)
	    # do nothing at the moment
		;;
esac
dnl ----------------------------------------------
dnl enable debug flags
dnl -----------------------------------------------
AC_MSG_CHECKING([whether extra debug flags are to be used when compiling])
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable extra debug flags (no)]),
[
if test x"${enableval}" = x"yes" ; then
	AC_MSG_RESULT(yes)
	case "$CXX" in
	    g++*)
			CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
			OPT_CFLAGS=""
			TRY_CFLAGS="-O0"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			CXXFLAGS="$OPT_CFLAGS $CXXFLAGS -DDIRAC_DEBUG"
		    ;;
	    icc)
			CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
			CXXFLAGS="-DDIRAC_DEBUG -g -O0 $CXXFLAGS"
		    # report only errors and warnings as errors
		    CXXFLAGS="$CXXFLAGS -w1 -Werror -wr964 -wr963" 
		    ;;
	    cl*|CL*)
		    # -Od turn off optimisation, -Z7 turn on debugging info
			CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[0-9]]*//g'`
			CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[[a-z]]*//g'`
			CXXFLAGS=`echo $CXXFLAGS | sed 's/-W[[0-9]]*//g'`
		    CXXFLAGS="$CXXFLAGS -Od -Z7 -W2"
			if test x"$enable_shared" = "xyes"; then
			  LIBFLAGS="$LIBFLAGS -DEBUG";
            fi
		    ;;
        *)
		    # do nothing at the moment
			;;
    esac
else
	AC_MSG_RESULT(no)
fi], 
[
	AC_MSG_RESULT(no)
	OPT_CFLAGS=""
	case "$CXX" in
    g++*|icc)
		TRY_CFLAGS="-O3"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		TRY_CFLAGS="$OPT_CFLAGS -Wuninitialized"
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		dnl arch specific flags
		case "$host" in
			i386-*) TRY_CFLAGS="$OPT_CFLAGS -march=i386";;
			i486-*) TRY_CFLAGS="$OPT_CFLAGS -march=i486";;
			i586-*) TRY_CFLAGS="$OPT_CFLAGS -march=pentium";;
			i686-*) TRY_CFLAGS="$OPT_CFLAGS -march=pentiumpro";;
			k6-*)   TRY_CFLAGS="$OPT_CFLAGS -march=k6";;
		esac
		AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
		;;
	*)
		;;
	esac

    #Try more optimising flags if supported
	case "$CXX" in
	    g++*)
			dnl TRY_CFLAGS="$OPT_CFLAGS -fprefetch-loop-arrays"
			dnl AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -fexpensive-optimizations"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -frerun-cse-after-loop"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -frerun-loop-opt"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -minline-all-stringops"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -fschedule-insns2"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -falign-functions=4"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			dnl TRY_CFLAGS="$OPT_CFLAGS -preferred-stack-boundary=4"
			dnl AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -fforce-addr"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			TRY_CFLAGS="$OPT_CFLAGS -pipe"
			AC_TRY_CXXFLAGS([],[], [$TRY_CFLAGS $CXXFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
			;;
		*)
		    # do nothing at the moment
			;;
	esac
    CXXFLAGS="$OPT_CFLAGS $CXXFLAGS"
]
)
AC_LANG_POP(C++)

dnl ----------------------------------------------
dnl enable MMX optimization flag
dnl TODO: need to fix this test
dnl -----------------------------------------------
AC_MSG_CHECKING([whether optimizations using MMX instructions are enabled])
AC_ARG_ENABLE(mmx, AC_HELP_STRING([--enable-mmx], [enable MMX optimization (default=yes)]), [enable_mmx="${enableval}"], [enable_mmx="yes"])

if test x"${enable_mmx}" = x"yes" ; then
	case "$CXX" in
	    g++*)
			AC_LANG_PUSH(C++)
			TRY_CFLAGS="-mmmx"
			AC_TRY_CXXFLAGS([#include <mmintrin.h>],[], [$TRY_CFLAGS $CXXFLAGS],[CXXFLAGS="$CXXFLAGS $TRY_CFLAGS -DHAVE_MMX"])
			AC_LANG_POP(C++)
			;;
   	    icc)
   			AC_LANG_PUSH(C++)
   			AC_CHECK_HEADER(mmintrin.h,[AC_MSG_RESULT(yes); CXXFLAGS="$CXXFLAGS -DHAVE_MMX=1"], [AC_MSG_RESULT(["no"])])
   			AC_LANG_POP(C++)
   			;;
        *)
		    # do nothing
			AC_MSG_RESULT(["no"])
			;;
    esac
else
	AC_MSG_RESULT(no)
fi

dnl -----------------------------------------------
dnl Setup for the cppunit testsuite
dnl -----------------------------------------------
AC_LANG_PUSH(C++)
dnl need to determine how to run AC_CHECK_LIB on a c++ library
dnl Until then just use AC_CHECK_HEADER by itself
dnl AC_CHECK_HEADER([cppunit/TestRunner.h],
dnl     [AC_CHECK_LIB([cppunit], [main], [HAVE_CPPUNIT="true"], [HAVE_CPPUNIT="false"], [ -ldl ])], [HAVE_CPPUNIT="false"])
AC_CHECK_HEADER([cppunit/TestRunner.h],[HAVE_CPPUNIT="true"], [HAVE_CPPUNIT="false"])
	if test $HAVE_CPPUNIT = "true"; then
		AC_MSG_CHECKING([whether unit tests code will compile and link])
		SAVE_LIBS=$LIBS
		SAVE_CXXFLAGS=$CXXFLAGS
		LIBS="$LIBS -lcppunit -ldl"
		case `$LD -v 2>&1 < /dev/null` in
		*GNU* | *'with BFD'*)
			CXXFLAGS="$CXXFLAGS -Wl,--fatal-warnings"
			;;
		esac;
		AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <string> 
		#include <cppunit/TestResult.h> 
		#include <cppunit/TestRunner.h>]], [[CPPUNIT_NS::TestResult controller; CPPUNIT_NS::TestRunner runner;]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); HAVE_CPPUNIT="false"])
		LIBS=$SAVE_LIBS
		CXXFLAGS=$SAVE_CXXFLAGS
	fi
AM_CONDITIONAL(HAVE_CPPUNIT, $HAVE_CPPUNIT)
AC_LANG_POP(C++)

dnl -----------------------------------------------
dnl Check if static libraries to be used on non-Windows platforms
dnl -----------------------------------------------
AM_CONDITIONAL(USE_STATIC, test x"$enable_static" = "xyes")

dnl -----------------------------------------------
dnl Setup valgrind and necessary args for memcheck
dnl -----------------------------------------------
dnl Using -q --leak-check on valgrind pre-2.2 gives stderr output when
dnl no leaks are found so only use --leak-check with recent valgrind.
dnl valgrind is used during the make valgrind-check target.
AC_CHECK_PROGS(VALGRIND, valgrind)
if test x"$VALGRIND" != "x" ; then
	if $VALGRIND -q --tool=memcheck true 2>/dev/null; then
		VALGRIND="valgrind --tool=memcheck --leak-check=yes"
	fi
fi

dnl -----------------------------------------------
dnl Check if we need mathlib
dnl -----------------------------------------------
AC_LANG_PUSH(C++)
AC_SUBST([CONFIG_MATH_LIB],[])
AC_MSG_CHECKING([whether we need to link math lib])
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)])
AC_LANG_POP(C++)
dnl -----------------------------------------------
dnl Generates Makefile's, configuration files and scripts
dnl -----------------------------------------------

AC_OUTPUT(Makefile dirac.pc \
          doc/Makefile \
          libdirac_byteio/Makefile \
          libdirac_common/Makefile \
          libdirac_motionest/Makefile \
          libdirac_encoder/Makefile \
          libdirac_decoder/Makefile \
          encoder/Makefile \
          decoder/Makefile \
          unit_tests/Makefile \
	  util/Makefile \
          util/conversion/Makefile \
          util/conversion/common/Makefile \
	  util/instrumentation/Makefile \
	  util/instrumentation/libdirac_instrument/Makefile \
          win32/Makefile \
          win32/VisualStudio/Makefile )