source: git/configure.ac @ 81eda15

main
Last change on this file since 81eda15 was ce243b0, checked in by Olly Betts <olly@…>, 3 days ago

Require automake 1.14

This was released in 2013 so should be available everywhere, especially
as it's only needed by people wanting to bootstrap from git.

  • Property mode set to 100644
File size: 15.3 KB
Line 
1dnl Process this file with autoconf to produce a configure script
2
3dnl Need autoconf 2.50 or later for AC_ARG_VAR.  2.59 has been around for
4dnl long enough, that we might as well just require that.
5AC_PREREQ(2.59)
6AC_INIT([survex], [1.4.20], [https://trac.survex.com/])
7AM_INIT_AUTOMAKE([1.14 gnu -Wall -Wportability -Werror])
8RELEASE=1
9
10AC_SUBST(RELEASE)
11AC_CONFIG_HEADERS([config.h])
12AC_CONFIG_SRCDIR([src/aven.cc])
13
14COPYRIGHT_MSG="Copyright (C) 1990-2026 Olly Betts"
15AVEN_COPYRIGHT_MSG="Copyright (C) 1999-2003,2005,2006 Mark R. Shinwell"
16
17AC_DEFINE_UNQUOTED(COPYRIGHT_MSG, ["$COPYRIGHT_MSG"], [Copyright Message])
18AC_DEFINE_UNQUOTED(AVEN_COPYRIGHT_MSG, ["$AVEN_COPYRIGHT_MSG"],
19                   [Copyright Message for Aven])
20
21AC_SUBST(COPYRIGHT_MSG)
22AC_SUBST(AVEN_COPYRIGHT_MSG)
23
24COPYRIGHT_MSG_UTF8=`echo "$COPYRIGHT_MSG"|sed 's/(C)/©/'`
25AVEN_COPYRIGHT_MSG_UTF8=`echo "$AVEN_COPYRIGHT_MSG"|sed 's/(C)/©/'`
26
27AC_DEFINE_UNQUOTED(COPYRIGHT_MSG_UTF8, ["$COPYRIGHT_MSG_UTF8"],
28                   [Copyright Message in UTF-8])
29AC_DEFINE_UNQUOTED(AVEN_COPYRIGHT_MSG_UTF8, ["$AVEN_COPYRIGHT_MSG_UTF8"],
30                   [Copyright Message for Aven in UTF-8])
31
32dnl set PRETTYPACKAGE to PACKAGE with the first character capitalised
33PRETTYPACKAGE=`echo "$PACKAGE"|cut -b1|tr a-z A-Z``echo "$PACKAGE"|cut -b2-`
34AC_DEFINE_UNQUOTED(PRETTYPACKAGE, "$PRETTYPACKAGE",
35                   [Name of package (capitalised)])
36AC_SUBST(PRETTYPACKAGE)
37
38dnl set COMMAVERSION to VERSION with the dots replaced by commas -
39dnl e.g. "0,99" or "1,0,22"
40COMMAVERSION=`echo "$VERSION"|tr '.' ','`
41AC_DEFINE_UNQUOTED(COMMAVERSION, $COMMAVERSION,
42                   [Version number of package (comma-separated)])
43AC_SUBST(COMMAVERSION)
44
45PKGDOCDIR='${prefix}/share/doc/${PACKAGE}'
46AC_ARG_ENABLE(docdir,
47[  --enable-docdir=DIR Set directory for installing documentation to DIR],
48[case $enableval in
49 yes|no)
50  AC_MSG_ERROR([configure: Syntax: configure --enable-docdir=DIR]) ;;
51esac
52PKGDOCDIR="$enableval"
53]
54)
55PKGDOCDIR_EXPANDED=`
56 test NONE = "$prefix" && prefix="$ac_default_prefix"
57 test NONE = "$exec_prefix" && exec_prefix="$prefix"
58 eval echo "$PKGDOCDIR"
59`
60AC_SUBST(PKGDOCDIR)
61AC_SUBST(PKGDOCDIR_EXPANDED)
62
63AC_CANONICAL_HOST
64
65dnl Checks for programs.
66AC_PROG_CC
67AC_PROG_CPP
68
69AC_PROG_CXX
70AC_PROG_CXXCPP
71
72dnl Probe for any options needed to enable C++11 support.
73AX_CXX_COMPILE_STDCXX_11
74
75AC_LANG([C])
76
77AC_EXEEXT
78AC_OBJEXT
79
80mswindows=no
81macos=no
82case $host_os in
83darwin*) macos=yes ;;
84*mingw*|*cygwin*|windows*) mswindows=yes ;;
85esac
86
87AC_C_BIGENDIAN
88
89AC_ARG_VAR(STRIP, [Command for discarding symbols from object files])
90AC_PATH_TOOL(STRIP, strip, [echo "not stripping "])
91
92AC_CHECK_LIB(m, sqrt)
93
94dnl x86 has excess precision issues with 387 FP instructions, which are
95dnl avoided by using SSE instructions instead.  By default we require SSE2
96dnl which for Intel means a Pentium 4 which was launched in 2000; Pentium
97dnl 3 was finally discontinued in 2007.
98AC_ARG_ENABLE([sse],
99[AS_HELP_STRING([--disable-sse],
100                [disable use of SSE FP instructions on x86])]
101[AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
102                [set which SSE FP instructions to use on x86 (default: sse2)])],
103  [case ${enableval} in
104    sse|sse2|yes|no) ;;
105    *) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
106  esac],
107  [enable_sse=yes])
108
109AC_MSG_CHECKING([whether to use SSE instructions on x86])
110case $host_cpu in
111  i*86)
112    if test "$enable_sse" = no ; then
113      AC_MSG_RESULT([no - WARNING: Testsuite will probably fail])
114    else
115      dnl Default to sse2.
116      test "$enable_sse" != yes || enable_sse=sse2
117      if test yes = "$GXX"; then
118        AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
119        dnl We can unconditionally use -mtune=generic as it was added in GCC
120        dnl 4.2, and supported at least as far back as clang 3.0.
121        AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic"
122      else
123        AC_MSG_RESULT([don't know how to for compiler $CXX])
124      fi
125    fi
126    ;;
127  *)
128    AC_MSG_RESULT([non-x86 arch ($host_cpu)]) ;;
129esac
130
131dnl The wxWidgets libraries we need:
132wx_libs="core,gl"
133
134AC_ARG_VAR(WXCONFIG, [Old name for WX_CONFIG, accepted for compatibility])
135AC_ARG_VAR(WX_CONFIG, [wxWidgets configuration script to use to build Aven])
136: ${WX_CONFIG="$WXCONFIG"}
137
138AM_CONDITIONAL(WIN32, [test yes = "$mswindows"])
139AM_CONDITIONAL(MACOS, [test yes = "$macos"])
140
141if test -n "$WX_CONFIG" ; then
142  dnl WX_CONFIG specified - sanity check the value
143  dnl don't check for --ldflags - older wx-config didn't do that
144  if (exec >&5 2>&5;$WX_CONFIG --libs --cflags --cxxflags "$wx_libs";exit $?) then
145    :
146  else
147    AC_MSG_ERROR(['$WX_CONFIG --libs --cflags --cxxflags "$wx_libs"' does not work, bailing out])
148  fi
149else
150  if test yes = "$macos" ; then
151    wxdef=__WXMAC__
152  elif test yes = "$mswindows" ; then
153    wxdef=__WXMSW__
154  else
155    wxdef=__WXGTK__
156  fi
157  dnl See if wx-config exists and is for the correct version.
158  dnl Fedora seem to install as wx-config-3.2 with a symlink from wx-config, so
159  dnl look for the versioned name in preference.
160  dnl
161  dnl Arch Linux uses wx-config-gtk3.
162  AC_PATH_PROGS(WX_CONFIG, [wx-config-3.2 wx-config-gtk3 wx-config])
163  if test -n "$WX_CONFIG" ; then
164    if (exec >&5 2>&5;$WX_CONFIG --cflags "$wx_libs"|grep -e -D"$wxdef";exit $?) then
165      :
166    else
167      AC_MSG_ERROR([wxWidgets not for the right toolkit.  Run ./configure WX_CONFIG=/path/to/wx-config])
168    fi
169  else
170    AC_MSG_ERROR([wxWidgets not found.  Run ./configure WX_CONFIG=/path/to/wx-config])
171  fi
172fi
173
174dnl Unless the user has explicitly specified a --unicode setting, prefer
175dnl --unicode=yes if we can get it.
176case $WX_CONFIG in
177  *--unicode=*) ;;
178  *)
179    if (exec >&5 2>&5;$WX_CONFIG --unicode=yes --version "$wx_libs";exit $?) ; then
180      WX_CONFIG="$WX_CONFIG --unicode=yes"
181    elif (exec >&5 2>&5;$WX_CONFIG --unicode=no --version "$wx_libs";exit $?) ; then
182      WX_CONFIG="$WX_CONFIG --unicode=no"
183    fi ;;
184esac
185
186WX_LIBS=`$WX_CONFIG --libs "$wx_libs"`
187dnl Needed for nvidia drivers on linux (for some setups anyway).
188AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, [WX_LIBS="$WX_LIBS -lXxf86vm"], [], [$WX_LIBS])
189
190save_LIBS=$LIBS
191dnl Check if we need a library for OpenGL functions.  Usually it's the "GL"
192dnl library, but it's called opengl32 on Microsoft Windows).
193AC_SEARCH_LIBS([glPushMatrix], [GL opengl32], [WX_LIBS="$WX_LIBS $ac_cv_search_glPushMatrix"], [], [$WX_LIBS])
194dnl Check if we need a library for GLU functions.  Usually it's the "GLU"
195dnl library, but it's called glu32 on Microsoft Windows).
196AC_SEARCH_LIBS([gluProject], [GLU glu32], [WX_LIBS="$WX_LIBS $ac_cv_search_gluProject"], [], [$WX_LIBS])
197LIBS=$save_LIBS
198
199AC_SUBST(WX_LIBS)
200dnl macOS has OpenGL/gl.h and OpenGL/glu.h.
201AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h], [], [], [ ])
202AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h], [], [], [ ])
203dnl Older Debian mingw-w64 packages lacked GL/glext.h; macOS has OpenGL/glext.h.
204dnl Requires an explicit include of gl.h first.
205AC_CHECK_HEADERS([GL/glext.h OpenGL/glext.h], [], [], [
206  #ifdef HAVE_GL_GL_H
207  # include <GL/gl.h>
208  #elif defined HAVE_OPENGL_GL_H
209  # include <OpenGL/gl.h>
210  #endif
211  ])
212
213WX_CFLAGS=`$WX_CONFIG --cflags "$wx_libs"`
214AC_SUBST(WX_CFLAGS)
215WX_CXXFLAGS=`$WX_CONFIG --cxxflags "$wx_libs"`
216AC_SUBST(WX_CXXFLAGS)
217
218AC_LANG([C])
219save_CFLAGS=$CFLAGS
220CFLAGS="$CFLAGS $WX_CFLAGS"
221AC_CHECK_SIZEOF([wxChar], [], [
222  #include <wx/defs.h>
223  #include <wx/chartype.h>
224])
225CFLAGS=$save_CFLAGS
226
227dnl Check for FFmpeg libraries.
228PKG_CHECK_MODULES([FFMPEG], [libavcodec >= 57 libavformat libswscale libavutil], [
229  AC_DEFINE([WITH_FFMPEG], [1], [Use FFmpeg for movie export])
230  save_CXXFLAGS=$CXXFLAGS
231  save_LIBS=$LIBS
232  CFLAGS="$CFLAGS $FFMPEG_CFLAGS"
233  LIBS="$LIBS $FFMPEG_LIBS"
234  AC_CHECK_FUNCS([av_guess_format avio_open avio_close avformat_write_header avcodec_encode_video2 avcodec_free_frame avcodec_open2 avformat_new_stream av_frame_alloc av_frame_free])
235  AC_CHECK_DECLS([AVMEDIA_TYPE_VIDEO], [], [], [#include <libavcodec/avcodec.h>])
236  AC_CHECK_DECLS([AV_CODEC_ID_NONE], [], [], [#include <libavcodec/avcodec.h>])
237  AC_CHECK_DECLS([AV_PIX_FMT_RGB24], [], [], [#include <libavutil/pixfmt.h>])
238  AC_CHECK_DECLS([AV_PIX_FMT_YUV420P], [], [], [#include <libavutil/pixfmt.h>])
239  CXXFLAGS=$save_CXXFLAGS
240  LIBS=$save_LIBS
241], [
242  dnl Build without movie export feature.
243])
244AC_SUBST([FFMPEG_LIBS])
245AC_SUBST([FFMPEG_CFLAGS])
246
247dnl Check for PROJ.
248PKG_CHECK_MODULES([PROJ], [proj >= 6.2.0], [
249], [
250  dnl pkg-config support in proj seems quite new, so probe directly if not
251  dnl found.  We need proj_create_crs_to_crs_from_pj() which was added in
252  dnl 6.2.0.
253  AC_CHECK_LIB([proj], [proj_create_crs_to_crs_from_pj], [
254      PROJ_LIBS=-lproj
255      PROJ_CFLAGS=
256    ], [
257      AC_MSG_ERROR([PROJ required for coordinate transformations])
258    ])
259])
260AC_SUBST([PROJ_LIBS])
261AC_SUBST([PROJ_CFLAGS])
262
263dnl Check for GDAL.
264PKG_CHECK_MODULES([GDAL], [gdal >= 2.3], [
265  AC_DEFINE([HAVE_GDAL], [1], [Define to 1 if you have the 'GDAL' library.])
266], [
267  if test "$mswindows" = no ; then
268    AC_MSG_ERROR([GDAL required for geodata handling])
269  else
270    AC_MSG_WARN([GDAL required for geodata handling])
271  fi
272])
273AC_SUBST([GDAL_LIBS])
274AC_SUBST([GDAL_CFLAGS])
275
276dnl Checks for header files.
277
278AC_CHECK_HEADERS(string.h)
279
280AC_CHECK_FUNCS([popen hypot mmap strdup])
281
282dnl We don't access a FILE* from multiple threads and using the unlocked
283dnl versions has significantly less overhead, especially when reading/writing
284dnl byte-by-byte.  These are specified by POSIX:
285AC_CHECK_FUNCS([getc_unlocked putc_unlocked putchar_unlocked])
286dnl These are GNU extensions in glibc:
287AC_CHECK_FUNCS([feof_unlocked ferror_unlocked fread_unlocked fwrite_unlocked])
288dnl Microsoft extensions:
289AC_CHECK_FUNCS([_getc_nolock _putc_nolock _putchar_nolock _fread_nolock _fwrite_nolock])
290
291AC_CHECK_FUNCS([setenv unsetenv])
292
293AC_CHECK_FUNCS([fmemopen])
294
295dnl Microsoft-specific functions which support positional argument specifiers.
296AC_CHECK_FUNCS([_vfprintf_p _vsprintf_p])
297
298AC_PATH_PROG([SPHINX_BUILD], [sphinx-build], [$MISSING sphinx-build])
299AC_ARG_VAR([SPHINX_BUILD], [sphinx-build from python3-sphinx])
300
301AC_PATH_PROG([MSGFMT], [msgfmt], [$MISSING msgfmt])
302AC_ARG_VAR([MSGFMT], [msgfmt from gettext])
303
304AC_ARG_ENABLE([werror],
305  [AS_HELP_STRING([--enable-werror], [enable treating compiler warnings as errors [default=no]])],
306  [case ${enableval} in
307    yes|no) ;;
308  *) AC_MSG_ERROR([bad value ${enableval} for --enable-werror]) ;;
309  esac],
310  [enable_werror=no])
311
312dnl Put -Werror or equivalent in its own make variable so that it can easily
313dnl be overridden by `make WERROR=` if needed during development (e.g. if
314dnl you want to get a full list of compile warnings to fix rather than
315dnl stopping at the first file with warnings).
316WERROR=
317AC_SUBST([WERROR])
318
319dnl extra warning flags for building with GCC
320if test yes = "$GCC"; then
321  WERROR=-Werror
322  if test yes = "$cross_compiling"; then
323dnl    AM_CFLAGS="$AM_CFLAGS -Werror -Wall -Wunused -Wpointer-arith\
324dnl      -Wwrite-strings -Wcast-align"
325dnl -Wsign-compare causes a warning with the mingw FD_SET macro, so we have
326dnl to disable it for mingw builds.
327    AM_CFLAGS="$AM_CFLAGS -Wall -Wunused -Wpointer-arith\
328      -Wwrite-strings -Wcast-align"
329    AM_CXXFLAGS="$AM_CXXFLAGS -Wall -Wunused -Wpointer-arith\
330      -Wwrite-strings -Wcast-align -Wno-sign-compare"
331  else
332    AM_CFLAGS="$AM_CFLAGS -Wall -W -Wunused -Wshadow -Wpointer-arith\
333      -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wnested-externs\
334      -Wcast-align"
335    AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wunused -Wshadow -Wpointer-arith\
336      -Wwrite-strings -Wcast-align"
337  fi
338  dnl too many complaints from headers, etc: -Wconversion
339fi
340AC_SUBST(AM_CFLAGS)
341AC_SUBST(AM_CXXFLAGS)
342
343if test x$enable_werror != xyes; then
344  WERROR=
345fi
346
347dnl See if large file support is available.  Survex is unlikely to need to
348dnl process files > 2GB in size, but LFS is also needed for stat() to work
349dnl on filing systems which return 64 bit inode values, such as CIFS mounts.
350AC_SYS_LARGEFILE
351
352AC_ARG_ENABLE(profiling,
353[  --enable-profiling Build binaries to generate profiling information],
354[case $enableval in
355  yes) AM_CXXFLAGS="$AM_CXXFLAGS -pg"
356       AM_CFLAGS="$AM_CFLAGS -pg"
357       AC_MSG_RESULT(building binaries to generate profiling information);;
358  no) ;;
359  *) AC_MSG_ERROR(bad value $enableval for --enable-profiling) ;;
360esac])
361
362EXTRA_TEXT="AUTHORS COPYING NEWS TODO ChangeLog"
363AC_SUBST(EXTRA_TEXT)
364
365AC_SUBST_FILE(DESC)
366DESC=desc.txt
367AC_SUBST_FILE(AVENDESC)
368AVENDESC=desc-aven.txt
369
370dnl Don't define DATADIR if building for MS Windows - it won't be used, and
371dnl can conflict with the DATADIR typedef in objidl.h
372if test no = "$mswindows"; then
373  AC_DEFINE_DIR(DATADIR, datadir, [Location of platform independent support files])
374fi
375
376AH_BOTTOM(
377[/* Use _unlocked() variants of stdio functions where available, since they are
378 * faster, and we don't multithread file accesses.
379 */
380
381#ifdef HAVE_FEOF_UNLOCKED
382# define FEOF(F) feof_unlocked(F)
383#else
384# define FEOF(F) feof(F)
385#endif
386
387#ifdef HAVE_FERROR_UNLOCKED
388# define FERROR(F) ferror_unlocked(F)
389#else
390# define FERROR(F) ferror(F)
391#endif
392
393#ifdef HAVE_FREAD_UNLOCKED
394# define FREAD(P, S, N, F) fread_unlocked(P, S, N, F)
395#elif defined HAVE__FREAD_NOLOCK
396# define FREAD(P, S, N, F) _fread_nolock(P, S, N, F)
397#else
398# define FREAD(P, S, N, F) fread(P, S, N, F)
399#endif
400
401/* If we call this FWRITE() then macos errors out on uses with:
402 * error: called object type 'int' is not a function or function pointer
403 * Unclear what's going on - a conditional `#undef FWRITE` before defining
404 * doesn't help.
405 */
406#ifdef HAVE_FWRITE_UNLOCKED
407# define FWRITE_(P, S, N, F) fwrite_unlocked(P, S, N, F)
408#elif defined HAVE__FWRITE_NOLOCK
409# define FWRITE_(P, S, N, F) _fwrite_nolock(P, S, N, F)
410#else
411# define FWRITE_(P, S, N, F) fwrite(P, S, N, F)
412#endif
413
414#ifdef HAVE_GETC_UNLOCKED
415# define GETC(F) getc_unlocked(F)
416#elif defined HAVE__GETC_NOLOCK
417# define GETC(F) _getc_nolock(F)
418#else
419# define GETC(F) getc(F)
420#endif
421
422#ifdef HAVE_PUTC_UNLOCKED
423# define PUTC(C, F) putc_unlocked(C, F)
424#elif defined HAVE__PUTC_NOLOCK
425# define PUTC(C, F) _putc_nolock(C, F)
426#else
427# define PUTC(C, F) putc(C, F)
428#endif
429
430#ifdef HAVE_PUTC_UNLOCKED
431# define PUTCHAR(C) putchar_unlocked(C)
432#elif defined HAVE__PUTCHAR_NOLOCK
433# define PUTCHAR(C) _putchar_nolock(C)
434#else
435# define PUTCHAR(C) putchar(C)
436#endif
437
438#ifndef __cplusplus
439/* C23 added bool, false and true as keywords - let's emulate that and
440 * avoid every C file which uses these needing to include <stdbool.h>.
441 */
442# include <stdbool.h>
443
444/* C23 made static_assert() available by default - let's emulate that. */
445# if __STDC_VERSION__ >= 202311L
446// Available by default.
447# elif __STDC_VERSION__ >= 201112L
448# include <assert.h>
449# elif defined __COUNTER__
450// As a fallback for < C11, use a typedef for an array type where the size
451// is negative if the assertion fails.  Prior to C11 redefining a typedef was
452// not allowed so we need to generate unique typedef names (within a single
453// compilation).  __COUNTER__ provides an way to do this - it is a non-standard
454// extension, but supported by at least GCC, clang and MSVC.
455//
456// Using the standardised __LINE__ instead of __COUNTER__ here would fail if
457// two headers (or a header and the source file) happen to use static_assert()
458// on the same line number.
459#  define STATICASSERTTYPEDEFNAME(N) staticassert_##N
460#  define static_assert(CONDITION, MESSAGE) \
461    typedef int STATICASSERTTYPEDEFNAME(__COUNTER__)[(CONDITION) ? 1 : -1]
462# else
463// We don't check static_assert for pre-C11 compilers without __COUNTER__.
464#  define static_assert(...)
465# endif
466#endif
467])
468
469AC_CONFIG_FILES([
470 Makefile src/Makefile doc/Makefile lib/Makefile lib/icons/Makefile
471 lib/images/Makefile
472 tests/Makefile vim/Makefile survex.iss doc/index.htm
473 lib/Info.plist
474 ])
475AC_OUTPUT
Note: See TracBrowser for help on using the repository browser.