blob: 6c32dbfbab3f978c7ba9788ec1bb74a9c3577fdd [file] [log] [blame]
#!/bin/sh
# options script
#
# This file was developed by Reid Spencer and is distributed under the
# University of Illinois Open Source License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
# This script lets you set sticky options that can be set once with this command
# and then ignored for remaining commands used from the same directory.
# Include the library. This will either read the options from the .options
# file or it will set the variables to their default values.
if test ! -z "$LLVM_TOP" ; then
if test -f "$LLVM_TOP/library.sh" ; then
. "$LLVM_TOP/library.sh"
else
echo "Your LLVM_TOP variable is not set to an llvm-top directory"
exit 1
fi
elif test -f ./library.sh ; then
. ./library.sh
elif test -f ../library.sh ; then
. ../library.sh
else
echo Please run $0 from the llvm-top directory or a module directory.
exit 1
fi
# Process the arguments to set the new values
msg 3 "Processing new option arguments"
for arg in "$@" ; do
case "$arg" in
+ASSERTIONS) ASSERTIONS=1 ;;
-ASSERTIONS) ASSERTIONS=0 ;;
+CHECKING) CHECKING=1 ;;
-CHECKING) CHECKING=0 ;;
+DEBUG) DEBUG=1 ;;
-DEBUG) DEBUG=0 ;;
+DOXYGEN) DOXYGEN=1 ;;
-DOXYGEN) DOXYGEN=0 ;;
+OPT_FOR_SIZE) OPT_FOR_SIZE=1 ;;
-OPT_FOR_SIZE) OPT_FOR_SIZE=0 ;;
+OPTIMIZED) OPTIMIZED=1 ;;
-OPTIMIZED) OPTIMIZED=0 ;;
+PROFILING) PROFILING=1 ;;
-PROFILING) PROFILING=0 ;;
+STRIPPED) STRIPPED=1 ;;
-STRIPPED) STRIPPED=0 ;;
+THREADS) THREADS=1 ;;
-THREADS) THREADS=0 ;;
+VERBOSE) VERBOSE=1 ;;
-VERBOSE) VERBOSE=0 ;;
ASSERTIONS=*) ASSERTIONS=`echo "$arg" | sed -e 's/ASSERTIONS=//'` ;;
CHECKING=*) CHECKING=`echo "$arg" | sed -e 's/CHECKING=//'` ;;
DEBUG=*) DEBUG=`echo "$arg" | sed -e 's/DEBUG=//'` ;;
DESTDIR=*) DESTDIR=`echo "$arg" | sed -e 's/DESTDIR=//'` ;;
DOXYGEN=*) DOXYGEN=`echo "$arg" | sed -e 's/DOXYGEN=//'` ;;
LLVM_TOP=*) LLVM_TOP=`echo "$arg" | sed -e 's/LLVM_TOP=//'` ;;
OPT_FOR_SIZE=*) OPT_FOR_SIZE=`echo "$arg" | sed -e 's/OPT_FOR_SIZE=//'` ;;
OPTIMIZED=*) OPTIMIZED=`echo "$arg" | sed -e 's/OPTIMIZED=//'` ;;
PREFIX=*) PREFIX=`echo "$arg" | sed -e 's/PREFIX=//'` ;;
PROFILING=*) PROFILING=`echo "$arg" | sed -e 's/PROFILING=//'` ;;
STRIPPED=*) STRIPPED=`echo "$arg" | sed -e 's/STRIPPED=//'` ;;
TARGETS_TO_BUILD=*)
TARGETS_TO_BUILD=`echo "$arg" | sed -e 's/TARGETS_TO_BUILD=//'` ;;
THREADS=*) THREADS=`echo "$arg" | sed -e 's/THREADS=//'` ;;
USE_OBJ_DIR=*) USE_OBJ_DIR=`echo "$arg" | sed -e 's/USE_OBJ_DIR=//'` ;;
VERBOSE=*) VERBOSE=`echo "$arg" | sed -e 's/VERBOSE=//'` ;;
*) die 1 "Unrecognized option: $arg" ;;
esac
done
# Write the new options set to the .options file
msg 3 "Write options to .options file"
cat <<__EOF__ > "$options"
# LLVM configuration options database.
# This script is generated by "options" and included into library.sh
ASSERTIONS="$ASSERTIONS"
CHECKING="$CHECKING"
DEBUG="$DEBUG"
DESTDIR="$DESTDIR"
DOXYGEN="$DOXYGEN"
LLVM_TOP="$LLVM_TOP"
OPT_FOR_SIZE="$OPT_FOR_SIZE"
OPTIMIZED="$OPTIMIZED"
PREFIX="$PREFIX"
PROFILING="$PROFILING"
STRIPPED="$STRIPPED"
TARGETS_TO_BUILD="$TARGETS_TO_BUILD"
THREADS="$THREADS"
USE_OBJ_DIR="$USE_OBJ_DIR"
VERBOSE="$VERBOSE"
__EOF__
# If there were no arguments, just print the options for the user
msg 3 "Printing options"
if test "$#" -eq 0 ; then
cat "$options" | grep "="
fi