Commit ffeaf61c authored by Tiago Peixoto's avatar Tiago Peixoto

configure.ac: Major cleanup and improvements

parent f1404b20
This diff is collapsed.
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lib_cgal_core.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_CGAL_CORE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
# Test for the CGAL_Core library.
#
# By using the "--with-cgal=" option, define a special installation
# directory. If CGAL is not found there, the script will fail immediately.
# Otherwise, $CGAL_HOME is searched, then standard system locations.
#
# NOTE: This script depends on BOOST_CPPFLAGS, so be sure to run
# AX_BOOST_BASE in advance.
#
# This macro calls:
#
# AC_SUBST(CGAL_CPPFLAGS)
# AC_SUBST(CGAL_LDFLAGS)
#
# And sets:
#
# HAVE_CGAL
#
# LICENSE
#
# Copyright (c) 2010 Sebastian Hegler <sebastian.hegler@tu-dresden.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 3.1 (locally modified)
AC_DEFUN([AX_LIB_CGAL_CORE],[
dnl guess from env, or use given value
AC_ARG_WITH([cgal],
AS_HELP_STRING([--with-cgal@<:@=DIR@:>@],
[location of cgal installation, default $CGAL_HOME]),
[ac_cgal_dirs="$withval"],
[ac_cgal_dirs="$CGAL_HOME"' /usr /usr/local /opt /opt/local']
)
AC_LANG_PUSH([C++])
AC_CHECK_LIB(gmp, __gmpz_init, ,
[AC_MSG_ERROR([GNU MP not found (a CGAL dependency), see https://gmplib.org/])])
for ac_cgal_iterate in $ac_cgal_dirs ; do
CPPFLAGS_SAVED="$CPPFLAGS"
CGAL_CPPFLAGS="-I$ac_cgal_iterate/include"
CPPFLAGS="$CPPFLAGS $CGAL_CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
CGAL_LDFLAGS="-L$ac_cgal_iterate/lib -lCGAL -lCGAL_Core -lgmp"
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $CGAL_LDFLAGS"
export LDFLAGS
AC_MSG_CHECKING([whether CGAL is available in $ac_cgal_iterate])
dnl This test program is taken from:
dnl http://www.cgal.org/Manual/latest/examples/Convex_hull_2/vector_convex_hull_2.cpp
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[
[@%:@include <vector>]
[@%:@include <CGAL/Exact_predicates_inexact_constructions_kernel.h>]
[@%:@include <CGAL/convex_hull_2.h>]
[typedef CGAL::Exact_predicates_inexact_constructions_kernel K;]
[typedef K::Point_2 Point_2;]
[typedef std::vector<Point_2> Points;]
],
[
[Points points, result;
points.push_back(Point_2(0,0));
points.push_back(Point_2(10,0));
points.push_back(Point_2(10,10));
points.push_back(Point_2(6,5));
points.push_back(Point_2(4,1));
CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result));
//std::cout << result.size() << " points on the convex hull" << std::endl;]
])]
,[ac_cgal=yes],[ac_cgal=no])
LDFLAGS="$LDFLAGS_SAVED"
export LDFLAGS
CPPFLAGS="$CPPFLAGS_SAVED"
export CPPFLAGS
if test $ac_cgal = yes ; then
AC_MSG_RESULT([yes])
break
else
AC_MSG_RESULT([no])
fi
done
AC_LANG_POP([C++])
if test $ac_cgal = yes ; then
AC_DEFINE(HAVE_CGAL,[1],[Indicates presence of CGAL library])
AC_SUBST(CGAL_CPPFLAGS)
AC_SUBST(CGAL_LDFLAGS)
# execute ACTION-IF-FOUND
ifelse([$1], , :, [$1])
else
# execute ACTION-IF-NOT-FOUND
ifelse([$2], , :, [$2])
fi
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lib_expat.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_EXPAT([MINIMUM-VERSION])
#
# DESCRIPTION
#
# This macro provides tests of availability of Expat XML Parser of
# particular version or newer. This macro checks for Expat XML Parser
# headers and libraries and defines compilation flags
#
# Macro supports following options and their values:
#
# 1) Single-option usage:
#
# --with-expat -- yes, no, or path to Expat XML Parser
# installation prefix
#
# 2) Three-options usage (all options are required):
#
# --with-expat=yes
# --with-expat-inc -- path to base directory with Expat headers
# --with-expat-lib -- linker flags for Expat
#
# This macro calls:
#
# AC_SUBST(EXPAT_CFLAGS)
# AC_SUBST(EXPAT_LIBS)
# AC_SUBST(EXPAT_LDFLAGS)
# AC_SUBST(EXPAT_VERSION) -- only if version requirement is used
#
# And sets:
#
# HAVE_EXPAT
#
# LICENSE
#
# Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 10
AC_DEFUN([AX_LIB_EXPAT],
[
AC_ARG_WITH([expat],
AS_HELP_STRING([--with-expat=@<:@ARG@:>@],
[use Expat XML Parser from given prefix (ARG=path); check standard prefixes (ARG=yes); disable (ARG=no)]
),
[
if test "$withval" = "yes"; then
if test -f /usr/local/include/expat.h ; then
expat_prefix=/usr/local
elif test -f /usr/include/expat.h ; then
expat_prefix=/usr
else
expat_prefix=""
fi
expat_requested="yes"
elif test -d "$withval"; then
expat_prefix="$withval"
expat_requested="yes"
else
expat_prefix=""
expat_requested="no"
fi
],
[
dnl Default behavior is implicit yes
if test -f /usr/local/include/expat.h ; then
expat_prefix=/usr/local
elif test -f /usr/include/expat.h ; then
expat_prefix=/usr
else
expat_prefix=""
fi
]
)
AC_ARG_WITH([expat-inc],
AS_HELP_STRING([--with-expat-inc=@<:@DIR@:>@],
[path to Expat XML Parser headers]
),
[expat_include_dir="$withval"],
[expat_include_dir=""]
)
AC_ARG_WITH([expat-lib],
AS_HELP_STRING([--with-expat-lib=@<:@ARG@:>@],
[link options for Expat XML Parser libraries]
),
[expat_lib_flags="$withval"],
[expat_lib_flags=""]
)
EXPAT_CFLAGS=""
EXPAT_LIBS=""
EXPAT_VERSION=""
dnl
dnl Collect include/lib paths and flags
dnl
run_expat_test="no"
if test -n "$expat_prefix"; then
expat_include_dir="$expat_prefix/include"
expat_ld_flags="-L$expat_prefix/lib"
expat_lib_flags="-lexpat"
run_expat_test="yes"
elif test "$expat_requested" = "yes"; then
if test -n "$expat_include_dir" -a -n "$expat_lib_flags"; then
run_expat_test="yes"
fi
else
run_expat_test="no"
fi
dnl
dnl Check Expat XML Parser files
dnl
if test "$run_expat_test" = "yes"; then
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$expat_include_dir"
saved_LIBS="$LIBS"
LIBS="$LIBS $expat_lib_flags"
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $expat_ld_flags"
dnl
dnl Check Expat headers
dnl
AC_MSG_CHECKING([for Expat XML Parser headers in $expat_include_dir])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[
@%:@include <expat.h>
]],
[[]]
)],
[
EXPAT_CFLAGS="-I$expat_include_dir"
expat_header_found="yes"
AC_MSG_RESULT([found])
],
[
expat_header_found="no"
AC_MSG_RESULT([not found])
]
)
AC_LANG_POP([C++])
dnl
dnl Check Expat libraries
dnl
if test "$expat_header_found" = "yes"; then
AC_MSG_CHECKING([for Expat XML Parser libraries])
AC_LANG_PUSH([C++])
AC_LINK_IFELSE([
AC_LANG_PROGRAM(
[[
@%:@include <expat.h>
]],
[[
XML_Parser p = XML_ParserCreate(NULL);
XML_ParserFree(p);
p = NULL;
]]
)],
[
EXPAT_LIBS="$expat_lib_flags"
EXPAT_LDFLAGS="$expat_ld_flags"
expat_lib_found="yes"
AC_MSG_RESULT([found])
],
[
expat_lib_found="no"
AC_MSG_RESULT([not found])
]
)
AC_LANG_POP([C++])
fi
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
fi
AC_MSG_CHECKING([for Expat XML Parser])
if test "$run_expat_test" = "yes"; then
if test "$expat_header_found" = "yes" -a "$expat_lib_found" = "yes"; then
AC_SUBST([EXPAT_CFLAGS])
AC_SUBST([EXPAT_LDFLAGS])
AC_SUBST([EXPAT_LIBS])
HAVE_EXPAT="yes"
else
HAVE_EXPAT="no"
fi
AC_MSG_RESULT([$HAVE_EXPAT])
dnl
dnl Check Expat version
dnl
if test "$HAVE_EXPAT" = "yes"; then
expat_version_req=ifelse([$1], [], [], [$1])
if test -n "$expat_version_req"; then
AC_MSG_CHECKING([if Expat XML Parser version is >= $expat_version_req])
if test -f "$expat_include_dir/expat.h"; then
expat_major=`cat $expat_include_dir/expat.h | \
grep '^#define.*XML_MAJOR_VERSION.*[0-9]$' | \
sed -e 's/#define XML_MAJOR_VERSION.//'`
expat_minor=`cat $expat_include_dir/expat.h | \
grep '^#define.*XML_MINOR_VERSION.*[0-9]$' | \
sed -e 's/#define XML_MINOR_VERSION.//'`
expat_revision=`cat $expat_include_dir/expat.h | \
grep '^#define.*XML_MICRO_VERSION.*[0-9]$' | \
sed -e 's/#define XML_MICRO_VERSION.//'`
EXPAT_VERSION="$expat_major.$expat_minor.$expat_revision"
AC_SUBST([EXPAT_VERSION])
dnl Decompose required version string and calculate numerical representation
expat_version_req_major=`expr $expat_version_req : '\([[0-9]]*\)'`
expat_version_req_minor=`expr $expat_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
expat_version_req_revision=`expr $expat_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$expat_version_req_revision" = "x"; then
expat_version_req_revision="0"
fi
expat_version_req_number=`expr $expat_version_req_major \* 10000 \
\+ $expat_version_req_minor \* 100 \
\+ $expat_version_req_revision`
dnl Calculate numerical representation of detected version
expat_version_number=`expr $expat_major \* 10000 \
\+ $expat_minor \* 100 \
\+ $expat_revision`
expat_version_check=`expr $expat_version_number \>\= $expat_version_req_number`
if test "$expat_version_check" = "1"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_WARN([Found Expat XML Parser $EXPAT_VERSION, which is older than required. Possible compilation failure.])
fi
else
AC_MSG_RESULT([no])
AC_MSG_WARN([Missing expat.h header. Unable to determine Expat version.])
fi
fi
fi
else
HAVE_EXPAT="no"
AC_MSG_RESULT([$HAVE_EXPAT])
if test "$expat_requested" = "yes"; then
AC_MSG_WARN([Expat XML Parser support requested but headers or library not found. Specify valid prefix of Expat using --with-expat=@<:@DIR@:>@ or provide include directory and linker flags using --with-expat-inc and --with-expat-lib])
fi
fi
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_openmp.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile programs that use OpenMP a
# standard API and set of compiler directives for parallel programming
# (see http://www-unix.mcs/)
#
# On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_F77FLAGS
# output variable to the flag (e.g. -omp) used both to compile *and* link
# OpenMP programs in the current language.
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well.
#
# If you want to compile everything with OpenMP, you should set:
#
# CFLAGS="$CFLAGS $OPENMP_CFLAGS"
# #OR# CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
# #OR# FFLAGS="$FFLAGS $OPENMP_FFLAGS"
#
# (depending on the selected language).
#
# The user can override the default choice by setting the corresponding
# environment variable (e.g. OPENMP_CFLAGS).
#
# ACTION-IF-FOUND is a list of shell commands to run if an OpenMP flag is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
# not found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_OPENMP.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2015 John W. Peterson <jwpeterson@gmail.com>
# Copyright (c) 2016 Nick R. Papior <nickpapior@gmail.com>
#
# 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/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 12
AC_DEFUN([AX_OPENMP], [
AC_PREREQ([2.69]) dnl for _AC_LANG_PREFIX
AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown
# Flags to try: -fopenmp (gcc), -mp (SGI & PGI),
# -qopenmp (icc>=15), -openmp (icc),
# -xopenmp (Sun), -omp (Tru64),
# -qsmp=omp (AIX),
# none
ax_openmp_flags="-fopenmp -openmp -qopenmp -mp -xopenmp -omp -qsmp=omp none"
if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then
ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags"
fi
for ax_openmp_flag in $ax_openmp_flags; do
case $ax_openmp_flag in
none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;;
*) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;;
esac
AC_LINK_IFELSE([AC_LANG_SOURCE([[
@%:@include <omp.h>
static void
parallel_fill(int * data, int n)
{
int i;
@%:@pragma omp parallel for
for (i = 0; i < n; ++i)
data[i] = i;
}
int
main()
{
int arr[100000];
omp_set_num_threads(2);
parallel_fill(arr, 100000);
return 0;
}
]])],[ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break],[])
done
[]_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS
])
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then
m4_default([$2],:)
else
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp
fi
m4_default([$1], [AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])])
fi
])dnl AX_OPENMP
......@@ -2,21 +2,16 @@
SUBDIRS = centrality clustering correlations draw flow generation inference layout search spectral stats topology util
AM_CPPFLAGS =\
-I$(srcdir)/.. \
-I$(srcdir)/../boost-workaround \
-DHAVE_CONFIG_H
AM_CXXFLAGS =\
-Wall \
$(PYTHON_CPPFLAGS) \
$(BOOST_CPPFLAGS)
AM_CPPFLAGS = $(MOD_CPPFLAGS)
AM_CFLAGS = $(AM_CXXFLAGS)
libgraph_tool_coredir = $(MOD_DIR)
libgraph_tool_core_LTLIBRARIES = libgraph_tool_core.la
libgraph_tool_core_la_LIBADD = $(MOD_LIBADD)
libgraph_tool_core_la_LDFLAGS = $(MOD_LDFLAGS)
libgraph_tool_core_la_SOURCES = \
base64.cc \
demangle.cc \
......@@ -94,6 +89,3 @@ libgraph_tool_core_la_workaround_HEADERS = \
../boost-workaround/boost/graph/copy_alt.hpp \
../boost-workaround/boost/graph/stoer_wagner_min_cut.hpp
libgraph_tool_core_la_LIBADD = $(MOD_LIBADD)
libgraph_tool_core_la_LDFLAGS = $(MOD_LDFLAGS)
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = $(MOD_CPPFLAGS)
AM_CPPFLAGS = $(MOD_CPPFLAGS) $(CGAL_CPPFLAGS)
AM_CXXFLAGS = $(CXXFLAGS) $(CGAL_FLAGS)
AM_CXXFLAGS = $(CXXFLAGS)
libgraph_tool_generationdir = $(MOD_DIR)/generation
......@@ -10,7 +10,7 @@ libgraph_tool_generation_LTLIBRARIES = libgraph_tool_generation.la
libgraph_tool_generation_la_includedir = $(MOD_DIR)/include/generation
libgraph_tool_generation_la_LIBADD = $(MOD_LIBADD) $(CGAL_LIBADD)
libgraph_tool_generation_la_LIBADD = $(MOD_LIBADD) $(CGAL_LIBADD) $(CGAL_LDFLAGS)
libgraph_tool_generation_la_LDFLAGS = $(MOD_LDFLAGS)
......
......@@ -25,11 +25,7 @@ using namespace std;
bool graph_tool::graph_filtering_enabled()
{
#ifndef NO_GRAPH_FILTERING
return true;
#else
return false;
#endif
}
// Whenever no implementation is called, the following exception is thrown
......@@ -65,7 +61,6 @@ check_filtered(const Graph& g, const EdgeFilter& edge_filter,
{
typedef typename std::remove_const<
typename std::remove_reference<decltype(u)>::type>::type g_t;
#ifndef NO_GRAPH_FILTERING
if (e_active || v_active)
{
MaskFilter<EdgeFilter>
......@@ -91,9 +86,6 @@ check_filtered(const Graph& g, const EdgeFilter& edge_filter,
{
return std::ref(const_cast<g_t&>(u));
}
#else
return std::ref(const_cast<g_t&>(u));
#endif
};
auto check_reverse = [&](auto&& u) -> boost::any
......@@ -218,10 +210,6 @@ void GraphInterface::purge_vertices(boost::any aold_index)
void GraphInterface::set_vertex_filter_property(boost::any property, bool invert)
{
#ifdef NO_GRAPH_FILTERING
throw GraphException("graph filtering was not enabled at compile time");
#endif
try
{
_vertex_filter_map =
......@@ -239,10 +227,6 @@ void GraphInterface::set_vertex_filter_property(boost::any property, bool invert
void GraphInterface::set_edge_filter_property(boost::any property, bool invert)
{
#ifdef NO_GRAPH_FILTERING
throw GraphException("graph filtering was not enabled at compile time");
#endif
try
{
_edge_filter_map =
......
......@@ -367,11 +367,7 @@ struct never_filtered_never_reversed:
// sanity check
typedef boost::mpl::size<all_graph_views>::type n_views;
#ifndef NO_GRAPH_FILTERING
BOOST_MPL_ASSERT_RELATION(n_views::value, == , boost::mpl::int_<6>::value);
#else
BOOST_MPL_ASSERT_RELATION(n_views::value, == , boost::mpl::int_<3>::value);
#endif
// run_action() and gt_dispatch() implementation
// =============================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment