[AED] Add setup script

This commit is contained in:
Tiago Garcia 2023-10-06 14:04:18 +01:00
parent 33a63b45e5
commit 046ce3224e
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 25 additions and 0 deletions

25
2ano/1semestre/aed/setup.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <source file>"
exit 1
fi
if [ ! -f "$1" ]; then
echo "File $1 does not exist"
exit 1
fi
out_dirname=$(dirname "$1")
out_basename=$(basename "$1")
if [ ! -d "out" ]; then
mkdir out
fi
if [ ! -d "out/$out_dirname" ]; then
mkdir -p "out/$out_dirname"
fi
gcc -Wall -Wextra -Werror -g -o "out/$out_dirname/${out_basename%.*}" "$1" -lm
out/"$out_dirname"/"${out_basename%.*}"