-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·47 lines (42 loc) · 896 Bytes
/
build.sh
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
#!/bin/bash
# Define the source files
SOURCE_FILES="src/*/*.c"
# Binary directory
BIN_DIR="bin"
# Binary name
OUTPUT_BINARY="$BIN_DIR/game_of_life"
# Compile the program
compile() {
mkdir -p $BIN_DIR
# gcc -o $OUTPUT_BINARY $SOURCE_FILES
mpicc -fopenmp -O -o $OUTPUT_BINARY $SOURCE_FILES -lm
if [ $? -eq 0 ]; then
echo "Compilation successful. Binary created: $OUTPUT_BINARY"
else
echo "Compilation failed."
exit 1
fi
}
# Clean up binaries
clean() {
if [ -d $BIN_DIR ]; then
rm -rf $BIN_DIR
rm -rf "game_of_life.out"
rm -rf "out.txt"
echo "Cleanup successful."
else
echo "Nothing to clean. The binary does not exist."
fi
}
case "$1" in
compile)
compile
;;
clean)
clean
;;
*)
echo "Usage: $0 {compile|clean}"
exit 1
;;
esac