Skip to content

Commit

Permalink
add the AX_ABSOLUTE_HEADER macro
Browse files Browse the repository at this point in the history
it can be used to get the absolute path to an existing header (basically
by running some code through the C preprocessor and grepping it out)

Hate to add another SAGE_GMP_ variable, but this can be useful for configuring
iml to use the correct system GMP
  • Loading branch information
embray authored and dimpase committed Apr 18, 2019
1 parent 6d2b496 commit 43be546
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build/pkgs/mpir/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,20 @@ dnl Implement cases for what to do on different options here
if test x$sage_spkg_install_mpir = xyes -o x$sage_spkg_install_gmp = xyes; then
AC_SUBST(SAGE_GMP_PREFIX, ['$SAGE_LOCAL'])
AC_SUBST(SAGE_GMP_INCLUDE, ['$SAGE_LOCAL/include'])
AC_MSG_RESULT([using $SAGE_MP_LIBRARY SPKG (via --with-mp=$SAGE_MP_LIBRARY)])
else
dnl If found, we want to get the absolute path to where we
dnl found it for use with some packages (e.g. iml) that need
dnl this information at configure time
AX_ABSOLUTE_HEADER([gmp.h])
if test x$gl_cv_absolute_gmp_h = x; then
AC_MSG_ERROR(m4_normalize([
failed to find absolute path to gmp.h despite it being reported
found
]))
fi
AC_SUBST(SAGE_GMP_INCLUDE, [`AS_DIRNAME($gl_cv_absolute_gmp_h)`])
AC_SUBST(SAGE_GMP_PREFIX, [''])
AC_MSG_RESULT([using GMP-compatible library from the system])
fi
Expand Down
71 changes: 71 additions & 0 deletions m4/ax_absolute_header.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_absolute_header.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
#
# DESCRIPTION
#
# Find the absolute name of a header file, assuming the header exists. If
# the header were sys/inttypes.h, this macro would define
# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of
# sys/inttypes.h in config.h (e.g. `#define ABSOLUTE_SYS_INTTYPES_H
# "///usr/include/sys/inttypes.h"'). The three "///" are to pacify Sun C
# 5.8, which otherwise would say "warning: #include of /usr/include/...
# may be non-portable". Use `""', not `<>', so that the /// cannot be
# confused with a C99 comment.
#
# LICENSE
#
# Copyright (c) 2009 Derek Price
# Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
#
# 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 7

dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl From Derek Price.
dnl Modified by Rhys Ulerich to use AC_CHECK_HEADERS instead of _ONCE

AU_ALIAS([GL_TRILINOS_ABSOLUTE_HEADER], [AX_ABSOLUTE_HEADER])
AC_DEFUN([AX_ABSOLUTE_HEADER],
[AC_LANG_PREPROC_REQUIRE()dnl
AC_FOREACH([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_absolute_header],
[gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
m4_quote(m4_defn([gl_absolute_header])),
[AS_VAR_PUSHDEF([ac_header_exists],
[ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
AC_CHECK_HEADERS(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
if test AS_VAR_GET(ac_header_exists) = yes; then
AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
dnl eval is necessary to expand ac_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
AS_VAR_SET(gl_absolute_header,
[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
s#^/[^/]#//&#
p
q
}'`])
fi
AS_VAR_POPDEF([ac_header_exists])dnl
])dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
["AS_VAR_GET(gl_absolute_header)"],
[Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
AS_VAR_POPDEF([gl_absolute_header])dnl
])dnl
])# AX_ABSOLUTE_HEADER
1 change: 1 addition & 0 deletions src/bin/sage-env-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fi

# This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise
export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@"
export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@"
if [ -n "$SAGE_GMP_PREFIX" ]; then
# Many packages that depend on GMP accept a --with-gmp=<prefix> flag to
# their ./configure scripts. When using the system's GMP this is not
Expand Down

0 comments on commit 43be546

Please sign in to comment.