File: configure.ac

package info (click to toggle)
3depict 0.0.22-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 17,520 kB
  • sloc: cpp: 73,905; sh: 6,436; xml: 1,604; python: 350; ansic: 190; makefile: 177
file content (484 lines) | stat: -rw-r--r-- 13,204 bytes parent folder | download
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
AC_INIT([3Depict], [0.0.22]) 
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_PROG_CXX
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile])

m4_include([m4/ax_compare_version.m4])

#Ok, lets try using gcc style precompiled headers.
AM_CONDITIONAL(USE_PRECOMPILED_HEADERS, 1)

#Check sizeof
AC_CHECK_SIZEOF(size_t)

# Support {host_os} variable
AC_CANONICAL_HOST

dnl Test for wx-widgets
dnl ----------
AM_OPTIONS_WXCONFIG

case "${host_os}" in
	*mingw*)
		#Windows requires 3.1, as there is a bug with wxPropertyGrid modification during events
		# under GTK we use a hack to workaround, by keeping two grids, and flipping them in and out. 
		#This doesn't work properly under windows. wx3.1 is not available under linux  
		# (using repositories) at this time.
		AM_PATH_WXCONFIG(3.1.0, wxWin=1)
		;;	
	*)
		AM_PATH_WXCONFIG(3.0.0, wxWin=1)
esac
		
if test "$wxWin" != 1; then
AC_MSG_ERROR([
		wxWidgets must be installed on your system
		but wx-config script couldnt be found.

		Please check that wx-config is in path, the directory
		where wxWidgets libraries are installed (returned by
		'wx-config --libs' command) is in LD_LIBRARY_PATH or
		equivalent variable and wxWidgets version is above the minimum specified above.
])
fi


#Append the --gl-libs flag
WX_LIBS="$WX_LIBS `$WX_CONFIG_PATH --libs gl,propgrid`"

WANT_WINDRES="no"
case "${host_os}" in 
	*mingw*)
		#wx-config is a little unreliable in cross-compile mode
		# Manually append -DUNICODE to cppflags/cxxflags
		WX_CXXFLAGS="$WX_CXXFLAGS -DUNICODE"
		WX_CPPFLAGS="$WX_CPPFLAGS -DUNICODE"
		WANT_WINDRES="yes"
		;;
esac

AC_MSG_RESULT([Want windres... $WANT_WINDRES])

AM_CONDITIONAL([HAVE_WINDRES], [ test x"$WANT_WINDRES" == "xyes"] )


AC_SUBST(WX_LIBS)
dnl ----------


# Check for xml-config  (libxml2 configuration utility)
# ------------
# Test from icecast library (GPL)
AC_ARG_WITH(xml-config,
  [  --with-xml-config=PATH  use xml-config in PATH to find libxml ])

have_xml="no"
if test "$with_xml_config" != "no"
then
  if test -n "$with_xml_config" -a "$with_xml_config" != "yes"
  then
    XMLCONFIG="$with_xml_config"
    if ! test -x "$XMLCONFIG"
    then
      AC_MSG_ERROR([$with_xml_config cannot be run])
    fi
  else
    AC_CHECK_PROGS(XMLCONFIG, [xml2-config xml-config])
  fi

  if test -n "$XMLCONFIG"
  then
    AC_DEFINE(HAVE_LIBXML, 1, [Define if you have the GNOME XML library])
    have_xml="yes"
  else
    AC_MSG_ERROR([Unable to locate the configuration utility xml-config: specify with --with-xml-config, or ensure it is your PATH environment variable])
  fi
  XML_LIBS="`$XMLCONFIG --libs`"
  XML_CFLAGS="`$XMLCONFIG --cflags`"

  AC_SUBST(XML_CFLAGS)
  AC_SUBST(XML_LIBS)

fi
AM_CONDITIONAL(USE_XML, test "$have_xml" = "yes")
#----------------

# Check for FT2 - use pkg-config
#  freetype2  >=2.9.1 will no longer ship freetype-config
#  we used to use a modified version fo the graphviz code 
#  to check for freetype, but it was over-complex for our needs
dnl ----------
PKG_CHECK_MODULES(FT,freetype2)
CPPFLAGS="$CPPFLAGS $FT_CFLAGS"
LDFLAGS="$LDFLAGS $FT_LIBS"
dnl ----------

#Check for FTGL using custom script.
dnl ----------
AX_CHECK_FTGL() #Not doing anything???

AC_SUBST(FTGL_CFLAGS)
AC_SUBST(FTGL_LIBS)

dnl ----------

#Check for qhull, if we are not using sweep hull
dnl--------------

AC_ARG_WITH(libqhull-flags,
  [  --with-libqhull-flags=PATH : specify compiler flags for libqhull])
AC_ARG_WITH(libqhull-link,
  [  --with-libqhull-link=PATH : specify linker flag (library) for libqhull])

if test x"$with_libqhull_flags" != x"" ; then
    QHULL_CFLAGS="$with_libqhull_flags"
fi
AC_SUBST([QHULL_CFLAGS])

#Attempt to compile a test program
CFLAGS_ORIG="$CFLAGS"
CFLAGS="$CFLAGS $QHULL_CFLAGS"
AC_CHECK_HEADER([qhull/qhull_a.h],[AC_DEFINE(HAVE_QHULL,[],[Have got libqhull headers])],
	[AC_MSG_ERROR([Required libqhull headers not found (looking for qhull/qhull_a.h)])])

if test x"$with_libqhull_link" != x"" ;
then
	QHULL_LIBS="$with_libqhull_link"
else
	QHULL_LIBS="-lqhull"
fi
LIBS_ORIG="$LIBS"
LIBS="$LIBS $QHULL_LIBS $LDFLAGS"
AC_CHECK_LIB(qhull, qh_qhull, [AC_DEFINE(HAVE_QHULL,[],[qhull compilation OK])] , AC_MSG_ERROR([You must have libqhull installed and be able to compile a sample program. compiler flags can be set using the with-libqhull-flags and with-libqhull-link parameters ]))
CFLAGS="$CFLAGS_ORIG"
LIBS="$LIBS_ORIG"
AC_SUBST([QHULL_LIBS])	
dnl--------------



#Check for libpng
dnl--------------
AC_ARG_WITH(libpng-flags,
  [  --with-libpng-flags=PATH : specify compiler flags for libpng])
AC_ARG_WITH(libpng-link,
  [  --with-libpng-link=PATH : specify linker flag (library) for libpng])

#set libpng's compiler flags
if test x"$with_libpng_flags" != x"" ;
then
    PNG_CFLAGS="$with_libpng_flags"
fi
AC_SUBST(PNG_CFLAGS)

#set libpng's link flags
if test x"$with_libpng_link" != x"" ;
then
    PNG_LIBS="$with_libpng_link"
else

	AC_CHECK_LIB([png],[png_create_write_struct_2] , 
		[PNG_LIBS=-lpng], [PNG_USE_PKG_CFG=yes],-lm)

	AS_IF([test x"$PNG_USE_PKG_CFG" == x"yes" ],[
		PKG_CHECK_MODULES(PNG, libpng >= 1.2) ])
fi

AC_SUBST(PNG_LIBS)

#Attempt to compile a test program
CFLAGS_ORIG="$CFLAGS"
CFLAGS="$CFLAGS $PNG_CFLAGS"
AC_CHECK_HEADER([png.h],[AC_DEFINE(HAVE_PNG,[],[Have got libpng headers])],
	[AC_MSG_ERROR([Required libpng headers not found (looking for png.h])])

LIBS_ORIG="$LIBS"
LIBS="$LIBS $PNG_LIBS $LDFLAGS"
AC_CHECK_LIB(png, png_sig_cmp, [AC_DEFINE(HAVE_PNG,[],[PNG compilation OK])] , AC_MSG_ERROR([You must have libpng installed and be able to compile sample program]), -lz -lm)
CFLAGS="$CFLAGS_ORIG"
LIBS="$LIBS_ORIG"
	
dnl--------------


#Check for opengl
#------------


#Try linking against gluSphere windows usese -lglu32; mac?? ; linux -lGLU
case "${host_os}" in 
	mingw*|windows*|winnt)
		#win32 opengl names
		GL_LIBS="-lglu32 -lopengl32"
		#Add GLEW dependency for opengl > 1.1
		GL_LIBS="$GL_LIBS -lglew32"
		AC_SUBST(GL_LIBS)
		AC_PROG_LN_S 
		AC_PROG_RANLIB 
	    ;;
	darwin*)
		#This is handled by the --with-apple-opengl-framework 
		#option already. Nothing to do here

	    ;;
	 *)
		AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lglu", [AC_MSG_ERROR([Could not find GLU library])])
		GL_LIBS="-lGL -lGLU"
		AC_SUBST(GL_LIBS)

	   ;;
esac


#------------

#Check for Mathgl
dnl ----------
CFLAGS_ORIG="$CFLAGS"
LDFLAGS_ORIG="$LDFLAGS"


AC_ARG_WITH(mgl-flags,
  [  --with-mgl-flags=PATH : specify compiler flags for mathgl])
if test x"$with_mgl_flags" != x"" ; then
	MGL_CFLAGS="$with_mgl_flags"
	AC_SUBST(MGL_CFLAGS)
fi
CFLAGS="$CFLAGS $MGL_CFLAGS"

AC_ARG_WITH(mgl-libs,
  [  --with-mgl-libs=PATH : specify linker flag (library) for mathgl])
if test x"$with_mgl_libs" != x"" ; then
	MGL_LIBS="$with_mgl_libs"
else
	MGL_LIBS="-lmgl"
fi
AC_SUBST(MGL_LIBS)
LDFLAGS="$LDFLAGS $MGL_LIBS"

#  mathgl2.x uses mgl_cf.h for c functions.
AC_LANG_PUSH([C++])
AC_DEFINE(USE_MGL2, 1 , ["Enable mgl2 support"])
#AC_CHECK_HEADER("mgl2/mgl_cf.h",[],[AC_MSG_ERROR(["mgl2 specified, but header mgl2/mgl_cf.h not found"])],[])
AC_LANG_POP([C++])


CFLAGS="$CFLAGS_ORIG"
LDFLAGS="$LDFLAGS_ORIG"

dnl -------

#Check for gsl
dnl -------

AC_ARG_WITH(gsl-flags,
  [  --with-gsl-flags=PATH : specify compiler flags for gsl])
AC_ARG_WITH(gsl-libs,
  [  --with-gsl-libs=PATH : specify linker flag (library) for gsl])

if test x"$with_gsl_flags" != x"" ; then
    GSL_CFLAGS="$with_gsl_flags"
fi
if test x"$with_gsl_libs" != x"" ; then
    GSL_LIBS="$with_gsl_libs"
else
	AX_PATH_GSL([1.1],[],[AC_MSG_WARN(["Could not find GNU Scientific Library.. You should install this, as it is needed by mathgl. Otherwise, you can override it with --with-gsl-link and --with-gsl-flags. For example you might use the gsl-config program to spit out the needed libs."])])
fi

dnl -----------

#Check for libintl
dnl -----------------

AC_MSG_CHECKING( [ for libintl ] );

AC_ARG_WITH(intl-libs,
  [  --with-intl-libs=FLAGS: specify linker flags (library) for internationalisation libs])

if test x"$with_intl_libs" != x"" ; then
    GETTEXT_LIBS="$with_intl_libs"
    AC_SUBST(GETTEXT_LIBS)
    AC_MSG_RESULT( [ specified ]);
else
	case "${host_os}" in 
		darwin*)
			#Darwin requires explicit libintl
			GETTEXT_LIBS="-lintl -liconv"
			AC_SUBST(GETTEXT_LIBS)
    			AC_MSG_RESULT( [ $GETTEXT_LIBS ]);
		    ;;
		mingw*|windows*|winnt)
			GETTEXT_LIBS="-lintl"
			AC_SUBST(GETTEXT_LIBS)
    			AC_MSG_RESULT( [ $GETTEXT_LIBS ]);
		    ;;

		 *)
			#elsewhere it appears to be part of libc. or something.
			AC_MSG_RESULT( [ no ]);
		   ;;
	esac
fi


dnl -----------------


dnl -----------------
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([vigra/multi_array.hxx],[AC_DEFINE(HAVE_VIGRA,[],[Have got vigra headers])],
	[AC_MSG_ERROR([Required vigra headers not found (looking for vigra/multi_array.hxx)])])

AC_LANG_POP([C++])
dnl -----------------


#Should we compile with openMP?
AC_ARG_ENABLE(openmp-parallel,
  [  --enable-openmp-parallel  Enable OpenMP multi-CPU usage; requires GCC > 4.2 for parallel STL support ])
#Should we enable or disable debug checking?
AC_ARG_ENABLE(debug-checks,
  [  --disable-debug-checks Disable any debug checking, provides faster operation, but less information needed to debug internal problems, or to provide problem reports to developers ],[enable_debug_checks="no"],[enable_debug_checks="yes"])

AC_ARG_ENABLE(ubsan,
	[  --disable-ubsan Disable undefined behaviour sanitizer. Only takes effect on certain ubsan supporting compilers. Useful for working around ubsan aborts that you cant fix (eg 3rd party libs) ],
		[ enable_no_ubsan="yes"],[enable_no_ubsan="no"])

#Should we enable libvd (volume render library) support?
AC_ARG_ENABLE(libvd,
  [  --enable-libvd Enable volume render support, using the libvd library. ],[enable_libvd="yes"],[enable_libvd="no"])

if test x"$enable_openmp_parallel" != x"" ; 
then
	OPENMP_FLAGS="-fopenmp -D_GLIBCXX_PARALLEL"
	AC_SUBST(OPENMP_FLAGS)
fi

AX_COMPILER_VERSION
GCC_VERSION=$ax_cv_c_compiler_version
AX_COMPARE_VERSION( [ $GCC_VERSION ], le, 6.0,
		[ CXXFLAGS=" $CXXFLAGS -std=gnu++11" ] , [ DUMMY=" " ])

if test x"$enable_debug_checks" == x"yes" ; 
then
	DEBUG_FLAGS="-DDEBUG"

	AC_SUBST(DEBUG_FLAGS)

	if test x"$GCC" == x"yes" ; then


		AX_COMPARE_VERSION( [ $GCC_VERSION ], ge, 6.0,
				[ DEBUG_FLAGS=" $DEBUG_FLAGS -D_GLIBCXX_ASSERTIONS" ] , [ DUMMY=" " ])
		
		GXX="-O0"
		AC_SUBST(GXX)
			
		# Strip optimisation flags from debug build
		#--
		changequote({,})
		CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
		CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O[0-9s]*//g'`
		changequote([,])
		CFLAGS="$CFLAGS -g"
		CXXFLAGS="$CXXFLAGS -g"
		#--

		#Check for UbSan availability
		#--
		if test x"${enable_no_ubsan}" == x"no" ; then

			USE_UBSAN="no"

			case "${host_os}" in
				*inux*)

					AX_COMPARE_VERSION( [ $GCC_VERSION ], ge, 4.9,
							[ USE_UBSAN="yes" ] , [ USE_UBSAN="no" ])
					AX_COMPARE_VERSION( [ $GCC_VERSION ], ge, 6.0,
							[ USE_UBSAN_GCC6="yes" ] , [ USE_UBSAN_GCC6="no" ])
				;;
			esac

			if test x"$USE_UBSAN" == x"yes" ; then
				CFLAGS="$CFLAGS  -fsanitize=address -fsanitize=undefined -fsanitize=return -fsanitize=integer-divide-by-zero -fsanitize=vla-bound -fsanitize=null -fsanitize=signed-integer-overflow"
				CXXFLAGS="$CXXFLAGS  -fsanitize=address -fsanitize=undefined -fsanitize=return -fsanitize=integer-divide-by-zero -fsanitize=vla-bound -fsanitize=null -fsanitize=signed-integer-overflow"
				LDFLAGS="$LDFLAGS  -fsanitize=address -fsanitize=undefined -fsanitize=return "
				AC_MSG_RESULT(["Enabling Gcc-UbSan"]);
			fi

#			Disabled until we improve our compiler detection (clang)
#			if test x"$USE_UBSAN_GCC6" == x"yes" ; then
#				CFLAGS="$CFLAGS -fsanitize=bounds-strict" 
#				CXXFLAGS="$CXXFLAGS  -fsanitize=bounds-strict"
#				LDFLAGS="$LDFLAGS  -fsanitize=bounds-strict"
#				AC_MSG_RESULT(["Enabling More Gcc-UbSan (gcc6)"]);
#			fi
		fi
		#--
	
	fi

else 
	echo x"$enable_debug_checks"
	echo x"no"
	
	if test x"$enable_debug_checks" != x"no" ;
	then
		AC_MSG_ERROR(["Well something isnt right, debug checks should be enabled or disabled (yes/no), was $enable_debug_checks"])
	fi
fi

AC_ARG_ENABLE(gnu11,
  [  --enable-gnu11 use gnu11 C++ mode ] ) 
if test x"$enable_gnu11" == x"yes" ;
then
	#Should work for gcc (required for older gcc + mathgl combinations)
	CXXFLAGS="$CXXFLAGS --std=gnu++11"
fi

if test x"$enable_libvd" == x"yes" ; 
then
	AC_MSG_RESULT(["Enabling libvd"]);
	CXXFLAGS="$CXXFLAGS -DENABLE_LIBVD"
	LIBS="$CXXFLAGS -lvd"
else
	AC_MSG_RESULT([Libvd support disabled...])
fi

if test x"$CXX" = xdistcc ; then
	AC_MSG_RESULT(["Adding distcc link flags"]);
	#Add -lstdc++ to libs for distcc
	LIBS="$LIBS -lstdc++"
fi

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T 
AC_TYPE_UINT64_T 

# Checks for library functions.
AC_CHECK_FUNCS([atexit sqrt])
AC_CHECK_FUNCS([floor getcwd gettimeofday isascii memset ])
AC_CHECK_FUNCS([pow setlocale strdup sysinfo])
AC_C_INLINE()

#check for some headers
AC_CHECK_HEADERS([fenv.h libintl.h sys/time.h])
AC_CHECK_TYPES([ptrdiff_t])

#Check platform specific headers
case "${host_os}" in 
	darwin*)
		 AC_CHECK_HEADERS([mach/mach.h])
		;;
	*)
		;;
esac

AC_PROG_INSTALL
AC_OUTPUT