123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- #
- # /*
- # * This program is free software: you can redistribute it and/or modify
- # * it under the terms of the GNU General Public License as published by
- # * the Free Software Foundation, either version 3 of the License, or
- # * (at your option) any later version.
- # *
- # * This program is distributed in the hope that it will be useful,
- # * but WITHOUT ANY WARRANTY; without even the implied warranty of
- # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # * GNU General Public License for more details.
- # *
- # * You should have received a copy of the GNU General Public License
- # * along with this program. If not, see <http://www.gnu.org/licenses/>.
- # *
- # * SPDX-License-Identifier: GPL-3.0+
- # * License-Filename: LICENSE
- # *
- # */
- #
- # -*- Autoconf -*-
- # Process this file with autoconf to produce a configure script.
- # Macro: AC_INIT (package, version, [bug-report], [tarname], [url])
- # minor version number is increased at important feature change
- # Process with autogen.sh or manual:
- # aclocal
- # autoheader
- # autoconf
- # libtoolize --force --automake
- # automake -a --gnu --include-deps
- # or do this all using autoreconf
- #
- # test also using scan-build from llvm clang tools
- #
- AC_PREREQ([2.69])
- AC_INIT([kissgml], [1.0], [mooigraph@gmail.com])
- AC_CONFIG_SRCDIR([src/main.h])
- AC_CONFIG_HEADERS([config.h])
- AM_INIT_AUTOMAKE
- # Checks for programs.
- AC_PROG_CC
- AC_PROG_MAKE_SET
- # -DFORTIFY_SOURCE=2 does add glibc extra checks, see RedHat documentation
- # Need c11 mode because of %llu in printf() and (long long int) datatype and unnamed unions
- # Upcoming c standard is c17 using GNU GCC -std=c17
- # or CFLAGS="$CFLAGS ..."
- # do not optimize away memset()
- #CFLAGS="$CFLAGS -g -std=c99 -fno-builtin-memset -DFORTIFY_SOURCE=2 -fdump-rtl-expand-graph"
- CFLAGS="$CFLAGS -g -std=c99 -fno-builtin-memset -DFORTIFY_SOURCE=2"
- # Gcc compiler options
- # the option -frecord-gcc-switches puts the compiler options
- # in the binary ro read with: readelf -p .GCC.command.line a.out
- # https://github.com/Barro/compiler-warnings has lists of gcc options
- AC_DEFUN([GCC_COMPILER_WARNING],
- [AC_MSG_CHECKING(whether compiler accepts $1)
- AC_SUBST(WARNING_CFLAGS)
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
- AC_TRY_COMPILE(,
- [int x;],
- WARNING_CFLAGS="$WARNING_CFLAGS $1"
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- CFLAGS="$ac_save_CFLAGS"])
- # the fortify -D option needs optimizing, cannot use -O0 then.
- # for debug with gdb the -O0 is needed or it cannot find crashes.
- # prints gcc settings and include files and is very verbose
- # GCC_COMPILER_WARNING(--verbose)
- # GCC_COMPILER_WARNING(-H)
- AC_ARG_ENABLE(gcc-warnings,
- AC_HELP_STRING([--enable-gcc-warnings],
- [turn on lots of GCC warnings (not recommended)]),
- [case "${enableval}" in
- yes|no) ;;
- *) AC_MSG_ERROR([unknown value ${enableval} for gcc-warnings option expected yes or no]) ;;
- esac],
- [enableval=no])
- if test "${enableval}" = yes; then
- GCC_COMPILER_WARNING(-Werror)
- AC_SUBST([WERROR_CFLAGS], [$WARNING_CFLAGS])
- WARNING_CFLAGS=
- GCC_COMPILER_WARNING(-O0)
- GCC_COMPILER_WARNING(-Wall)
- GCC_COMPILER_WARNING(-Wextra)
- GCC_COMPILER_WARNING(-W)
- GCC_COMPILER_WARNING(-Wbad-function-cast)
- GCC_COMPILER_WARNING(-Wcast-align)
- GCC_COMPILER_WARNING(-ftrapv)
- GCC_COMPILER_WARNING(-Wformat)
- GCC_COMPILER_WARNING(-Wmissing-declarations)
- GCC_COMPILER_WARNING(-Wmissing-prototypes)
- GCC_COMPILER_WARNING(-Wnested-externs)
- GCC_COMPILER_WARNING(-Wshadow)
- GCC_COMPILER_WARNING(-Wstrict-prototypes)
- GCC_COMPILER_WARNING(-Woverlength-strings)
- GCC_COMPILER_WARNING(-Wformat-nonliteral)
- GCC_COMPILER_WARNING(-Wformat-security)
- GCC_COMPILER_WARNING(-Winit-self)
- GCC_COMPILER_WARNING(-Winline)
- GCC_COMPILER_WARNING(-Wmisleading-indentation)
- GCC_COMPILER_WARNING(-Wlogical-op)
- GCC_COMPILER_WARNING(-Wduplicated-cond)
- GCC_COMPILER_WARNING(-Wtautological-compare)
- GCC_COMPILER_WARNING(-Wshift-count-negative)
- GCC_COMPILER_WARNING(-Wshift-count-overflow)
- GCC_COMPILER_WARNING(-Wshift-negative-value)
- GCC_COMPILER_WARNING(-Wshift-overflow)
- GCC_COMPILER_WARNING(-Wnull-dereference)
- GCC_COMPILER_WARNING(-Wnonnull)
- GCC_COMPILER_WARNING(-Woverride-init-side-effects)
- GCC_COMPILER_WARNING(-Wunused-const-variable)
- GCC_COMPILER_WARNING(-Wframe-address)
- else
- WARNING_CFLAGS=
- GCC_COMPILER_WARNING(-Wall)
- GCC_COMPILER_WARNING(-Wshadow)
- GCC_COMPILER_WARNING(-Wno-overlength-strings)
- GCC_COMPILER_WARNING(-pedantic)
- GCC_COMPILER_WARNING(-D_FORTIFY_SOURCE=2)
- GCC_COMPILER_WARNING(-fstack-protector-strong)
- GCC_COMPILER_WARNING(-Wl,-O1)
- GCC_COMPILER_WARNING(-frecord-gcc-switches)
- GCC_COMPILER_WARNING(-grecord-gcc-switches)
- GCC_COMPILER_WARNING(-Wpointer-arith)
- GCC_COMPILER_WARNING(-fvar-tracking-assignments)
- GCC_COMPILER_WARNING(-fcompare-debug)
- GCC_COMPILER_WARNING(-flto)
- GCC_COMPILER_WARNING(-fcallgraph-info)
- GCC_COMPILER_WARNING(-fwhole-program)
- fi
- # GCC compiler rtl and tree data generation
- # GCC_COMPILER_WARNING(-fdump-rtl-all-graph)
- # GCC_COMPILER_WARNING(-fdump-tree-all-graph)
- # GCC_COMPILER_WARNING(-fcallgraph-info)
- # Checks for libraries.
- AC_CHECK_LIB([m], [sqrt])
- # Checks for header files.
- AC_CHECK_HEADERS([limits.h stdlib.h stdint.h string.h inttypes.h])
- # Checks for typedefs, structures, and compiler characteristics.
- # Checks for library functions.
- AC_CHECK_FUNCS(memset strdup)
- #-------------------------------------------
- # Check for math.h include and math library.
- # Old distros, use CHECK as a SEARCH backup.
- AC_CHECK_HEADER([math.h],
- AC_SEARCH_LIBS([cos],[m],[have_libm=yes],
- AC_CHECK_LIB([m],[cos],[have_libm=yes])))
- if test x"${have_libm}" != xyes; then
- AC_MSG_FAILURE([ERROR: Please install Math libraries and math.h include files for libm],[1])
- fi
- #-------------------------------------------
- # Check for C99 hypot. Error if none found.
- # Older compilers will have to set/use C99.
- AC_CHECK_FUNCS(hypot, ,[AC_MSG_FAILURE([ERROR: hypot() required but not found.],[1])])
- #-------------------------------------------
- # Check for C99 isfinite or finite. Use one.
- math_isfinite=no
- math_finite=no
- AC_CHECK_FUNCS(isfinite,
- [AC_DEFINE(HAVE_ISFINITE, 1)
- math_isfinite=true],
- [AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <math.h>]],
- [[double f = 0.0; isfinite(f)]])],
- [AC_DEFINE(HAVE_ISFINITE, 1)
- math_isfinite=true],
- [AC_CHECK_FUNCS(finite,
- [AC_DEFINE(HAVE_FINITE, 1)
- math_finite=true])])])
- if test x"${math_isfinite}" = xno && test x"${math_finite}" = xno; then
- AC_MSG_FAILURE([ERROR: isfinite() or finite() required but not found.],[1])
- fi
- AC_SUBST(HAVE_FINITE)
- AC_SUBST(HAVE_ISFINITE)
- # default to gtk+-2.0 setting to 1
- GTK_HAVE_API_VERSION_2=1
- GTK_HAVE_API_VERSION_3=0
- GTK_HAVE_API_VERSION_4=0
- AC_ARG_ENABLE(gtk2,
- [ --enable-gtk2 Use GTK 2.0 in preference to GTK 3.0 [[default=no]]],
- [if test "$enableval" = "yes"
- then
- prefer_gtk2=yes
- else
- prefer_gtk2=no
- fi])
- AC_MSG_CHECKING([which gtk+ version to compile against])
- AC_ARG_WITH([gtk],
- [AS_HELP_STRING([--with-gtk=2.0|3.0|4.0],[which gtk+ version to compile against (default: 3.0)])],
- [case "$with_gtk" in
- 2.0|3.0|4.0) ;;
- *) AC_MSG_ERROR([invalid gtk version specified]) ;;
- esac],
- [with_gtk=2.0])
- AC_MSG_RESULT([$with_gtk])
- case "$with_gtk" in
- 2.0) GTK_API_VERSION=2.0
- GTK_REQUIRED=2.0.0
- GTK_HAVE_API_VERSION_2=1
- GTK_HAVE_API_VERSION_3=0
- GTK_HAVE_API_VERSION_4=0
- ;;
- 3.0) GTK_API_VERSION=3.0
- GTK_REQUIRED=2.91.0
- GTK_HAVE_API_VERSION_2=0
- GTK_HAVE_API_VERSION_3=1
- GTK_HAVE_API_VERSION_4=0
- ;;
- 4.0) GTK_API_VERSION=4.0
- GTK_REQUIRED=3.91.0
- GTK_HAVE_API_VERSION_2=0
- GTK_HAVE_API_VERSION_3=0
- GTK_HAVE_API_VERSION_4=1
- ;;
- esac
- #
- AC_SUBST([GTK_API_VERSION])
- AC_SUBST([GTK_REQUIRED])
- #
- AM_CONDITIONAL([HAVE_GTK_2],[test "$with_gtk" = "2.0"])
- AM_CONDITIONAL([HAVE_GTK_3],[test "$with_gtk" = "3.0"])
- AM_CONDITIONAL([HAVE_GTK_4],[test "$with_gtk" = "4.0"])
- #
- AC_DEFINE_UNQUOTED([GTK_HAVE_API_VERSION_2], [$GTK_HAVE_API_VERSION_2], [gtk version 2])
- AC_DEFINE_UNQUOTED([GTK_HAVE_API_VERSION_3], [$GTK_HAVE_API_VERSION_3], [gtk version 3])
- AC_DEFINE_UNQUOTED([GTK_HAVE_API_VERSION_4], [$GTK_HAVE_API_VERSION_4], [gtk version 4])
- # Preliminary check for pkg-config
- if test -z "$PKG_CONFIG"; then
- AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
- fi
- if test "$PKG_CONFIG" = "no" ; then
- echo "
- Please install pkg-config and then reconfigure mooigraph.
- pkg-config is available from http://www.freedesktop.org/
- "
- exit 1
- fi
- # glib 2.0 (needed even if not building GUI; we need 2.14 for regexp functions)
- PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14.0, have_glib2="yes", have_glib2="no")
- if test "${have_glib2}" = "no" ; then
- echo "
- Please install glib-2.0 >= 2.14.0 and then reconfigure mooigraph.
- glib-2.0 is available from http://www.gtk.org/
- "
- exit 1
- fi
- # Initial check for GTK availability
- if test "$prefer_gtk2" = "yes" ; then
- PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.14.0,
- GTK_CFLAGS=$GTK2_CFLAGS
- GTK_LIBS=$GTK2_LIBS
- CFLAGS="$CFLAGS $GTK_CFLAGS"
- LIBS="$LIBS $GTK_LIBS"
- gtk_version="2.0",
- echo "GTK 2 >= 2.14.0 not found"
- )
- elif test "$prefer_gtk2" = "no" ; then
- PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.0.1,
- GTK_CFLAGS=$GTK3_CFLAGS
- GTK_LIBS=$GTK3_LIBS
- CFLAGS="$CFLAGS $GTK_CFLAGS"
- LIBS="$LIBS $GTK_LIBS"
- dnl AC_DEFINE(USE_GTK3)
- gtk_version="3.0"
- fake_gtkspinner="no",
- echo "GTK 3 >= 3.0.1 not found"
- )
- fi
- dnl GTK 2.0 fallback in case preference not given
- if test "$prefer_gtk2" = "no" && test "$gtk_version" = "none" ; then
- PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.14.0,
- GTK_CFLAGS=$GTK2_CFLAGS
- GTK_LIBS=$GTK2_LIBS
- CFLAGS="$CFLAGS $GTK_CFLAGS"
- LIBS="$LIBS $GTK_LIBS"
- gtk_version="2.0",
- build_gui="no"
- echo "GTK 2 >= 2.14.0 not found"
- )
- fi
- #
- PKG_CHECK_MODULES(GTK, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED)
- AC_SUBST(GTK_CFLAGS)
- AC_SUBST(GTK_LIBS)
- # final compiler settings
- AC_SUBST(PACKAGE_CFLAGS)
- # final compiler settings
- AC_SUBST(PACKAGE_CFLAGS)
- AC_SUBST(WARNING_CFLAGS)
- AC_CONFIG_FILES([Makefile src/Makefile])
- AC_OUTPUT
- AC_MSG_NOTICE([
- Configuration:
- Source code location ${srcdir}
- Build code location ${builddir}
- Destination prefix ${prefix}
- Compiler ${CC}
- Config GTK version "${with_gtk}"
- Config warning flags "${WARNING_CFLAGS}"
- Config CFLAGS "${CFLAGS}"
- Config LIBS "${LIBS}"
- Config GTK_CFLAGS "${GTK_CFLAGS}"
- Config GTK_LIBS "${GTK_LIBS}"
- ])
|