forked from forefireAPI/forefire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-forefire-osx.sh
More file actions
86 lines (72 loc) · 2.39 KB
/
install-forefire-osx.sh
File metadata and controls
86 lines (72 loc) · 2.39 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -e
echo "====== MAC OS REQUIREMENTS ========"
# Update Homebrew.
brew update
# Ensure Xcode Command Line Tools are installed.
if ! xcode-select -p > /dev/null 2>&1; then
echo "Xcode Command Line Tools not found. Installing..."
xcode-select --install
fi
# Install dependencies via Homebrew.
brew install cmake
brew install netcdf
brew install netcdf-cxx
# Set NETCDF_HOME to the prefix for the NetCDF C library.
export NETCDF_HOME=$(brew --prefix netcdf)
echo "NETCDF_HOME set to $NETCDF_HOME"
# Set NETCDF_CXX_HOME to the prefix for the NetCDF C++ library.
export NETCDF_CXX_HOME=$(brew --prefix netcdf-cxx)
echo "NETCDF_CXX_HOME set to $NETCDF_CXX_HOME"
# Debug: list headers in NETCDF_HOME/include
echo "Contents of $NETCDF_HOME/include:"
ls -l "$NETCDF_HOME/include"
# Create a symlink in NETCDF_HOME/include so that "netcdf" points to "netcdf.h"
cd "$NETCDF_HOME/include"
if [ ! -e netcdf ]; then
echo "Creating symlink for netcdf -> netcdf.h"
ln -s netcdf.h netcdf
else
echo "Symlink for netcdf already exists."
fi
cd - > /dev/null
# Debug: list the contents of NETCDF_CXX_HOME/lib
cd "$NETCDF_CXX_HOME/lib"
echo "Contents of $NETCDF_CXX_HOME/lib:"
ls -l
# Determine target library name.
target=""
if [ -e libnetcdf-cxx4.dylib ]; then
target="libnetcdf-cxx4.dylib"
elif [ -e libnetcdf-cxx.dylib ]; then
target="libnetcdf-cxx.dylib"
else
echo "Error: Neither libnetcdf-cxx4.dylib nor libnetcdf-cxx.dylib found in $NETCDF_CXX_HOME/lib"
exit 1
fi
echo "Using target library: $target"
if [ ! -e libnetcdf_c++4.dylib ]; then
echo "Creating symlink: libnetcdf_c++4.dylib -> $target"
ln -s "$target" libnetcdf_c++4.dylib
else
echo "Symlink libnetcdf_c++4.dylib already exists."
fi
echo "Contents after symlink creation:"
ls -l
cd - > /dev/null
# Set LIBRARY_PATH for the linker.
export LIBRARY_PATH=$NETCDF_CXX_HOME/lib:$LIBRARY_PATH
echo "LIBRARY_PATH set to: $LIBRARY_PATH"
echo "==========================="
echo "========= FOREFIRE ========"
echo "==========================="
# Create build directory, configure, and compile ForeFire.
mkdir -p build
cd build
# Pass include flags for both netcdf-cxx and netcdf,
# and add the netcdf-cxx lib directory to the shared linker flags.
cmake -D NETCDF_HOME=$NETCDF_HOME \
-DCMAKE_CXX_FLAGS="-I$NETCDF_CXX_HOME/include -I$NETCDF_HOME/include" \
-DCMAKE_SHARED_LINKER_FLAGS="-L$NETCDF_CXX_HOME/lib" \
../
make