Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
More improvements to buildscripts. Can now build with OpenMP on M1 Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 21, 2023
1 parent e259874 commit d156d95
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 47 deletions.
9 changes: 1 addition & 8 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,8 @@ if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then

LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
CPPFLAGS="${CPPFLAGS} -isystem ${PREFIX}/include"
LDFLAGS="${LDFLAGS} -L${PREFIX}/lib -fPIE"
LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"
CPATH="${CPATH} ${PREFIX}/include}"
CFLAGS="${CFLAGS} -Wno-unused-but-set-variable -fPIC"
LIBS="${LIBS} -lgomp"

if [ $COMPILER = "GNU-Mac" ]; then
LDFLAGS="${LDFLAGS} -Wl,-no_compact_unwind"
CFLAGS="${CFLAGS} -Wno-deprecated-non-prototype"
fi

HDF5_ROOT="${PREFIX}"
HDF5_LIBDIR="${HDF5_ROOT}/lib"
Expand Down
53 changes: 29 additions & 24 deletions buildscripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ printf "*********************************************************\n"
printf "Copying files to ${DEPENDENCY_DIR}\n"
mkdir -p ${DEPENDENCY_DIR}
cd $DEPENDENCY_DIR
if [ -d ${DEPENDENCY_DIR}/zlib-${ZLIB_VER} ]; then
cd ${DEPENDENCY_DIR}/zlib-${ZLIB_VER}
make distclean
cd ${DEPENDENCY_DIR}
else
if [ ! -d ${DEPENDENCY_DIR}/zlib-${ZLIB_VER} ]; then
[ -d ${DEPENDENCY_DIR}/zlib-* ] && rm -rf ${DEPENDENCY_DIR}/zlib-*
wget -qO- https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/zlib-${ZLIB_VER}.tar.gz | tar xvz
fi
Expand All @@ -49,31 +45,20 @@ if [[ (-d ${DEPENDENCY_DIR}/hdfsrc) && (-f ${DEPENDENCY_DIR}/hdfsrc/README.md) ]
fi
fi

if [ -d ${DEPENDENCY_DIR}/hdfsrc ]; then
cd ${DEPENDENCY_DIR}/hdfsrc
make distclean
cd ${DEPENDENCY_DIR}
else
if [ ! -d ${DEPENDENCY_DIR}/hdfsrc ]; then
wget -qO- https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz
fi

if [ -d ${DEPENDENCY_DIR}/netcdf-c-${NC_VER} ]; then
cd ${DEPENDENCY_DIR}/netcdf-c-${NC_VER}
make distclean
cd ${DEPENDENCY_DIR}
else
if [ ! -d ${DEPENDENCY_DIR}/netcdf-c-${NC_VER} ]; then
[ -d ${DEPENDENCY_DIR}/netcdf-c-* ] && rm -rf ${DEPENDENCY_DIR}/netcdf-c-*
wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NC_VER}.tar.gz | tar xvz
fi

if [ -d ${DEPENDENCY_DIR}/netcdf-fortran-${NF_VER} ]; then
cd ${DEPENDENCY_DIR}/netcdf-fortran-${NF_VER}
make distclean
cd ${DEPENDENCY_DIR}
else
if [ ! -d ${DEPENDENCY_DIR}/netcdf-fortran-${NF_VER} ]; then
[ -d ${DEPENDENCY_DIR}/netcdf-fortran-* ] && rm -rf ${DEPENDENCY_DIR}/netcdf-fortran-*
wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v${NF_VER}.tar.gz | tar xvz
fi

cd $ROOT_DIR
printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
Expand All @@ -83,10 +68,30 @@ printf "Installing to ${PREFIX}\n"
printf "\n"

set -e
${SCRIPT_DIR}/build_zlib.sh ${ARGS}
${SCRIPT_DIR}/build_hdf5.sh ${ARGS}
${SCRIPT_DIR}/build_netcdf-c.sh ${ARGS}
${SCRIPT_DIR}/build_netcdf-fortran.sh ${ARGS}
if [ ! -f ${PREFIX}/lib/libz.a ]; then
${SCRIPT_DIR}/build_zlib.sh ${ARGS}
else
echo "Found: ${PREFIX}/lib/libz.a"
fi

if [ ! -f ${PREFIX}/lib/libhdf5.a ]; then
${SCRIPT_DIR}/build_hdf5.sh ${ARGS}
else
echo "Found: ${PREFIX}/lib/libhdf5.a"
fi


if [ ! -f ${PREFIX}/lib/libnetcdf.a ]; then
${SCRIPT_DIR}/build_netcdf-c.sh ${ARGS}
else
echo "Found: ${PREFIX}/lib/libnetcdf.a"
fi

if [ ! -f ${PREFIX}/lib/libnetcdff.a ]; then
${SCRIPT_DIR}/build_netcdf-fortran.sh ${ARGS}
else
` echo "Found: ${PREFIX}/lib/libnetcdff.a"
fi
printf "\n"
printf "*********************************************************\n"
Expand Down
2 changes: 2 additions & 0 deletions buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ if [ $? -ne 0 ]; then
exit 1
fi

make distclean

1 change: 1 addition & 0 deletions buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ if [ $? -ne 0 ]; then
exit 1
fi

make distclean
2 changes: 2 additions & 0 deletions buildscripts/build_netcdf-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ if [ $? -ne 0 ]; then
exit 1
fi

make distclean

4 changes: 0 additions & 4 deletions buildscripts/build_swiftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ fi

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"
SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DUSE_OPENMP=OFF -DUSE_SIMD=OFF"
fi

cd $ROOT_DIR

Expand Down
4 changes: 3 additions & 1 deletion buildscripts/build_zlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ fi
if [ $? -ne 0 ]; then
printf "zlib could not be compiled.\n"
exit 1
fi
fi

make distclean
33 changes: 23 additions & 10 deletions buildscripts/set_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,29 @@ case $COMPILER in
CPP=${CPP:-$(command -v cpp)}
;;
GNU-Mac)
GCCVER=${GCCVER:-13}
printf "GCC Version: ${GCCVER}\n"
FC=${FC:-$HOMEBREW_PREFIX/bin/gfortran-${GCCVER}}
CC=${CC:-$HOMEBREW_PREFIX/bin/gcc-${GCCVER}}
CXX=${CXX:-$HOMEBREW_PREFIX/bin/g++-${GCCVER}}
CPP=${CPP:-$HOMEBREW_PREFIX/bin/cpp-${GCCVER}}
AR=${AR:-$HOMEBREW_PREFIX/bin/gcc-ar-${GCCVER}}
NM=${NM:-$HOMEBREW_PREFIX/bin/gcc-nm-${GCCVER}}
RANLIB=${RANLIB:-$HOMEBREW_PREFIX/bin/gcc-ranlib-${GCCVER}}
LD_LIBRARY_PATH="${HOMEBREW_PREFIX}/lib/gcc/${GCCVER}/lib:${LD_LIBRARY_PATH}"

if $(brew --version &> /dev/null); then
brew install llvm@16 libomp
else
echo \"Please install Homebrew first\"
exit 1
fi
COMPILER_PREFIX=${COMPILER_PREFIX:-"/opt/homebrew/opt/llvm"}
CC=${CC:-${COMPILER_PREFIX}/bin/clang}
CXX=${CXX:-${COMPILER_PREFIX}/bin/clang++}
CPP=${CPP:-${COMPILER_PREFIX}/bin/clang-cpp}
AR=${AR:-${COMPILER_PREFIX}/bin/llvm-ar}
NM=${NM:-${COMPILER_PREFIX}/bin/llvm-nm}
RANLIB=${RANLIB:-${COMPILER_PREFIX}/bin/llvm-ranlib}
FROOT=$(realpath $(dirname $(command -v gfortran))/..)
FC=$(command -v gfortran)
LD_LIBRARY_PATH="${COMPILER_PREFIX}/lib:${FROOT}/lib:${LD_LIBRARY_PATH}"
LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++"
LIBS="-L/opt/homebrew/opt/libomp/lib -lomp ${LIBS}"
CPATH="${FROOT}/include:${CPATH}"
CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${CFLAGS}"
CXXFLAGS="${CFLAGS} ${CXXFLAGS}"
FCFLAGS="${CFLAGS} ${FCFLAGS}"
;;
*)
printf "Unknown compiler type: ${COMPILER}\n"
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from skbuild import setup
from pathlib import Path

with open('version.txt') as version_file:
version = version_file.read().strip()
Expand All @@ -20,6 +21,8 @@
author='David A. Minton',
author_email='daminton@purdue.edu',
url='https://github.itap.purdue.edu/MintonGroup/swiftest',
long_description=Path("README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
python_requires=">=3.8",
license="GPLv3",
classifiers=[
Expand Down

0 comments on commit d156d95

Please sign in to comment.