-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall_M1.sh
More file actions
executable file
·83 lines (72 loc) · 2.56 KB
/
install_M1.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.56 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
#!/bin/bash
echo "Setting up UPSIDE2 for Apple Silicon Mac (M1/M2/M3/M4) with Apple Clang..."
echo `pwd`
# Detect Apple Silicon and set appropriate variables
if [[ $(uname -m) == "arm64" ]]; then
echo "Detected Apple Silicon (ARM64) architecture"
ARCH_TYPE="arm64"
else
echo "Error: This script is designed for Apple Silicon Macs only"
echo "Detected architecture: $(uname -m)"
exit 1
fi
# Set the project path dynamically based on current directory
upside_path="$(pwd)"
# Remove existing source.sh and generate a fresh one from template
echo "Generating fresh source.sh from template..."
if [ -f "source.sh" ]; then
echo "Backing up existing source.sh to source.sh.backup"
cp source.sh source.sh.backup
fi
rm -f source.sh
cp source_arm source.sh
sed -i '' "s|UP_PATH|$upside_path|g" source.sh
echo "Generated source.sh with path: $upside_path"
# Source the environment
source source.sh
# Set up OpenMP environment variables explicitly
LIBOMP_PREFIX=$(brew --prefix libomp)
export OpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I$LIBOMP_PREFIX/include"
export OpenMP_CXX_LIB_NAMES="omp"
export OpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I$LIBOMP_PREFIX/include"
export OpenMP_C_LIB_NAMES="omp"
export OpenMP_omp_LIBRARY="$LIBOMP_PREFIX/lib/libomp.dylib"
export CMAKE_PREFIX_PATH="$LIBOMP_PREFIX:$CMAKE_PREFIX_PATH"
echo "OpenMP configuration:"
echo " LIBOMP_PREFIX: $LIBOMP_PREFIX"
echo " OpenMP_CXX_FLAGS: $OpenMP_CXX_FLAGS"
echo " OpenMP_CXX_LIB_NAMES: $OpenMP_CXX_LIB_NAMES"
echo " OpenMP_omp_LIBRARY: $OpenMP_omp_LIBRARY"
# Clean previous build
echo "Cleaning previous build..."
rm -rf obj/*
cd obj
# Configure with Apple Silicon optimized settings using Apple Clang
echo "Configuring CMake for Apple Silicon with Apple Clang..."
cmake ../src/ \
-DEIGEN3_INCLUDE_DIR=$EIGEN_HOME \
-DCMAKE_OSX_ARCHITECTURES=$ARCH_TYPE \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_FLAGS="-std=c++11" \
-DCMAKE_C_FLAGS="" \
-DOpenMP_CXX_FLAGS="$OpenMP_CXX_FLAGS" \
-DOpenMP_C_FLAGS="$OpenMP_C_FLAGS" \
-DOpenMP_CXX_LIB_NAMES="$OpenMP_CXX_LIB_NAMES" \
-DOpenMP_C_LIB_NAMES="$OpenMP_C_LIB_NAMES" \
-DOpenMP_omp_LIBRARY="$OpenMP_omp_LIBRARY" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH"
# Build with verbose output
echo "Building UPSIDE2..."
make VERBOSE=1
# Check if build was successful
if [ $? -eq 0 ]; then
echo "Build completed successfully!"
echo "Executables created:"
ls -la upside*
echo "Shared library created:"
ls -la libupside*
else
echo "Build failed. Please check the error messages above."
exit 1
fi