forked from Chirag-Khandelwal/ls_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·38 lines (28 loc) · 846 Bytes
/
build.sh
File metadata and controls
executable file
·38 lines (28 loc) · 846 Bytes
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
#!/usr/bin/env bash
compiler="clang"
os=$(uname)
if [[ "$os" == 'Linux' ]]; then
compiler="gcc"
fi
if ! [[ -z "${COMPILER}" ]]; then
compiler="${COMPILER}"
fi
compiler_version=$($compiler --version)
echo "Using compiler: $compiler"
echo "Creating directories ..."
mkdir -p "buildfiles/src/"
mkdir -p "bin"
find src -name "*.c" | grep -v "tests" | grep -v "main.c" | while read -r src_file; do
echo "Compiling: $src_file ..."
$compiler -O2 -std=gnu99 -c $src_file -o buildfiles/$src_file.o -I/usr/local/include
if ! [[ $? == 0 ]]; then
break
fi
done
if ! [[ $? == 0 ]]; then
echo "Error in compiling sources, will not continue"
exit $?
fi
echo "Building ..."
buildfiles=$(find buildfiles -name "*.c.o" | paste -sd " " -)
$compiler -O2 -std=c11 -g -o bin/ls_extended src/main.c $buildfiles -I/usr/local/include -L/usr/local/lib