-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (38 loc) · 856 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
#!/bin/bash
# Define the compiler and flags
CC=gcc
CFLAGS="-Wall"
LIBS=""
# Check the operating system
OS=$(uname -s)
# Set the compilation flags and libraries based on the OS
if [[ "$OS" == "Linux" ]]; then
if [[ "$(lsb_release -si)" == "Debian" ]] || [[ "$(lsb_release -si)" == "Kali" ]]; then
LIBS=$(pkg-config --libs sdl2)
CFLAGS+=" $(pkg-config --cflags sdl2)"
elif [[ "$(lsb_release -si)" == "Arch" ]] || [[ "$(lsb_release -si)" == "ManjaroLinux" ]]; then
LIBS="-lSDL2"
fi
fi
# Compile the program
compile() {
$CC -o fractal fractal.c $LIBS $CFLAGS
}
# Clean the project
clean() {
rm -f fractal
}
# Main script logic
case "$1" in
compile)
compile
;;
clean)
clean
;;
*)
echo "Usage: ./build.sh [compile|clean]"
exit 1
;;
esac
exit 0