khanat-code-old/code/ryzom/tools/scripts/linux/buildmode

141 lines
2.9 KiB
Text
Raw Normal View History

2014-09-06 18:56:06 +00:00
#!/bin/sh
###########################################################################
# Files associated to each mode
DEBUG_FILE=$RYZOM_PATH/.mode_debug
#RELEASE_FILE=$RYZOM_PATH/.mode_release
STATIC_FILE=$RYZOM_PATH/.mode_static
DYNAMIC_FILE=$RYZOM_PATH/.mode_dynamic
SILENT_FILE=$RYZOM_PATH/.mode_silent
###########################################################################
# Print status
printMode()
{
echo ""
echo "Compilation modes :"
echo ""
echo " Debug mode : $DEBUG_MODE"
# echo " Release mode : $RELEASE_MODE"
echo ""
echo " Static linking : $STATIC_MODE"
echo " Dynamic linking : $DYNAMIC_MODE"
echo ""
echo " Silent compilation : $SILENT_MODE"
echo ""
}
###########################################################################
# Get the specific mode value and set the corresponding variable
getMode()
{
local VAR=$1
local FILE=$2
if test -f $FILE
then
eval $VAR=ON
else
eval $VAR=OFF
fi
}
###########################################################################
# Set a specific mode to ON if it's OFF, and to OFF if its ON
setMode()
{
local VAR=$1
local FILE=$2
# Get the current mode value
OLD_VALUE=$(eval echo \$$VAR)
if test X"$OLD_VALUE" = "XOFF"
then
# Set the MODE to ON in case it's OFF
NEW_VALUE=ON
touch -f $FILE || (echo "Error : cannot create mode files" && exit 1)
else
# Set the MODE to OFF in case it's ON
NEW_VALUE=OFF
rm -f $FILE || (echo "Error : cannot delete mode files" && exit 1)
fi
eval $VAR=$NEW_VALUE
}
###########################################################################
# Print command usage
printUsage()
{
echo ""
echo "Usage: `basename $0` [debug] [static] [dynamic] [silent]"
echo " debug -> turn ON/OFF debug compilation"
echo " static -> turn ON/OFF static linking"
echo " dynamic -> turn ON/OFF dynamic linking"
echo " slient -> turn ON/OFF silent compilation"
echo ""
}
###########################################################################
# Get the mode settings
getMode DEBUG_MODE $DEBUG_FILE
#getMode RELEASE_MODE $RELEASE_FILE
getMode STATIC_MODE $STATIC_FILE
getMode DYNAMIC_MODE $DYNAMIC_FILE
getMode SILENT_MODE $SILENT_FILE
# Print the mode values and exit if there is no argument
if test $# -eq 0
then
printMode
exit 0
fi
while test $# -gt 0
do
case $1 in
debug)
setMode DEBUG_MODE $DEBUG_FILE
;;
# release)
# setMode RELEASE_MODE $RELEASE_FILE
# ;;
static)
setMode STATIC_MODE $STATIC_FILE
;;
dynamic)
setMode DYNAMIC_MODE $DYNAMIC_FILE
;;
silent)
setMode SILENT_MODE $SILENT_FILE
;;
*) echo "Error : $1 : Unknown argument"
printUsage
exit 1
;;
esac
shift
done
printMode
exit 0