2015-06-17 16:05:26 +00:00
|
|
|
print_help_option() # $1 = option $@ = description
|
|
|
|
{
|
|
|
|
_opt="$1"
|
|
|
|
shift 1
|
2016-08-27 23:49:09 +00:00
|
|
|
printf " %-25s %s\n" "$_opt" "$@"
|
2015-06-17 16:05:26 +00:00
|
|
|
}
|
|
|
|
|
2010-12-30 01:52:02 +00:00
|
|
|
print_help()
|
2012-06-02 20:05:14 +00:00
|
|
|
{ cat << EOF
|
|
|
|
====================
|
|
|
|
Quickbuild script
|
|
|
|
====================
|
|
|
|
Package: $PACKAGE_NAME
|
|
|
|
|
|
|
|
General environment variables:
|
2015-06-17 16:05:26 +00:00
|
|
|
CC: C compiler
|
|
|
|
CFLAGS: C compiler flags
|
|
|
|
CXX: C++ compiler
|
|
|
|
CXXFLAGS: C++ compiler flags
|
|
|
|
LDFLAGS: Linker flags
|
2012-06-02 20:05:14 +00:00
|
|
|
|
|
|
|
General options:
|
|
|
|
EOF
|
2015-06-17 16:05:26 +00:00
|
|
|
print_help_option "--prefix=PATH" "Install path prefix"
|
|
|
|
print_help_option "--global-config-dir=PATH" "System wide config file prefix"
|
|
|
|
print_help_option "--host=HOST" "cross-compile to build programs to run on HOST"
|
|
|
|
print_help_option "--help" "Show this help"
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Custom options:"
|
|
|
|
|
2012-06-02 20:05:14 +00:00
|
|
|
while IFS='=#' read VAR VAL COMMENT; do
|
|
|
|
VAR=$(echo "${VAR##HAVE_}" | tr '[A-Z]' '[a-z]')
|
2016-01-29 17:57:21 +00:00
|
|
|
case "$VAR" in
|
|
|
|
'c89_'*) true;;
|
2012-06-12 20:16:16 +00:00
|
|
|
*)
|
2016-01-29 17:57:21 +00:00
|
|
|
case "$VAL" in
|
|
|
|
'yes'*)
|
2016-03-20 23:12:56 +00:00
|
|
|
print_help_option "--disable-$VAR" "Disable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
'no'*)
|
2016-03-20 23:12:56 +00:00
|
|
|
print_help_option "--enable-$VAR" "Enable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
'auto'*)
|
2016-03-20 23:12:56 +00:00
|
|
|
print_help_option "--enable-$VAR" "Enable $COMMENT"
|
|
|
|
print_help_option "--disable-$VAR" "Disable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
*)
|
2016-08-28 00:06:50 +00:00
|
|
|
print_help_option "--with-$VAR" "Config $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
esac
|
2012-06-02 20:05:14 +00:00
|
|
|
esac
|
|
|
|
done < 'qb/config.params.sh'
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 20:05:14 +00:00
|
|
|
opt_exists() # $opt is returned if exists in OPTS
|
2012-06-12 20:16:16 +00:00
|
|
|
{ opt=$(echo "$1" | tr '[a-z]' '[A-Z]')
|
2012-06-02 20:05:14 +00:00
|
|
|
for OPT in $OPTS; do [ "$opt" = "$OPT" ] && return; done
|
2016-01-28 23:48:11 +00:00
|
|
|
echo "Unknown option $2"; exit 1
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 20:05:14 +00:00
|
|
|
parse_input() # Parse stuff :V
|
2012-06-12 20:16:16 +00:00
|
|
|
{ OPTS=; while IFS='=' read VAR dummy; do OPTS="$OPTS ${VAR##HAVE_}"; done < 'qb/config.params.sh'
|
|
|
|
#OPTS contains all available options in config.params.sh - used to speedup
|
|
|
|
#things in opt_exists()
|
2012-06-02 20:05:14 +00:00
|
|
|
|
|
|
|
while [ "$1" ]; do
|
|
|
|
case "$1" in
|
|
|
|
--prefix=*) PREFIX=${1##--prefix=};;
|
2013-05-27 23:59:06 +00:00
|
|
|
--global-config-dir=*) GLOBAL_CONFIG_DIR=${1##--global-config-dir=};;
|
2012-12-08 23:20:55 +00:00
|
|
|
--host=*) CROSS_COMPILE=${1##--host=}-;;
|
2012-06-02 20:05:14 +00:00
|
|
|
--enable-*)
|
2016-01-28 23:48:11 +00:00
|
|
|
opt_exists "${1##--enable-}" "$1"
|
2012-06-02 20:05:14 +00:00
|
|
|
eval "HAVE_$opt=yes"
|
|
|
|
;;
|
|
|
|
--disable-*)
|
2016-01-28 23:48:11 +00:00
|
|
|
opt_exists "${1##--disable-}" "$1"
|
2012-06-02 20:05:14 +00:00
|
|
|
eval "HAVE_$opt=no"
|
|
|
|
;;
|
|
|
|
--with-*)
|
2014-06-05 09:45:44 +00:00
|
|
|
arg="${1##--with-}"
|
|
|
|
val="${arg##*=}"
|
2016-01-28 23:48:11 +00:00
|
|
|
opt_exists "${arg%%=*}" "$1"
|
2014-06-05 09:45:44 +00:00
|
|
|
eval "$opt=\"$val\""
|
2012-06-02 20:05:14 +00:00
|
|
|
;;
|
|
|
|
-h|--help) print_help; exit 0;;
|
2016-01-28 23:48:11 +00:00
|
|
|
*) echo "Unknown option $1"; exit 1;;
|
2012-06-02 20:05:14 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 20:05:14 +00:00
|
|
|
. qb/config.params.sh
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2012-06-12 20:16:16 +00:00
|
|
|
parse_input "$@"
|