Added configure.ac

This commit is contained in:
Anthony Scemama 2021-11-15 17:37:51 +01:00
parent 8471cb050a
commit 64a6454fd7
5 changed files with 279 additions and 1 deletions

2
.gitignore vendored
View File

@ -8,4 +8,4 @@ make.config
src/ZMQ/f77_zmq.h
ezfio_config/properties.config
bin/
*.mod

27
configure.ac Normal file
View File

@ -0,0 +1,27 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([QMC=Chem], [2.0.0], [https://gitlab.com/scemama/qmcchem/-/issues/new])
AC_CONFIG_SRCDIR([README.md])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([include/config.h])
# Checks for programs.
AC_PROG_AWK
AC_PROG_FC
#AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AX_PROG_IRPF90
# Checks for libraries.
AX_ZMQ([4.0], [], [ AC_MSG_ERROR([Please install ZeroMQ >= 4.0]) ])
AC_LANG([Fortran])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

96
m4/ax_check_gnu_make.m4 Normal file
View File

@ -0,0 +1,96 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_GNU_MAKE([run-if-true],[run-if-false])
#
# DESCRIPTION
#
# This macro searches for a GNU version of make. If a match is found:
#
# * The makefile variable `ifGNUmake' is set to the empty string, otherwise
# it is set to "#". This is useful for including a special features in a
# Makefile, which cannot be handled by other versions of make.
# * The makefile variable `ifnGNUmake' is set to #, otherwise
# it is set to the empty string. This is useful for including a special
# features in a Makefile, which can be handled
# by other versions of make or to specify else like clause.
# * The variable `_cv_gnu_make_command` is set to the command to invoke
# GNU make if it exists, the empty string otherwise.
# * The variable `ax_cv_gnu_make_command` is set to the command to invoke
# GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
# * If GNU Make is found, its version is extracted from the output of
# `make --version` as the last field of a record of space-separated
# columns and saved into the variable `ax_check_gnu_make_version`.
# * Additionally if GNU Make is found, run shell code run-if-true
# else run shell code run-if-false.
#
# Here is an example of its use:
#
# Makefile.in might contain:
#
# # A failsafe way of putting a dependency rule into a makefile
# $(DEPEND):
# $(CC) -MM $(srcdir)/*.c > $(DEPEND)
#
# @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
# @ifGNUmake@ include $(DEPEND)
# @ifGNUmake@ else
# fallback code
# @ifGNUmake@ endif
#
# Then configure.in would normally contain:
#
# AX_CHECK_GNU_MAKE()
# AC_OUTPUT(Makefile)
#
# Then perhaps to cause gnu make to override any other make, we could do
# something like this (note that GNU make always looks for GNUmakefile
# first):
#
# if ! test x$_cv_gnu_make_command = x ; then
# mv Makefile GNUmakefile
# echo .DEFAULT: > Makefile ;
# echo \ $_cv_gnu_make_command \$@ >> Makefile;
# fi
#
# Then, if any (well almost any) other make is called, and GNU make also
# exists, then the other make wraps the GNU make.
#
# LICENSE
#
# Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
# Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@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 12
AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
[AC_PROG_AWK
AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
_cv_gnu_make_command="" ;
dnl Search all the common names for GNU make
for a in "$MAKE" make gmake gnumake ; do
if test -z "$a" ; then continue ; fi ;
if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
_cv_gnu_make_command=$a ;
AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
break ;
fi
done ;])
dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])])
AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])
AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1])
AC_SUBST([ifGNUmake])
AC_SUBST([ifnGNUmake])
])

69
m4/ax_irpf90.m4 Normal file
View File

@ -0,0 +1,69 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_irpf90.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PROG_IRPF90
#
# DESCRIPTION
#
# Check for the program 'irpf90', let script continue if exists, pops up
# error message if not.
#
# Besides checking existence, this macro also set these environment
# variables upon completion:
#
# IRPF90 = which irpf90
#
# DEPENDENCIES
#
# AX_CHECK_GNU_MAKE
#
# LICENSE
#
# Copyright (c) 2021 Anthony Scemama
#
# 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 2 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 <https://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.
AU_ALIAS([AC_PROG_IRPF90], [AX_PROG_IRPF90])
AC_DEFUN([AX_PROG_IRPF90], [
# Requirements
AC_REQUIRE([AX_CHECK_GNU_MAKE])
AS_IF([test "x$ifGNUmake" = "x#"], [ AC_MSG_ERROR([GNU Make (gmake) is required with IRPF90]) ])
# IRPF90
AC_PATH_PROG([IRPF90], [irpf90], [nocommand])
AS_IF([test "x$IRPF90" = xnocommand], [
AC_MSG_ERROR([irpf90 not found in $PATH]) ])
])

86
m4/ax_zmq.m4 Normal file
View File

@ -0,0 +1,86 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_zmq.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_ZMQ([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
# Test for the ZMQ libraries of a particular version (or newer). The
# default version tested for is 4.0.0.
#
# The macro tests for ZMQ libraries in the library/include path, and, when
# provided, also in the path given by --with-zmq.
#
# This macro calls:
#
# AC_SUBST(ZMQ_CPPFLAGS) / AC_SUBST(ZMQ_LDFLAGS) / AC_SUBST(ZMQ_LIBS)
#
# And sets:
#
# HAVE_ZMQ
#
# LICENSE
#
# Copyright (c) 2016 Jeroen Meijer <jjgmeijer@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 3
AC_DEFUN([AX_ZMQ], [
AC_ARG_WITH([zmq], [AS_HELP_STRING([--with-zmq=<prefix>],[ZMQ prefix directory])], [
ZMQ_LDFLAGS="-L${with_zmq}/lib"
ZMQ_CPPFLAGS="-I${with_zmq}/include"
])
HAVE_ZMQ=0
if test "$with_zmq" != "no"; then
LD_FLAGS="$LDFLAGS $ZMQ_LDFLAGS"
CPPFLAGS="$CPPFLAGS $ZMQ_CPPFLAGS"
AC_LANG_PUSH([C])
AC_CHECK_HEADER(zmq.h, [zmq_h=yes], [zmq_h=no])
AC_LANG_POP([C])
if test "$zmq_h" = "yes"; then
version=ifelse([$1], ,4.0.0,$1)
AC_MSG_CHECKING([for ZMQ version >= $version])
version=$(echo $version | tr '.' ',')
AC_EGREP_CPP([version_ok], [
#include <zmq.h>
#if defined(ZMQ_VERSION) && ZMQ_VERSION >= ZMQ_MAKE_VERSION($version)
version_ok
#endif
],[
AC_MSG_RESULT(yes)
HAVE_ZMQ=1
ZMQ_LIBS="-lzmq"
AC_SUBST(ZMQ_LDFLAGS)
AC_SUBST(ZMQ_CPPFLAGS)
AC_SUBST(ZMQ_LIBS)
], AC_MSG_RESULT([no valid ZMQ version was found]))
else
AC_MSG_WARN([no valid ZMQ installation was found])
fi
if test $HAVE_ZMQ = 1; then
# execute ACTION-IF-FOUND (if present):
ifelse([$2], , :, [$2])
else
# execute ACTION-IF-NOT-FOUND (if present):
ifelse([$3], , :, [$3])
fi
else
AC_MSG_NOTICE([not checking for ZMQ])
fi
AC_DEFINE(HAVE_ZMQ,,[define if the ZMQ library is available])
])