forked from FESOM/fesom2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·66 lines (54 loc) · 1.99 KB
/
configure.sh
File metadata and controls
executable file
·66 lines (54 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -e
HERE=$PWD
SOURCE_DIR="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"
BUILD_DIR=${BUILD_DIR:-build}
# Parse arguments
CLEAN_BUILD=false
ENV_ARGS=()
# Process arguments
for arg in "$@"; do
if [ "$arg" = "--clean" ]; then
CLEAN_BUILD=true
else
ENV_ARGS+=("$arg")
fi
done
# Clean if requested - do this before sourcing env.sh as cleaning doesn't need environment setup
if [ "$CLEAN_BUILD" = true ]; then
echo "Cleaning build directory and installed files..."
if [ -d "${BUILD_DIR}" ]; then
if [ -f "${BUILD_DIR}/CMakeCache.txt" ]; then
# Only attempt make clean and uninstall if we have a valid build directory
cd ${BUILD_DIR}
echo "Running make clean..."
make clean 2>/dev/null || true
echo "Running make uninstall..."
make uninstall 2>/dev/null || echo "No uninstall target available"
cd ${HERE}
fi
# Remove the build directory for a completely fresh build
echo "Removing build directory..."
rm -rf ${BUILD_DIR}
fi
echo "Clean completed successfully"
# Recreate build directory
mkdir -p ${BUILD_DIR}
fi
# Source environment with the original arguments (minus --clean)
source env.sh "${ENV_ARGS[@]}"
mkdir -p ${BUILD_DIR} # make sure not to commit this to svn or git
cd ${BUILD_DIR}
# Don't pass environment arguments (like 'ubuntu') to cmake
# Only pass arguments that start with - (like -DENABLE_OPENMP=ON)
CMAKE_ONLY_ARGS=""
for arg in "${ENV_ARGS[@]}"; do
if [[ "$arg" =~ ^- ]]; then
CMAKE_ONLY_ARGS="$CMAKE_ONLY_ARGS $arg"
fi
done
cmake ${SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=$HERE -DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS} ${CMAKE_ONLY_ARGS}
# not required when re-compiling
# additional cmake arguments can be passed to configure.sh
# this also includes fesom specific options in CMakeLists, can be used as -DFESOM_COUPLED=ON
make install -j`nproc --all`