From 00a289eb8fdfbe0140de3b6afa2d81eef7ffc72f Mon Sep 17 00:00:00 2001 From: elkogerville Date: Thu, 13 Nov 2025 13:59:24 +0100 Subject: [PATCH 001/153] test file --- elko.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 elko.txt diff --git a/elko.txt b/elko.txt new file mode 100644 index 0000000000..e69de29bb2 From 4b98191e08fba9bd0f5049987c43a180ef8f8ed5 Mon Sep 17 00:00:00 2001 From: elkogerville Date: Thu, 13 Nov 2025 14:03:47 +0100 Subject: [PATCH 002/153] remove test file --- elko.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 elko.txt diff --git a/elko.txt b/elko.txt deleted file mode 100644 index e69de29bb2..0000000000 From 53becee1c4b9c16c03cd52378e2b6defc9575b48 Mon Sep 17 00:00:00 2001 From: elkogerville Date: Thu, 13 Nov 2025 16:03:57 +0100 Subject: [PATCH 003/153] created amuse_uclchem directory in amuse/src --- src/amuse_uclchem/Makefile | 130 ++ src/amuse_uclchem/__init__.py | 1 + src/amuse_uclchem/interface.f90 | 15 + src/amuse_uclchem/interface.py | 117 + .../packages/amuse-uclchem-PACKAGE.amuse_deps | 1 + .../amuse-uclchem-PACKAGE/pyproject.toml | 40 + .../packages/amuse-uclchem-PACKAGE/uclchem | 1 + .../packages/amuse-uclchem.amuse_deps | 1 + .../packages/amuse-uclchem/pyproject.toml | 47 + .../packages/amuse-uclchem/uclchem | 1 + src/amuse_uclchem/src/Makefile | 20 + src/amuse_uclchem/src/uclchem.f90 | 5 + src/amuse_uclchem/support/config.mk.in | 88 + src/amuse_uclchem/support/configure.ac | 75 + src/amuse_uclchem/support/shared/config.guess | 1812 +++++++++++++++ src/amuse_uclchem/support/shared/config.sub | 1971 +++++++++++++++++ src/amuse_uclchem/support/shared/install-sh | 541 +++++ .../support/shared/m4/amuse_conda.m4 | 36 + .../support/shared/m4/amuse_cuda.m4 | 232 ++ .../support/shared/m4/amuse_detect_os.m4 | 19 + .../support/shared/m4/amuse_download.m4 | 38 + .../support/shared/m4/amuse_lib.m4 | 138 ++ .../support/shared/m4/amuse_lib_healpix.m4 | 48 + .../support/shared/m4/amuse_lib_qhull.m4 | 30 + .../support/shared/m4/amuse_opencl.m4 | 63 + .../support/shared/m4/amuse_venv.m4 | 31 + .../support/shared/m4/ax_blas.m4 | 241 ++ .../support/shared/m4/ax_check_classpath.m4 | 61 + .../support/shared/m4/ax_check_gnu_make.m4 | 96 + .../support/shared/m4/ax_count_cpus.m4 | 101 + .../support/shared/m4/ax_lapack.m4 | 134 ++ .../support/shared/m4/ax_lib_hdf5.m4 | 323 +++ .../support/shared/m4/ax_lib_netcdf4.m4 | 277 +++ src/amuse_uclchem/support/shared/m4/ax_mpi.m4 | 235 ++ .../support/shared/m4/ax_openmp.m4 | 123 + .../support/shared/m4/ax_prog_jar.m4 | 50 + .../support/shared/m4/ax_prog_java.m4 | 116 + .../support/shared/m4/ax_prog_java_works.m4 | 92 + .../support/shared/m4/ax_prog_javac.m4 | 80 + .../support/shared/m4/ax_prog_javac_works.m4 | 73 + src/amuse_uclchem/support/shared/m4/fftw.m4 | 122 + .../support/shared/m4/fortran.m4 | 43 + src/amuse_uclchem/support/shared/m4/gmp.m4 | 103 + src/amuse_uclchem/support/shared/m4/gsl.m4 | 122 + src/amuse_uclchem/support/shared/m4/mpfr.m4 | 109 + src/amuse_uclchem/support/shared/m4/pkg.m4 | 343 +++ src/amuse_uclchem/support/shared/uninstall.sh | 51 + src/amuse_uclchem/tests/test_uclchem.py | 12 + 48 files changed, 8408 insertions(+) create mode 100644 src/amuse_uclchem/Makefile create mode 100644 src/amuse_uclchem/__init__.py create mode 100644 src/amuse_uclchem/interface.f90 create mode 100644 src/amuse_uclchem/interface.py create mode 100644 src/amuse_uclchem/packages/amuse-uclchem-PACKAGE.amuse_deps create mode 100644 src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/pyproject.toml create mode 120000 src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/uclchem create mode 100644 src/amuse_uclchem/packages/amuse-uclchem.amuse_deps create mode 100644 src/amuse_uclchem/packages/amuse-uclchem/pyproject.toml create mode 120000 src/amuse_uclchem/packages/amuse-uclchem/uclchem create mode 100644 src/amuse_uclchem/src/Makefile create mode 100644 src/amuse_uclchem/src/uclchem.f90 create mode 100644 src/amuse_uclchem/support/config.mk.in create mode 100644 src/amuse_uclchem/support/configure.ac create mode 100755 src/amuse_uclchem/support/shared/config.guess create mode 100755 src/amuse_uclchem/support/shared/config.sub create mode 100755 src/amuse_uclchem/support/shared/install-sh create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_conda.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_cuda.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_detect_os.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_download.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_lib.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_lib_healpix.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_lib_qhull.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_opencl.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/amuse_venv.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_blas.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_check_classpath.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_check_gnu_make.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_count_cpus.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_lapack.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_lib_hdf5.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_lib_netcdf4.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_mpi.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_openmp.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_prog_jar.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_prog_java.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_prog_java_works.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_prog_javac.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/ax_prog_javac_works.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/fftw.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/fortran.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/gmp.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/gsl.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/mpfr.m4 create mode 100644 src/amuse_uclchem/support/shared/m4/pkg.m4 create mode 100755 src/amuse_uclchem/support/shared/uninstall.sh create mode 100644 src/amuse_uclchem/tests/test_uclchem.py diff --git a/src/amuse_uclchem/Makefile b/src/amuse_uclchem/Makefile new file mode 100644 index 0000000000..fd24c592c0 --- /dev/null +++ b/src/amuse_uclchem/Makefile @@ -0,0 +1,130 @@ +ifneq (,$(filter-out clean distclean, $(MAKECMDGOALS))) +include support/config.mk +endif + + +# Detecting dependencies +support/config.mk: + cd support && ./configure + + +# Downloading the code +##### Remove if not needed ##### +VERSION = VERSION + +uclchem.tar.gz: + ##### Modify URL as needed ##### + $(DOWNLOAD) https://github.com/uclchem/uclchem/archive/$(VERSION).tar.gz >$@ + +PATCHES := $(shell cat patches/series) + +src/uclchem-$(VERSION): uclchem.tar.gz + ##### Modify as needed ##### + tar xf $< + mv uclchem-$(VERSION) src + ##### Apply patches here, if needed ##### + patch + # ) + pass + + def define_particle_sets(self, handler): + """Define any particle sets inside the model.""" + # handler.define_set('particles', 'index_of_the_particle') + # handler.set_new('particles', 'new_particle') + # handler.set_delete('particles', 'delete_particle') + # handler.add_setter('particles', 'set_state') + # handler.add_getter('particles', 'get_state') + # handler.add_setter('particles', 'set_mass') + # handler.add_getter('particles', 'get_mass', names=('mass',)) + pass + + def define_grids(self, handler): + """Define any grids inside the model.""" + # handler.define_grid('grid',axes_names = ["x", "y"], grid_class=StructuredGrid) + # handler.set_grid_range('grid', '_grid_range') + # handler.add_getter('grid', 'get_grid_position', names=["x", "y"]) + # handler.add_getter('grid', 'get_rho', names=["density"]) + # handler.add_setter('grid', 'set_rho', names=["density"]) + pass + + # def define_converter(self, handler): + # """Handle unit conversion if an (optional) unit converter is specified.""" + # if self.unit_converter is not None: + # handler.set_converter( + # self.unit_converter.as_converter_from_si_to_generic() + # ) diff --git a/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE.amuse_deps b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE.amuse_deps new file mode 100644 index 0000000000..e5ab274ccd --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE.amuse_deps @@ -0,0 +1 @@ +c c++ fortran java python cmake install download mpi openmp cuda opencl x11 opengl blas lapack gsl gmp mpfr fftw hdf5 netcdf4 diff --git a/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/pyproject.toml b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/pyproject.toml new file mode 100644 index 0000000000..372906f4a6 --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/pyproject.toml @@ -0,0 +1,40 @@ +[project] +name = "amuse-uclchem-PACKAGE" +dynamic = ["version"] +requires-python = ">=3.7" +dependencies = [ + "amuse-framework==2025.9.1.dev3+gce21df1cc", + "amuse-uclchem" +] + +[build-system] +requires = ["hatchling", "versioningit"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "versioningit" + +[tool.versioningit.next-version] +method = "smallest" + +[tool.versioningit.format] +distance = "{next_version}.dev{distance}+{vcs}{rev}" +dirty = "{base_version}+d{build_date:%Y%m%d}" +distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}" + +[tool.versioningit.vcs] +method = { module = "version_helper", value = "get_amuse_version", module-dir = "amuse_uclchem/support/shared" } + +[tool.hatch.build] +skip-excluded-dirs = true + +[tool.hatch.build.targets.wheel] +include = ["amuse_uclchem"] +exclude = ["amuse_uclchem/*"] +artifacts = ["amuse_uclchem/uclchem_PACKAGE_worker"] + +[tool.pytest.ini_options] +pythonpath = ["amuse_uclchem/tests/", "../../../../../tests"] + +testpaths = ["amuse_uclchem/tests"] + diff --git a/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/uclchem b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/uclchem new file mode 120000 index 0000000000..c25bddb6dd --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem-PACKAGE/uclchem @@ -0,0 +1 @@ +../.. \ No newline at end of file diff --git a/src/amuse_uclchem/packages/amuse-uclchem.amuse_deps b/src/amuse_uclchem/packages/amuse-uclchem.amuse_deps new file mode 100644 index 0000000000..e5ab274ccd --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem.amuse_deps @@ -0,0 +1 @@ +c c++ fortran java python cmake install download mpi openmp cuda opencl x11 opengl blas lapack gsl gmp mpfr fftw hdf5 netcdf4 diff --git a/src/amuse_uclchem/packages/amuse-uclchem/pyproject.toml b/src/amuse_uclchem/packages/amuse-uclchem/pyproject.toml new file mode 100644 index 0000000000..ac76648883 --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem/pyproject.toml @@ -0,0 +1,47 @@ +[project] +name = "amuse-uclchem" +version = "0.0.1" +# use the line below instead of the version above if this code is inside the AMUSE +# repository +# dynamic = ["version"] +requires-python = ">=3.7" +dependencies = [ + "amuse-framework==2025.9.1.dev3+gce21df1cc" +] + +[build-system] +requires = ["hatchling", "versioningit"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "versioningit" + +[tool.versioningit.next-version] +method = "smallest" + +[tool.versioningit.format] +distance = "{next_version}.dev{distance}+{vcs}{rev}" +dirty = "{base_version}+d{build_date:%Y%m%d}" +distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}" + +[tool.versioningit.vcs] +method = { module = "version_helper", value = "get_amuse_version", module-dir = "amuse_uclchem/support/shared" } + +[tool.hatch.build] +skip-excluded-dirs = true + +[tool.hatch.build.targets.wheel] +include = ["amuse_uclchem/**/*.py"] +exclude = [ + "amuse_uclchem/packages", + "amuse_uclchem/support", + "amuse_uclchem/src", + "amuse_uclchem/tests" + ] +artifacts = ["amuse_uclchem/uclchem_worker"] + +[tool.pytest.ini_options] +pythonpath = ["amuse_uclchem/tests/"] + +testpaths = ["amuse_uclchem/tests"] + diff --git a/src/amuse_uclchem/packages/amuse-uclchem/uclchem b/src/amuse_uclchem/packages/amuse-uclchem/uclchem new file mode 120000 index 0000000000..c25bddb6dd --- /dev/null +++ b/src/amuse_uclchem/packages/amuse-uclchem/uclchem @@ -0,0 +1 @@ +../.. \ No newline at end of file diff --git a/src/amuse_uclchem/src/Makefile b/src/amuse_uclchem/src/Makefile new file mode 100644 index 0000000000..a0c44a85fa --- /dev/null +++ b/src/amuse_uclchem/src/Makefile @@ -0,0 +1,20 @@ +CODELIB = libuclchem.a + +CODEOBJS = uclchem.o + + +all: $(CODELIB) + +clean: + rm -f *.o *.a *.mod + +distclean: clean + +$(CODELIB): $(CODEOBJS) + rm -f $@ + $(AR) -ruv $@ $(CODEOBJS) + $(RANLIB) $@ + +%.o: %.f90 + $(FC) $(FCFLAGS) -c -o $@ $< + diff --git a/src/amuse_uclchem/src/uclchem.f90 b/src/amuse_uclchem/src/uclchem.f90 new file mode 100644 index 0000000000..9f2dd93c3d --- /dev/null +++ b/src/amuse_uclchem/src/uclchem.f90 @@ -0,0 +1,5 @@ +function echo(input) + integer echo, input + echo = input +end function + diff --git a/src/amuse_uclchem/support/config.mk.in b/src/amuse_uclchem/support/config.mk.in new file mode 100644 index 0000000000..528ac0bf45 --- /dev/null +++ b/src/amuse_uclchem/support/config.mk.in @@ -0,0 +1,88 @@ +# Compilers +FC = @FC@ +MPIFC = @MPIFC@ + +CPU_COUNT = @CPU_COUNT@ + +# Tools +AR = @AR@ +RANLIB = @RANLIB@ + +# DOWNLOAD = @DOWNLOAD@ +# TAR = @TAR@ +# UNZIP = @UNZIP@ +# GUNZIP = @GUNZIP@ +# BUNZIP2 = @BUNZIP2@ +# UNXZ = @UNXZ@ +# PERL = @PERL@ + + +# AMUSE framework libraries +# STOPCOND_CFLAGS = @STOPCOND_CFLAGS@ +# STOPCOND_LIBS = @STOPCOND_LIBS@ + +# STOPCONDMPI_CFLAGS = @STOPCONDMPI_CFLAGS@ +# STOPCONDMPI_LIBS = @STOPCONDMPI_LIBS@ + +# AMUSE_MPI_CFLAGS = @AMUSE_MPI_CFLAGS@ +# AMUSE_MPI_LIBS = @AMUSE_MPI_LIBS@ + +FORSOCKETS_CFLAGS = @FORSOCKETS_CFLAGS@ +FORSOCKETS_LIBS = @FORSOCKETS_LIBS@ + +# SIMPLE_HASH_CFLAGS = @SIMPLE_HASH_CFLAGS@ +# SIMPLE_HASH_LIBS = @SIMPLE_HASH_LIBS@ + +# G6LIB_CFLAGS = @G6LIB_CFLAGS@ +# G6LIB_LIBS = @G6LIB_LIBS@ + + +# External dependencies +# OPENMP_FCFLAGS = @OPENMP_FCFLAGS@ + +# CUDA_TK = @CUDA_TK@ +# NVCC = @NVCC@ +# CUDA_FLAGS = @CUDA_FLAGS@ +# CUDA_LDFLAGS = @CUDA_LDFLAGS@ + +# FOUND_CL = @FOUND_CL@ +# CL_CFLAGS = @CL_CFLAGS@ +# CL_LIBS = @CL_LIBS@ +# HAVE_CL_CL_H = @HAVE_CL_CL_H@ +# HAVE_OPENCL_CL_H = @HAVE_OPENCL_CL_H@ + +# BLAS_LIBS = @BLAS_LIBS@ +# LAPACK_LIBS = @LAPACK_LIBS@ +# FLIBS = @FLIBS@ + +# GSL_FLAGS = @GSL_FLAGS@ +# GSL_LIBS = @GSL_LIBS@ + +# FOUND_GMP= @FOUND_GMP@ +# GMP_FLAGS = @GMP_FLAGS@ +# GMP_LIBS = @GMP_LIBS@ + +# FOUND_MPFR = @FOUND_MPFR@ +# MPFR_FLAGS = @MPFR_FLAGS@ +# MPFR_LIBS = @MPFR_LIBS@ + +# FOUND_FFTW = @FOUND_FFTW@ +# FFTW_FLAGS = @FFTW_FLAGS@ +# FFTW_LIBS = @FFTW_LIBS@ + +# HDF5_VERSION = @HDF5_VERSION@ +# HDF5_CPPFLAGS = @HDF5_CPPFLAGS@ +# HDF5_FFLAGS = @HDF5_FFLAGS@ +# HDF5_LDFLAGS = @HDF5_LDFLAGS@ +# HDF5_LIBS = @HDF5_LIBS@ +# HDF5_FLIBS = @HDF5_FLIBS@ + +# NETCDF4_VERSION = @NETCDF4_VERSION@ +# NETCDF4_FFLAGS = @NETCDF4_FFLAGS@ +# NETCDF4_LDFLAGS = @NETCDF4_LDFLAGS@ +# NETCDF4_LIBS = @NETCDF4_LIBS@ +# NETCDF4_FLIBS = @NETCDF4_FLIBS@ + +# SAPPORO_LIGHT_CFLAGS = @SAPPORO_LIGHT_CFLAGS@ +# SAPPORO_LIGHT_LIBS = @SAPPORO_LIGHT_LIBS@ + diff --git a/src/amuse_uclchem/support/configure.ac b/src/amuse_uclchem/support/configure.ac new file mode 100644 index 0000000000..986ef35db0 --- /dev/null +++ b/src/amuse_uclchem/support/configure.ac @@ -0,0 +1,75 @@ +AC_CONFIG_AUX_DIR([shared]) +AC_CONFIG_MACRO_DIRS([shared/m4]) + +AC_INIT([amuse-uclchem], [1.0]) + +# Pick up Conda env or virtualenv +AMUSE_VENV() + +# Set CPU_COUNT +AX_COUNT_CPUS() +AC_SUBST(CPU_COUNT) + +# Find the compiler(s) +AC_PROG_FC() +AX_FC_ISO_C_BINDING() + +# Find tools for creating static libraries +AC_CHECK_TARGET_TOOL([AR], [ar], [:]) +AS_IF([test $AR = ":"], [AC_MSG_ERROR([ar command not found.])]) + +AC_PROG_RANLIB() +AS_IF([test $RANLIB = ":"], [AC_MSG_ERROR([ranlib command not found.])]) + + +# Find tools to download and unpack with +# AMUSE_DOWNLOAD() +# AC_CHECK_TOOL(TAR, tar) +# AC_CHECK_TOOL(UNZIP, unzip) +# AC_CHECK_TOOL(GUNZIP, gunzip) +# AC_CHECK_TOOL(BUNZIP2, bunzip2) +# AC_CHECK_TOOL(UNXZ, unxz) +# AC_CHECK_TOOL(PERL, perl) + + +# Find AMUSE libraries +# AMUSE_LIB_STOPCOND() +# AMUSE_LIB_STOPCONDMPI() +# AMUSE_LIB_AMUSE_MPI() +AMUSE_LIB_FORSOCKETS() +# AMUSE_LIB_SIMPLE_HASH() +# AMUSE_LIB_G6LIB() +# AMUSE_LIB_SAPPORO_LIGHT() + + +# Find external dependencies +AC_LANG_PUSH([Fortran]) + +##### MPI is always needed to build the worker ##### +AX_MPI() + +##### Remove anything not needed by the code ##### + +# AC_OPENMP() +# AC_SUBST(OPENMP_FCFLAGS) + +# AMUSE_CUDA() +# AMUSE_OPENCL() + +# AX_LAPACK() # calls AX_BLAS automatically +# AX_PATH_GSL(1.0, [FOUND_GSL=yes]) +# AX_GMP() +# AX_MPFR() +# AX_FFTW() +# AX_LIB_HDF5() +# AX_LIB_NETCDF4() + +##### End remove anything not needed by the code ##### + +AC_LANG_POP([Fortran]) + + +# Generate output +AC_CONFIG_FILES([config.mk]) +AC_OUTPUT + diff --git a/src/amuse_uclchem/support/shared/config.guess b/src/amuse_uclchem/support/shared/config.guess new file mode 100755 index 0000000000..f6d217a49f --- /dev/null +++ b/src/amuse_uclchem/support/shared/config.guess @@ -0,0 +1,1812 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2024 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2024-01-01' + +# This file 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 . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess +# +# Please send patches to . + + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system '$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2024 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try '$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +# Just in case it came from the environment. +GUESS= + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if test -f /.attbin/uname ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case $UNAME_SYSTEM in +Linux|GNU|GNU/*) + LIBC=unknown + + set_cc_for_build + cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #elif defined(__GLIBC__) + LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif + #endif + #endif + EOF + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)` + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case $UNAME_MACHINE_ARCH in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case $UNAME_VERSION in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + GUESS=$machine-${os}${release}${abi-} + ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; + *:ekkoBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; + *:SolidBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; + macppc:MirBSD:*:*) + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; + *:MirBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; + *:Sortix:*:*) + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; + alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case $ALPHA_CPU_TYPE in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; + Amiga*:UNIX_System_V:4.0:*) + GUESS=m68k-unknown-sysv4 + ;; + *:[Aa]miga[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; + *:[Mm]orph[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-morphos + ;; + *:OS/390:*:*) + GUESS=i370-ibm-openedition + ;; + *:z/VM:*:*) + GUESS=s390-ibm-zvmoe + ;; + *:OS400:*:*) + GUESS=powerpc-ibm-os400 + ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + GUESS=arm-unknown-riscos + ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + GUESS=hppa1.1-hitachi-hiuxmpp + ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; + NILE*:*:*:dcosx) + GUESS=pyramid-pyramid-svr4 + ;; + DRS?6000:unix:4.0:6*) + GUESS=sparc-icl-nx6 + ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; + s390x:SunOS:*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; + sun4H:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; + sun4*:SunOS:*:*) + case `/usr/bin/arch -k` in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like '4.1.3-JL'. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; + sun3*:SunOS:*:*) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in + sun3) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun4) + GUESS=sparc-sun-sunos$UNAME_RELEASE + ;; + esac + ;; + aushp:SunOS:*:*) + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; + m68k:machten:*:*) + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; + powerpc:machten:*:*) + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; + RISC*:Mach:*:*) + GUESS=mips-dec-mach_bsd4.3 + ;; + RISC*:ULTRIX:*:*) + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; + VAX*:ULTRIX*:*:*) + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; + Motorola:PowerMAX_OS:*:*) + GUESS=powerpc-motorola-powermax + ;; + Motorola:*:4.3:PL8-*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:Power_UNIX:*:*) + GUESS=powerpc-harris-powerunix + ;; + m88k:CX/UX:7*:*) + GUESS=m88k-harris-cxux7 + ;; + m88k:*:4*:R4*) + GUESS=m88k-motorola-sysv4 + ;; + m88k:*:3*:R3*) + GUESS=m88k-motorola-sysv3 + ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 + then + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x + then + GUESS=m88k-dg-dgux$UNAME_RELEASE + else + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE + fi + else + GUESS=i586-dg-dgux$UNAME_RELEASE + fi + ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + GUESS=m88k-dolphin-sysv3 + ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + GUESS=m88k-motorola-sysv3 + ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + GUESS=m88k-tektronix-sysv3 + ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + GUESS=m68k-tektronix-bsd + ;; + *:IRIX*:*:*) + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + GUESS=i386-ibm-aix + ;; + ia64:AIX:*:*) + if test -x /usr/bin/oslevel ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + GUESS=$SYSTEM_NAME + else + GUESS=rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + GUESS=rs6000-ibm-aix3.2.4 + else + GUESS=rs6000-ibm-aix3.2 + fi + ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; + *:AIX:*:*) + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + GUESS=rs6000-bull-bosx + ;; + DPX/2?00:B.O.S.:*:*) + GUESS=m68k-bull-sysv3 + ;; + 9000/[34]??:4.3bsd:1.*:*) + GUESS=m68k-hp-bsd + ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + GUESS=m68k-hp-bsd4.4 + ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if test -x /usr/bin/getconf; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if test "$HP_ARCH" = hppa2.0w + then + set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; + 3050*:HI-UX:*:*) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; + 9000/8??:4.3bsd:*:*) + GUESS=hppa1.0-hp-bsd + ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; + hp8??:OSF1:*:*) + GUESS=hppa1.0-hp-osf + ;; + i*86:OSF1:*:*) + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk + else + GUESS=$UNAME_MACHINE-unknown-osf1 + fi + ;; + parisc*:Lites*:*:*) + GUESS=hppa1.1-hp-lites + ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + GUESS=c1-convex-bsd + ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + GUESS=c34-convex-bsd + ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + GUESS=c38-convex-bsd + ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + GUESS=c4-convex-bsd + ;; + CRAY*Y-MP:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; + CRAY*T3E:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; + CRAY*SV1:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; + *:UNICOS/mp:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; + sparc*:BSD/OS:*:*) + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; + *:BSD/OS:*:*) + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; + i*:CYGWIN*:*) + GUESS=$UNAME_MACHINE-pc-cygwin + ;; + *:MINGW64*:*) + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; + *:MINGW*:*) + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; + *:MSYS*:*) + GUESS=$UNAME_MACHINE-pc-msys + ;; + i*:PW*:*) + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; + *:Interix*:*) + case $UNAME_MACHINE in + x86) + GUESS=i586-pc-interix$UNAME_RELEASE + ;; + authenticamd | genuineintel | EM64T) + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; + IA64) + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; + esac ;; + i*:UWIN*:*) + GUESS=$UNAME_MACHINE-pc-uwin + ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + GUESS=x86_64-pc-cygwin + ;; + prep*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; + *:GNU:*:*) + # the GNU system + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; + aarch64:Linux:*:*) + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI + ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arm*:Linux:*:*) + set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi + else + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf + fi + fi + ;; + avr32*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + cris:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + crisv32:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + e2k:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + frv:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + hexagon:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:Linux:*:*) + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; + ia64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + k1om:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m32r*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m68*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + mips:Linux:*:* | mips64:Linux:*:*) + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + MIPS_ENDIAN=el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + MIPS_ENDIAN= + #else + MIPS_ENDIAN= + #endif + #endif +EOF + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + openrisc*:Linux:*:*) + GUESS=or1k-unknown-linux-$LIBC + ;; + or32:Linux:*:* | or1k*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + padre:Linux:*:*) + GUESS=sparc-unknown-linux-$LIBC + ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + GUESS=hppa64-unknown-linux-$LIBC + ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; + esac + ;; + ppc64:Linux:*:*) + GUESS=powerpc64-unknown-linux-$LIBC + ;; + ppc:Linux:*:*) + GUESS=powerpc-unknown-linux-$LIBC + ;; + ppc64le:Linux:*:*) + GUESS=powerpc64le-unknown-linux-$LIBC + ;; + ppcle:Linux:*:*) + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + s390:Linux:*:* | s390x:Linux:*:*) + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; + sh64*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sh*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + tile*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + vax:Linux:*:*) + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; + x86_64:Linux:*:*) + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; + xtensa*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + GUESS=i386-sequent-sysv4 + ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; + i*86:OS/2:*:*) + # If we were able to find 'uname', then EMX Unix compatibility + # is probably installed. + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; + i*86:XTS-300:*:STOP) + GUESS=$UNAME_MACHINE-unknown-stop + ;; + i*86:atheos:*:*) + GUESS=$UNAME_MACHINE-unknown-atheos + ;; + i*86:syllable:*:*) + GUESS=$UNAME_MACHINE-pc-syllable + ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; + i*86:*DOS:*:*) + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL + fi + ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv32 + fi + ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + GUESS=i586-pc-msdosdjgpp + ;; + Intel:Mach:3*:*) + GUESS=i386-pc-mach3 + ;; + paragon:*:*:*) + GUESS=i860-intel-osf1 + ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 + fi + ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + GUESS=m68010-convergent-sysv + ;; + mc68k:UNIX:SYSTEM5:3.51m) + GUESS=m68k-convergent-sysv + ;; + M680?0:D-NIX:5.3:*) + GUESS=m68k-diab-dnix + ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; + mc68030:UNIX_System_V:4.*:*) + GUESS=m68k-atari-sysv4 + ;; + TSUNAMI:LynxOS:2.*:*) + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; + rs6000:LynxOS:2.*:*) + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; + SM[BE]S:UNIX_SV:*:*) + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; + RM*:ReliantUNIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + RM*:SINIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + GUESS=$UNAME_MACHINE-sni-sysv4 + else + GUESS=ns32k-sni-sysv + fi + ;; + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort + # says + GUESS=i586-unisys-sysv4 + ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + GUESS=hppa1.1-stratus-sysv4 + ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + GUESS=i860-stratus-sysv4 + ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=$UNAME_MACHINE-stratus-vos + ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=hppa1.1-stratus-vos + ;; + mc68*:A/UX:*:*) + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; + news*:NEWS-OS:6*:*) + GUESS=mips-sony-newsos6 + ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE + else + GUESS=mips-unknown-sysv$UNAME_RELEASE + fi + ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + GUESS=powerpc-be-beos + ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + GUESS=powerpc-apple-beos + ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + GUESS=i586-pc-beos + ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; + SX-4:SUPER-UX:*:*) + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; + SX-5:SUPER-UX:*:*) + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; + SX-6:SUPER-UX:*:*) + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; + SX-7:SUPER-UX:*:*) + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; + SX-8:SUPER-UX:*:*) + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; + SX-8R:SUPER-UX:*:*) + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; + SX-ACE:SUPER-UX:*:*) + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; + Power*:Rhapsody:*:*) + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; + *:Rhapsody:*:*) + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build + fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE + fi + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; + *:QNX:*:4*) + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; + NSE-*:NONSTOP_KERNEL:*:*) + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; + *:NonStop-UX:*:*) + GUESS=mips-compaq-nonstopux + ;; + BS2000:POSIX*:*:*) + GUESS=bs2000-siemens-sysv + ;; + DS/*:UNIX_System_V:*:*) + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "${cputype-}" = 386; then + UNAME_MACHINE=i386 + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype + fi + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; + *:TOPS-10:*:*) + GUESS=pdp10-unknown-tops10 + ;; + *:TENEX:*:*) + GUESS=pdp10-unknown-tenex + ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + GUESS=pdp10-dec-tops20 + ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + GUESS=pdp10-xkl-tops20 + ;; + *:TOPS-20:*:*) + GUESS=pdp10-unknown-tops20 + ;; + *:ITS:*:*) + GUESS=pdp10-unknown-its + ;; + SEI:*:*:SEIUX) + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; + *:DragonFly:*:*) + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; + esac ;; + *:XENIX:*:SysV) + GUESS=i386-pc-xenix + ;; + i*86:skyos:*:*) + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; + i*86:rdos:*:*) + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; + x86_64:VMkernel:*:*) + GUESS=$UNAME_MACHINE-unknown-esx + ;; + amd64:Isilon\ OneFS:*:*) + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF +fi + +exit 1 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/amuse_uclchem/support/shared/config.sub b/src/amuse_uclchem/support/shared/config.sub new file mode 100755 index 0000000000..2c6a07ab3c --- /dev/null +++ b/src/amuse_uclchem/support/shared/config.sub @@ -0,0 +1,1971 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2024 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2024-01-01' + +# This file 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 . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2024 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try '$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 + ;; + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 + ;; + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ + | windows-* ) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac + ;; + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac + ;; + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac + ;; +esac + +# Decode 1-component or ad-hoc basic machines +case $basic_machine in + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond + ;; + op50n) + cpu=hppa1.1 + vendor=oki + ;; + op60c) + cpu=hppa1.1 + vendor=oki + ;; + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + basic_os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + basic_os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + basic_os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $basic_os in + irix*) + ;; + *) + basic_os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + basic_os=nextstep2 + ;; + *) + basic_os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + basic_os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf + ;; + none) + cpu=none + vendor=none + ;; + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine + ;; + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` + ;; + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <&2 + exit 1 + ;; + esac + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $vendor in + digital*) + vendor=dec + ;; + commodore*) + vendor=cbm + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if test x"$basic_os" != x +then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +obj= +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <&2 + fi + ;; + *) + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) + ;; + uclinux-uclibc*- ) + ;; + managarm-mlibc*- | managarm-kernel*- ) + ;; + windows*-msvc*-) + ;; + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 + exit 1 + ;; + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 + ;; + kfreebsd*-gnu*- | kopensolaris*-gnu*-) + ;; + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) + ;; + nto-qnx*-) + ;; + os2-emx-) + ;; + *-eabi*- | *-gnueabi*-) + ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) + # Blank kernel with real OS is always fine. + ;; + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 + exit 1 + ;; +esac + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) + vendor=acorn + ;; + *-sunos*) + vendor=sun + ;; + *-cnk* | *-aix*) + vendor=ibm + ;; + *-beos*) + vendor=be + ;; + *-hpux*) + vendor=hp + ;; + *-mpeix*) + vendor=hp + ;; + *-hiux*) + vendor=hitachi + ;; + *-unos*) + vendor=crds + ;; + *-dgux*) + vendor=dg + ;; + *-luna*) + vendor=omron + ;; + *-genix*) + vendor=ns + ;; + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) + vendor=ibm + ;; + s390-* | s390x-*) + vendor=ibm + ;; + *-ptx*) + vendor=sequent + ;; + *-tpf*) + vendor=ibm + ;; + *-vxsim* | *-vxworks* | *-windiss*) + vendor=wrs + ;; + *-aux*) + vendor=apple + ;; + *-hms*) + vendor=hitachi + ;; + *-mpw* | *-macos*) + vendor=apple + ;; + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) + vendor=atari + ;; + *-vos*) + vendor=stratus + ;; + esac + ;; +esac + +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" +exit + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/amuse_uclchem/support/shared/install-sh b/src/amuse_uclchem/support/shared/install-sh new file mode 100755 index 0000000000..ec298b5374 --- /dev/null +++ b/src/amuse_uclchem/support/shared/install-sh @@ -0,0 +1,541 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2020-11-14.01; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + +backupsuffix= +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. + -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG + +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. + +If -S is not specified, no backups are attempted. + +Email bug reports to bug-automake@gnu.org. +Automake home page: https://www.gnu.org/software/automake/ +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -p) cpprog="$cpprog -p";; + + -s) stripcmd=$stripprog;; + + -S) backupsuffix="$2" + shift;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/amuse_uclchem/support/shared/m4/amuse_conda.m4 b/src/amuse_uclchem/support/shared/m4/amuse_conda.m4 new file mode 100644 index 0000000000..f015fa7dab --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_conda.m4 @@ -0,0 +1,36 @@ +# AMUSE_CONDA_LIST() +# +# Runs conda list and saves the result in amuse_conda_list. +# The conda list command is rather slow, so we can avoid an annoying wait by running +# it once and saving the output for use with AMUSE_CONDA_PACKAGE below. +# +# Note that we can't save newlines in a shell variable, so we're replacing them with +# circumflexes instead. We change them back below before grepping. +AC_DEFUN([AMUSE_CONDA_LIST],[ + amuse_conda_list="$(conda list | tr '\n' '^')" +]) + + +# AMUSE_CONDA_PACKAGE(VARIABLE, NAME, VALUE) +# +# Checks that the given package is installed in the active conda environment. +# +# You must run AMUSE_CONDA_LIST() before calling this macro. +# +# Sets $VARIABLE to VALUE if the package was found, or "yes" if VALUE is not passed. +AC_DEFUN([AMUSE_CONDA_PACKAGE],[ + AC_MSG_CHECKING([for conda package $2]) + ax_conda_package_line="$(echo $amuse_conda_list | tr '^' '\n' | grep '^$2 ')" + AS_IF([test "$?" = "0"], [ + # $1="$(AS_ECHO("$ax_conda_package_line") | tr -s ' ' | cut -f 2 -d ' ')" + m4_if([$3],[], [ + $1="yes" + ], [ + $1="$3" + ]) + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_cuda.m4 b/src/amuse_uclchem/support/shared/m4/amuse_cuda.m4 new file mode 100644 index 0000000000..1da58a131e --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_cuda.m4 @@ -0,0 +1,232 @@ +# AMUSE_CUDA_VERIFY_HEADERS(PATH) +# +# Checks that the given path contains a CUDA installation with include/cuda.h. +# +# Sets amuse_cuda_verify_FLAGS to -I/path/to/cuda/include if successful. +AC_DEFUN([AMUSE_CUDA_VERIFY_HEADERS], [ + AS_IF([test "x$1" = x], [ + amuse_cuda_verify_msg="for cuda.h" + amuse_cuda_flags= + ], [ + amuse_cuda_verify_msg="for cuda.h in $1/include" + amuse_cuda_flags="-I$1/include" + ]) + + AC_MSG_CHECKING([$amuse_cuda_verify_msg]) + amuse_cuda_verify_FLAGS= + + ax_save_CFLAGS="$CFLAGS" + + CFLAGS="$amuse_cuda_flags" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ])], [ + amuse_cuda_verify_FLAGS="$CFLAGS" + amuse_cuda_verify_headers_found="yes" + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$ax_save_CFLAGS" +]) + +# AMUSE_CUDA_VERIFY_LIBS(PATH) +# +# Checks that the given path contains a CUDA installation with lib/libcudart.so or +# lib64/libcudart.so. +# +# Sets amuse_cuda_verify_LDFLAGS to -L/path/to/cuda/lib{64} if successful. +AC_DEFUN([AMUSE_CUDA_VERIFY_LIBS], [ + AS_IF([test "x$1" = x], [ + amuse_cuda_verify_msg="for libcudart" + amuse_cuda_ldflags= + ], [ + amuse_cuda_verify_msg="for libcudart in $1/lib" + amuse_cuda_verify_msg64="for libcudart in $1/lib64" + amuse_cuda_ldflags="-L$1/lib" + amuse_cuda_ldflags64="-L$1/lib64" + ]) + + AC_MSG_CHECKING([$amuse_cuda_verify_msg]) + amuse_cuda_verify_LDFLAGS= + + ax_save_LDFLAGS="$LDFLAGS" + ax_save_LIBS="$LIBS" + + LDFLAGS="$amuse_cuda_ldflags" + LIBS="-lcudart" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [cudaFree(0);])], [ + amuse_cuda_verify_LDFLAGS="$LDFLAGS" + amuse_cuda_verify_libs_found="yes" + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + + AS_IF([test "x$amuse_cuda_verify_libs_found" = x], [ + AC_MSG_CHECKING([$amuse_cuda_verify_msg64]) + LDFLAGS="$amuse_cuda_ldflags64" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [cudaFree(0);])], [ + amuse_cuda_verify_LDFLAGS="$LDFLAGS" + amuse_cuda_verify_libs_found="yes" + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + ]) + + LIBS="$ax_save_LIBS" + LDFLAGS="$ax_save_LDFLAGS" +]) + +# AMUSE_CUDA_VERIFY_SET_VARS(CUDA_TK) +# +# Sets CUDA_TK, NVCC, CUDA_FLAGS and CUDA_LDFLAGS from the internal values, if all +# of them have been found. +AC_DEFUN([AMUSE_CUDA_VERIFY_SET_VARS], [ + AS_IF( + [test \(x"$amuse_cuda_verify_NVCC" != x\) -a \(x"$amuse_cuda_verify_headers_found" != x\) -a \(x"$amuse_cuda_verify_libs_found" != x\)], + [ + CUDA_TK="$1" + NVCC="$amuse_cuda_verify_NVCC" + CUDA_FLAGS="$amuse_cuda_verify_FLAGS" + CUDA_LDFLAGS="$amuse_cuda_verify_LDFLAGS" + ] + ) +]) + +# AMUSE_CUDA_VERIFY(PATH) +# +# Checks that the given path contains a CUDA installation with bin/nvcc, +# lib/libcudart.so, and include/cuda.h. +# +# Sets CUDA_TK= if successful, and if successful also sets NVCC to the location +# of nvcc, CUDA_LDFLAGS to -L/path/to/cuda/libs, and CUDA_FLAGS to +# -I/path/to/cuda/include. +AC_DEFUN([AMUSE_CUDA_VERIFY], [ + amuse_cuda_verify_headers_found= + amuse_cuda_verify_libs_found= + + AS_IF([test -d $1], [ + AC_PATH_PROG([amuse_cuda_verify_NVCC], [nvcc], [], [$1/bin]) + + AS_IF([test x"$amuse_cuda_verify_NVCC" != x], [ + AMUSE_CUDA_VERIFY_HEADERS([$1]) + ]) + + AS_IF([test x"$amuse_cuda_verify_headers_found" != x], [ + AMUSE_CUDA_VERIFY_LIBS([$1]) + ]) + + AMUSE_CUDA_VERIFY_SET_VARS([$1]) + ], [ + AC_MSG_NOTICE([$1 does not exist or is not a directory, CUDA not found there]) + ]) +]) + +# AMUSE_CUDA_VERIFY_DEFAULT() +# +# Checks for NVCC on the PATH, then finds the CUDA directory from there. +# +# Sets CUDA_TK= if successful, and if successful also sets NVCC to the location +# of nvcc, CUDA_LDFLAGS to -L/path/to/cuda/libs, and CUDA_FLAGS to +# -I/path/to/cuda/include. +AC_DEFUN([AMUSE_CUDA_VERIFY_DEFAULT], [ + AC_PATH_PROG([amuse_cuda_verify_NVCC], [nvcc]) + + AS_IF([test x"$amuse_cuda_verify_NVCC" != x], [ + # Got nvcc, verify that we have the rest too + amuse_cuda_verify_ctk_rel=$(dirname -- "$amuse_cuda_verify_NVCC")/.. + # Canonicalise path portably so that it looks nicer + amuse_cuda_verify_CUDA_TK=$(test -d "$amuse_cuda_verify_ctk_rel" && CDPATH= cd -P -- "$amuse_cuda_verify_ctk_rel" && pwd -P) + + AS_IF([test x"$amuse_cuda_verify_NVCC" != x], [ + AMUSE_CUDA_VERIFY_HEADERS() + ]) + + AS_IF([test x"$amuse_cuda_verify_headers_found" != x], [ + AMUSE_CUDA_VERIFY_LIBS() + ]) + + AMUSE_CUDA_VERIFY_SET_VARS([$amuse_cuda_verify_CUDA_TK]) + ], [ + AC_MSG_NOTICE([Could not find CUDA via PATH]) + ]) +]) + +# AMUSE_CUDA +# ---------------------------------------------------------- +# set up for CUDA +# +# will set: +# +# CUDA_TK +# NVCC +# +# CUDA_LDFLAGS (with -L/path/to/cuda/lib) +# CUDA_FLAGS (with -I/path/to/cuda/include) +# +# and call AC_SUBST on them. +# +AC_DEFUN([AMUSE_CUDA], [ + AC_LANG_PUSH([C]) + AS_IF([test x"$CUDA_TK" != x], [ + # User set CUDA_TK, verify and use it if it works + AMUSE_CUDA_VERIFY($CUDA_TK) + + AS_IF([test x"$NVCC" = x], [ + AC_MSG_ERROR([CUDA_TK is set, but there is no nvcc in $CUDA_TK/bin. Please set CUDA_TK to the CUDA installation directory, or unset it to autodetect.]) + ]) + ], [ + # CUDA_TK not set, try to discover CUDA via PATH + AMUSE_CUDA_VERIFY_DEFAULT() + + # Not in PATH, try default directory + AS_IF([test x"$CUDA_TK" = x], [ + AMUSE_CUDA_VERIFY([/usr/local/cuda]) + ]) + + # Try /usr/local/cuda-#.#, but only if there's exactly one match + AS_IF([test x"$CUDA_TK" = x], [ + # List CUDA installations + amuse_cuda_installs=$(ls -1 -d /usr/local/cuda-*.* 2>/dev/null) + # If there's more than one, the above will have newlines, and change when we do this + amuse_cuda_installs2=$(echo "x${amuse_cuda_installs}" | tr -d '[:space:]') + AS_IF([test "x${amuse_cuda_installs}" != x], [ + AS_IF([test "x${amuse_cuda_installs}" = "${amuse_cuda_installs2}"], [ + # Here, there's exactly one match + AMUSE_CUDA_VERIFY([$amuse_cuda_installs]) + ], [ + AC_MSG_NOTICE([Multiple CUDA installations found in /usr/local, without a /usr/local/cuda symlink. Please set CUDA_TK to specify which one you want to use.]) + ]) + ], [ + AC_MSG_NOTICE([No CUDA installations found in /usr/local]) + ]) + ]) + + # Try some other locations + for dir in /opt/cuda /usr/local/cuda/cuda /opt/cuda/cuda ; do + AS_IF([test x"$CUDA_TK" = x], [ + AMUSE_CUDA_VERIFY([$dir]) + ]) + done + + # These directories were checked by the old macro, but they're highly obsolete + # so we're not trying them anymore: + # /usr/lib/nvidia, /usr/include/nvidia, /usr/lib/nvidia-current, /usr/include/nvidia-current + + AS_IF([test x"$CUDA_TK" = x], [ + AC_MSG_NOTICE([CUDA not found. Set CUDA_TK if you have it in an odd location.]) + ]) + ]) + + AS_IF([test x"$CUDA_TK" != x], [ + AC_MSG_NOTICE([CUDA found at $CUDA_TK]) + AC_SUBST(CUDA_TK) + AC_SUBST(NVCC) + AC_SUBST(CUDA_FLAGS) + AC_SUBST(CUDA_LDFLAGS) + ]) + + AC_LANG_POP([C]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_detect_os.m4 b/src/amuse_uclchem/support/shared/m4/amuse_detect_os.m4 new file mode 100644 index 0000000000..ad5375e7b2 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_detect_os.m4 @@ -0,0 +1,19 @@ +# Macro for detecting the platform we're on +# +# Sets AMUSE_ON_MACOS if we're on macOS, or AMUSE_ON_LINUX if we're on GNU/Linux. +AC_DEFUN([AMUSE_DETECT_OS], [ + AC_CANONICAL_TARGET + if test "x$target_os" == "xlinux-gnu" + then + AMUSE_ON_LINUX=1 + fi + + if test "x$target_vendor" == "xapple" + then + AMUSE_ON_MACOS=1 + fi + + AC_SUBST([AMUSE_ON_LINUX]) + AC_SUBST([AMUSE_ON_MACOS]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_download.m4 b/src/amuse_uclchem/support/shared/m4/amuse_download.m4 new file mode 100644 index 0000000000..6cd03aee6f --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_download.m4 @@ -0,0 +1,38 @@ +# Helper macros for detecting download tools +# +# Some of the community codes aren't included with AMUSE, but are downloaded at build +# time. We need a tool for that, and here is where we find one. +# +# AMUSE_DOWNLOAD() +# +# Searches for a download tool. Two popular and commonly available command line +# download tools are curl and wget. This macro tries to find either one of them +# and sets DOWNLOAD to a command that will take a URL and download its contents to +# standard output. This makes it easier to write that output to a file with a known +# name, which you usually want in a Makefile. +# +# To download a file, use $(DOWNLOAD) https://example.com >example.html +# +AC_DEFUN([AMUSE_DOWNLOAD], [ + AC_CHECK_TOOL(WGET, wget) + AC_CHECK_TOOL(CURL, curl) + + AC_MSG_CHECKING([for a wget or curl to download files with]) + if test "x$WGET" != "x" + then + # The MESA SDK server rejects wget, this is the official work-around + DOWNLOAD="$WGET --progress=bar:force:noscroll --user-agent='' -O -" + AC_MSG_RESULT([yes]) + else + if test "x$CURL" != "x" + then + DOWNLOAD="$CURL -L" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + fi + + AC_SUBST([DOWNLOAD]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_lib.m4 b/src/amuse_uclchem/support/shared/m4/amuse_lib.m4 new file mode 100644 index 0000000000..a378d8de44 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_lib.m4 @@ -0,0 +1,138 @@ +# Helper macros for detecting AMUSE libraries. +# +# See https://stackoverflow.com/questions/10220946/pkg-check-modules-considered-harmful +# for some background on why we're not using PKG_CHECK_MODULES directly. Do note that +# PKG_CHECK_MODULES checks for pkg-config and gives a useful error these days, so that +# that page is partially outdated. + +# AMUSE_LIB(prefix, module, library, function) +# +# Searches for an AMUSE library and sets ${prefix}_CFLAGS, ${prefix}_LIBS to the +# appropriate values if it is found. +# +# prefix: prefix for the variables to be set +# module: name of the pkg-config module to search for if needed +# library: name of the library to be searched for +# function: name of a function in the library to use for the link check +AC_DEFUN([AMUSE_LIB], [ + amuse_save_LIBS="$LIBS" + amuse_save_LIB_CFLAGS="$[$1][_CFLAGS]" + amuse_save_LIB_LIBS="$[$1][_LIBS]" + amuse_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + + # If we have an active virtualenv, make sure pkg-config searches it + if test "a${VIRTUAL_ENV}" != "a" + then + PKG_CONFIG_PATH="${VIRTUAL_ENV}/lib/pkgconfig:${PKG_CONFIG_PATH}" + fi + + # All AMUSE libs export C symbols + AC_LANG_PUSH([C]) + + # Search for the library, first directly then fall back to pkg-config + AC_SEARCH_LIBS([$4], [$3], [ + FOUND_$1="yes" + $1_LIBS="$LIBS" + $1_CFLAGS="" + ], [ + PKG_CHECK_MODULES([$1], [$2], [ + FOUND_$1="yes" + ], [ + FOUND_$1="no" + ]) + ]) + + AC_LANG_POP([C]) + + PKG_CONFIG_PATH="$amuse_save_PKG_CONFIG_PATH" + LIBS="$amuse_save_LIBS" + + # If we have an active CONDA environment, assume that the lib is coming from + # there and add an additional flag so that .mod files can be found. Only really + # needed for stopcond and forsockets, and hopefully conda-forge will give us a + # better solution soon. + if test "${FOUND_$1}" == "yes" -a "x$CONDA_PREFIX" != "x" + then + $1_CFLAGS="${$1_CFLAGS} -I${CONDA_PREFIX}/include" + fi + + # If the user overrode the variables, go with what they set instead of + # what we just detected. + AS_IF([test "x$amuse_save_LIB_CFLAGS" != "x"], [ + $1_CFLAGS="$amuse_save_LIB_CFLAGS" + ]) + AS_IF([test "x$amuse_save_LIB_LIBS" != "x"], [ + $1_LIBS="$amuse_save_LIB_LIBS" + ]) + + AC_SUBST([FOUND_][$1]) + AC_SUBST([$1][_CFLAGS]) + AC_SUBST([$1][_LIBS]) +]) + + +# AMUSE_LIB_STOPCOND() +# +# Searches for the AMUSE stopping conditions library and sets STOPCOND_CFLAGS +# and STOPCOND_LIBS to the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_STOPCOND], [ + AMUSE_LIB([STOPCOND], [stopcond], [stopcond], [is_condition_enabled]) +]) + + +# AMUSE_LIB_STOPCONDMPI() +# +# Searches for the AMUSE stopping conditions library and sets STOPCONDMPI_CFLAGS +# and STOPCONDMPI_LIBS to the appropriate values if it is found. +# +# We use a different function here, to avoid getting a cached value from +# AMUSE_LIB_STOPCOND if both are used. Seems like it indexes by function name. +AC_DEFUN([AMUSE_LIB_STOPCONDMPI], [ + AMUSE_LIB([STOPCONDMPI], [stopcondmpi], [stopcondmpi], [get_set_conditions_]) +]) + + +# AMUSE_LIB_AMUSE_MPI() +# +# Searches for the AMUSE MPI helper library and sets AMUSE_MPI_CFLAGS and +# AMUSE_MPI_LIBS to the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_AMUSE_MPI], [ + AMUSE_LIB([AMUSE_MPI], [amuse_mpi], [amuse_mpi], [get_comm_world]) +]) + + +# AMUSE_LIB_FORSOCKETS() +# +# Searches for the AMUSE forsockets library and sets FORSOCKETS_CFLAGS and +# FORSOCKETS_LIBS to the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_FORSOCKETS], [ + AMUSE_LIB([FORSOCKETS], [forsockets], [forsockets], [forsockets_close]) +]) + + +# AMUSE_LIB_SIMPLE_HASH() +# +# Searches for the AMUSE simple hash library and sets SIMPLE_HASH_CFLAGS and +# SIMPLE_HASH_LIBS to the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_SIMPLE_HASH], [ + AMUSE_LIB([SIMPLE_HASH], [simple_hash], [simple_hash], [init_hash]) +]) + + +# AMUSE_LIB_G6LIB() +# +# Searches for the g6 library and sets G6LIB_CFLAGS and G6LIB_LIBS to +# the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_G6LIB], [ + AMUSE_LIB([G6LIB], [g6lib], [g6], [g6_npipes]) +]) + + +# AMUSE_LIB_SAPPORO_LIGHT() +# +# Searches for the Sapporo light library and sets SAPPORO_LIGHT_CFLAGS and +# SAPPORO_LIGHT_LIBS to the appropriate values if it is found. +AC_DEFUN([AMUSE_LIB_SAPPORO_LIGHT], [ + AMUSE_LIB([SAPPORO_LIGHT], [sapporo_light], [sapporo], [get_device_count]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_lib_healpix.m4 b/src/amuse_uclchem/support/shared/m4/amuse_lib_healpix.m4 new file mode 100644 index 0000000000..07b6ef6c5e --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_lib_healpix.m4 @@ -0,0 +1,48 @@ +# Helper macro for detecting libhealpix_cxx +# +# AMUSE_LIB_HEALPIX_CXX() +# +# Searches for libhealpix_cxx and sets FOUND_HEALPIX_CXX to "yes" if found. +# +# Also sets HEALPIX_CXX_LIBS to any needed link commands, and HEALPIX_CXX_CFLAGS to any +# needed compiler flags. +# +AC_DEFUN([AMUSE_LIB_HEALPIX_CXX], [ + amuse_lib_healpix_cxx_save_libs="$LIBS" + + AC_MSG_CHECKING([for HEALPix]) + + AC_LANG_PUSH([C++]) + + LIBS="-lhealpix_cxx" + + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + Healpix_Base hb; + ]) + ], [ + FOUND_HEALPIX_CXX="yes" + HEALPIX_CXX_CFLAGS="" + HEALPIX_CXX_LIBS="$LIBS" + + AC_MSG_RESULT([yes]) + ], + [ + # Not found, try pkg-config instead + PKG_CHECK_MODULES([HEALPIX_CXX], [healpix_cxx], [ + FOUND_HEALPIX_CXX="yes" + AC_MSG_RESULT([yes]) + ], [ + FOUND_HEALPIX_CXX="no" + AC_MSG_RESULT([no]) + ]) + ]) + + AC_LANG_POP([C++]) + + AC_SUBST([HEALPIX_CXX_CFLAGS]) + AC_SUBST([HEALPIX_CXX_LIBS]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_lib_qhull.m4 b/src/amuse_uclchem/support/shared/m4/amuse_lib_qhull.m4 new file mode 100644 index 0000000000..8761694163 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_lib_qhull.m4 @@ -0,0 +1,30 @@ +# Helper macro for detecting libqhull +# +# AMUSE_LIB_QHULL() +# +# Searches for libqhull and sets FOUND_QHULL to "yes" if found. +# +# Also sets QHULL_LIBS to any needed link commands, and QHULL_FLAGS to any needed +# compiler flags. +# +# Recent versions of libqhull have a reentrant libqhull_r and also a libqhull_p, but we +# test only for libqhull. +# +AC_DEFUN([AMUSE_LIB_QHULL], [ + amuse_lib_qhull_save_libs="$LIBS" + + LIBS="" + AC_SEARCH_LIBS([qh_freeqhull], [qhull_r], [ + FOUND_QHULL="yes" + ], []) + QHULL_LIBS="$LIBS" + QHULL_FLAGS="" + + LIBS="$amuse_lib_qhull_save_libs" + + AC_CHECK_HEADERS([libqhull_r/libqhull_r.h], [], [FOUND_QHULL="no"]) + + AC_SUBST([QHULL_LIBS]) + AC_SUBST([QHULL_FLAGS]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_opencl.m4 b/src/amuse_uclchem/support/shared/m4/amuse_opencl.m4 new file mode 100644 index 0000000000..28b1efcd8e --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_opencl.m4 @@ -0,0 +1,63 @@ +# Helper macro for detecting OpenCL for C. + +# AMUSE_OPENCL() +# +# Sets FOUND_OPENCL to "yes" if OpenCL is found, to "no" if it is not. +# Sets OPENCL_CFLAGS and OPENCL_LIBS as needed. +# Calls AC_SUBST on all of the above. +# +AC_DEFUN([AMUSE_OPENCL], [ + amuse_save_CFLAGS="$CFLAGS" + amuse_save_LIBS="$LIBS" + + AC_MSG_CHECKING([for OpenCL]) + + # If the user overrode the variables, then we'll use what they set and verify that + # it works. + AS_IF([test "x$OPENCL_CFLAGS" != "x"], [ + amuse_user_OPENCL_CFLAGS="$OPENCL_CFLAGS" + CFLAGS="$OPENCL_CFLAGS $CFLAGS" + ]) + AS_IF([test "x$OPENCL_LIBS" != "x"], [ + amuse_user_OPENCL_LIBS="$OPENCL_LIBS" + LIBS="$OPENCL_LIBS $LIBS" + ]) + + # We only use OpenCL from C, in huayno + AC_LANG_PUSH([C]) + + # Search for the headers + m4_define([amuse_opencl_test_program], [AC_LANG_PROGRAM([ + #if defined(__APPLE__) || defined(__MACOSX) + #include + #else + #include + #endif + ], [clFinish(0)])]) + + AC_COMPILE_IFELSE([amuse_opencl_test_program], [ + # Search for the library as well + LIBS="-lOpenCL $LIBS" + AC_LINK_IFELSE([amuse_opencl_test_program], [ + FOUND_OPENCL="yes" + OPENCL_LIBS="-lOpenCL" + OPENCL_CFLAGS="" + ], [ + FOUND_OPENCL="no" + ]) + ], [ + FOUND_OPENCL="no" + ]) + + AC_LANG_POP([C]) + + LIBS="$amuse_save_LIBS" + CFLAGS="$amuse_save_CFLAGS" + + AC_MSG_RESULT([$FOUND_OPENCL]) + + AC_SUBST([FOUND_OPENCL]) + AC_SUBST([OPENCL_CFLAGS]) + AC_SUBST([OPENCL_LIBS]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/amuse_venv.m4 b/src/amuse_uclchem/support/shared/m4/amuse_venv.m4 new file mode 100644 index 0000000000..155d88d9d6 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/amuse_venv.m4 @@ -0,0 +1,31 @@ +# Helper macro for installing into Conda envs and virtualenvs. + +# AMUSE_VENV() +# +# Detect the active Conda env or virtualenv and extend LDFLAGS and +# PKG_CONFIG_PATH to point to it. This then makes it possible to detect the AMUSE +# libraries as installed in the environment and link to them. +# +AC_DEFUN([AMUSE_VENV], [ + AS_IF([test "x$VIRTUAL_ENV" != x], [ + CFLAGS="$CFLAGS -I${VIRTUAL_ENV}/include" + CXXFLAGS="$CXXFLAGS -I${VIRTUAL_ENV}/include" + FFLAGS="$FFLAGS -I${VIRTUAL_ENV}/include" + FCFLAGS="$FCFLAGS -I${VIRTUAL_ENV}/include" + LDFLAGS="$LDFLAGS -L${VIRTUAL_ENV}/lib -Wl,-rpath,${VIRTUAL_ENV}/lib" + PKG_CONFIG_PATH="$VIRTUAL_ENV/lib/pkgconfig:$PKG_CONFIG_PATH" + ]) + + AS_IF([test "x$CONDA_PREFIX" != x], [ + # Conda does not set FCFLAGS, so we copy from FFLAGS here + FCFLAGS="$FFLAGS" + LDFLAGS="$LDFLAGS -L${CONDA_PREFIX}/lib -Wl,-rpath,${CONDA_PREFIX}/lib" + # Conda pkg-config includes this already, but in case we have one from + # the system... + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${CONDA_PREFIX}/lib/pkgconfig" + ]) + # Needs to be exported or the PKG_CHECK_MODULES macro won't see it + export PKG_CONFIG_PATH + AC_SUBST([FFLAGS]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_blas.m4 b/src/amuse_uclchem/support/shared/m4/ax_blas.m4 new file mode 100644 index 0000000000..95719050a9 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_blas.m4 @@ -0,0 +1,241 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_blas.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro looks for a library that implements the BLAS linear-algebra +# interface (see http://www.netlib.org/blas/). On success, it sets the +# BLAS_LIBS output variable to hold the requisite library linkages. +# +# To link with BLAS, you should link with: +# +# $BLAS_LIBS $LIBS $FLIBS +# +# in that order. FLIBS is the output variable of the +# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is +# sometimes necessary in order to link with F77 libraries. Users will also +# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same +# reason. +# +# Many libraries are searched for, from ATLAS to CXML to ESSL. The user +# may also use --with-blas= in order to use some specific BLAS +# library . In order to link successfully, however, be aware that you +# will probably need to use the same Fortran compiler (which can be set +# via the F77 env. var.) as was used to compile the BLAS library. +# +# ACTION-IF-FOUND is a list of shell commands to run if a BLAS library 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_BLAS. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2019 Geoffrey M. Oxberry +# +# 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 . +# +# 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 17 + +AU_ALIAS([ACX_BLAS], [AX_BLAS]) +AC_DEFUN([AX_BLAS], [ +AC_PREREQ([2.55]) +AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS]) +AC_REQUIRE([AC_CANONICAL_HOST]) +ax_blas_ok=no + +AC_ARG_WITH(blas, + [AS_HELP_STRING([--with-blas=], [use BLAS library ])]) +case $with_blas in + yes | "") ;; + no) ax_blas_ok=disable ;; + -* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o) + BLAS_LIBS="$with_blas" + ;; + *) BLAS_LIBS="-l$with_blas" ;; +esac + +# Get fortran linker names of BLAS functions to check for. +AC_F77_FUNC(sgemm) +AC_F77_FUNC(dgemm) + +ax_blas_save_LIBS="$LIBS" +LIBS="$LIBS $FLIBS" + +# First, check BLAS_LIBS environment variable +if test $ax_blas_ok = no; then +if test "x$BLAS_LIBS" != x; then + save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" + AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes], [BLAS_LIBS=""]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi +fi + +# BLAS linked to by default? (happens on some supercomputers) +if test $ax_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="$LIBS" + AC_MSG_CHECKING([if $sgemm is being linked in already]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi + +# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(openblas, $sgemm, [ax_blas_ok=yes + BLAS_LIBS="-lopenblas"]) +fi + +# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(atlas, ATL_xerbla, + [AC_CHECK_LIB(f77blas, $sgemm, + [AC_CHECK_LIB(cblas, cblas_dgemm, + [ax_blas_ok=yes + BLAS_LIBS="-lcblas -lf77blas -latlas"], + [], [-lf77blas -latlas])], + [], [-latlas])]) +fi + +# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, + [AC_CHECK_LIB(dgemm, $dgemm, + [AC_CHECK_LIB(sgemm, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"], + [], [-lblas])], + [], [-lblas])]) +fi + +# BLAS in Intel MKL library? +if test $ax_blas_ok = no; then + # MKL for gfortran + if test x"$ac_cv_fc_compiler_gnu" = xyes; then + # 64 bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_gf_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32 bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_gf, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf -lmkl_sequential -lmkl_core -lpthread]) + fi + # MKL for other compilers (Intel, PGI, ...?) + else + # 64-bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_intel_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32-bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_intel, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel -lmkl_sequential -lmkl_core -lpthread]) + fi + fi +fi +# Old versions of MKL +if test $ax_blas_ok = no; then + AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread]) +fi + +# BLAS in Apple vecLib library? +if test $ax_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" + AC_MSG_CHECKING([for $sgemm in -framework vecLib]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi + +# BLAS in Alpha CXML library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"]) +fi + +# BLAS in Alpha DXML library? (now called CXML, see above) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"]) +fi + +# BLAS in Sun Performance library? +if test $ax_blas_ok = no; then + if test "x$GCC" != xyes; then # only works with Sun CC + AC_CHECK_LIB(sunmath, acosp, + [AC_CHECK_LIB(sunperf, $sgemm, + [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" + ax_blas_ok=yes],[],[-lsunmath])]) + fi +fi + +# BLAS in SCSL library? (SGI/Cray Scientific Library) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"]) +fi + +# BLAS in SGIMATH library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(complib.sgimath, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) +fi + +# BLAS in IBM ESSL library? (requires generic BLAS lib, too) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, + [AC_CHECK_LIB(essl, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], + [], [-lblas $FLIBS])]) +fi + +# Generic BLAS library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"]) +fi + +AC_SUBST(BLAS_LIBS) + +LIBS="$ax_blas_save_LIBS" + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_blas_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1]) + : +else + ax_blas_ok=no + $2 +fi +])dnl AX_BLAS diff --git a/src/amuse_uclchem/support/shared/m4/ax_check_classpath.m4 b/src/amuse_uclchem/support/shared/m4/ax_check_classpath.m4 new file mode 100644 index 0000000000..55b43d93e3 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_check_classpath.m4 @@ -0,0 +1,61 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_classpath.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_CLASSPATH +# +# DESCRIPTION +# +# AX_CHECK_CLASSPATH just displays the CLASSPATH, for the edification of +# the user. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 . +# +# 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 6 + +AU_ALIAS([AC_CHECK_CLASSPATH], [AX_CHECK_CLASSPATH]) +AC_DEFUN([AX_CHECK_CLASSPATH],[ +if test "x$CLASSPATH" = x; then + echo "You have no CLASSPATH, I hope it is good" +else + echo "You have CLASSPATH $CLASSPATH, hope it is correct" +fi +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_check_gnu_make.m4 b/src/amuse_uclchem/support/shared/m4/ax_check_gnu_make.m4 new file mode 100644 index 0000000000..71ffe34817 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_check_gnu_make.m4 @@ -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 +# Copyright (c) 2015 Enrico M. Crisostomo +# +# 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]) +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_count_cpus.m4 b/src/amuse_uclchem/support/shared/m4/ax_count_cpus.m4 new file mode 100644 index 0000000000..5db8925534 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_count_cpus.m4 @@ -0,0 +1,101 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_count_cpus.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COUNT_CPUS([ACTION-IF-DETECTED],[ACTION-IF-NOT-DETECTED]) +# +# DESCRIPTION +# +# Attempt to count the number of logical processor cores (including +# virtual and HT cores) currently available to use on the machine and +# place detected value in CPU_COUNT variable. +# +# On successful detection, ACTION-IF-DETECTED is executed if present. If +# the detection fails, then ACTION-IF-NOT-DETECTED is triggered. The +# default ACTION-IF-NOT-DETECTED is to set CPU_COUNT to 1. +# +# LICENSE +# +# Copyright (c) 2014,2016 Karlson2k (Evgeny Grin) +# Copyright (c) 2012 Brian Aker +# Copyright (c) 2008 Michael Paul Bailey +# Copyright (c) 2008 Christophe Tournayre +# +# 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 22 + + AC_DEFUN([AX_COUNT_CPUS],[dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([AC_PROG_EGREP])dnl + AC_MSG_CHECKING([the number of available CPUs]) + CPU_COUNT="0" + + # Try generic methods + + # 'getconf' is POSIX utility, but '_NPROCESSORS_ONLN' and + # 'NPROCESSORS_ONLN' are platform-specific + command -v getconf >/dev/null 2>&1 && \ + CPU_COUNT=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null` || CPU_COUNT="0" + AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v nproc >/dev/null 2>&1]],[[: # empty]],[dnl + # 'nproc' is part of GNU Coreutils and is widely available + CPU_COUNT=`OMP_NUM_THREADS='' nproc 2>/dev/null` || CPU_COUNT=`nproc 2>/dev/null` || CPU_COUNT="0" + ])dnl + + AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[: # empty]],[dnl + # Try platform-specific preferred methods + AS_CASE([[$host_os]],dnl + [[*linux*]],[[CPU_COUNT=`lscpu -p 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+,' -c` || CPU_COUNT="0"]],dnl + [[*darwin*]],[[CPU_COUNT=`sysctl -n hw.logicalcpu 2>/dev/null` || CPU_COUNT="0"]],dnl + [[freebsd*]],[[command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n kern.smp.cpus 2>/dev/null` || CPU_COUNT="0"]],dnl + [[netbsd*]], [[command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n hw.ncpuonline 2>/dev/null` || CPU_COUNT="0"]],dnl + [[solaris*]],[[command -v psrinfo >/dev/null 2>&1 && CPU_COUNT=`psrinfo 2>/dev/null | $EGREP -e '^@<:@0-9@:>@.*on-line' -c 2>/dev/null` || CPU_COUNT="0"]],dnl + [[mingw*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl + [[msys*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl + [[cygwin*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]]dnl + )dnl + ])dnl + + AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v sysctl >/dev/null 2>&1]],[[: # empty]],[dnl + # Try less preferred generic method + # 'hw.ncpu' exist on many platforms, but not on GNU/Linux + CPU_COUNT=`sysctl -n hw.ncpu 2>/dev/null` || CPU_COUNT="0" + ])dnl + + AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[: # empty]],[dnl + # Try platform-specific fallback methods + # They can be less accurate and slower then preferred methods + AS_CASE([[$host_os]],dnl + [[*linux*]],[[CPU_COUNT=`$EGREP -e '^processor' -c /proc/cpuinfo 2>/dev/null` || CPU_COUNT="0"]],dnl + [[*darwin*]],[[CPU_COUNT=`system_profiler SPHardwareDataType 2>/dev/null | $EGREP -i -e 'number of cores:'|cut -d : -f 2 -s|tr -d ' '` || CPU_COUNT="0"]],dnl + [[freebsd*]],[[CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu@<:@0-9@:>@+: '|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0"]],dnl + [[netbsd*]], [[CPU_COUNT=`command -v cpuctl >/dev/null 2>&1 && cpuctl list 2>/dev/null| $EGREP -e '^@<:@0-9@:>@+ .* online ' -c` || \ + CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu@<:@0-9@:>@+ at'|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0"]],dnl + [[solaris*]],[[command -v kstat >/dev/null 2>&1 && CPU_COUNT=`kstat -m cpu_info -s state -p 2>/dev/null | $EGREP -c -e 'on-line'` || \ + CPU_COUNT=`kstat -m cpu_info 2>/dev/null | $EGREP -c -e 'module: cpu_info'` || CPU_COUNT="0"]],dnl + [[mingw*]],[AS_IF([[CPU_COUNT=`reg query 'HKLM\\Hardware\\Description\\System\\CentralProcessor' 2>/dev/null | $EGREP -e '\\\\@<:@0-9@:>@+$' -c`]],dnl + [[: # empty]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]])],dnl + [[msys*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]],dnl + [[cygwin*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]]dnl + )dnl + ])dnl + + AS_IF([[test "x$CPU_COUNT" != "x0" && test "$CPU_COUNT" -gt 0 2>/dev/null]],[dnl + AC_MSG_RESULT([[$CPU_COUNT]]) + m4_ifvaln([$1],[$1],)dnl + ],[dnl + m4_ifval([$2],[dnl + AS_UNSET([[CPU_COUNT]]) + AC_MSG_RESULT([[unable to detect]]) + $2 + ], [dnl + CPU_COUNT="1" + AC_MSG_RESULT([[unable to detect (assuming 1)]]) + ])dnl + ])dnl + ])dnl diff --git a/src/amuse_uclchem/support/shared/m4/ax_lapack.m4 b/src/amuse_uclchem/support/shared/m4/ax_lapack.m4 new file mode 100644 index 0000000000..abaff9d171 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_lapack.m4 @@ -0,0 +1,134 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_lapack.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro looks for a library that implements the LAPACK linear-algebra +# interface (see http://www.netlib.org/lapack/). On success, it sets the +# LAPACK_LIBS output variable to hold the requisite library linkages. +# +# To link with LAPACK, you should link with: +# +# $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS +# +# in that order. BLAS_LIBS is the output variable of the AX_BLAS macro, +# called automatically. FLIBS is the output variable of the +# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is +# sometimes necessary in order to link with F77 libraries. Users will also +# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same +# reason. +# +# The user may also use --with-lapack= in order to use some specific +# LAPACK library . In order to link successfully, however, be aware +# that you will probably need to use the same Fortran compiler (which can +# be set via the F77 env. var.) as was used to compile the LAPACK and BLAS +# libraries. +# +# ACTION-IF-FOUND is a list of shell commands to run if a LAPACK library +# 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_LAPACK. +# +# LICENSE +# +# Copyright (c) 2009 Steven G. Johnson +# Copyright (c) 2019 Geoffrey M. Oxberry +# +# 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 . +# +# 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 10 + +AU_ALIAS([ACX_LAPACK], [AX_LAPACK]) +AC_DEFUN([AX_LAPACK], [ +AC_REQUIRE([AX_BLAS]) +ax_lapack_ok=no + +AC_ARG_WITH(lapack, + [AS_HELP_STRING([--with-lapack=], [use LAPACK library ])]) +case $with_lapack in + yes | "") ;; + no) ax_lapack_ok=disable ;; + -* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o) + LAPACK_LIBS="$with_lapack" + ;; + *) LAPACK_LIBS="-l$with_lapack" ;; +esac + +# Get fortran linker name of LAPACK function to check for. +AC_F77_FUNC(cheev) + +# We cannot use LAPACK if BLAS is not found +if test "x$ax_blas_ok" != xyes; then + ax_lapack_ok=noblas + LAPACK_LIBS="" +fi + +# First, check LAPACK_LIBS environment variable +if test "x$LAPACK_LIBS" != x; then + save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS" + AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$cheev])], [ax_lapack_ok=yes], [LAPACK_LIBS=""]) + AC_MSG_RESULT($ax_lapack_ok) + LIBS="$save_LIBS" + if test $ax_lapack_ok = no; then + LAPACK_LIBS="" + fi +fi + +# LAPACK linked to by default? (is sometimes included in BLAS lib) +if test $ax_lapack_ok = no; then + save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS" + AC_CHECK_FUNC($cheev, [ax_lapack_ok=yes]) + LIBS="$save_LIBS" +fi + +# Generic LAPACK library? +for lapack in lapack lapack_rs6k; do + if test $ax_lapack_ok = no; then + save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" + AC_CHECK_LIB($lapack, $cheev, + [ax_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS]) + LIBS="$save_LIBS" + fi +done + +AC_SUBST(LAPACK_LIBS) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_lapack_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1]) + : +else + ax_lapack_ok=no + $2 +fi +])dnl AX_LAPACK diff --git a/src/amuse_uclchem/support/shared/m4/ax_lib_hdf5.m4 b/src/amuse_uclchem/support/shared/m4/ax_lib_hdf5.m4 new file mode 100644 index 0000000000..074c2a820a --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_lib_hdf5.m4 @@ -0,0 +1,323 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_HDF5([serial/parallel]) +# +# DESCRIPTION +# +# This macro provides tests of the availability of HDF5 library. +# +# The optional macro argument should be either 'serial' or 'parallel'. The +# former only looks for serial HDF5 installations via h5cc. The latter +# only looks for parallel HDF5 installations via h5pcc. If the optional +# argument is omitted, serial installations will be preferred over +# parallel ones. +# +# The macro adds a --with-hdf5 option accepting one of three values: +# +# no - do not check for the HDF5 library. +# yes - do check for HDF5 library in standard locations. +# path - complete path to the HDF5 helper script h5cc or h5pcc. +# +# If HDF5 is successfully found, this macro calls +# +# AC_SUBST(HDF5_VERSION) +# AC_SUBST(HDF5_CC) +# AC_SUBST(HDF5_CFLAGS) +# AC_SUBST(HDF5_CPPFLAGS) +# AC_SUBST(HDF5_LDFLAGS) +# AC_SUBST(HDF5_LIBS) +# AC_SUBST(HDF5_FC) +# AC_SUBST(HDF5_FFLAGS) +# AC_SUBST(HDF5_FLIBS) +# AC_SUBST(HDF5_TYPE) +# AC_DEFINE(HAVE_HDF5) +# +# and sets with_hdf5="yes". Additionally, the macro sets +# with_hdf5_fortran="yes" if a matching Fortran wrapper script is found. +# Note that Autoconf's Fortran support is not used to perform this check. +# H5CC and H5FC will contain the appropriate serial or parallel HDF5 +# wrapper script locations. +# +# If HDF5 is disabled or not found, this macros sets with_hdf5="no" and +# with_hdf5_fortran="no". +# +# Your configuration script can test $with_hdf to take any further +# actions. HDF5_{C,CPP,LD}FLAGS may be used when building with C or C++. +# HDF5_F{FLAGS,LIBS} should be used when building Fortran applications. +# +# To use the macro, one would code one of the following in "configure.ac" +# before AC_OUTPUT: +# +# 1) dnl Check for HDF5 support +# AX_LIB_HDF5() +# +# 2) dnl Check for serial HDF5 support +# AX_LIB_HDF5([serial]) +# +# 3) dnl Check for parallel HDF5 support +# AX_LIB_HDF5([parallel]) +# +# One could test $with_hdf5 for the outcome or display it as follows +# +# echo "HDF5 support: $with_hdf5" +# +# You could also for example, override the default CC in "configure.ac" to +# enforce compilation with the compiler that HDF5 uses: +# +# AX_LIB_HDF5([parallel]) +# if test "$with_hdf5" = "yes"; then +# CC="$HDF5_CC" +# else +# AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.]) +# fi +# +# The HDF5_TYPE environment variable returns "parallel" or "serial", +# depending on which type of library is found. +# +# LICENSE +# +# Copyright (c) 2009 Timothy Brown +# Copyright (c) 2010 Rhys Ulerich +# +# 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 20 + +AC_DEFUN([AX_LIB_HDF5], [ + +AC_REQUIRE([AC_PROG_SED]) +AC_REQUIRE([AC_PROG_AWK]) +AC_REQUIRE([AC_PROG_GREP]) + +dnl Check first argument is one of the recognized values. +dnl Fail eagerly if is incorrect as this simplifies case statements below. +if test "m4_normalize(m4_default([$1],[]))" = "" ; then + : # Recognized value +elif test "m4_normalize(m4_default([$1],[]))" = "serial" ; then + : # Recognized value +elif test "m4_normalize(m4_default([$1],[]))" = "parallel"; then + : # Recognized value +else + AC_MSG_ERROR([ +Unrecognized value for AX[]_LIB_HDF5 within configure.ac. +If supplied, argument 1 must be either 'serial' or 'parallel'. +]) +fi + +dnl Add a default --with-hdf5 configuration option. +AC_ARG_WITH([hdf5], + AS_HELP_STRING( + [--with-hdf5=[yes/no/PATH]], + m4_case(m4_normalize([$1]), + [serial], [location of h5cc for serial HDF5 configuration], + [parallel], [location of h5pcc for parallel HDF5 configuration], + [location of h5cc or h5pcc for HDF5 configuration]) + ), + [if test "$withval" = "no"; then + with_hdf5="no" + elif test "$withval" = "yes"; then + with_hdf5="yes" + else + with_hdf5="yes" + H5CC="$withval" + fi], + [with_hdf5="yes"] +) + +dnl Set defaults to blank +HDF5_CC="" +HDF5_VERSION="" +HDF5_CFLAGS="" +HDF5_CPPFLAGS="" +HDF5_LDFLAGS="" +HDF5_LIBS="" +HDF5_FC="" +HDF5_FFLAGS="" +HDF5_FLIBS="" +HDF5_TYPE="" + +dnl Try and find hdf5 compiler tools and options. +if test "$with_hdf5" = "yes"; then + if test -z "$H5CC"; then + dnl Check to see if H5CC is in the path. + AC_PATH_PROGS( + [H5CC], + m4_case(m4_normalize([$1]), + [serial], [h5cc], + [parallel], [h5pcc], + [h5cc h5pcc]), + []) + else + AC_MSG_CHECKING([Using provided HDF5 C wrapper]) + AC_MSG_RESULT([$H5CC]) + fi + AC_MSG_CHECKING([for HDF5 type]) + AS_CASE([$H5CC], + [*h5pcc], [HDF5_TYPE=parallel], + [*h5cc], [HDF5_TYPE=serial], + [HDF5_TYPE=neither]) + AC_MSG_RESULT([$HDF5_TYPE]) + AC_MSG_CHECKING([for HDF5 libraries]) + if test ! -f "$H5CC" || test ! -x "$H5CC"; then + AC_MSG_RESULT([no]) + AC_MSG_WARN(m4_case(m4_normalize([$1]), + [serial], [ +Unable to locate serial HDF5 compilation helper script 'h5cc'. +Please specify --with-hdf5= as the full path to h5cc. +HDF5 support is being disabled (equivalent to --with-hdf5=no). +], [parallel],[ +Unable to locate parallel HDF5 compilation helper script 'h5pcc'. +Please specify --with-hdf5= as the full path to h5pcc. +HDF5 support is being disabled (equivalent to --with-hdf5=no). +], [ +Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'. +Please specify --with-hdf5= as the full path to h5cc or h5pcc. +HDF5 support is being disabled (equivalent to --with-hdf5=no). +])) + with_hdf5="no" + with_hdf5_fortran="no" + else + dnl Get the h5cc output + HDF5_SHOW=$(eval $H5CC -show) + + dnl Get the actual compiler used + HDF5_CC=$(eval $H5CC -show | head -n 1 | $AWK '{print $[]1}') + if test "$HDF5_CC" = "ccache"; then + HDF5_CC=$(eval $H5CC -show | head -n 1 | $AWK '{print $[]2}') + fi + + dnl h5cc provides both AM_ and non-AM_ options + dnl depending on how it was compiled either one of + dnl these are empty. Lets roll them both into one. + + dnl Look for "HDF5 Version: X.Y.Z" + HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' \ + | $AWK '{print $[]3}') + + dnl A ideal situation would be where everything we needed was + dnl in the AM_* variables. However most systems are not like this + dnl and seem to have the values in the non-AM variables. + dnl + dnl We try the following to find the flags: + dnl (1) Look for "NAME:" tags + dnl (2) Look for "H5_NAME:" tags + dnl (3) Look for "AM_NAME:" tags + dnl + HDF5_tmp_flags=$(eval $H5CC -showconfig \ + | $GREP 'FLAGS\|Extra libraries:' \ + | $AWK -F: '{printf("%s "), $[]2}' ) + + dnl Find the installation directory and append include/ + HDF5_tmp_inst=$(eval $H5CC -showconfig \ + | $GREP 'Installation point:' \ + | $AWK '{print $[]NF}' ) + + dnl Add this to the CPPFLAGS + HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include" + + dnl Now sort the flags out based upon their prefixes + for arg in $HDF5_SHOW $HDF5_tmp_flags ; do + case "$arg" in + -I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_CPPFLAGS="$HDF5_CPPFLAGS $arg" + ;; + -L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_LDFLAGS="$HDF5_LDFLAGS $arg" + ;; + -l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ + || HDF5_LIBS="$HDF5_LIBS $arg" + ;; + esac + done + + HDF5_LIBS="-lhdf5 $HDF5_LIBS" + AC_MSG_RESULT([yes (version $[HDF5_VERSION])]) + + dnl See if we can compile + AC_LANG_PUSH([C]) + ax_lib_hdf5_save_CC=$CC + ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS + ax_lib_hdf5_save_LIBS=$LIBS + ax_lib_hdf5_save_LDFLAGS=$LDFLAGS + CC=$HDF5_CC + CPPFLAGS=$HDF5_CPPFLAGS + LIBS=$HDF5_LIBS + LDFLAGS=$HDF5_LDFLAGS + AC_CHECK_HEADER([hdf5.h], [ac_cv_hadf5_h=yes], [ac_cv_hadf5_h=no]) + AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libhdf5=yes], + [ac_cv_libhdf5=no]) + if test "$ac_cv_hadf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then + AC_MSG_WARN([Unable to compile HDF5 test program]) + fi + dnl Look for HDF5's high level library + AC_HAVE_LIBRARY([hdf5_hl], [HDF5_LIBS="-lhdf5_hl $HDF5_LIBS"], [], []) + + CC=$ax_lib_hdf5_save_CC + CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS + LIBS=$ax_lib_hdf5_save_LIBS + LDFLAGS=$ax_lib_hdf5_save_LDFLAGS + AC_LANG_POP([C]) + + AC_MSG_CHECKING([for matching HDF5 Fortran wrapper]) + dnl Presume HDF5 Fortran wrapper is just a name variant from H5CC + H5FC=$(eval echo -n $H5CC | $SED -n 's/cc$/fc/p') + if test -x "$H5FC"; then + AC_MSG_RESULT([$H5FC]) + with_hdf5_fortran="yes" + AC_SUBST([H5FC]) + + dnl Again, pry any remaining -Idir/-Ldir from compiler wrapper + for arg in `$H5FC -show` + do + case "$arg" in #( + -I*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \ + || HDF5_FFLAGS="$HDF5_FFLAGS $arg" + ;;#( + -L*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \ + || HDF5_FFLAGS="$HDF5_FFLAGS $arg" + dnl HDF5 installs .mod files in with libraries, + dnl but some compilers need to find them with -I + echo $HDF5_FFLAGS | $GREP -e "-I${arg#-L}" >/dev/null \ + || HDF5_FFLAGS="$HDF5_FFLAGS -I${arg#-L}" + ;; + esac + done + + dnl Make Fortran link line by inserting Fortran libraries + for arg in $HDF5_LIBS + do + case "$arg" in #( + -lhdf5_hl) HDF5_FLIBS="$HDF5_FLIBS -lhdf5hl_fortran $arg" + ;; #( + -lhdf5) HDF5_FLIBS="$HDF5_FLIBS -lhdf5_fortran $arg" + ;; #( + *) HDF5_FLIBS="$HDF5_FLIBS $arg" + ;; + esac + done + else + AC_MSG_RESULT([no]) + with_hdf5_fortran="no" + fi + + AC_SUBST([HDF5_VERSION]) + AC_SUBST([HDF5_CC]) + AC_SUBST([HDF5_CFLAGS]) + AC_SUBST([HDF5_CPPFLAGS]) + AC_SUBST([HDF5_LDFLAGS]) + AC_SUBST([HDF5_LIBS]) + AC_SUBST([HDF5_FC]) + AC_SUBST([HDF5_FFLAGS]) + AC_SUBST([HDF5_FLIBS]) + AC_SUBST([HDF5_TYPE]) + AC_DEFINE([HAVE_HDF5], [1], [Defined if you have HDF5 support]) + fi +fi +]) diff --git a/src/amuse_uclchem/support/shared/m4/ax_lib_netcdf4.m4 b/src/amuse_uclchem/support/shared/m4/ax_lib_netcdf4.m4 new file mode 100644 index 0000000000..e9dd487a02 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_lib_netcdf4.m4 @@ -0,0 +1,277 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_lib_netcdf4.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_NETCDF4([serial/parallel]) +# +# DESCRIPTION +# +# This macro provides tests of the availability of the NetCDF v4 library. +# +# The optional macro argument should be either 'serial' or 'parallel'. The +# macro will call nc-config to check the output of the '--has-pnetcdf' +# option and error out if the requested parallel isn't supported. +# +# If the optional argument is omitted, no check is made to see if NetCDF +# has parallel support. +# +# The macro adds a --with-netcdf4 option accepting one of three values: +# +# no - do not check for the NetCDF4 library. +# yes - do check for NetCDF4 library in standard locations. +# path - installation prefix for NetCDF version 4. +# +# If NetCDF4 is successfully found, this macro calls +# +# AC_SUBST(NETCDF4_VERSION) +# AC_SUBST(NETCDF4_CC) +# AC_SUBST(NETCDF4_CFLAGS) +# AC_SUBST(NETCDF4_CPPFLAGS) +# AC_SUBST(NETCDF4_LDFLAGS) +# AC_SUBST(NETCDF4_LIBS) +# AC_SUBST(NETCDF4_FC) +# AC_SUBST(NETCDF4_FFLAGS) +# AC_SUBST(NETCDF4_FLIBS) +# AC_DEFINE(HAVE_NETCDF4) +# +# It also sets +# +# with_netcdf4="yes" +# with_netcdf4_fortran="yes" (if NetCDF has Fortran support) +# with_netcdf4_parallel="yes" (if NetCDF has MPI support) +# +# If NetCDF4 is disabled or not found, this macros sets +# +# with_netcdf4="no" +# with_netcdf4_fortran="no" +# +# Note it does not set with_netcdf4_parallel in this case. +# +# Your configuration script can test $with_netcdf4 to take any further +# actions. NETCDF4_{C,CPP,LD}FLAGS may be used when building with C or +# C++. NETCDF4_F{FLAGS,LIBS} and NETCDF4_LDFLAGS should be used when +# building Fortran applications. +# +# To use the macro, one would code one of the following in "configure.ac" +# before AC_OUTPUT: +# +# 1) dnl Check for NetCDF4 support +# AX_LIB_NETCDF4() +# +# 2) dnl Check for serial NetCDF4 support +# AX_LIB_NETCDF4([serial]) +# +# 3) dnl Check for parallel NetCDF4 support +# AX_LIB_NETCDF4([parallel]) +# +# One could test $with_netcdf4 for the outcome or display it as follows +# +# echo "NetCDF v4 support: $with_netcdf4" +# +# One could also for example, override the default CC in "configure.ac" to +# enforce compilation with the compiler that NetCDF v4 was built with: +# +# AX_LIB_NETCDF4([parallel]) +# if test "$with_netcdf4" = "yes"; then +# CC="$NETCDF4_CC" +# else +# AC_MSG_ERROR([Unable to find NetCDF4, we need parallel NetCDF4.]) +# fi +# +# LICENSE +# +# Copyright (c) 2016 Timothy Brown +# +# 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 2 + +AC_DEFUN([AX_LIB_NETCDF4], [ + +AC_REQUIRE([AC_PROG_SED]) +AC_REQUIRE([AC_PROG_AWK]) +AC_REQUIRE([AC_PROG_GREP]) + +dnl Check first argument is one of the recognized values. +dnl Fail eagerly if is incorrect as this simplifies case statements below. +if test "m4_normalize(m4_default([$1],[]))" = "" ; then + netcdf4_requested_mode="serial" +elif test "m4_normalize(m4_default([$1],[]))" = "serial" ; then + netcdf4_requested_mode="serial" +elif test "m4_normalize(m4_default([$1],[]))" = "parallel"; then + netcdf4_requested_mode="parallel" +else + AC_MSG_ERROR([ +Unrecognized value for AX[]_LIB_NETCDF4 within configure.ac. +If supplied, argument 1 must be either 'serial' or 'parallel'. +]) +fi + +dnl Add a default --with-netcdf4 configuration option. +AC_ARG_WITH([netcdf4], + AS_HELP_STRING( + [--with-netcdf4=[yes/no/PATH]], + m4_case(m4_normalize([$1]), + [serial], [base directory of serial NetCDF4 installation], + [parallel], [base directory of parallel NetCDF4 installation], + [base directory of NetCDF4 installation]) + ), + [if test "$withval" = "no"; then + with_netcdf4="no" + elif test "$withval" = "yes"; then + with_netcdf4="yes" + else + with_netcdf4="yes" + NETCDF4_PREFIX="${withval}" + NC_CONFIG="${withval}/bin/nc-config" + fi], + [with_netcdf4="yes"] +) + +dnl Set defaults to blank +NETCDF4_CC="" +NETCDF4_VERSION="" +NETCDF4_CFLAGS="" +NETCDF4_CPPFLAGS="" +NETCDF4_LDFLAGS="" +NETCDF4_LIBS="" +NETCDF4_FC="" +NETCDF4_FFLAGS="" +NETCDF4_FLIBS="" + +dnl Try and find NetCDF4 tools and options. +if test "$with_netcdf4" = "yes"; then + if test -z "$NC_CONFIG"; then + dnl Check to see if NC_CONFIG is in the path. + AC_PATH_PROGS([NC_CONFIG], [nc-config], []) + NETCDF4_PREFIX=$(AS_DIRNAME([$(AS_DIRNAME(["$NC_CONFIG"]))])) + else + AC_MSG_CHECKING([Using provided NetCDF4 prefix]) + AC_MSG_RESULT([$NC_CONFIG]) + fi + + AC_MSG_CHECKING([for NetCDF4 libraries]) + + if test ! -f "$NC_CONFIG" || test ! -x "$NC_CONFIG"; then + AC_MSG_RESULT([no]) + AC_MSG_WARN([ + +Unable to locate NetCDF4 compilation helper script 'nc-config'. +Please specify --with-netcdf4= as the full path prefix +where NetCDF4 has been installed. +NetCDF4 support is being disabled (equivalent to --with-netcdf4=no). +]) + with_netcdf4="no" + with_netcdf4_fortran="no" + else + dnl Get the actual compiler used + NETCDF4_CC=$(eval $NC_CONFIG --cc | $AWK '{print $[]1}') + if test "$NETCDF4_CC" = "ccache"; then + NETCDF4_CC=$(eval $NC_CONFIG --cc | $AWK '{print $[]2}') + fi + + dnl Look for version + NETCDF4_VERSION=$(eval $NC_CONFIG --version | $AWK '{print $[]2}') + + dnl Look for the CFLAGS + NETCDF4_CFLAGS=$(eval $NC_CONFIG --cflags) + + dnl Look for the LIBS and LDFLAGS + NETCDF4_tmp_clibs=$(eval $NC_CONFIG --libs) + + dnl Sort out the tmp libs based on their prefixes + for arg in $NETCDF4_tmp_clibs ; do + case "$arg" in + -L*) echo $NETCDF4_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || NETCDF4_LDFLAGS="$arg $NETCDF4_LDFLAGS" + ;; + -l*) echo $NETCDF4_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ + || NETCDF4_LIBS="$arg $NETCDF4_LIBS" + ;; + esac + done + + AC_MSG_RESULT([yes (version $[NETCDF4_VERSION])]) + + dnl See if we need (and have) parallel support + if test "$netcdf4_requested_mode" = "parallel" ; then + with_netcdf4_parallel=$(eval $NC_CONFIG --has-pnetcdf) + if test "$with_netcdf4_parallel" = "no" ; then + AC_MSG_ERROR([ +parallel NetCDF4 is not supported (while it was requested) +]) + fi + fi + + dnl See if we can compile + ax_lib_netcdf4_save_CC=$CC + ax_lib_netcdf4_save_CPPFLAGS=$CPPFLAGS + ax_lib_netcdf4_save_LIBS=$LIBS + ax_lib_netcdf4_save_LDFLAGS=$LDFLAGS + CC=$NETCDF4_CC + CFLAGS=$NETCDF4_CFLAGS + LIBS=$NETCDF4_LIBS + LDFLAGS=$NETCDF4_LDFLAGS + AC_CHECK_HEADER([netcdf.h], [ac_cv_netcdf4_h=yes], [ac_cv_netcdf4_h=no]) + AC_CHECK_LIB([netcdf], [nc_create], [ac_cv_libnetcdf4=yes], + [ac_cv_libnetcdf4=no]) + if test "$ac_cv_netcdf4_h" = "no" && \ + test "$ac_cv_libnetcdf4" = "no" ; then + AC_MSG_WARN([Unable to compile NetCDF4 test program]) + fi + + CC=$ax_lib_netcdf4_save_CC + CFLAGS=$ax_lib_netcdf4_save_CFLAGS + LIBS=$ax_lib_netcdf4_save_LIBS + LDFLAGS=$ax_lib_hdf5_save_LDFLAGS + + + AC_MSG_CHECKING([for matching NetCDF4 Fortran libraries]) + NF_CONFIG="${NETCDF4_PREFIX}/bin/nf-config" + if test ! -f "$NF_CONFIG" || test ! -x "$NF_CONFIG"; then + AC_MSG_RESULT([no]) + with_netcdf4_fortran="no" + else + NETCDF_FVERSION=$(eval $NF_CONFIG --version | $AWK '{print $[]2}') + AC_MSG_RESULT([yes (version $[NETCDF_FVERSION])]) + NETCDF4_FC=$(eval $NF_CONFIG --fc | $AWK '{print $[]1}') + if test "$NETCDF4_FC" = "ccache"; then + NETCDF4_FC=$(eval $NF_CONFIG --fc | $AWK '{print $[]2}') + fi + dnl Look for the FFLAGS + NETCDF4_FFLAGS=$(eval $NC_CONFIG --fflags) + + dnl Look for the FLIBS and LDFLAGS + NETCDF4_tmp_flibs=$(eval $NC_CONFIG --flibs) + + dnl Sort out the tmp libs based on their prefixes + for arg in $NETCDF4_tmp_flibs ; do + case "$arg" in + -L*) echo $NETCDF4_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ + || NETCDF4_LDFLAGS="$arg $NETCDF4_LDFLAGS" + ;; + -l*) echo $NETCDF4_FLIBS | $GREP -e "$arg" 2>&1 >/dev/null \ + || NETCDF4_FLIBS="$arg $NETCDF4_FLIBS" + ;; + esac + done + with_netcdf4_fortran="yes" + fi + + AC_SUBST([NETCDF4_VERSION]) + AC_SUBST([NETCDF4_CC]) + AC_SUBST([NETCDF4_CFLAGS]) + AC_SUBST([NETCDF4_LDFLAGS]) + AC_SUBST([NETCDF4_LIBS]) + AC_SUBST([NETCDF4_FC]) + AC_SUBST([NETCDF4_FFLAGS]) + AC_SUBST([NETCDF4_FLIBS]) + AC_DEFINE([HAVE_NETCDF4], [1], [Defined if you have NETCDF4 support]) + fi +fi +]) diff --git a/src/amuse_uclchem/support/shared/m4/ax_mpi.m4 b/src/amuse_uclchem/support/shared/m4/ax_mpi.m4 new file mode 100644 index 0000000000..dbde02a9c4 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_mpi.m4 @@ -0,0 +1,235 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_mpi.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro tries to find out how to compile programs that use MPI +# (Message Passing Interface), a standard API for parallel process +# communication (see http://www-unix.mcs.anl.gov/mpi/) +# +# On success, it sets the MPICC, MPICXX, MPIF77, or MPIFC output variable +# to the name of the MPI compiler, depending upon the current language. +# (This may just be $CC/$CXX/$F77/$FC, but is more often something like +# mpicc/mpiCC/mpif77/mpif90.) It also sets MPILIBS to any libraries that +# are needed for linking MPI (e.g. -lmpi or -lfmpi, if a special +# MPICC/MPICXX/MPIF77/MPIFC was not found). +# +# If you want to compile everything with MPI, you should use something +# like this for C: +# +# if test -z "$CC" && test -n "$MPICC"; then +# CC="$MPICC" +# fi +# AC_PROG_CC +# AX_MPI +# CC="$MPICC" +# LIBS="$MPILIBS $LIBS" +# +# and similar for C++ (change all instances of CC to CXX), Fortran 77 +# (with F77 instead of CC) or Fortran (with FC instead of CC). +# +# NOTE: The above assumes that you will use $CC (or whatever) for linking +# as well as for compiling. (This is the default for automake and most +# Makefiles.) +# +# The user can force a particular library/compiler by setting the +# MPICC/MPICXX/MPIF77/MPIFC and/or MPILIBS environment variables. +# +# ACTION-IF-FOUND is a list of shell commands to run if an MPI library is +# found, and ACTION-IF-NOT-FOUND is a list of commands to run if it is not +# found. If ACTION-IF-FOUND is not specified, the default action will +# define HAVE_MPI. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Julian C. Cummings +# +# 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 . +# +# 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 7 + +AU_ALIAS([ACX_MPI], [AX_MPI]) +AC_DEFUN([AX_MPI], [ +AC_PREREQ([2.71]) dnl for AC_LANG_CASE + +AC_LANG_CASE([C], [ + AC_REQUIRE([AC_PROG_CC]) + AC_ARG_VAR(MPICC,[MPI C compiler command]) + AC_CHECK_PROGS(MPICC, mpicc hcc mpxlc_r mpxlc mpcc cmpicc, $CC) + ax_mpi_save_CC="$CC" + CC="$MPICC" + AC_SUBST(MPICC) + AC_MSG_CHECKING([checking MPI C flags]) + ax_mpi_c_flags="`$MPICC -showme:compile 2>/dev/null| cut -d\ -f2-`" + ax_mpi_c_libs="`$MPICC -showme:link 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_c_flags" = "x"],[ + ax_mpi_c_flags="`$MPICC -show -c 2>/dev/null| cut -d\ -f2-|sed s/-c\ //`" + ax_mpi_c_libs="`$MPICC -show 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_c_flags" = "x"],[AC_MSG_RESULT([could not determine c flags from show functions])],[AC_MSG_RESULT([flags found])]) + + ], [ + AC_MSG_RESULT([flags found])]) + MPI_CFLAGS="$ax_mpi_c_flags" + MPI_CLIBS="$ax_mpi_c_libs" + AC_SUBST(MPI_CFLAGS) + AC_SUBST(MPI_CLIBS) + +], +[C++], [ + AC_REQUIRE([AC_PROG_CXX]) + AC_ARG_VAR(MPICXX,[MPI C++ compiler command]) + AC_CHECK_PROGS(MPICXX, mpicxx mpiCC mpic++ hcp mpxlC_r mpxlC mpCC cmpic++, $CXX) + ax_mpi_save_CXX="$CXX" + CXX="$MPICXX" + AC_SUBST(MPICXX) + + AC_MSG_CHECKING([checking MPI C++ flags]) + ax_mpi_cc_flags="`$MPICXX -showme:compile 2>/dev/null| cut -d\ -f2-`" + ax_mpi_cc_libs="`$MPICXX -showme:link 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_cc_flags" = "x"],[ + ax_mpi_cc_flags="`$MPICXX -show -c 2>/dev/null| cut -d\ -f2-|sed s/-c\ //`" + ax_mpi_cc_libs="`$MPICXX -show 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_cc_flags" = "x"],[AC_MSG_RESULT([could not determine C++ flags from show functions])],[AC_MSG_RESULT([flags found])]) + + ], [ + AC_MSG_RESULT([flags found])]) + MPI_CXXFLAGS="$ax_mpi_cc_flags" + MPI_CXXLIBS="$ax_mpi_cc_libs" + AC_SUBST(MPI_CXXFLAGS) + AC_SUBST(MPI_CXXLIBS) + +], +[Fortran 77], [ + AC_REQUIRE([AC_PROG_F77]) + AC_ARG_VAR(MPIF77,[MPI Fortran 77 compiler command]) + AC_CHECK_PROGS(MPIF77, mpif77 hf77 mpxlf_r mpxlf mpf77 cmpifc, $F77) + ax_mpi_save_F77="$F77" + F77="$MPIF77" + AC_SUBST(MPIF77) +], +[Fortran], [ + AC_REQUIRE([AC_PROG_FC]) + AC_ARG_VAR(MPIFC,[MPI Fortran compiler command]) + AC_CHECK_PROGS(MPIFC, mpif90 mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpf90 cmpif90c, $FC) + ax_mpi_save_FC="$FC" + FC="$MPIFC" + AC_SUBST(MPIFC) + AC_MSG_CHECKING([checking MPI Fortran flags]) + ax_mpi_fc_flags="`$MPIFC -showme:compile 2>/dev/null| cut -d\ -f2-`" + ax_mpi_fc_libs="`$MPIFC -showme:link 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_fc_flags" = "x"],[ + ax_mpi_fc_flags="`$MPIFC -show -c 2>/dev/null| cut -d\ -f2-|sed s/-c\ //`" + ax_mpi_fc_libs="`$MPIFC -show 2>/dev/null| cut -d\ -f2-`" + AS_IF([test "x$ax_mpi_fc_flags" = "x"],[AC_MSG_RESULT([could not determine c flags from show functions])],[AC_MSG_RESULT([flags found])]) + + ], [ + AC_MSG_RESULT([flags found])]) + MPI_FCFLAGS="$ax_mpi_fc_flags" + MPI_FCLIBS="$ax_mpi_fc_libs" + AC_SUBST(MPI_FCFLAGS) + AC_SUBST(MPI_FCLIBS) +]) + +if test x = x"$MPILIBS"; then + AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])], + [C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])], + [Fortran 77], [AC_MSG_CHECKING([for MPI_Init]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[ call MPI_Init])],[MPILIBS=" " + AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])], + [Fortran], [AC_MSG_CHECKING([for MPI_Init]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[ call MPI_Init])],[MPILIBS=" " + AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])]) +fi +AC_LANG_CASE([Fortran 77], [ + if test x = x"$MPILIBS"; then + AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"]) + fi + if test x = x"$MPILIBS"; then + AC_CHECK_LIB(fmpich, MPI_Init, [MPILIBS="-lfmpich"]) + fi +], +[Fortran], [ + if test x = x"$MPILIBS"; then + AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"]) + fi + if test x = x"$MPILIBS"; then + AC_CHECK_LIB(mpichf90, MPI_Init, [MPILIBS="-lmpichf90"]) + fi + +]) +if test x = x"$MPILIBS"; then + AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"]) +fi +if test x = x"$MPILIBS"; then + AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"]) +fi + +dnl We have to use AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) and not AC_CHECK_HEADER because the +dnl latter uses $CPP, not $CC (which may be mpicc). +AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then + AC_MSG_CHECKING([for mpi.h]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])],[AC_MSG_RESULT(yes)],[MPILIBS="" + AC_MSG_RESULT(no)]) +fi], +[C++], [if test x != x"$MPILIBS"; then + AC_MSG_CHECKING([for mpi.h]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])],[AC_MSG_RESULT(yes)],[MPILIBS="" + AC_MSG_RESULT(no)]) +fi], +[Fortran 77], [if test x != x"$MPILIBS"; then + AC_MSG_CHECKING([for mpif.h]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS="" + AC_MSG_RESULT(no)]) +fi], +[Fortran], [if test x != x"$MPILIBS"; then + AC_MSG_CHECKING([for mpif.h]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS="" + AC_MSG_RESULT(no)]) +fi]) + +AC_LANG_CASE([C], [CC="$ax_mpi_save_CC"], + [C++], [CXX="$ax_mpi_save_CXX"], + [Fortran 77], [F77="$ax_mpi_save_F77"], + [Fortran], [FC="$ax_mpi_save_FC"]) + +AC_SUBST(MPILIBS) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x = x"$MPILIBS"; then + $2 + : +else + ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1]) + : +fi +])dnl AX_MPI diff --git a/src/amuse_uclchem/support/shared/m4/ax_openmp.m4 b/src/amuse_uclchem/support/shared/m4/ax_openmp.m4 new file mode 100644 index 0000000000..866e1d6645 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_openmp.m4 @@ -0,0 +1,123 @@ +# =========================================================================== +# https://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 +# Copyright (c) 2015 John W. Peterson +# Copyright (c) 2016 Nick R. Papior +# +# 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 . +# +# 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 13 + +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 + +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 diff --git a/src/amuse_uclchem/support/shared/m4/ax_prog_jar.m4 b/src/amuse_uclchem/support/shared/m4/ax_prog_jar.m4 new file mode 100644 index 0000000000..76ed8147c6 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_prog_jar.m4 @@ -0,0 +1,50 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAR +# +# DESCRIPTION +# +# AX_PROG_JAR tests for an existing jar program. It uses the environment +# variable JAR then tests in sequence various common jar programs. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAR=yourcompiler before calling +# AX_PROG_JAR +# +# - at the configure level, setenv JAR +# +# You can use the JAR variable in your Makefile.in, with @JAR@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# 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 8 + +AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) +AC_DEFUN([AX_PROG_JAR],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) +test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) +AC_PROVIDE([$0])dnl +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_prog_java.m4 b/src/amuse_uclchem/support/shared/m4/ax_prog_java.m4 new file mode 100644 index 0000000000..c4312ee8e7 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_prog_java.m4 @@ -0,0 +1,116 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA +# +# DESCRIPTION +# +# Here is a summary of the main macros: +# +# AX_PROG_JAVAC: finds a Java compiler. +# +# AX_PROG_JAVA: finds a Java virtual machine. +# +# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). +# +# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops +# otherwise. +# +# AX_TRY_COMPILE_JAVA: attempt to compile user given source. +# +# AX_TRY_RUN_JAVA: attempt to compile and run user given source. +# +# AX_JAVA_OPTIONS: adds Java configure options. +# +# AX_PROG_JAVA tests an existing Java virtual machine. It uses the +# environment variable JAVA then tests in sequence various common Java +# virtual machines. For political reasons, it starts with the free ones. +# You *must* call [AX_PROG_JAVAC] before. +# +# If you want to force a specific VM: +# +# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA +# +# (but after AC_INIT) +# +# - at the configure level, setenv JAVA +# +# You can use the JAVA variable in your Makefile.in, with @JAVA@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude virtual machines (rationale: most Java programs +# cannot run with some VM like kaffe). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# A Web page, with a link to the latest CVS snapshot is at +# . +# +# This is a sample configure.in Process this file with autoconf to produce +# a configure script. +# +# AC_INIT(UnTag.java) +# +# dnl Checks for programs. +# AC_CHECK_CLASSPATH +# AX_PROG_JAVAC +# AX_PROG_JAVA +# +# dnl Checks for classes +# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) +# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) +# +# AC_OUTPUT(Makefile) +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 . +# +# 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 10 + +AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) +AC_DEFUN([AX_PROG_JAVA],[ +m4_define([m4_ax_prog_java_list], [kaffe java])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) +test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) +m4_undefine([m4_ax_prog_java_list])dnl +AX_PROG_JAVA_WORKS +AC_PROVIDE([$0])dnl +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_prog_java_works.m4 b/src/amuse_uclchem/support/shared/m4/ax_prog_java_works.m4 new file mode 100644 index 0000000000..d92b7b8ddc --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_prog_java_works.m4 @@ -0,0 +1,92 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 . +# +# 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 11 + +AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) +AC_DEFUN([AX_PROG_JAVA_WORKS], [ + if test x$ac_cv_prog_javac_works = xno; then + AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) + fi + if test x$ac_cv_prog_javac_works = x; then + AX_PROG_JAVAC + fi +AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +TEST=Test +changequote(, )dnl +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +public static void main (String args[]) { + System.exit (0); +} } +EOF +changequote([, ])dnl + if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then + : + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) + fi +if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then + ac_cv_prog_java_works=yes +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +] +) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_prog_javac.m4 b/src/amuse_uclchem/support/shared/m4/ax_prog_javac.m4 new file mode 100644 index 0000000000..9dae89b1bb --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_prog_javac.m4 @@ -0,0 +1,80 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_javac.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC +# +# DESCRIPTION +# +# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment +# variable JAVAC then tests in sequence various common Java compilers. For +# political reasons, it starts with the free ones. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AX_PROG_JAVAC +# +# - at the configure level, setenv JAVAC +# +# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude compilers (rationale: most Java programs cannot +# compile with some compilers like guavac). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 . +# +# 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 8 + +AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) +AC_DEFUN([AX_PROG_JAVAC],[ +m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) +m4_undefine([m4_ax_prog_javac_list])dnl +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AX_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) + diff --git a/src/amuse_uclchem/support/shared/m4/ax_prog_javac_works.m4 b/src/amuse_uclchem/support/shared/m4/ax_prog_javac_works.m4 new file mode 100644 index 0000000000..f0efe85342 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/ax_prog_javac_works.m4 @@ -0,0 +1,73 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 . +# +# 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 7 + +AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) +AC_DEFUN([AX_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) + diff --git a/src/amuse_uclchem/support/shared/m4/fftw.m4 b/src/amuse_uclchem/support/shared/m4/fftw.m4 new file mode 100644 index 0000000000..45a55f06fc --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/fftw.m4 @@ -0,0 +1,122 @@ +# AX_FFTW +# ---------------------------------------------------------- +# set up for FFTW +# +AC_DEFUN([AX_FFTW],[ + AC_ARG_WITH(fftw, + AS_HELP_STRING([--with-fftw=PFX],[Prefix where FFTW has been installed ]), + [ + test "$withval" = no && AC_MSG_WARN([fftw is a required package for some modules]) + test "$withval" = yes || fftw_prefix="$withval" + with_fftw=yes ], + [ with_fftw=yes ] + ) + + AS_IF([test "x$with_fftw" != xno ], + [ + #user override + AS_IF([test "x$FFTW_LIBS" != x && test "x$FFTW_FLAGS" != x ], + [ + have_fftw=yes + FOUND_FFTW="yes" + ], + [ + saved_LIBS="$LIBS" + saved_CXXFLAGS="$CXXFLAGS" + FFTW_LIBS="" + FFTW_FLAGS="" + FOUND_FFTW="no" + if test x$fftw_prefix == x; then + if test x$PREFIX != x; then + fftw_prefix=$PREFIX + fi + fi + if test x$fftw_prefix != x; then + ac_FFTW_CFLAGS="-I$fftw_prefix/include" + ac_FFTW_LDOPTS="-L$fftw_prefix/lib" + + + save_CFLAGS="$CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CFLAGS="$ac_FFTW_CFLAGS $save_CFLAGS" + CPPFLAGS="$ac_FFTW_CFLAGS $save_CPPFLAGS" + AC_CHECK_HEADER( + [fftw3.h], + [FFTW_FLAGS="$ac_FFTW_CFLAGS" + FOUND_FFTW="yes"], + [AC_MSG_WARN([Cannot find headers (fftw3.h) of the library FFTW in $fftw_prefix/include.])] + ) + CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" + + save_LIBS="$LIBS" + LIBS="$ac_FFTW_LDOPTS -lfftw3 -lfftw3_threads $save_LIBS" + + cache_var=AS_TR_SH([ac_cv_lib_fftw3_fftw_plan_dft_r2c]) + AC_CHECK_LIB([fftw3], [fftw_plan_dft_r2c], + [FFTW_LIBS="$ac_FFTW_LDOPTS -lfftw3 -lfftw3_threads"], + [FOUND_FFTW="no"] + ) + $as_unset $cache_var + if test x$FOUND_FFTW != xyes; then + LIBS="$ac_FFTW_LDOPTS -lfftw3 -lfftw3_threads -lm $save_LIBS" + AC_CHECK_LIB([fftw3], [fftw_plan_dft_r2c], + [FOUND_FFTW="yes" + FFTW_LIBS="$ac_FFTW_LDOPTS -lfftw3 -lfftw3_threads -lm"], + [AC_MSG_WARN([libfftw3 : library missing. (Cannot find symbol fftw_plan_dft_r2c) in $fftw_prefix. Check if libfftw3 is installed and if the version is correct])] + ) + $as_unset $cache_var + fi + LIBS="$save_LIBS" + fi + + if test x$FOUND_FFTW != xyes; then + PKG_CHECK_MODULES([FFTW],[fftw3 >= 3.2], + [ + FFTW_FLAGS="$FFTW_CFLAGS" + FFTW_LIBS="$FFTW_LIBS -lfftw3_threads" + FOUND_FFTW=yes + ], + [] + ) + fi + + if test x$FOUND_FFTW != xyes; then + AC_CHECK_HEADER( + [fftw3.h], + [FFTW_FLAGS="" + FOUND_FFTW="yes"], + [AC_MSG_WARN([Cannot find headers (fftw3.h) of the library FFTW in $fftw_prefix/include.])] + ) + cache_var=AS_TR_SH([ac_cv_lib_fftw3_fftw_plan_dft_r2c]) + AC_CHECK_LIB( + [fftw3], + [fftw_plan_dft_r2c], + [FFTW_LIBS="-lfftw3 -lfftw3_threads"], + [FOUND_FFTW="no"] + ) + $as_unset $cache_var + + if test x$FOUND_FFTW != xyes; then + + save_LIBS="$LIBS" + LIBS="-lfftw3_threads -lm $save_LIBS" + AC_CHECK_LIB([fftw3], [fftw_plan_dft_r2c], + [FOUND_FFTW="yes" + FFTW_LIBS="$ac_FFTW_LDOPTS -lfftw3 -lfftw3_threads -lm"], + [FOUND_FFTW="no" + AC_MSG_WARN([libfftw3 : library missing. (Cannot find symbol fftw_plan_dft_r2c) in $fftw_prefix. Check if libfftw3 is installed and if the version is correct])] + ) + LIBS="$save_LIBS" + fi + fi + + + ]) + ]) + + AC_SUBST(FOUND_FFTW) + AC_SUBST(FFTW_FLAGS) + AC_SUBST(FFTW_LIBS) + ] +) diff --git a/src/amuse_uclchem/support/shared/m4/fortran.m4 b/src/amuse_uclchem/support/shared/m4/fortran.m4 new file mode 100644 index 0000000000..8b042cd390 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/fortran.m4 @@ -0,0 +1,43 @@ +AC_DEFUN([AX_FC_WORKS],[ +AC_LANG_PUSH(Fortran) +AC_MSG_CHECKING([whether the Fortran 90 compiler ($FC $FCFLAGS $LDFLAGS) works]) +AC_LINK_IFELSE([ + AC_LANG_SOURCE([ + program conftest + integer, dimension(10) :: n + end + ]) +],[ + ax_cv_prog_fc_works="yes" + AC_MSG_RESULT([$ax_cv_prog_fc_works]) +],[ + ax_cv_prog_fc_works="no" + AC_MSG_WARN([installation or configuration problem: Fortran 90 compiler cannot create executables.]) +]) +# The intel compiler sometimes generates these work.pc and .pcl files +rm -f work.pc work.pcl +AC_LANG_POP(Fortran) +]) + + +AC_DEFUN([AX_FC_ISO_C_BINDING],[ +AC_LANG_PUSH(Fortran) +AC_MSG_CHECKING([if the fortran compiler supports iso c binding]) +AC_LINK_IFELSE([ + AC_LANG_SOURCE([ + program conftest + use ISO_C_BINDING + integer, dimension(10) :: n + end + ]) +],[ + FC_ISO_C_BINDINGS="yes" + AC_MSG_RESULT([$ax_cv_fc_iso_c_bindings]) +],[ + FC_ISO_C_BINDINGS="no" + AC_MSG_RESULT([no, fortran codes and sockets or embedding will not work.]) +]) +# The intel compiler sometimes generates these work.pc and .pcl files +rm -f work.pc work.pcl +AC_LANG_POP(Fortran) +]) diff --git a/src/amuse_uclchem/support/shared/m4/gmp.m4 b/src/amuse_uclchem/support/shared/m4/gmp.m4 new file mode 100644 index 0000000000..584168bd12 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/gmp.m4 @@ -0,0 +1,103 @@ +# AX_GMP +# ---------------------------------------------------------- +# set up for GMP +# +AC_DEFUN([AX_GMP],[ + AC_ARG_WITH(gmp, + AS_HELP_STRING([--with-gmp=PFX],[Prefix where GMP has been installed ]), + [ + test "$withval" = no && AC_MSG_WARN([gmp is a required package for some modules]) + test "$withval" = yes || gmp_prefix="$withval" + with_gmp=yes ], + [ with_gmp=yes ] + ) + + AS_IF([test "x$with_gmp" != xno ], + [ + #user override + AS_IF([test "x$GMP_LIBS" != x ], + [ + have_gmp=yes + FOUND_GMP="yes" + ], + [ + + + + saved_LIBS="$LIBS" + saved_CXXFLAGS="$CXXFLAGS" + GMP_LIBS="" + GMP_FLAGS="" + FOUND_GMP="no" + if test x$gmp_prefix == x; then + if test x$PREFIX != x; then + gmp_prefix=$PREFIX + fi + fi + if test x$gmp_prefix != x; then + ac_gmp_CFLAGS="-I$gmp_prefix/include" + ac_gmp_LDOPTS="-L$gmp_prefix/lib" + + + save_CFLAGS="$CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CFLAGS="$ac_gmp_CFLAGS $save_CFLAGS" + CPPFLAGS="$ac_gmp_CFLAGS $save_CPPFLAGS" + AC_CHECK_HEADER( + [gmp.h], + [GMP_FLAGS="$ac_gmp_CFLAGS" + FOUND_GMP="yes"], + [AC_MSG_WARN([Cannot find headers (gmp.h) of the library GMP in $gmp_prefix/include.])] + ) + CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" + + if test x$FOUND_GMP == xyes; then + save_LIBS="$LIBS" + LIBS="$ac_gmp_LDOPTS -lgmp $save_LIBS" + AC_CHECK_LIB([gmp], [__gmpz_init], + [GMP_LIBS="$ac_gmp_LDOPTS -lgmp"], + [FOUND_GMP="no" + AC_MSG_WARN([libgmp : library missing. (Cannot find symbol gmpz_init) in $gmp_prefix. Check if libgmp is installed and if the version is correct])] + ) + LIBS="$save_LIBS" + fi + fi + if test x$FOUND_GMP != xyes; then + PKG_CHECK_MODULES([GMP],[gmp >= 3], + [ + GMP_FLAGS="$GMP_FLAGS" + GMP_LIBS="$GMP_LIBS" + FOUND_GMP=yes + ], + [] + ) + + fi + + if test x$FOUND_GMP != xyes; then + AC_CHECK_HEADER( + [gmp.h], + [GMP_FLAGS="" + FOUND_GMP="yes"], + [AC_MSG_WARN([Cannot find headers (gmp.h) of the library GMP.])] + ) + AC_CHECK_LIB( + [gmp], + [__gmpz_init], + [GMP_LIBS="-lgmp"], + [ + FOUND_GMP="no" + AC_MSG_WARN([libgmp : library missing. (Cannot find symbol gmpz_init). Check if libgmp is installed and if the version is correct])] + ) + fi + + + ]) + ]) + + AC_SUBST(FOUND_GMP) + AC_SUBST(GMP_FLAGS) + AC_SUBST(GMP_LIBS) + ] +) diff --git a/src/amuse_uclchem/support/shared/m4/gsl.m4 b/src/amuse_uclchem/support/shared/m4/gsl.m4 new file mode 100644 index 0000000000..96c3189801 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/gsl.m4 @@ -0,0 +1,122 @@ +# Configure path for the GNU Scientific Library +# Christopher R. Gabriel , April 2000 + + +AC_DEFUN([AX_PATH_GSL], +[ +AC_ARG_WITH(gsl-prefix,[ --with-gsl-prefix=PFX Prefix where GSL is installed (optional)], + gsl_prefix="$withval", gsl_prefix="") +AC_ARG_WITH(gsl-exec-prefix,[ --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)], + gsl_exec_prefix="$withval", gsl_exec_prefix="") +AC_ARG_ENABLE(gsltest, [ --disable-gsltest Do not try to compile and run a test GSL program], + , enable_gsltest=yes) + + if test "x${GSL_CONFIG+set}" != xset ; then + if test "x$gsl_prefix" != x ; then + GSL_CONFIG="$gsl_prefix/bin/gsl-config" + fi + if test "x$gsl_exec_prefix" != x ; then + GSL_CONFIG="$gsl_exec_prefix/bin/gsl-config" + fi + fi + + + if test "x${GSL_CONFIG+set}" == xset ; then + if test -x "${GSL_CONFIG}" ; then + gsl_config_exists=yes + else + gsl_config_exists=no + fi + fi + FOUND_GSL=no + if test "x$GSL_CFLAGS" != x ; then + if test "x$GSL_LIBS" != x ; then + GSL_FLAGS="$GSL_CFLAGS" + GSL_LIBS="$GSL_LIBS" + FOUND_GSL=yes + AC_SUBST(GSL_FLAGS) + fi + fi + if test "$FOUND_GSL" = "no"; then + if test "x$gsl_config_exists" != xyes ; then + PKG_CHECK_MODULES([GSL],[gsl >= 1.0], + [ + GSL_FLAGS="$GSL_CFLAGS" + GSL_LIBS="$GSL_LIBS" + FOUND_GSL=yes + AC_SUBST(GSL_FLAGS) + + ifelse([$2], , :, [$2]) + ], + [ + ] + ) + fi + fi + if test "$FOUND_GSL" = "no"; then + AC_PATH_PROG(GSL_CONFIG, gsl-config, no) + min_gsl_version=ifelse([$1], ,0.2.5,$1) + AC_MSG_CHECKING(for GSL - version >= $min_gsl_version) + no_gsl="" + if test "$GSL_CONFIG" = "no" ; then + no_gsl=yes + else + GSL_FLAGS=`$GSL_CONFIG --cflags` + GSL_LIBS=`$GSL_CONFIG --libs` + + gsl_version=`$GSL_CONFIG --version` + AS_VERSION_COMPARE( + [$gsl_version], + [$min_gsl_version], + [no_gsl=yes], + + ) + fi + if test "x$no_gsl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GSL_CONFIG" = "no" ; then + echo "*** The gsl-config script installed by GSL could not be found" + echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GSL_CONFIG environment variable to the" + echo "*** full path to gsl-config." + else + if test -f conf.gsltest ; then + : + else + echo "*** Could not run GSL test program, checking why..." + CFLAGS="$CFLAGS $GSL_FLAGS" + LIBS="$LIBS $GSL_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ return 0; ]])],[ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GSL or finding the wrong" + echo "*** version of GSL. If it is not finding GSL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],[ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GSL was incorrectly installed" + echo "*** or that you have moved GSL since it was installed. In the latter case, you" + echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + # GSL_FLAGS="" + # GSL_LIBS="" + ifelse([$3], , :, [$3]) + fi + + fi + AC_SUBST(GSL_FLAGS) + AC_SUBST(GSL_LIBS) + rm -f conf.gsltest + +]) + +AU_ALIAS([AM_PATH_GSL], [AX_PATH_GSL]) diff --git a/src/amuse_uclchem/support/shared/m4/mpfr.m4 b/src/amuse_uclchem/support/shared/m4/mpfr.m4 new file mode 100644 index 0000000000..eba25c6dc9 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/mpfr.m4 @@ -0,0 +1,109 @@ +# AX_MPFR +# ---------------------------------------------------------- +# set up for MPFR +# +AC_DEFUN([AX_MPFR],[ + AC_ARG_WITH(mpfr, + AS_HELP_STRING([--with-mpfr=PFX],[Prefix where MPFR has been installed ]), + [ + test "$withval" = no && AC_MSG_WARN([mpfr is a required package for some modules]) + test "$withval" = yes || mpfr_prefix="$withval" + with_mpfr=yes ], + [ with_mpfr=yes ] + ) + + AS_IF([test "x$with_mpfr" != xno ], + [ + #user override + AS_IF([test "x$MPFR_LIBS" != x ], + [ + have_mpfr=yes + FOUND_MPFR="yes" + ], + [ + + + + saved_LIBS="$LIBS" + saved_CXXFLAGS="$CXXFLAGS" + MPFR_LIBS="" + MPFR_FLAGS="" + FOUND_MPFR="no" + if test x$mpfr_prefix == x; then + if test x$PREFIX != x; then + mpfr_prefix=$PREFIX + fi + fi + if test x$mpfr_prefix != x; then + ac_mpfr_CFLAGS="-I$mpfr_prefix/include" + ac_mpfr_LDOPTS="-L$mpfr_prefix/lib" + + + save_CFLAGS="$CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CFLAGS="$ac_mpfr_CFLAGS $save_CFLAGS" + CPPFLAGS="$ac_mpfr_CFLAGS $save_CPPFLAGS" + + cache_var=AS_TR_SH([ac_cv_header_mpfr.h]) + AC_CHECK_HEADER( + [mpfr.h], + [MPFR_FLAGS="$ac_mpfr_CFLAGS" + FOUND_MPFR="yes"], + [AC_MSG_WARN([Cannot find headers (mpfr.h) of the library MPFR in $mpfr_prefix/include.])] + ) + $as_unset $cache_var + CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" + + if test x$FOUND_MPFR == xyes; then + save_LIBS="$LIBS" + LIBS="$ac_mpfr_LDOPTS -lmpfr $save_LIBS" + + cache_var=AS_TR_SH([ac_cv_lib_mpfr_mpfr_init]) + AC_CHECK_LIB([mpfr], [mpfr_init], + [MPFR_LIBS="$ac_mpfr_LDOPTS -lmpfr"], + [FOUND_MPFR="no" + AC_MSG_WARN([libmpfr : library missing. (Cannot find symbol mpfr_init) in $mpfr_prefix. Check if libmpfr is installed and if the version is correct])] + ) + LIBS="$save_LIBS" + $as_unset $cache_var + fi + fi + if test x$FOUND_MPFR != xyes; then + PKG_CHECK_MODULES([MPFR],[mpfr >= 3], + [ + MPFR_FLAGS="$MPFR_FLAGS" + MPFR_LIBS="$MPFR_LIBS" + FOUND_MPFR=yes + ], + [] + ) + + fi + + if test x$FOUND_MPFR != xyes; then + AC_CHECK_HEADER( + [mpfr.h], + [MPFR_FLAGS="" + FOUND_MPFR="yes"], + [AC_MSG_WARN([Cannot find headers (mpfr.h) of the library MPFR.])] + ) + AC_CHECK_LIB( + [mpfr], + [mpfr_init], + [MPFR_LIBS="-lmpfr"], + [ + FOUND_MPFR="no" + AC_MSG_WARN([libmpfr : library missing. (Cannot find symbol mpfr_init). Check if libmpfr is installed and if the version is correct])] + ) + fi + + + ]) + ]) + + AC_SUBST(FOUND_MPFR) + AC_SUBST(MPFR_FLAGS) + AC_SUBST(MPFR_LIBS) + ] +) diff --git a/src/amuse_uclchem/support/shared/m4/pkg.m4 b/src/amuse_uclchem/support/shared/m4/pkg.m4 new file mode 100644 index 0000000000..d8549a4789 --- /dev/null +++ b/src/amuse_uclchem/support/shared/m4/pkg.m4 @@ -0,0 +1,343 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 11 (pkg-config-0.29.1) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.1]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR + +dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------ +dnl +dnl Prepare a "--with-" configure option using the lowercase +dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and +dnl PKG_CHECK_MODULES in a single macro. +AC_DEFUN([PKG_WITH_MODULES], +[ +m4_pushdef([with_arg], m4_tolower([$1])) + +m4_pushdef([description], + [m4_default([$5], [build with ]with_arg[ support])]) + +m4_pushdef([def_arg], [m4_default([$6], [auto])]) +m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) +m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) + +m4_case(def_arg, + [yes],[m4_pushdef([with_without], [--without-]with_arg)], + [m4_pushdef([with_without],[--with-]with_arg)]) + +AC_ARG_WITH(with_arg, + AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, + [AS_TR_SH([with_]with_arg)=def_arg]) + +AS_CASE([$AS_TR_SH([with_]with_arg)], + [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], + [auto],[PKG_CHECK_MODULES([$1],[$2], + [m4_n([def_action_if_found]) $3], + [m4_n([def_action_if_not_found]) $4])]) + +m4_popdef([with_arg]) +m4_popdef([description]) +m4_popdef([def_arg]) + +])dnl PKG_WITH_MODULES + +dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ----------------------------------------------- +dnl +dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES +dnl check._[VARIABLE-PREFIX] is exported as make variable. +AC_DEFUN([PKG_HAVE_WITH_MODULES], +[ +PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) + +AM_CONDITIONAL([HAVE_][$1], + [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) +])dnl PKG_HAVE_WITH_MODULES + +dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------------------ +dnl +dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after +dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make +dnl and preprocessor variable. +AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], +[ +PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) + +AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], + [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) +])dnl PKG_HAVE_DEFINE_WITH_MODULES diff --git a/src/amuse_uclchem/support/shared/uninstall.sh b/src/amuse_uclchem/support/shared/uninstall.sh new file mode 100755 index 0000000000..e08122700e --- /dev/null +++ b/src/amuse_uclchem/support/shared/uninstall.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +PACKAGE="$1" + +if test -z "${PACKAGE}" ; then + echo " Incorrect usage, please specify a package name as the first argument." + exit 1 +fi + +if test -n "${VIRTUAL_ENV}${CONDA_DEFAULT_ENV}" ; then + pip_package_line=$(pip list | grep "${PACKAGE} ") + if [ "a${pip_package_line}" = "a" ] ; then + printf '%s\n' " Package ${PACKAGE} was not installed, not uninstalling." + exit 0 + fi +fi + +if test -n "${VIRTUAL_ENV}" ; then + # grep -q stops reading when a match is found, which then crashes pip list, so we + # redirect instead. With conda list we can use -q as usual. + if [ "a${pip_package_line}" != "a" ] ; then + pip uninstall -y ${PACKAGE} + fi +fi + +if test -n "${CONDA_DEFAULT_ENV}" ; then + conda_package_line=$(conda list | grep "^${PACKAGE} ") + if printf '%s' "${conda_package_line}" | grep "" >/dev/null 2>&1 ; then + # Conda is showing a pip-installed develop package. However, there may be a + # conda package hidden underneath, so we're going to try to conda uninstall + # anyway to fix that if needed. This will fail if everything is as it should + # be, so we make sure to inhibit the error message to reduce confusion. + EXPECTING_FAIL=true + fi + + if printf '%s' "${conda_package_line}" | grep -v "pypi$" >/dev/null 2>&1 ; then + TMPOUT=$(mktemp) + conda remove -y ${PACKAGE} >${TMPOUT} 2>&1 + err="$?" + # If it failed and we were not expecting it to, print the output + if test "$err" != 0 -a -z "${EXPECTING_FAIL}" ; then + cat ${TMPOUT} + fi + rm ${TMPOUT} + fi + + if [ "a${pip_package_line}" != "a" ] ; then + pip uninstall -y ${PACKAGE} + fi +fi + diff --git a/src/amuse_uclchem/tests/test_uclchem.py b/src/amuse_uclchem/tests/test_uclchem.py new file mode 100644 index 0000000000..5bd65272c9 --- /dev/null +++ b/src/amuse_uclchem/tests/test_uclchem.py @@ -0,0 +1,12 @@ +from amuse.support.testing.amusetest import TestWithMPI + +from amuse.community.uclchem.interface import uclchemInterface, uclchem + +class uclchemInterfaceTests(TestWithMPI): + + def test_echo_int(self): + instance = uclchemInterface() + result,error = instance.echo_int(12) + self.assertEquals(error, 0) + self.assertEquals(result, 12) + instance.stop() From 2aeb166b98973f5fc800c089f630f24ae0a41240 Mon Sep 17 00:00:00 2001 From: elkogerville Date: Thu, 13 Nov 2025 16:25:31 +0100 Subject: [PATCH 004/153] added uclchem to src/amuse/community and added DS_Store to gitignore --- .gitignore | 4 ++++ src/amuse/community/uclchem/__init__.py | 1 + src/amuse/community/uclchem/interface.py | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 src/amuse/community/uclchem/__init__.py create mode 100644 src/amuse/community/uclchem/interface.py diff --git a/.gitignore b/.gitignore index ab9fc0910f..b92f662a8b 100644 --- a/.gitignore +++ b/.gitignore @@ -455,3 +455,7 @@ packages/dist # standard directory for a virtualenv env/ + +# mac DS_Store +.DS_Store +**/.DS_Store diff --git a/src/amuse/community/uclchem/__init__.py b/src/amuse/community/uclchem/__init__.py new file mode 100644 index 0000000000..527f469a15 --- /dev/null +++ b/src/amuse/community/uclchem/__init__.py @@ -0,0 +1 @@ +from .interface import Uclchem diff --git a/src/amuse/community/uclchem/interface.py b/src/amuse/community/uclchem/interface.py new file mode 100644 index 0000000000..b01e491705 --- /dev/null +++ b/src/amuse/community/uclchem/interface.py @@ -0,0 +1,7 @@ +from amuse.support.import_helper import load_code + + +UclChemInterface = load_code("uclchem", "UclChemInterface") +UclChem = load_code("uclchem", "UclChem") + +Uclchem = UclChem From 24542e9b4d8c6b8106938d43eb3a4f54cb6da1c3 Mon Sep 17 00:00:00 2001 From: elkogerville Date: Thu, 13 Nov 2025 16:47:18 +0100 Subject: [PATCH 005/153] added uclchem src to amuse/sec/amuse_uclchem/src --- src/amuse_uclchem/src/amuse_helpers.f90 | 685 + src/amuse_uclchem/src/chemistry.f90 | 318 + src/amuse_uclchem/src/cloud.f90 | 65 + src/amuse_uclchem/src/collapse.f90 | 376 + src/amuse_uclchem/src/constants.f90 | 61 + src/amuse_uclchem/src/cshock.f90 | 247 + src/amuse_uclchem/src/defaultparameters.f90 | 115 + src/amuse_uclchem/src/dvode.f90 | 18968 ++++++++++++++++ src/amuse_uclchem/src/hash.f90 | 82 + src/amuse_uclchem/src/hotcore.f90 | 170 + src/amuse_uclchem/src/io.f90 | 116 + src/amuse_uclchem/src/jacobian.f90 | 6576 ++++++ src/amuse_uclchem/src/jshock.f90 | 144 + src/amuse_uclchem/src/main.f90 | 43 + src/amuse_uclchem/src/network.f90 | 4189 ++++ src/amuse_uclchem/src/odes.f90 | 5148 +++++ src/amuse_uclchem/src/photoreactions.f90 | 560 + src/amuse_uclchem/src/physics-core.f90 | 162 + src/amuse_uclchem/src/rates.f90 | 311 + src/amuse_uclchem/src/sputtering.f90 | 233 + src/amuse_uclchem/src/surfacereactions.f90 | 291 + .../src/utils/generate_param_docs.py | 21 + .../src/utils/make_python_docs.sh | 30 + src/amuse_uclchem/src/utils/push_to_github.sh | 12 + .../src/utils/remove_table_styles.py | 25 + src/amuse_uclchem/src/wrap.f90 | 629 + 26 files changed, 39577 insertions(+) create mode 100644 src/amuse_uclchem/src/amuse_helpers.f90 create mode 100755 src/amuse_uclchem/src/chemistry.f90 create mode 100755 src/amuse_uclchem/src/cloud.f90 create mode 100644 src/amuse_uclchem/src/collapse.f90 create mode 100644 src/amuse_uclchem/src/constants.f90 create mode 100755 src/amuse_uclchem/src/cshock.f90 create mode 100644 src/amuse_uclchem/src/defaultparameters.f90 create mode 100755 src/amuse_uclchem/src/dvode.f90 create mode 100644 src/amuse_uclchem/src/hash.f90 create mode 100644 src/amuse_uclchem/src/hotcore.f90 create mode 100644 src/amuse_uclchem/src/io.f90 create mode 100644 src/amuse_uclchem/src/jacobian.f90 create mode 100644 src/amuse_uclchem/src/jshock.f90 create mode 100755 src/amuse_uclchem/src/main.f90 create mode 100644 src/amuse_uclchem/src/network.f90 create mode 100644 src/amuse_uclchem/src/odes.f90 create mode 100644 src/amuse_uclchem/src/photoreactions.f90 create mode 100755 src/amuse_uclchem/src/physics-core.f90 create mode 100755 src/amuse_uclchem/src/rates.f90 create mode 100644 src/amuse_uclchem/src/sputtering.f90 create mode 100644 src/amuse_uclchem/src/surfacereactions.f90 create mode 100644 src/amuse_uclchem/src/utils/generate_param_docs.py create mode 100755 src/amuse_uclchem/src/utils/make_python_docs.sh create mode 100755 src/amuse_uclchem/src/utils/push_to_github.sh create mode 100644 src/amuse_uclchem/src/utils/remove_table_styles.py create mode 100644 src/amuse_uclchem/src/wrap.f90 diff --git a/src/amuse_uclchem/src/amuse_helpers.f90 b/src/amuse_uclchem/src/amuse_helpers.f90 new file mode 100644 index 0000000000..4527e0a336 --- /dev/null +++ b/src/amuse_uclchem/src/amuse_helpers.f90 @@ -0,0 +1,685 @@ +MODULE uclchemhelper + USE physicscore + USE chemistry + USE io + USE constants + use network + IMPLICIT NONE + type particle_type + !Particles are defined here + integer :: id + double precision :: density !unit = cm^-3 + double precision :: temperature !unit = K + double precision :: ionrate !unit = galactic cr ionization rate + double precision :: uvrad !unit = Habing + double precision :: abundances(nSpec+1) + end type + integer :: nmols + type(particle_type), allocatable :: particles(:) + + double precision :: tcurrent ! time unit = yr + + integer :: nparticle + integer :: tot_id + + character(len=500) :: out_species + + integer, parameter :: NMAX=1000000 + + logical :: particles_searcheable=.FALSE. + integer, allocatable :: pid(:) + +CONTAINS + function chem_initialize() result(ret) + integer :: ret + tcurrent=0. + nparticle=0 + tot_id=0 + nmols=nspec + if(.not.allocated(particles)) allocate(particles(NMAX)) + particles(:)%density=0. + + ret=0 + end function + + function chem_commit_parameters() result(ret) + integer :: ret + ret=0 + end function + + function chem_commit_particles() result (ret) + integer :: ret + integer :: n + integer :: i + + particles_searcheable=.FALSE. + nparticle=clean_particles(particles) + ret=0 + end function + + function chem_end() result(ret) + integer :: ret + if(allocated(particles)) deallocate(particles) + ret=0 + end function + + function set_particle_state(id,density,temperature,ionrate,uvrad) result(ret) + integer :: ret + integer :: id,index + double precision :: density, temperature, ionrate, uvrad + index=find_particle(id) + if(index.LT.0) then + ret=index + return + endif + + particles(index)%density=density + particles(index)%temperature=temperature + particles(index)%ionrate=ionrate + particles(index)%uvrad=uvrad + ret=0 + + end function + + function get_particle_state(id,density,temperature,ionrate,uvrad) result(ret) + integer :: ret + integer :: id,index + double precision :: density, temperature, ionrate, uvrad + index=find_particle(id) + if(index.LT.0) then + ret=index + return + endif + + density=particles(index)%density + temperature=particles(index)%temperature + ionrate=particles(index)%ionrate + uvrad=particles(index)%uvrad + ret=0 + + end function + + function get_particle_abundance(id, aid, abundance) result(ret) + integer :: ret + integer :: id,index,aid + double precision :: abundance + index=find_particle(id) + if(index.LT.0) then + ret=index + return + endif + if(aid.LT.1.OR.aid.GT.500) then + ret=-1 + return + endif + abundance=particles(index)%abundances(aid) + ret=0 + end function + + function set_particle_abundance(id, aid, abundance) result(ret) + integer :: ret + integer :: id,index,aid + double precision :: abundance + index=find_particle(id) + if(index.LT.0) then + ret=index + return + endif + if(aid.LT.1.OR.aid.GT.500) then + ret=-1 + return + endif + particles(index)%abundances(aid)=abundance + ret=0 + end function + + function add_particle(id,density,temperature,ionrate,uvrad) result(ret) + use network + integer :: ret + integer :: i,id + double precision :: density, temperature, ionrate, uvrad + double precision :: x(500) + particles_searcheable=.FALSE. + id=new_id() + i=nparticle+1 + + if(i.GT.NMAX) then + ret=-1 + return + endif + particles(i)%id=id + particles(i)%density=density + particles(i)%temperature=temperature + particles(i)%ionrate=ionrate + particles(i)%uvrad=uvrad + particles(i)%abundances=1.d-40 + + if(density.GT.0) then + !values taken from the UCLchem default parameters + particles(i)%abundances(nh) = 0.5 !H + particles(i)%abundances(nh2) = 0.25 !H2 + particles(i)%abundances(nhe) = 0.1 !He + particles(i)%abundances(ncx) = 1.77d-04 !C+ (C is fully ionised by default) + particles(i)%abundances(nc) = 1.d-10 !C + particles(i)%abundances(no) = 3.34d-04 !O + particles(i)%abundances(nn) = 6.18d-05 !N + particles(i)%abundances(nmg) = 2.256d-06 !Mg + particles(i)%abundances(np) = 7.78d-08 !P + particles(i)%abundances(nf) = 3.6d-08 ! + particles(i)%abundances(nsx) = 3.51d-6 !S + particles(i)%abundances(nsix) = 1.78d-06 !Si + particles(i)%abundances(nclx) = 3.39d-08 !Cl + particles(i)%abundances(nelec) = 1.77d-04 + 3.51d-6 + 1.78d-06 + 3.39d-08 !electrons; sum of ions + endif + + nparticle=nparticle+1 + ret=0 + end function + + function remove_particle(id) result(ret) + integer :: ret + integer :: i,id + i=find_particle(id) + if(i.LE.0) then + ret=i + return + endif + if(particles(i)%density.LT.0) then + ret=-4 + return + endif + particles(i)%density=-1. + ret=0 + end function + + function new_id() + integer new_id + tot_id=tot_id+1 + new_id=tot_id + end function + + function find_particle(id_) result(index) + !Function to find a particle with a given id. Taken from the Krome interface. + use hashMod + type(hash_type),save :: hash + integer id_,index + integer, save :: nbod=0 + + if(.NOT.particles_searcheable) then + nbod=nparticle + if(allocated(pid)) deallocate(pid) + allocate(pid(nbod)) + pid(1:nbod)=particles(1:nbod)%id + call initHash(nbod/2+1,nbod, pid,hash) + particles_searcheable=.TRUE. + endif + + + index=find(id_,pid,hash) + + if(index.LE.0) then + index=-1 + return + endif + if(index.GT.nbod) then + index=-2 + return + endif + if(pid(index).NE.id_) then + index=-3 + return + endif + + end function + + function get_current_time(time) result(ret) + integer :: ret + double precision :: time + time = tcurrent + ret = 0 + end function + + function clean_particles(par) result(np) + integer :: left,right,np + type(particle_type), allocatable :: par(:) + type(particle_type) :: tmp + left=1 + if(.NOT.allocated(par)) then + np = 0 + return + endif + right=size(par) + if(right.EQ.0) then + np=0 + return + endif + do while(.TRUE.) + do while(par(left)%density.GT.0.AND.left.LT.right) + left=left+1 + enddo + do while(par(right)%density.LE.0.AND.left.LT.right) + right=right-1 + enddo + if(left.LT.right) then + tmp=par(left) + par(left)=par(right) + par(right)=tmp + else + exit + endif + enddo + if(par(left)%density.GT.0) left=left+1 + np=left-1 + end function + + function simple_evolution(dictionary, outSpeciesIn) result(ret) + !Evolves each particle seperately + integer :: ret + integer :: i, iret + CHARACTER(LEN=*) :: dictionary(:) + CHARACTER(LEN=*) :: outSpeciesIn + + ret = 0 + INCLUDE 'defaultparameters.f90' + print *, outSpeciesIn + do i=1,nparticle + CALL dictionaryParser(dictionary(i), outSpeciesIn,ret) + iret = evolve_1_particle(particles(i)) + ret = min(iret,ret) + enddo + tcurrent = timeInYears + return + + end function + + function evolve_1_particle(part) result(ret) + use cloud_mod + type(particle_type) :: part + integer :: ret + + dstep=1 + + + call coreInitializePhysics(ret) + CALL coreInitializePhysics(ret) + + CALL initializeChemistry(readabunds=.FALSE.) + + dstep=1 + !Make sure the saved abundances from previous steps are used + abund(:,1) = part%abundances + DO WHILE (((endAtFinalDensity) .and. (density(1) < finalDens)) .or. & + &((.not. endAtFinalDensity) .and. (timeInYears < finalTime))) + currentTimeold=currentTime + !In standard UCLchem, each physics module has its own timestep scheme. + CALL updateTargetTime + !loop over parcels, counting from centre out to edge of cloud + DO dstep=1,points + !reset time if this isn't first depth point + + currentTime=currentTimeold + !update chemistry from currentTime to targetTime + CALL updateChemistry(ret) + IF (ret .lt. 0) THEN + write(*,*) 'Error updating chemistry' + RETURN + END IF + + !get time in years for output, currentTime is now equal to targetTime + timeInYears= currentTime/SECONDS_PER_YEAR + + !Update physics so it's correct for new currentTime and start of next time step + Call coreUpdatePhysics + !Sublimation checks if Sublimation should happen this time step and does it + CALL sublimation(abund) + + !write this depth step now time, chemistry and physics are consistent + CALL output + END DO + END DO + !Save the computed abundances to the particle set + part%abundances=abund(:,1) + currentTime = 0.0 + end function + + SUBROUTINE get_rates(dictionary,abundancesIn,speciesIndx,rateIndxs,& + &speciesRates,successFlag,transfer,swap,bulk_layers) + !Given a species of interest, some parameters and abundances, this subroutine + !return the rate of all reactions that include that species plus some extra variables + !to allow for the calculation of the rate of bulk/surface ice transfer. + USE cloud_mod + USE network, only : nspec + CHARACTER(LEN=*):: dictionary + DOUBLE PRECISION :: abundancesIn(500),speciesRates(500) + DOUBLE PRECISION :: transfer,swap,bulk_layers + INTEGER:: rateIndxs(500),speciesIndx, successFlag + DOUBLE PRECISION :: ydot(nspec+1) + INTEGER :: speci,bulk_version,surface_version + !f2py intent(in) dictionary,abundancesIn,speciesIndx,rateIndxs + !f2py intent(out) speciesRates,successFlag,transfer,swap,bulk_layers + INCLUDE 'defaultparameters.f90' + + CALL dictionaryParser(dictionary, "",successFlag) + IF (successFlag .lt. 0) THEN + WRITE(*,*) 'Error reading parameter dictionary' + RETURN + END IF + CALL coreInitializePhysics(successFlag) + CALL initializePhysics(successFlag) + IF (successFlag .lt. 0) then + WRITE(*,*) 'Error initializing physics' + RETURN + END IF + + CALL initializeChemistry(readAbunds) + dstep=1 + successFlag=1 + abund(:nspec,dstep)=abundancesIn(:nspec) + abund(neq,dstep)=initialDens + currentTime=0.0 + timeInYears=0.0 + + targetTime=1.0d-7 + CALL updateChemistry(successFlag) + + CALL F(NEQ,currentTime,abund(:,dstep),ydot) + + speciesRates=rate(rateIndxs) + + IF ((specname(speciesIndx)(1:1) .eq. "#") .or.& + & (specname(speciesIndx)(1:1) .eq. "@")) THEN + DO speci=1,nSpec + IF (specname(speci) .eq. "@"//specname(speciesIndx)(2:)) bulk_version=speci + IF (specname(speci) .eq. "#"//specname(speciesIndx)(2:)) surface_version=speci + END DO + IF (YDOT(nsurface) .lt. 0) THEN + transfer=YDOT(nsurface)*surfaceCoverage*abund(bulk_version,1)/safeBulk + ELSE + transfer=YDOT(nsurface)*surfaceCoverage*abund(surface_version,1) + END If + swap=totalSwap + bulk_layers=bulkLayersReciprocal + ELSE + swap=0.0 + transfer=0.0 + bulk_layers=0.0 + END IF + + END SUBROUTINE get_rates + + SUBROUTINE dictionaryParser(dictionary, outSpeciesIn,successFlag) + !Reads the input parameters from a string containing a python dictionary/JSON format + !set of parameter names and values. + !dictionary - lowercase keys matching the names of the parameters in the select case below + !OutSpeciesIn - string containing the species to output + !successFlag - integer flag to indicate success + CHARACTER(LEN=*) :: dictionary, outSpeciesIn + INTEGER, INTENT(OUT) :: successFlag + INTEGER, ALLOCATABLE, DIMENSION(:) :: locations + LOGICAL :: ChemicalDuplicateCheck + INTEGER :: posStart, posEnd, whileInteger,inputindx + CHARACTER(LEN=100) :: inputParameter, inputValue + close(10) + close(11) + close(7) + + !always deallocate these so that if user didn't specify them, + ! they don't remain from previous run + IF (ALLOCATED(outIndx)) DEALLOCATE(outIndx) + IF (ALLOCATED(outSpecies)) DEALLOCATE(outSpecies) + + !All reads use IOSTAT which will change successFlag from 0 if an error occurs + !so set zero and check for non-zero each loop. + successFlag=0 + + whileInteger = 0 + + posStart = scan(dictionary, '{') + DO WHILE (whileInteger .NE. 1) + posEnd = scan(dictionary, ':') + inputParameter = dictionary(posStart+2:posEnd-2) + dictionary = dictionary(posEnd:) + posStart = scan(dictionary, ' ') + IF (scan(dictionary, ',') .EQ. 0) THEN + posEnd = scan(dictionary, '}') + whileInteger = 1 + ELSE + posEnd = scan(dictionary, ',') + END IF + inputValue = dictionary(posStart+1:posEnd-1) + + SELECT CASE (inputParameter) + CASE('alpha') + !To provide alphas, set keyword alpha in inputdictionary with a dictionary value + !that dictionary should be index:value pairs for the alpha array + posStart=scan(dictionary,'{') + posEnd=scan(dictionary,'}') + CALL coefficientParser(dictionary(posStart+1:posEnd),alpha) + CASE('beta') + !To provide alphas, set keyword alpha in inputdictionary with a dictionary value + !that dictionary should be index:value pairs for the alpha array + posStart=scan(dictionary,'{') + posEnd=scan(dictionary,'}') + CALL coefficientParser(dictionary(posStart+1:posEnd),beta) + CASE('gamma') + !To provide alphas, set keyword alpha in inputdictionary with a dictionary value + !that dictionary should be index:value pairs for the alpha array + posStart=scan(dictionary,'{') + posEnd=scan(dictionary,'}') + CALL coefficientParser(dictionary(posStart+1:posEnd),gama) + CASE('initialtemp') + READ(inputValue,*,iostat=successFlag) initialTemp + CASE('initialdens') + READ(inputValue,*,iostat=successFlag) initialDens + CASE('finaldens') + READ(inputValue,*,iostat=successFlag) finalDens + CASE('currenttime') + READ(inputValue,*,iostat=successFlag) currentTime + CASE('finaltime') + READ(inputValue,*,iostat=successFlag) finalTime + CASE('radfield') + READ(inputValue,*,iostat=successFlag) radfield + CASE('zeta') + READ(inputValue,*,iostat=successFlag) zeta + CASE('freezefactor') + READ(inputValue,*,iostat=successFlag) freezeFactor + CASE('rout') + READ(inputValue,*,iostat=successFlag) rout + CASE('rin') + READ(inputValue,*,iostat=successFlag) rin + CASE('baseav') + READ(inputValue,*,iostat=successFlag) baseAv + CASE('points') + READ(inputValue,*,iostat=successFlag) points + CASE('endatfinaldensity') + Read(inputValue,*,iostat=successFlag) endAtFinalDensity + CASE('freefall') + READ(inputValue,*,iostat=successFlag) freefall + CASE('freefallfactor') + READ(inputValue,*,iostat=successFlag) freefallFactor + CASE('desorb') + READ(inputValue,*,iostat=successFlag) desorb + CASE('h2desorb') + READ(inputValue,*,iostat=successFlag) h2desorb + CASE('crdesorb') + READ(inputValue,*,iostat=successFlag) crdesorb + CASE('uvdesorb') + READ(inputValue,*,iostat=successFlag) uvdesorb + CASE('thermdesorb') + READ(inputValue,*,iostat=successFlag) uvdesorb + CASE('instantsublimation') + READ(inputValue,*,iostat=successFlag) instantSublimation + CASE('cosmicrayattenuation') + READ(inputValue,*,iostat=successFlag) cosmicRayAttenuation + CASE('ionmodel') + READ(inputValue,*,iostat=successFlag) ionModel + CASE('improvedh2crpdissociation') + READ(inputValue,*,iostat=successFlag) improvedH2CRPDissociation + CASE('ion') + READ(inputValue,*,iostat=successFlag) ion + CASE('fhe') + READ(inputValue,*,iostat=successFlag) fhe + CASE('fc') + READ(inputValue,*,iostat=successFlag) fc + CASE('fo') + READ(inputValue,*,iostat=successFlag) fo + CASE('fn') + READ(inputValue,*,iostat=successFlag) fn + CASE('fs') + READ(inputValue,*,iostat=successFlag) fs + CASE('fmg') + READ(inputValue,*,iostat=successFlag) fmg + CASE('fsi') + READ(inputValue,*,iostat=successFlag) fsi + CASE('fcl') + READ(inputValue,*,iostat=successFlag) fcl + CASE('fp') + READ(inputValue,*,iostat=successFlag) fp + CASE('ff') + READ(inputValue,*,iostat=successFlag) ff + CASE('outspecies') + READ(inputValue,*,iostat=successFlag) nout + ALLOCATE(outIndx(nout)) + ALLOCATE(outSpecies(nout)) + IF (outSpeciesIn .eq. "") THEN + write(*,*) "Outspecies parameter set but no outspecies string given" + write(*,*) "general(parameter_dict,outSpeciesIn) requires a delimited string of species names" + write(*,*) "if outSpecies or columnFlag is set in the parameter dictionary" + successFlag=-1 + RETURN + ELSE + READ(outSpeciesIn,*, END=22) outSpecies + IF (outSpeciesIn .eq. "") THEN +22 write(*,*) "mismatch between outSpeciesIn and number given in dictionary" + write(*,*) "Number:",nout + write(*,*) "Species list:",outSpeciesIn + successFlag=-1 + RETURN + END IF + END IF + !assign array indices for important species to the integers used to store them. + DO i=1,nspec + DO j=1,nout + IF (specname(i).eq.outSpecies(j)) outIndx(j)=i + END DO + END DO + CASE('writestep') + READ(inputValue,*,iostat=successFlag) writeStep + CASE('ebmaxh2') + READ(inputValue,*,iostat=successFlag) ebmaxh2 + CASE('epsilon') + READ(inputValue,*,iostat=successFlag) epsilon + CASE('uvcreff') + READ(inputValue,*,iostat=successFlag) uvcreff + CASE('ebmaxcr') + READ(inputValue,*,iostat=successFlag) ebmaxcr + CASE('phi') + READ(inputValue,*,iostat=successFlag) phi + CASE('ebmaxuvcr') + READ(inputValue,*,iostat=successFlag) ebmaxuvcr + CASE('uv_yield') + READ(inputValue,*,iostat=successFlag) uv_yield + CASE('metallicity') + READ(inputValue,*,iostat=successFlag) metallicity + CASE('omega') + READ(inputValue,*,iostat=successFlag) omega + CASE('reltol') + READ(inputValue,*,iostat=successFlag) reltol + CASE('abstol_factor') + READ(inputValue,*,iostat=successFlag) abstol_factor + CASE('abstol_min') + READ(inputValue,*,iostat=successFlag) abstol_min + ! CASE('jacobian') + ! READ(inputValue,*) jacobian + CASE('abundsavefile') + READ(inputValue,*,iostat=successFlag) abundSaveFile + abundSaveFile = TRIM(abundSaveFile) + open(abundSaveID,file=abundSaveFile,status="unknown") + CASE('abundloadfile') + READ(inputValue,*,iostat=successFlag) abundLoadFile + abundLoadFile = TRIM(abundLoadFile) + open(abundLoadID,file=abundLoadFile,status='old') + CASE('outputfile') + READ(inputValue,*,iostat=successFlag) outFile + outputFile = trim(outFile) + fullOutput=.True. + open(outputId,file=outputFile,status='unknown',iostat=successFlag) + IF (successFlag .ne. 0) THEN + write(*,*) "An error occured when opening the output file!"//& + & NEW_LINE('A')//& + &" The failed file was ",outputFile& + &, NEW_LINE('A')//"A common error is that the directory doesn't exist"& + &//NEW_LINE('A')//"************************" + successFlag=-1 + RETURN + END IF + CASE('columnfile') + IF (trim(outSpeciesIn) .NE. '' ) THEN + columnOutput=.True. + READ(inputValue,*,iostat=successFlag) columnFile + columnFile = trim(columnFile) + open(columnId,file=columnFile,status='unknown') + ELSE + WRITE(*,*) "Error in output species. No species were given but a column file was given." + WRITE(*,*) "columnated output requires output species to be chosen." + successFlag=-1 + RETURN + END IF + + CASE DEFAULT + WRITE(*,*) "Problem with given parameter: '", trim(inputParameter), "'." + WRITE(*,*) "This is either not supported yet, or invalid." + successFlag=-1 + RETURN + END SELECT + dictionary = dictionary(posEnd:) + IF (SCAN(dictionary,',') .eq. 0) whileInteger=1 + + !check for failure + IF (successFlag .ne. 0) THEN + WRITE(*,*) "Error reading ",inputParameter + write(*,*) "This is usually due to wrong type." + successFlag=PARAMETER_READ_ERROR + RETURN + END IF + END DO + + END SUBROUTINE dictionaryParser + + SUBROUTINE coefficientParser(coeffDictString,coeffArray) + !Similar to dictionaryParser, it reads a python dictionary + !however, it's intended to read pairs of reaction indices and coefficient values + !for the alpha, beta, and gama arrays. + ! No return value, just modifies the coeffArray + CHARACTER(LEN=*) :: coeffDictString + REAL(dp), INTENT(INOUT) :: coeffArray(*) + INTEGER :: inputIndx,posStart,posEnd + CHARACTER(LEN=100) :: inputValue + LOGICAL :: continue_flag + + continue_flag=.True. + DO WHILE (continue_flag) + !substring containing integer key + posStart=1 + posEnd=SCAN(coeffDictString,':') + !read it into index integer + READ(coeffDictString(posStart:posEnd-1),*) inputindx + + !substring including alpha value for the index. + posStart=posEnd+1 + posEnd=SCAN(coeffDictString,',') + !last value will have a } instead of , so grab index and tell loop to finish + IF (posEnd .eq. 0) THEN + posEnd=SCAN(coeffDictString,"}") + continue_flag=.False. + END IF + + !read that substring + inputValue=coeffDictString(posStart:posEnd-1) + READ(inputValue,*) coeffArray(inputIndx) + !update string to remove this entry + coeffDictString=coeffDictString(posEnd+1:) + END DO + END SUBROUTINE coefficientParser + +END MODULE uclchemhelper \ No newline at end of file diff --git a/src/amuse_uclchem/src/chemistry.f90 b/src/amuse_uclchem/src/chemistry.f90 new file mode 100755 index 0000000000..844a687eed --- /dev/null +++ b/src/amuse_uclchem/src/chemistry.f90 @@ -0,0 +1,318 @@ +! Chemistry module of UCL_CHEM. ! +! Contains all the core machinery of the code, not really intended to be altered in standard ! +! use. Use a (custom) physics module to alter temp/density behaviour etc. ! +! ! +! chemistry module contains rates.f90, a series of subroutines to calculate all reaction rates! +! when updateChemistry is called from main, these rates are calculated, the ODEs are solved ! +! from currentTime to targetTime to get abundances at targetTime and then all abundances are ! +! written to the fullOutput file. ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +MODULE chemistry +USE physicscore +USE dvode_f90_m +USE network +USE photoreactions +USE surfacereactions +USE constants +IMPLICIT NONE + !These integers store the array index of important species and reactions, x is for ions + !loop counters + INTEGER :: i,j,l,writeStep,writeCounter=0,loopCounter,failedIntegrationCounter + INTEGER, PARAMETER :: maxLoops=10,maxConsecutiveFailures=10 + + !Flags to control desorption processes + LOGICAL :: desorb,h2desorb,crdesorb,uvdesorb,thermdesorb + + + !Array to store reaction rates + REAL(dp) :: rate(nreac) + + + !DLSODE variables + INTEGER :: ITASK,ISTATE,NEQ,MXSTEP + REAL(dp) :: reltol,abstol_factor,abstol_min + REAL(dp), ALLOCATABLE :: abstol(:) + TYPE(VODE_OPTS) :: OPTIONS + !initial fractional elemental abudances and arrays to store abundances + REAL(dp) :: fh,fd,fhe,fc,fo,fn,fs,fmg,fsi,fcl,fp,ff,ffe,fli,fna,fpah,f15n,f13c,f18O,metallicity + REAL(dp) :: h2col,cocol,ccol,h2colToCell,cocolToCell,ccolToCell + REAL(dp),ALLOCATABLE :: abund(:,:) + + !Variables controlling chemistry + LOGICAL :: PARAMETERIZE_H2FORM=.True. + REAL(dp) :: radfield,freezeFactor,omega,grainArea,cion,h2dis,lastTemp=0.0 + REAL(dp) :: ebmaxh2,epsilon,ebmaxcr,phi,ebmaxuvcr,uv_yield,uvcreff + REAL(dp), PARAMETER :: h2StickingZero=0.87d0,hStickingZero=1.0d0, h2StickingTemp=87.0d0,hStickingTemp=52.0d0 + + + REAL(dp) :: turbVel=1.0 + REAL(dp) :: MIN_ABUND = 1.0d-30 !Minimum abundance allowed +CONTAINS + SUBROUTINE initializeChemistry(readAbunds) + LOGICAL, INTENT(IN) :: readAbunds + ! Sets variables at the start of every run. + ! Since python module persists, it's not enough to set initial + ! values in module definitions above. Reset here. + NEQ=nspec+1 + IF (ALLOCATED(abund)) DEALLOCATE(abund,vdiff) + ALLOCATE(abund(NEQ,points),vdiff(SIZE(iceList))) + !Set abundances to initial elemental if not reading them in. + IF (.NOT. readAbunds) THEN + !ensure abund is initially zero + abund= MIN_ABUND + + !Start by filling all metallicity scaling elements + !neutral atoms + abund(no,:) = fo + abund(nn,:) = fn + abund(nmg,:) = fmg + abund(np,:) = fp + abund(nf,:) = ff + !abund(nfe,:) = ffe + abund(nna,:) = fna + abund(nli,:) = fli + abund(npah,:) = fpah + !default to ions + abund(nsx,:) = fs + abund(nsix,:) = fsi + abund(nclx,:) = fcl + !Decide how much carbon is initiall ionized using parameters.f90 + SELECT CASE (ion) + CASE(0) + abund(nc,:)=fc + abund(ncx,:)=1.d-10 + CASE(1) + abund(nc,:)=fc*0.5 + abund(ncx,:)=fc*0.5 + CASE(2) + abund(nc,:)=1.d-10 + abund(ncx,:)=fc + END SELECT + + !isotopes + abund(n18o,:) = f18o + abund(n15n,:) = f15n + abund(n13c,:) = f13c + + abund(nelec,:)=abund(ncx,:)+abund(nsix,:)+abund(nsx,:)+abund(nclx,:) + + abund=abund*metallicity + + !Total H nuclei is always 1 so put fh into H and whatever is left over in H2 + abund(nh,:) = fh + abund(nh2,:) = 0.5*(1.0e0-fh) + abund(nd,:)=fd + + abund(nhe,:) = fhe + ENDIF + abund(neq,:)=density + !Initial calculations of diffusion frequency for each species bound to grain + !and other parameters required for diffusion reactions + DO i=lbound(iceList,1),ubound(iceList,1) + j=iceList(i) + vdiff(i)=VDIFF_PREFACTOR*bindingEnergy(i)/mass(j) + vdiff(i)=dsqrt(vdiff(i)) + END DO + + !DVODE SETTINGS + ISTATE=1 + ITASK=1 + + !set integration counts + loopCounter=0 + failedIntegrationCounter=0 + + IF (.NOT. ALLOCATED(abstol)) THEN + ALLOCATE(abstol(NEQ)) + END IF + !OPTIONS = SET_OPTS(METHOD_FLAG=22, ABSERR_VECTOR=abstol, RELERR=reltol,USER_SUPPLIED_JACOBIAN=.FALSE.) + + !Set rates to zero to ensure they don't hold previous values or random ones if we don't set them in calculateReactionRates + rate=0.0 + !We typically don't recalculate rates that only depend on temperature if the temp hasn't changed + !use arbitrarily high value to make sure they are calculated at least once. + lastTemp=99.0d99 + END SUBROUTINE initializeChemistry + + + + SUBROUTINE updateChemistry(successFlag) + !Updates the abundances for the next time step, first updating chemical variables and reaction rates, + !then by solving the ODE system to obtain new abundances. + !Solving ODEs is complex so we have two checks to try to automatically overcome difficulties and end stalled models + !Firstly, the integration subroutine is called up to maxLoops times whilst adjusting variables to help integration converge. + !If it succeeds before maxLoops, we continue as normal, otherwise we'll call it a fail. + !Secondly, we check for stalls caused by the the solver loop reducing the targetTime to overcome difficulties. + !That reduction the possibility of the code "succeeding" by integrating tiny target times. We have a counter that resets each time + !the code integrates to the planned targetTime rather than a reduced one. If the counter reaches maxConsecutiveFailures, we end the code. + + INTEGER, INTENT(OUT) :: successFlag + real(dp) :: originalTargetTime !targetTime can be altered by integrator but we'd like to know if it was changed + + !Integration can fail in a way that we can manage. Allow maxLoops tries before giving up. + loopCounter=0 + successFlag=1 + originalTargetTime=targetTime + DO WHILE((currentTime .lt. targetTime) .and. (loopCounter .lt. maxLoops)) + !allow option for dens to have been changed elsewhere. + IF (.not. freefall) abund(nspec+1,dstep)=density(dstep) + + !First sum the total column density over all points further towards edge of cloud + IF (dstep.gt.1) THEN + h2ColToCell=(sum(abund(nh2,:dstep-1)*density(:dstep-1)))*(cloudSize/real(points)) + coColToCell=(sum(abund(nco,:dstep-1)*density(:dstep-1)))*(cloudSize/real(points)) + cColToCell=(sum(abund(nc,:dstep-1)*density(:dstep-1)))*(cloudSize/real(points)) + ELSE + h2ColToCell=0.0 + coColToCell=0.0 + cColToCell=0.0 + ENDIF + !then add half the column density of the current point to get average in this "cell" + h2Col=h2ColToCell+0.5*abund(nh2,dstep)*density(dstep)*(cloudSize/real(points)) + coCol=coColToCell+0.5*abund(nco,dstep)*density(dstep)*(cloudSize/real(points)) + cCol=cColToCell+0.5*abund(nc,dstep)*density(dstep)*(cloudSize/real(points)) + + !Reset surface and bulk values in case of integration error or sputtering + abund(nBulk,dstep)=sum(abund(bulkList,dstep)) + abund(nSurface,dstep)=sum(abund(surfaceList,dstep)) + !recalculate coefficients for ice processes + safeMantle=MAX(1d-30,abund(nSurface,dstep)) + safeBulk=MAX(1d-30,abund(nBulk,dstep)) + + if (refractoryList(1) .gt. 0) safeBulk=safeBulk-SUM(abund(refractoryList,dstep)) + bulkLayersReciprocal=MIN(1.0,NUM_SITES_PER_GRAIN/(GAS_DUST_DENSITY_RATIO*safeBulk)) + surfaceCoverage=bulkGainFromMantleBuildUp() + + + CALL calculateReactionRates + + !Integrate chemistry, and return fail if unrecoverable error was reached + CALL integrateODESystem(successFlag) + IF (successFlag .lt. 0) THEN + write(*,*) "Integration failed, exiting" + RETURN + END IF + + + + !1.d-30 stops numbers getting too small for fortran. + WHERE(abund