From 83b1346577e4d66c9b5b35373c1f43f1cf17f69e Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Sat, 20 Jan 2024 16:34:16 +0800 Subject: [PATCH 4/6] configure.ac: clear up a mess --- configure.ac | 110 +++++++-------------------------------------------- 1 file changed, 14 insertions(+), 96 deletions(-) diff --git configure.ac configure.ac index d7fd391..860a972 100644 --- configure.ac +++ configure.ac @@ -175,7 +175,7 @@ fi # AM_INIT_AUTOMAKE([subdir-objects serial-tests]) -AC_PREFIX_DEFAULT(/usr/local) +AC_PREFIX_DEFAULT(/opt/local) AC_CONFIG_SRCDIR([src/include/a68g.h]) AC_CONFIG_HEADERS([a68g-config.h]) AC_PROG_INSTALL @@ -199,12 +199,12 @@ if test "x$GCC" != "xyes"; then else # On rhel8 "rpmbuild" sneaks in -pie and -fPIE, so a68g also needs to pass through. # On Suse15 the header files for pgsql and R have their own directories. - COPTFLAGS="-g -O2 -Wall -I /usr/include/pgsql -I /usr/lib64/R/include" - LDOPTFLAG="-L /usr/lib64/R/lib" + COPTFLAGS="-g -O2 -Wall $CPPFLAGS" + LDOPTFLAG="$LDFLAGS" # from /usr/lib/rpm/redhat/macros CFLAGS="${CFLAGS:-$COPTFLAGS}" ; export CFLAGS LDFLAGS="${LDFLAGS:-$LDOPTFLAGS}" ; export LDFLAGS - A68G_AC_PROG_CC_CFLAGS([--std=c17]) + A68G_AC_PROG_CC_CFLAGS([-std=c17]) A68G_AC_PROG_CC_CFLAGS([-Wall]) A68G_AC_PROG_CC_CFLAGS([-Wshadow]) A68G_AC_PROG_CC_CFLAGS([-Wunused-variable]) @@ -471,98 +471,16 @@ AC_MSG_NOTICE([check extra include directories...]) EXTRA_INCLUDES="" -# Set -I/usr/local/include for *BSD - -if test "x$bsd_include_dirs" = "xyes"; then - AC_MSG_NOTICE([... /usr/local/include]) - EXTRA_INCLUDES="-I/usr/local/include" -fi - -# Homebrew on macOS - -if test -d /opt/homebrew; then - AC_MSG_NOTICE([... /opt/homebrew]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/opt/homebrew/include" - CFLAGS="$CFLAGS -I/opt/homebrew/include" - CPPFLAGS="$CPPFLAGS -I/opt/homebrew/include" - CXXFLAGS="$CXXFLAGS -I/opt/homebrew/include" - LDFLAGS="$LDFLAGS -L/opt/homebrew/lib" -fi - -# MacPorts on macOS - -if test -d /opt/local; then - AC_MSG_NOTICE([... /opt/local]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/opt/local/include" - CFLAGS="$CFLAGS -I/opt/local/include" - CPPFLAGS="$CPPFLAGS -I/opt/local/include" - CXXFLAGS="$CXXFLAGS -I/opt/local/include" - LDFLAGS="$LDFLAGS -L/opt/local/lib" -fi - -# GSL on OpenBSD - -if test -d /usr/local/include/gsl; then - AC_MSG_NOTICE([... /usr/local/include/gsl]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/usr/local/include" - CFLAGS="$CFLAGS -I/usr/local/include" - CPPFLAGS="$CPPFLAGS -I/usr/local/include" - CXXFLAGS="$CXXFLAGS -I/usr/local/include" - LDFLAGS="$LDFLAGS -L/usr/local/lib" -fi - -# R on Debian -# -# if test -d /usr/share/R/include; then -# AC_MSG_NOTICE([... /usr/share/R/include]) -# AC_DEFINE(HAVE_USR_SHARE_R_INCLUDE, 1, [Define this if /usr/share/R/include was detected]) -# EXTRA_INCLUDES="$EXTRA_INCLUDES -I/usr/share/R/include" -# CFLAGS="$CFLAGS -I/usr/share/R/include" -# CPPFLAGS="$CPPFLAGS -I/usr/share/R/include" -# CXXFLAGS="$CXXFLAGS -I/usr/share/R/include" -# LDFLAGS="$LDFLAGS -L/usr/share/R/lib" -# fi - -# Postgresql - -if test -d /usr/local/pgsql/include; then - AC_MSG_NOTICE([... /usr/local/pgsql/include]) - AC_DEFINE(HAVE_USR_LOCAL_PGSQL_INCLUDE, 1, [Define this if /usr/local/pgsql/include was detected]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/usr/local/pgsql/include" - CFLAGS="$CFLAGS -I/usr/local/pgsql/include" - CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include" - CXXFLAGS="$CXXFLAGS -I/usr/local/pgsql/include" - LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib" -fi - -if test -d /usr/pkg/pgsql/include; then - AC_MSG_NOTICE([... /usr/pkg/pgsql/include]) - AC_DEFINE(HAVE_USR_PKG_PGSQL_INCLUDE, 1, [Define this if /usr/pkg/pgsql/include was detected]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/usr/pkg/pgsql/include" - CFLAGS="$CFLAGS -I/usr/pkg/pgsql/include" - CPPFLAGS="$CPPFLAGS -I/usr/pkg/pgsql/include" - CXXFLAGS="$CXXFLAGS -I/usr/pkg/pgsql/include" - LDFLAGS="$LDFLAGS -L/usr/pkg/pgsql/lib" -fi - -if test -d /opt/local/pgsql/include; then - AC_MSG_NOTICE([... /opt/local/pgsql/include]) - AC_DEFINE(HAVE_OPT_LOCAL_PGSQL_INCLUDE, 1, [Define this if /opt/local/pgsql/include was detected]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/opt/local/pgsql/include" - CFLAGS="$CFLAGS -I/opt/local/pgsql/include" - CPPFLAGS="$CPPFLAGS -I/opt/local/pgsql/include" - CXXFLAGS="$CXXFLAGS -I/opt/local/pgsql/include" - LDFLAGS="$LDFLAGS -L/opt/local/pgsql/lib" -fi - -if test -d /usr/include/postgresql; then - AC_MSG_NOTICE([... /usr/include/postgresql]) - AC_DEFINE(HAVE_USR_INCLUDE_POSTGRESQL, 1, [Define this if /usr/include/postgresql was detected]) - EXTRA_INCLUDES="$EXTRA_INCLUDES -I/usr/include/postgresql" - CFLAGS="$CFLAGS -I/usr/include/postgresql" - CPPFLAGS="$CPPFLAGS -I/usr/include/postgresql" - CXXFLAGS="$CXXFLAGS -I/usr/include/postgresql" - LDFLAGS="$LDFLAGS -L/usr/lib" +# Prefix should be set by the user. +# Pass extra flags via env. + +if test -d $prefix; then + AC_MSG_NOTICE([... $prefix]) + EXTRA_INCLUDES="$EXTRA_INCLUDES -I$prefix/include" + CFLAGS="$CFLAGS -I$prefix/include" + CPPFLAGS="$CPPFLAGS -I$prefix/include" + CXXFLAGS="$CXXFLAGS -I$prefix/include" + LDFLAGS="$LDFLAGS -L$prefix/lib" fi AC_DEFINE_UNQUOTED(INCLUDE_DIR, "$EXTRA_INCLUDES", [Platform dependent])