From f46be522944bdfc1ffdd8f5de0114befb91398a3 Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:08:46 -0400 Subject: [PATCH] Split the dependency build up so that each one can be build separately. More adjustments on the road to getting a stable build --- .gitignore | 1 + buildscripts/build_all.sh | 2 - buildscripts/build_dependencies.sh | 101 +---------------------- buildscripts/build_hdf5.sh | 95 ++++++++++++++++++++++ buildscripts/build_netcdf-c.sh | 117 +++++++++++++++++++++++++++ buildscripts/build_netcdf-fortran.sh | 90 +++++++++++++++++++++ buildscripts/build_swiftest.sh | 29 +++++-- buildscripts/build_zlib.sh | 80 ++++++++++++++++++ buildscripts/swiftest-build-env.yml | 1 + setup.py | 7 -- src/CMakeLists.txt | 4 +- 11 files changed, 413 insertions(+), 114 deletions(-) create mode 100755 buildscripts/build_hdf5.sh create mode 100755 buildscripts/build_netcdf-c.sh create mode 100755 buildscripts/build_netcdf-fortran.sh create mode 100755 buildscripts/build_zlib.sh diff --git a/.gitignore b/.gitignore index fad43d522..62d904a21 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ dump* **/_skbuild *.egg* swiftest-* +__pycache__* #Documentation diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index 7647c236f..925128285 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -45,8 +45,6 @@ echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}" case $OS in MacOSX) COMPILER="GNU-Mac" - export MACOSX_DEPLOYMENT_TARGET=13 - export LDFLAGS="-Wl,-no_compact_unwind" ;; Linux) COMPILER="GNU-Linux" diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index df3155a06..9dc06fed2 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -21,7 +21,6 @@ USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]" IFORT=false PREFIX=/usr/local COMPILER="" -CARG="" while getopts ":c:p:" ARG; do case "${ARG}" in c) @@ -54,102 +53,10 @@ printf "Using ${COMPILER} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n" printf "Installing to ${PREFIX}\n" printf "\n" -export HDF5_ROOT="${PREFIX}" -export HDF5_LIBDIR="${HDF5_ROOT}/lib" -export HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" -export HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" -export NCDIR="${PREFIX}" -export NFDIR="${PREFIX}" -export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}" -export CPPFLAGS="${CPPFLAGS} -isystem {$PREFIX}/include" -export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" -export CPATH="${PREFIX}/include:${CPATH}" -export CFLAGS="${CFLAGS} -Wno-unused-but-set-variable" - -if [ $COMPILER = "GNU-Mac" ]; then - export MACOSX_DEPLOYMENT_TARGET=13 - export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" - export CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype" -fi - -printf "LIBS: ${LIBS}\n" -printf "CFLAGS: ${CFLAGS}\n" -printf "CPPFLAGS: ${CPPFLAGS}\n" -printf "CPATH: ${CPATH}\n" -printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" -printf "LDFLAGS: ${LDFLAGS}\n" - -printf "*********************************************************\n" -printf "* BUILDING ZLIB STATIC LIBRARY *\n" -printf "*********************************************************\n" -cd zlib-1.2.13 -./configure --prefix=${PREFIX} --static -make -make install -if [ $? -ne 0 ]; then - printf "zlib could not be compiled.\n" - exit 1 -fi - -printf "\n" -printf "*********************************************************\n" -printf "* BUILDING HDF5 STATIC LIBRARY *\n" -printf "*********************************************************\n" -cd ../hdf5-1.14.1-2 -if [ $COMPILER = "GNU-Mac" ]; then - read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) - if [ $ARCH = "arm64" ]; then - printf "Manually setting bin/config.sub to arm-apple-darwin\n" - printf "echo arm-apple-darwin" > bin/config.sub - fi -fi -COPTS="--disable-shared --enable-build-mode=production --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}" -./configure ${COPTS} -make && make install -if [ $? -ne 0 ]; then - printf "hdf5 could not be compiled.\n" - exit 1 -fi - - -printf "\n" -printf "*********************************************************\n" -printf "* BUILDING NETCDF-C STATIC LIBRARY *\n" -printf "*********************************************************\n" -cd ../netcdf-c-4.9.2 -COPTS="--disable-shared --disable-dap --disable-byterange --prefix=${PREFIX}" -if [ ! $COMPILER = "GNU-Mac" ]; then - COPTS="${COPTS} --disable-libxml2" -fi -printf "COPTS: ${COPTS}\n" - - -./configure $COPTS -make && make check && make install -if [ $? -ne 0 ]; then - printf "netcdf-c could not be compiled."\n - exit 1 -fi - -if [ $COMPILER = "Intel" ]; then - export FCFLAGS="${CFLAGS} -standard-semantics" -else - export FCFLAGS="${CFLAGS}" -fi -export FFLAGS=${CFLAGS} - -export LIBS="$(${PREFIX}/bin/nc-config --libs --static)" -printf "\n" -printf "*********************************************************\n" -printf "* BUILDING NETCDF-FORTRAN STATIC LIBRARY *\n" -printf "*********************************************************\n" -cd ../netcdf-fortran-4.6.1 -./configure --disable-shared --with-pic --prefix=${PREFIX} -make && make check && make install -if [ $? -ne 0 ]; then - printf "netcdf-fortran could not be compiled.\n" - exit 1 -fi +${SCRIPT_DIR}/build_zlib.sh -c $COMPILER -p $PREFIX +${SCRIPT_DIR}/build_hdf5.sh -c $COMPILER -p $PREFIX +${SCRIPT_DIR}/build_netcdf-c.sh -c $COMPILER -p $PREFIX +${SCRIPT_DIR}/build_netcdf-fortran.sh -c $COMPILER -p $PREFIX printf "\n" printf "*********************************************************\n" diff --git a/buildscripts/build_hdf5.sh b/buildscripts/build_hdf5.sh new file mode 100755 index 000000000..b574a010b --- /dev/null +++ b/buildscripts/build_hdf5.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# This script will build all of the dependency libraries needed by Swiftest. Builds the following from source: +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest 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. +# Swiftest 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 Swiftest. +# If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR + +# Parse arguments +USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]" +IFORT=false +PREFIX=/usr/local +COMPILER="" +CARG="" +while getopts ":c:p:" ARG; do + case "${ARG}" in + c) + COMPILER="${OPTARG}" + ;; + p) + PREFIX="${OPTARG}" + ;; + :) + echo "Error: -${OPTARG} requires an argument." + echo $USTMT + exit 1 + ;; + *) + ;; + esac +done +CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER" +read -r CC CXX FC F77 CPP < <($CMD) +export CC=${CC} +export CXX=${CXX} +export FC=${FC} +export F77=${F77} +export CPP=${CPP} + +export HDF5_ROOT="${PREFIX}" +export HDF5_LIBDIR="${HDF5_ROOT}/lib" +export HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +export HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" +export NCDIR="${PREFIX}" +export NFDIR="${PREFIX}" +export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}" +export CPPFLAGS="${CPPFLAGS} -isystem {$PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" +export CPATH="${PREFIX}/include:${CPATH}" +export CFLAGS="${CFLAGS} -Wno-unused-but-set-variable" + +if [ $COMPILER = "GNU-Mac" ]; then + export MACOSX_DEPLOYMENT_TARGET=13 + export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" + export CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype" +fi + +printf "\n" +printf "*********************************************************\n" +printf "* BUILDING HDF5 STATIC LIBRARY *\n" +printf "*********************************************************\n" +printf "LIBS: ${LIBS}\n" +printf "CFLAGS: ${CFLAGS}\n" +printf "CPPFLAGS: ${CPPFLAGS}\n" +printf "CPATH: ${CPATH}\n" +printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" +printf "LDFLAGS: ${LDFLAGS}\n" +printf "*********************************************************\n" + +cd ${BUILD_DIR}/hdf5-* +if [ $COMPILER = "GNU-Mac" ]; then + read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) + if [ $ARCH = "arm64" ]; then + printf "Manually setting bin/config.sub to arm-apple-darwin\n" + printf "echo arm-apple-darwin" > bin/config.sub + fi +fi +COPTS="--disable-shared --enable-build-mode=production --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}" +./configure ${COPTS} +make && make install +if [ $? -ne 0 ]; then + printf "hdf5 could not be compiled.\n" + exit 1 +fi + diff --git a/buildscripts/build_netcdf-c.sh b/buildscripts/build_netcdf-c.sh new file mode 100755 index 000000000..412d0b3d2 --- /dev/null +++ b/buildscripts/build_netcdf-c.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# This script will build all of the dependency libraries needed by Swiftest. Builds the following from source: +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest 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. +# Swiftest 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 Swiftest. +# If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR + +# Parse arguments +USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]" +IFORT=false +PREFIX=/usr/local +COMPILER="" +CARG="" +while getopts ":c:p:" ARG; do + case "${ARG}" in + c) + COMPILER="${OPTARG}" + ;; + p) + PREFIX="${OPTARG}" + ;; + :) + echo "Error: -${OPTARG} requires an argument." + echo $USTMT + exit 1 + ;; + *) + ;; + esac +done +CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER" +read -r CC CXX FC F77 CPP < <($CMD) +export CC=${CC} +export CXX=${CXX} +export FC=${FC} +export F77=${F77} +export CPP=${CPP} + +export HDF5_ROOT="${PREFIX}" +export HDF5_LIBDIR="${HDF5_ROOT}/lib" +export HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +export HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" +export NCDIR="${PREFIX}" +export NFDIR="${PREFIX}" +export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}" +export CPPFLAGS="${CPPFLAGS} -isystem {$PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" +export CPATH="${PREFIX}/include:${CPATH}" +export CFLAGS="${CFLAGS} -Wno-unused-but-set-variable" + +if [ $COMPILER = "GNU-Mac" ]; then + export MACOSX_DEPLOYMENT_TARGET=13 + export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" + export CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype" +fi + +printf "\n" +printf "*********************************************************\n" +printf "* BUILDING NETCDF-C STATIC LIBRARY *\n" +printf "*********************************************************\n" +printf "LIBS: ${LIBS}\n" +printf "CFLAGS: ${CFLAGS}\n" +printf "CPPFLAGS: ${CPPFLAGS}\n" +printf "CPATH: ${CPATH}\n" +printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" +printf "LDFLAGS: ${LDFLAGS}\n" +printf "*********************************************************\n" + +cd ${BUILD_DIR}/netcdf-c-* +COPTS="--disable-shared --disable-dap --disable-byterange --prefix=${PREFIX}" +if [ ! $COMPILER = "GNU-Mac" ]; then + COPTS="${COPTS} --disable-libxml2" +fi +printf "COPTS: ${COPTS}\n" +./configure $COPTS +make && make check && make install +if [ $? -ne 0 ]; then + printf "netcdf-c could not be compiled."\n + exit 1 +fi + +if [ $COMPILER = "Intel" ]; then + export FCFLAGS="${CFLAGS} -standard-semantics" +else + export FCFLAGS="${CFLAGS}" +fi +export FFLAGS=${CFLAGS} + +export LIBS="$(${PREFIX}/bin/nc-config --libs --static)" +printf "\n" +printf "*********************************************************\n" +printf "* BUILDING NETCDF-FORTRAN STATIC LIBRARY *\n" +printf "*********************************************************\n" +cd ../netcdf-fortran-4.6.1 +./configure --disable-shared --with-pic --prefix=${PREFIX} +make && make check && make install +if [ $? -ne 0 ]; then + printf "netcdf-fortran could not be compiled.\n" + exit 1 +fi + +printf "\n" +printf "*********************************************************\n" +printf "* DEPENDENCIES ARE BUILT *\n" +printf "*********************************************************\n" +printf "Dependencys are installed to: ${PREFIX}\n\n" diff --git a/buildscripts/build_netcdf-fortran.sh b/buildscripts/build_netcdf-fortran.sh new file mode 100755 index 000000000..0e21d964d --- /dev/null +++ b/buildscripts/build_netcdf-fortran.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# This script will build all of the dependency libraries needed by Swiftest. Builds the following from source: +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest 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. +# Swiftest 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 Swiftest. +# If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR + +# Parse arguments +USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]" +IFORT=false +PREFIX=/usr/local +COMPILER="" +CARG="" +while getopts ":c:p:" ARG; do + case "${ARG}" in + c) + COMPILER="${OPTARG}" + ;; + p) + PREFIX="${OPTARG}" + ;; + :) + echo "Error: -${OPTARG} requires an argument." + echo $USTMT + exit 1 + ;; + *) + ;; + esac +done +CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER" +read -r CC CXX FC F77 CPP < <($CMD) +export CC=${CC} +export CXX=${CXX} +export FC=${FC} +export F77=${F77} +export CPP=${CPP} + + +export HDF5_ROOT="${PREFIX}" +export HDF5_LIBDIR="${HDF5_ROOT}/lib" +export HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +export HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" +export NCDIR="${PREFIX}" +export NFDIR="${PREFIX}" +export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}" +export CPPFLAGS="${CPPFLAGS} -isystem {$PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" +export CPATH="${PREFIX}/include:${CPATH}" +export CFLAGS="${CFLAGS} -Wno-unused-but-set-variable" + +if [ $COMPILER = "GNU-Mac" ]; then + export MACOSX_DEPLOYMENT_TARGET=13 + export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" + export CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype" +fi + +export LIBS="$(${PREFIX}/bin/nc-config --libs --static)" + +printf "\n" +printf "*********************************************************\n" +printf "* BUILDING NETCDF-FORTRAN STATIC LIBRARY *\n" +printf "*********************************************************\n" +printf "LIBS: ${LIBS}\n" +printf "CFLAGS: ${CFLAGS}\n" +printf "CPPFLAGS: ${CPPFLAGS}\n" +printf "CPATH: ${CPATH}\n" +printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" +printf "LDFLAGS: ${LDFLAGS}\n" +printf "*********************************************************\n" + +cd ${BUILD_DIR}/netcdf-fortran-* +./configure --disable-shared --with-pic --disable-zstandard-plugin --prefix=${PREFIX} +make && make check && make install +if [ $? -ne 0 ]; then + printf "netcdf-fortran could not be compiled.\n" + exit 1 +fi + diff --git a/buildscripts/build_swiftest.sh b/buildscripts/build_swiftest.sh index 7e4ef7b71..8ba96a4ee 100755 --- a/buildscripts/build_swiftest.sh +++ b/buildscripts/build_swiftest.sh @@ -46,18 +46,19 @@ export CPP=${CPP} printf "Using ${COMPILER} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n\n" printf "Installing to ${PREFIX}\n" printf "Dependency libraries in ${PREFIX}\n" + export DEPDIR=$PREFIX export NETCDF_FORTRAN_HOME=$DEPDIR -export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${DEPDIR}/lib" +export LD_LIBRARY_PATH="${DEPDIR}/lib:${LD_LIBRARY_PATH}" export CPPFLAGS="${CPPFLAGS} -I{$DEPDIR}/include" export LDFLAGS="${LDFLAGS} -L${DEPDIR}/lib" -export CPATH="${CPATH}:${DEPDIR}/include" +export CPATH="${DEPDIR}/include:${CPATH}" if [ $COMPILER = "GNU-Mac" ]; then - export MACOSX_DEPLOYMENT_TARGET=13 + # export MACOSX_DEPLOYMENT_TARGET=13 export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" + printf "MACOSX_DEPLOYMENT_TARGET: ${MACOSX_DEPLOYMENT_TARGET}\n" fi - NFCFG="${DEPDIR}/bin/nf-config" if command -v $NFCFG &> /dev/null; then export LIBS=$($NFCFG --flibs) @@ -84,11 +85,27 @@ read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) echo $OS $ARCH if [ $OS = "MacOSX" ] && [ $ARCH = "arm64" ]; then printf "OpenMP not supported on Apple M1 Silicon quite yet\n" - export SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DUSE_OPENMP=OFF" + export SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DUSE_OPENMP=OFF -DUSE_SIMD=OFF" fi cd $ROOT_DIR + +printf "\n" +printf "*********************************************************\n" +printf "* BUILDING SWIFTEST *\n" +printf "*********************************************************\n" +printf "LIBS: ${LIBS}\n" +printf "CFLAGS: ${CFLAGS}\n" +printf "FFLAGS: ${FFLAGS}\n" +printf "FCFLAGS: ${FCFLAGS}\n" +printf "CPPFLAGS: ${CPPFLAGS}\n" +printf "CPATH: ${CPATH}\n" +printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" +printf "LDFLAGS: ${LDFLAGS}\n" +printf "NETCDF_FORTRAN_HOME: ${NETCDF_FORTRAN_HOME}\n" +printf "SKBUILD_CONFIGURE_OPTIONS: ${SKBUILD_CONFIGURE_OPTIONS}\n" +printf "*********************************************************\n" + python3 -m pip install build pip -python3 -m build python3 -m pip install . -v diff --git a/buildscripts/build_zlib.sh b/buildscripts/build_zlib.sh new file mode 100755 index 000000000..28a0784fa --- /dev/null +++ b/buildscripts/build_zlib.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# This script will build all of the dependency libraries needed by Swiftest. Builds the following from source: +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest 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. +# Swiftest 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 Swiftest. +# If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR + +# Parse arguments +USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]" +IFORT=false +PREFIX=/usr/local +COMPILER="" +CARG="" +while getopts ":c:p:" ARG; do + case "${ARG}" in + c) + COMPILER="${OPTARG}" + ;; + p) + PREFIX="${OPTARG}" + ;; + :) + echo "Error: -${OPTARG} requires an argument." + echo $USTMT + exit 1 + ;; + *) + ;; + esac +done +CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER" +read -r CC CXX FC F77 CPP < <($CMD) +export CC=${CC} +export CXX=${CXX} +export FC=${FC} +export F77=${F77} +export CPP=${CPP} + +export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}" +export CPPFLAGS="${CPPFLAGS} -isystem {$PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" +export CPATH="${PREFIX}/include:${CPATH}" +export CFLAGS="${CFLAGS} -Wno-unused-but-set-variable" + +if [ $COMPILER = "GNU-Mac" ]; then + export MACOSX_DEPLOYMENT_TARGET=13 + export LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind" + export CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype" +fi + +printf "*********************************************************\n" +printf "* BUILDING ZLIB STATIC LIBRARY *\n" +printf "*********************************************************\n" +printf "LIBS: ${LIBS}\n" +printf "CFLAGS: ${CFLAGS}\n" +printf "CPPFLAGS: ${CPPFLAGS}\n" +printf "CPATH: ${CPATH}\n" +printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n" +printf "LDFLAGS: ${LDFLAGS}\n" +printf "*********************************************************\n" + +cd ${BUILD_DIR}/zlib-* +./configure --prefix=${PREFIX} --static +make +make install +if [ $? -ne 0 ]; then + printf "zlib could not be compiled.\n" + exit 1 +fi diff --git a/buildscripts/swiftest-build-env.yml b/buildscripts/swiftest-build-env.yml index 914b3ffdb..c61059d8e 100644 --- a/buildscripts/swiftest-build-env.yml +++ b/buildscripts/swiftest-build-env.yml @@ -11,6 +11,7 @@ dependencies: - scikit-build>=0.17 - cmake>=3.5.0 - cython>=3.0.0 + - json5>=0.9 - make - m4 - ninja \ No newline at end of file diff --git a/setup.py b/setup.py index 43828867c..545aab4f1 100644 --- a/setup.py +++ b/setup.py @@ -12,12 +12,6 @@ from skbuild import setup -cmake_args = [ - '-DCMAKE_BUILD_TYPE=RELEASE', - '-DUSE_COARRAY:BOOL=OFF', - '-DUSE_OPENMP:BOOL=ON', - ] - with open('version.txt') as version_file: version = version_file.read().strip() @@ -47,7 +41,6 @@ 'Programming Language :: Python :: 3', ], keywords='astronomy astrophysics planetary nbody integrator symplectic wisdom-holman', - cmake_args=cmake_args, install_requires= [ 'numpy>=1.24.3', 'scipy>=1.10.1', diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4fe40861..610160ca0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -163,10 +163,10 @@ ELSE () TARGET_LINK_LIBRARIES(${SWIFTEST_DRIVER} PUBLIC ${SWIFTEST_LIBRARY} ${NETCDF_LIBRARIES} $ENV{LIBS}) ENDIF (BUILD_SHARED_LIBS) -IF(USE_OPENMP) +IF(USE_OPENMP OR USE_SIMD) SET_PROPERTY(TARGET ${SWIFTEST_LIBRARY} ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY COMPILE_FLAGS "${OpenMP_Fortran_FLAGS} ") SET_PROPERTY(TARGET ${SWIFTEST_LIBRARY} ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY LINK_FLAGS "${OpenMP_Fortran_FLAGS} ") -ENDIF(USE_OPENMP) +ENDIF() IF(USE_COARRAY) TARGET_COMPILE_DEFINITIONS(${SWIFTEST_LIBRARY} PUBLIC -DCOARRAY)