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

Commit

Permalink
More improvements to build scripts for 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 acafd5b commit 52d4acc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 28 deletions.
13 changes: 1 addition & 12 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)
USTMT="Usage: ${0} <-d /path/to/dependency/source> [-p /prefix/path|{/usr/local}] [-m MACOSX_DEPLOYMENT_TARGET|{11.0}]"
PREFIX=/usr/local
DEPENDENCY_DIR="${ROOT_DIR}/_dependencies"
MACOSX_DEPLOYMENT_TARGET="11.0"
MACOSX_DEPLOYMENT_TARGET="13.0"
while getopts ":d:p:m:h" ARG; do
case "${ARG}" in
d)
Expand Down Expand Up @@ -46,17 +46,6 @@ while getopts ":d:p:m:h" ARG; do
done

read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)
case $OS in
MacOSX)
COMPILER="GNU-Mac"
;;
Linux)
COMPILER="GNU-Linux"
;;
*)
printf "This script is not tested for ${OS}-${ARCH}\n"
;;
esac

if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then
. ${SCRIPT_DIR}/set_compilers.sh
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cd $ROOT_DIR
printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
printf "Using ${COMPILER} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "\n"

Expand Down
2 changes: 1 addition & 1 deletion buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/hdfsrc
if [ $COMPILER = "GNU-Mac" ]; then
if [ $OS = "MacOSX" ]; 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"
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/netcdf-c-*
COPTS="--disable-shared --disable-dap --disable-byterange --disable-testsets --prefix=${PREFIX}"
if [ ! $COMPILER = "GNU-Mac" ]; then
if [ ! $OS = "MacOSX" ]; then
COPTS="${COPTS} --disable-libxml2"
fi
printf "COPTS: ${COPTS}\n"
Expand Down
4 changes: 2 additions & 2 deletions buildscripts/build_swiftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ if [ ! -f "${ROOT_DIR}/setup.py" ]; then
exit 1
fi

printf "Using ${COMPILER} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n\n"
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n\n"
printf "Installing to ${PREFIX}\n"
printf "Dependency libraries in ${PREFIX}\n"


SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF"

if [ $COMPILER = "Intel" ]; then
if [ $OS = "Intel" ]; then
FCFLAGS="${CFLAGS} -standard-semantics"
FFLAGS=${CFLAGS}
SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DMACHINE_CODE_VALUE=\"SSE2\""
Expand Down
23 changes: 12 additions & 11 deletions buildscripts/set_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
# Parse arguments
case "$COMPILER" in
Intel|GNU-Linux|GNU-Mac)
case "$OS" in
Intel|Linux|MacOSX)
;;
*)
echo "Unknown compiler type: $COMPILER"
echo "Valid options are Intel, GNU-Linux, or GNU-Mac"
echo "Unknown compiler type: $OS"
echo "Valid options are Intel, Linux, or MacOSX"
echo $USTMT
exit 1
;;
esac

set -a
# Only replace compiler definitions if they are not already set
case $COMPILER in
case $OS in
Intel)
if [ ! -v FC ]; then
if command -v ifx &> /dev/null; then
Expand Down Expand Up @@ -82,13 +82,13 @@ case $COMPILER in

CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13}
;;
GNU-Linux)
Linux)
FC=${FC:-$(command -v gfortran)}
CC=${CC:-$(command -v gcc)}
CXX=${CXX:-$(command -v g++)}
CPP=${CPP:-$(command -v cpp)}
;;
GNU-Mac)
MacOSX)

if $(brew --version &> /dev/null); then
brew install llvm@16 libomp
Expand All @@ -106,17 +106,18 @@ case $COMPILER in
FROOT=$(realpath $(dirname $(command -v gfortran))/..)
FC=$(command -v gfortran)
LD_LIBRARY_PATH="${COMPILER_PREFIX}/lib:${FROOT}/lib:${LD_LIBRARY_PATH}"
LDFLAGS="-L${HOMEBREW_PREFIX}/opt/llvm/lib/c++ -Wl,-rpath,${HOMEBREW_PREFIX}/opt/llvm/lib/c+ -L${HOMEBREW_PREFIX}/opt/libomp/lib"
LDFLAGS="-L${HOMEBREW_PREFIX}/opt/llvm/lib/c++ -Wl,-rpath,${HOMEBREW_PREFIX}/opt/llvm/lib/c+ -L${HOMEBREW_PREFIX}/opt/libomp/lib -Wl,-no_compact_unwind"
CPPFLAGS="-isystem ${HOMEBREW_PREFIX}/opt/libomp/include"
LIBS="-lomp ${LIBS}"
CPATH="${FROOT}/include:${CPATH}"
CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${CFLAGS}"
CXXFLAGS="${CFLAGS} ${CXXFLAGS}"
FCFLAGS="${CFLAGS} ${FCFLAGS}"
CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${CFLAGS} -Wno-deprecated-non-prototype"
fi
;;
*)
printf "Unknown compiler type: ${COMPILER}\n"
echo "Valid options are Intel, GNU-Linux, or GNU-Mac"
printf "Unknown compiler type: ${OS}\n"
echo "Valid options are Intel, Linux, or MacOSX"
printf $USTMT
exit 1
;;
Expand Down

0 comments on commit 52d4acc

Please sign in to comment.