123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- #
- # /*
- # * 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
- # *
- # */
- #
- # 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
- # This needs GCC in c11 mode because of printf(), and stdint.h uint64_t
- #
- AC_PREREQ([2.69])
- AC_INIT([tuxsee], [8.0], [mooigraph@gmail.com], [tuxsee.tar.gz], [https://notabug.org/mooigraph])
- AC_CONFIG_SRCDIR([src/main.c])
- AC_CONFIG_HEADERS([config.h])
- AC_COPYRIGHT([
- # /*
- # * 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
- # *
- # */
- ])
- # optional gcc option can be like this AM_INIT_AUTOMAKE([-Wall])
- AM_INIT_AUTOMAKE
- AC_CONFIG_MACRO_DIR([m4])
- AC_USE_SYSTEM_EXTENSIONS
- # compilation date in config.h
- CONFIG_DATE=`date +%Y%m%d`
- AC_SUBST(CONFIG_DATE)
- AC_DEFINE_UNQUOTED(COMPILE_DATE, ["$CONFIG_DATE"], [Year, month and day this program is compiled.])
- # Add host to config.h
- AC_DEFINE_UNQUOTED(USED_HOST, ["$host"], [Host system under which the program will run.])
- AC_DEFINE_UNQUOTED(USED_BUILD, ["$build"], [Build system under which the program was compiled on.])
- # needed to support older automake versions
- AC_SUBST(abs_top_builddir)
- AC_SUBST(abs_top_srcdir)
- AC_LANG(C)
- # Checks for programs.
- AC_PROG_CC
- AC_PROG_MAKE_SET
- AC_PROG_RANLIB
- AM_PROG_CC_C_O
- # -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=c11 -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)
- GCC_COMPILER_WARNING(-Wtype-limits)
- else
- WARNING_CFLAGS=
- GCC_COMPILER_WARNING(-Wall)
- GCC_COMPILER_WARNING(-Wshadow)
- GCC_COMPILER_WARNING(-Wno-overlength-strings)
- 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(-fwhole-program)
- fi
- # GCC compiler rtl and tree data generation
- # GCC_COMPILER_WARNING(-fdump-rtl-all-graph)
- # GCC_COMPILER_WARNING(-fdump-tree-all-graph)
- AC_ARG_ENABLE(crosswin32,
- AC_HELP_STRING([--enable-crosswin32],
- [cross-compile on GNU/Linux with mingw a 32bits windows exe]),
- [case "${enableval}" in
- yes|no) ;;
- *) AC_MSG_ERROR([bad value ${enableval} for crosswin32 option]) ;;
- esac],
- [enableval=no])
- if test "${enableval}" = yes; then
- # cross compile
- CC="i686-w64-mingw32-gcc"
- AC_MSG_RESULT(yes cross compilation)
- else
- # linux compile
- AC_MSG_RESULT(no cross compilation)
- fi
- # we want to avoid tests in case we're crosscompiling
- # since we wouldn't be able to run the executable in that case
- AM_CONDITIONAL(NO_CROSSCOMPILING, test "$cross_compiling" = no )
- # 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.
- AC_TYPE_SIZE_T
- AC_TYPE_UID_T
- AC_CHECK_SIZEOF(char)
- AC_CHECK_SIZEOF(short)
- AC_CHECK_SIZEOF(long)
- AC_CHECK_SIZEOF(int)
- AC_CHECK_SIZEOF(void *)
- AC_CHECK_SIZEOF(char *)
- #AC_CHECK_SIZEOF(size_t) mingw issue
- AC_CHECK_SIZEOF(ssize_t)
- AC_CHECK_SIZEOF(long long)
- AC_CHECK_SIZEOF(__int64)
- AC_CHECK_SIZEOF(int64_t)
- AC_CHECK_SIZEOF(__int128)
- # Checks for library functions.
- AC_FUNC_MALLOC
- AC_FUNC_REALLOC
- AC_CHECK_FUNCS(memset memset_s mtrace strdup)
- # Joystick plugin
- AC_ARG_ENABLE(joystick,
- [ --enable-joystick joystick control (default enabled)])
- if test "${enable_joystick}" = "yes"; then
- AC_CHECK_HEADER(linux/joystick.h)
- fi
- # prepare for gtk-4.0 here
- # default to gtk+-2.0 setting to 1
- GTK_HAVE_API_VERSION_2=0
- GTK_HAVE_API_VERSION_3=1
- 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=3.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)
- AC_CONFIG_FILES([Makefile src/Makefile])
- AC_OUTPUT
- # ST_REPORT(NAME, VALUE)
- AC_DEFUN([ST_REPORT], [ m4_format([%-30s %s], [$1], [$2])])
- # ST_REPORT_ARG(NAME)
- AC_DEFUN([ST_REPORT_ARG], [ST_REPORT([--[$1]], [$translit([$1], -, _)])
- ])
- # ST_REPORT_ARGS(NAMES)
- AC_DEFUN([ST_REPORT_ARGS], [m4_foreach(name, [$1], [ST_REPORT_ARG(name)])
- ])
- # ST_REPORT_FEATURE(FEATURE)
- AC_DEFUN([ST_REPORT_FEATURE],
- [ST_REPORT([--enable-[$1]],
- [$ST_FEATURE_VAR_NAME([$1]) $ST_FEATURE_DISABLE_REASON_VAR_NAME([$1])])])
- # ST_REPORT_FEATURES(FEATURES)
- AC_DEFUN([ST_REPORT_FEATURES], [m4_foreach(feature, [$1], [ST_REPORT_FEATURE(feature)])
- ])
- echo "$0 complete, type 'make' to build"
- echo
- echo " "
- echo " "
- echo " "
- echo " , , "
- echo " / \ "
- echo " ((__-^^-,-^^-__)) "
- echo " '-__- - '--__- "
- echo " -O O- "
- echo " \ / "
- echo " ): :( "
- echo " :o_o: "
- echo " - "
- echo " "
- echo " "
- echo " "
- echo This system is `uname -a`;
- cat <<EOF
- $PACKAGE_NAME $VERSION is ready to be built.
- The following settings will be used:
- Installation prefixes
- ST_REPORT_ARGS([prefix, exec-prefix])
- Installation directories
- ST_REPORT_ARGS([bindir, datadir, libdir, includedir])
- Use "make" to compile $PACKAGE_NAME $VERSION.
- use ./configure --with-gtk=2.0 for gtk-2
- use ./configure --with-gtk=3.0 for gtk-3
- use ./configure --with-gtk=4.0 for gtk-4
- use ./configure --enable-gcc-warnings to enable gcc warnings and checks
- EOF
- AC_MSG_RESULT([
- Building programs with prefix=$prefix
- c-compiler: $CC
- c-flags: $CFLAGS
- gtk-version: $GTK_API_VERSION
- gtk-c-flags: $GTK_CFLAGS
- gtk-libs: $GTK_LIBS
- ]);
- # end
|