Skip to content

Instantly share code, notes, and snippets.

@bertwesarg
Created February 26, 2015 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertwesarg/8d2bd38677a467779318 to your computer and use it in GitHub Desktop.
Save bertwesarg/8d2bd38677a467779318 to your computer and use it in GitHub Desktop.
## -*- mode: autoconf -*-
##
## This file is part of the Score-P software (http://www.score-p.org)
##
## Copyright (c) 2009-2012,
## RWTH Aachen University, Germany
##
## Copyright (c) 2009-2012,
## Gesellschaft fuer numerische Simulation mbH Braunschweig, Germany
##
## Copyright (c) 2009-2014,
## Technische Universitaet Dresden, Germany
##
## Copyright (c) 2009-2012,
## University of Oregon, Eugene, USA
##
## Copyright (c) 2009-2012,
## Forschungszentrum Juelich GmbH, Germany
##
## Copyright (c) 2009-2012,
## German Research School for Simulation Sciences GmbH, Juelich/Aachen, Germany
##
## Copyright (c) 2009-2012,
## Technische Universitaet Muenchen, Germany
##
## This software may be modified and distributed under the terms of
## a BSD-style license. See the COPYING file in the package base
## directory for details.
##
## file afs_package.m4
# AFS_PACKAGE_INIT
# ----------------
# Common AC_DEFINE's and AC_SUBST's for the package based on its name.
# Call this only in the top-level configure.ac, sub-builds should call
# `AFS_PACKAGE_BUILD_INIT`.
#
# List of defined autoconf macros:
# `AFS_PACKAGE_name`:: The tarname of the package in lower case
# `AFS_PACKAGE_NAME`:: The tarname of the package in upper case
# `AFS_PACKAGE_TO_TOP`:: The relative path to the top-level configure
# including a trailing slash (empty for the
# top-level configure itself)
# List of provided automake substitutions:
# `AFS_PACKAGE_name`:: The value of AFS_PACKAGE_name
# `AFS_PACKAGE_NAME`:: The value of AFS_PACKAGE_NAME
#
AC_DEFUN_ONCE([AFS_PACKAGE_INIT], [
m4_case([$#],
[0], [],
[1], [m4_ifnblank($1, [m4_fatal([$0: too many arguments: $@])])],
[m4_fatal([$0: too many arguments: $@])])dnl
m4_pushdef([_afs_package_tmp], m4_tolower(AC_PACKAGE_TARNAME))dnl
AC_SUBST([AFS_PACKAGE_name], _afs_package_tmp)
m4_define([AFS_PACKAGE_name], _afs_package_tmp)dnl
m4_popdef([_afs_package_tmp])dnl
m4_pushdef([_afs_package_tmp], m4_toupper(AC_PACKAGE_TARNAME))dnl
AC_SUBST([AFS_PACKAGE_NAME], _afs_package_tmp)
m4_define([AFS_PACKAGE_NAME], _afs_package_tmp)dnl
m4_popdef([_afs_package_tmp])dnl
dnl May be redefined by AFS_PACKAGE_BUILD_INIT
m4_define([AFS_PACKAGE_TO_TOP], [])dnl
])
# AFS_PACKAGE_BUILD_INIT(BUILD-NAME, [TO-TOP])
# --------------------------------------------
# Initializes an sub-build configure. It is sufficient to call
# `AFS_PACKAGE_BUILD_INIT`, `AFS_PACKAGE_INIT` will be called automatically.
#
# The relative path to the top-level configure to this configure
# can be specified with TO-TOP, defaulting to `../`.
#
# List of defined autoconf macros:
# `AFS_PACKAGE_BUILD`:: The normalized name of the build (e.g., 'backend',
# 'MPI backend')
# `AFS_PACKAGE_BUILD_name`:: The build name usable as a symbol in lower case
# (e.g., backend, mpi_backend)
# `AFS_PACKAGE_BUILD_NAME`:: The build name usable as a symbol in upper case
# (e.g., BACKEND, MPI_BACKEND)
# List of provided automake substitutions:
# 'AFS_PACKAGE_BUILD_name' The value of AFS_PACKAGE_BUILD_name
# 'AFS_PACKAGE_BUILD_NAME' The value of AFS_PACKAGE_BUILD_NAME
# `AFS_PACKAGE_TO_TOP`:: The value of AFS_PACKAGE_TO_TOP
# 'afs_srcdir' The relative path to the source directory (i.e.,
# where the top-level configure resides)
# List of provided config header defines:
# `AFS_PACKAGE_BUILD`:: The value of AFS_PACKAGE_BUILD as a string
# constant
# `AFS_PACKAGE_BUILD_name`:: The value of AFS_PACKAGE_BUILD_name
# `AFS_PACKAGE_BUILD_NAME`:: The value of AFS_PACKAGE_BUILD_NAME
# `AFS_PACKAGE_SRCDIR`:: The relative path to the source directory as
# string constant including a trailing slash
# `AFS_PACKAGE_name`:: The value of AFS_PACKAGE_name
# `AFS_PACKAGE_NAME`:: The value of AFS_PACKAGE_NAME
#
AC_DEFUN_ONCE([AFS_PACKAGE_BUILD_INIT], [
AC_REQUIRE([AFS_PACKAGE_INIT])dnl
m4_case([$#],
[0], [m4_fatal([$0: missing arguments])],
[1], [m4_ifblank(m4_normalize($1), [m4_fatal([$0: empty BUILD-NAME argument])])],
[2], [m4_ifblank(m4_normalize($1), [m4_fatal([$0: empty BUILD-NAME argument])])],
[m4_fatal([$0: too many arguments: $@])])dnl
m4_pushdef([_afs_package_tmp], m4_normalize($1))dnl
AC_DEFINE_UNQUOTED([AFS_PACKAGE_BUILD], "_afs_package_tmp",
[Name of the sub-build.])
m4_define([AFS_PACKAGE_BUILD], _afs_package_tmp)dnl
m4_popdef([_afs_package_tmp])dnl
dnl Overwrites AFS_PACKAGE_TO_TOP defined in AFS_PACKAGE_INIT.
m4_pushdef([_afs_package_tmp], m4_default([$2], [../]))dnl
dnl undefine previously defined by AFS_PACKAGE_INIT
m4_undefine([AFS_PACKAGE_TO_TOP])
AC_SUBST([AFS_PACKAGE_TO_TOP], _afs_package_tmp)
m4_define([AFS_PACKAGE_TO_TOP], _afs_package_tmp)dnl
m4_if(m4_substr(AFS_PACKAGE_TO_TOP, decr(len(AFS_PACKAGE_TO_TOP))), [/],
[], [m4_fatal([$0: no trailing slash in TO-TOP argument: ]AFS_PACKAGE_TO_TOP)])
m4_popdef([_afs_package_tmp])dnl
# when building inplace, $srcdir equals ., ignore $srcdir than
AS_CASE([$srcdir],
[.], [afs_srcdir="]AFS_PACKAGE_TO_TOP["],
[afs_srcdir="${srcdir}/]AFS_PACKAGE_TO_TOP["])dnl
AC_DEFINE_UNQUOTED([[AFS_PACKAGE_SRCDIR]],
["${afs_srcdir}"], [Relative path to the top-level source directory.])
AC_SUBST([afs_srcdir])
m4_pushdef([_afs_package_tmp],
m4_bpatsubst(m4_tolower(m4_normalize($1)), [[^a-z0-9]+], [_]))dnl
AC_DEFINE_UNQUOTED([AFS_PACKAGE_BUILD_name], _afs_package_tmp,
[Symbol name of the sub-build in lower case.])
AC_SUBST([AFS_PACKAGE_BUILD_name], _afs_package_tmp)
m4_define([AFS_PACKAGE_BUILD_name], _afs_package_tmp)dnl
m4_popdef([_afs_package_tmp])dnl
m4_pushdef([_afs_package_tmp],
m4_toupper(AFS_PACKAGE_BUILD_name))dnl
AC_DEFINE_UNQUOTED([AFS_PACKAGE_BUILD_NAME], _afs_package_tmp,
[Symbol name of the sub-build in upper case.])
AC_SUBST([AFS_PACKAGE_BUILD_NAME], _afs_package_tmp)
m4_define([AFS_PACKAGE_BUILD_NAME], _afs_package_tmp)dnl
m4_popdef([_afs_package_tmp])dnl
AC_DEFINE_UNQUOTED([[AFS_PACKAGE_name]], AFS_PACKAGE_name,
[The package name usable as a symbol in lower case.])
AC_DEFINE_UNQUOTED([[AFS_PACKAGE_NAME]], AFS_PACKAGE_NAME,
[The package name usable as a symbol in upper case.])
])
## -*- mode: autoconf -*-
##
## This file is part of the Score-P software (http://www.score-p.org)
##
## Copyright (c) 2009-2011,
## RWTH Aachen University, Germany
##
## Copyright (c) 2009-2011,
## Gesellschaft fuer numerische Simulation mbH Braunschweig, Germany
##
## Copyright (c) 2009-2014,
## Technische Universitaet Dresden, Germany
##
## Copyright (c) 2009-2011,
## University of Oregon, Eugene, USA
##
## Copyright (c) 2009-2013,
## Forschungszentrum Juelich GmbH, Germany
##
## Copyright (c) 2009-2011,
## German Research School for Simulation Sciences GmbH, Juelich/Aachen, Germany
##
## Copyright (c) 2009-2011,
## Technische Universitaet Muenchen, Germany
##
## This software may be modified and distributed under the terms of
## a BSD-style license. See the COPYING file in the package base
## directory for details.
##
## file afs_summary.m4
# AFS_SUMMARY_INIT
# ----------------
# Initializes the summary system and adds the pacakge header (possibly
# including the sub-build name) to it. It removes config.summary files
# from previous configure runs recursively, therefore you need to call
# AFS_SUMMARY_INIT before any sub-configures.
# The sub-build name is used from the `AFS_PACKAGE_BUILD` variable
# set by the AFS_PACKAGE_INIT macro.
AC_DEFUN([AFS_SUMMARY_INIT], [
rm -f AC_PACKAGE_TARNAME.summary
LC_ALL=C find . -name config.summary -exec rm -f '{}' \;
cat >config.summary <<_ACEOF
AS_HELP_STRING(AC_PACKAGE_NAME[]m4_ifdef([AFS_PACKAGE_BUILD], [ (]AFS_PACKAGE_BUILD[):]), [], 32, 128)
_ACEOF
])
AC_DEFUN([AFS_SUMMARY_SECTION], [
AC_REQUIRE([AFS_SUMMARY_INIT])
cat >>config.summary <<_ACEOF
AS_HELP_STRING([ $1:], [], 32, 128)
_ACEOF
])
AC_DEFUN([AFS_SUMMARY], [
AC_REQUIRE([AFS_SUMMARY_INIT])
cat >>config.summary <<_ACEOF
AS_HELP_STRING([ $1:], [$2], 32, 128)
_ACEOF
])
# additional output if ./configure was called with --verbose
AC_DEFUN([AFS_SUMMARY_VERBOSE], [
AS_IF([test "x${verbose}" = "xyes"], [
AFS_SUMMARY([$1], [$2])
])
])
AC_DEFUN([_AFS_SUMMARY_SHOW], [
AS_ECHO([""])
cat AC_PACKAGE_TARNAME.summary
])
# AFS_SUMMARY_COLLECT([SHOW-COND])
# --------------------------------
# Collectes the summary of all configures recusivly into the file
# $PACKAGE.summary. If SHOW-COND is not given, or the expression is
# evaluates to true in an AS_IF the summary is also printed to stdout.
# Should be called after AC_OUTPUT.
AC_DEFUN([AFS_SUMMARY_COLLECT], [
(
AS_ECHO(["Configure command:"])
prefix=" $as_myself "
printf "%-32s" "$prefix"
padding=" "
AS_IF([test ${#prefix} -gt 32], [
sep="\\$as_nl$padding"
], [
sep=""
])
eval "set x $ac_configure_args"
shift
AS_FOR([ARG], [arg], [], [
AS_CASE([$arg],
[*\'*], [arg="`$as_echo "$arg" | sed "s/'/'\\\\\\\\''/g"`"])
AS_ECHO_N(["$sep'$arg'"])
sep=" \\$as_nl$padding"
])
AS_ECHO([""])
AS_ECHO([""])
sep="Configuration summary:"
LC_ALL=C find . -name config.summary |
LC_ALL=C $AWK -F "config.summary" '{print $[]1}' |
LC_ALL=C sort |
LC_ALL=C $AWK '{print $[]0 "config.summary"}' |
while read summary
do
AS_ECHO(["$sep"])
cat $summary
sep=""
done
) >AC_PACKAGE_TARNAME.summary
m4_ifblank($1,
[_AFS_SUMMARY_SHOW],
[AS_IF([$1], [_AFS_SUMMARY_SHOW])])
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment