created install way
This commit is contained in:
parent
a9b482d907
commit
39a4a02955
103
build.sh
103
build.sh
@ -6,38 +6,91 @@
|
|||||||
rm -rf out/*
|
rm -rf out/*
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
files="
|
testFile="src/test/main.c"
|
||||||
src/test/main.c
|
sourceFiles="src/*.c"
|
||||||
|
includeFiles="include/*.h"
|
||||||
src/*.c
|
|
||||||
include/*.h
|
|
||||||
"
|
|
||||||
|
|
||||||
compiler="cc"
|
compiler="cc"
|
||||||
output="out/why2"
|
output="out/why2"
|
||||||
|
installOutput="libwhy2.so"
|
||||||
flags="-Wall -ljson-c -lcurl"
|
flags="-Wall -ljson-c -lcurl"
|
||||||
|
includeDirectory="/usr/include/why2"
|
||||||
|
|
||||||
# Check for debug flag
|
if [[ "$1" == "test" ]]; then ########## TEST ##########
|
||||||
if [[ "$*" == "debug" ]]; then
|
###
|
||||||
flags="$flags -g"
|
echo "Using '$compiler' as default compiler."
|
||||||
echo "Using debug flag"
|
###
|
||||||
fi
|
|
||||||
|
|
||||||
###
|
# Check for debug flag
|
||||||
echo "Using '$compiler' as default compiler. (Flags: $flags)"
|
if [[ "$2" == "debug" ]]; then ########## TEST & DEBUG ##########
|
||||||
echo "Compiling..."
|
flags="$flags -g"
|
||||||
###
|
echo "Using debug flag"
|
||||||
|
fi
|
||||||
|
|
||||||
# Compile
|
###
|
||||||
$compiler $files $flags -o $output
|
echo "Compiling... (Flags: $flags)"
|
||||||
|
###
|
||||||
|
|
||||||
|
# Compile
|
||||||
|
$compiler $testFile $sourceFiles $includeFiles $flags -o $output
|
||||||
|
|
||||||
|
# Compilation failed
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -e "\nCompilation failed. Did you run 'configure.sh' and 'build.sh install' first?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
###
|
||||||
|
echo "Output generated as '$output'"
|
||||||
|
###
|
||||||
|
elif [[ "$1" == "install" ]]; then ########## INSTALL ##########
|
||||||
|
###
|
||||||
|
echo "Using '$compiler' as default compiler."
|
||||||
|
###
|
||||||
|
|
||||||
|
flags="-Wall -fPIC -c"
|
||||||
|
|
||||||
|
###
|
||||||
|
echo "Compiling... (Flags: $flags)"
|
||||||
|
###
|
||||||
|
|
||||||
|
$compiler $flags $sourceFiles
|
||||||
|
|
||||||
|
flags="-Wall -shared"
|
||||||
|
|
||||||
|
###
|
||||||
|
echo "Compiling library... (Flags: $flags)"
|
||||||
|
###
|
||||||
|
|
||||||
|
$compiler $flags -o $installOutput *.o
|
||||||
|
|
||||||
|
###
|
||||||
|
echo "Installing..."
|
||||||
|
###
|
||||||
|
|
||||||
|
# Create why2 directory
|
||||||
|
if [[ ! -d $includeDirectory ]]; then
|
||||||
|
mkdir $includeDirectory
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv $installOutput /usr/lib/
|
||||||
|
cp $includeFiles $includeDirectory
|
||||||
|
|
||||||
|
# Compilation failed
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo -e "\nCompilation failed. Did you run 'build.sh' with sudo?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
###
|
||||||
|
echo "Finished! Cleaning up..."
|
||||||
|
###
|
||||||
|
|
||||||
|
rm -rf *.o
|
||||||
|
else ########## ERR ##########
|
||||||
|
###
|
||||||
|
echo "You have to enter 'test' or 'install' as arguments."
|
||||||
|
###
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
echo -e "\nCompilation failed. Did you run 'configure.sh' first?"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###
|
|
||||||
echo "Output generated as '$output'"
|
|
||||||
###
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user