RetroArch/qb/qb.params.sh

118 lines
3.2 KiB
Bash
Raw Normal View History

2015-06-17 16:05:26 +00:00
print_help_option() # $1 = option $@ = description
{
_opt="$1"
shift 1
printf ' %-26s %s\n' "$_opt" "$@"
2015-06-17 16:05:26 +00:00
}
2010-12-30 01:52:02 +00:00
print_help()
{ 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
General options:
EOF
2015-06-17 16:05:26 +00:00
print_help_option "--prefix=PATH" "Install path prefix"
print_help_option "--sysconfdir=PATH" "System wide config file prefix"
print_help_option "--bindir=PATH" "Binary install directory"
print_help_option "--datarootdir=PATH" "Read-only data install directory"
print_help_option "--docdir=PATH" "Documentation install directory"
print_help_option "--mandir=PATH" "Manpage install directory"
print_help_option "--global-config-dir=PATH" "System wide config file prefix (Deprecated)"
print_help_option "--build=BUILD" "The build system (no-op)"
2017-11-22 23:33:35 +00:00
print_help_option "--host=HOST" "Cross-compile with HOST-gcc instead of gcc"
2015-06-17 16:05:26 +00:00
print_help_option "--help" "Show this help"
printf %s\\n '' 'Custom options:'
2015-06-17 16:05:26 +00:00
2017-11-18 03:08:36 +00:00
while read -r VAR COMMENT; do
TMPVAR="${VAR%=*}"
COMMENT="${COMMENT#*#}"
VAL="${VAR#*=}"
VAR="$(printf %s "${TMPVAR#HAVE_}" | tr '[:upper:]' '[:lower:]')"
case "$VAR" in
'c89_'*|'cxx_'*) continue;;
2012-06-12 20:16:16 +00:00
*)
case "$VAL" in
'yes'*)
2016-03-20 23:12:56 +00:00
print_help_option "--disable-$VAR" "Disable $COMMENT";;
'no'*)
print_help_option "--enable-$VAR" "Enable $COMMENT";;
'auto'*)
print_help_option "--enable-$VAR" "Enable $COMMENT"
2016-03-20 23:12:56 +00:00
print_help_option "--disable-$VAR" "Disable $COMMENT";;
*)
print_help_option "--with-$VAR" "Config $COMMENT";;
esac
esac
done < 'qb/config.params.sh'
2010-12-30 01:52:02 +00:00
}
opt_exists() # $opt is returned if exists in OPTS
{ opt="$(printf %s "$1" | tr '[:lower:]' '[:upper:]')"
2017-11-18 09:17:00 +00:00
err="$2"
eval "set -- $OPTS"
for OPT do [ "$opt" = "$OPT" ] && return; done
die 1 "Unknown option $err"
2010-12-30 01:52:02 +00:00
}
parse_input() # Parse stuff :V
2019-02-08 20:28:15 +00:00
{ BUILD=''
OPTS=''
while read -r VAR _; do
2017-11-18 03:08:36 +00:00
TMPVAR="${VAR%=*}"
NEWVAR="${TMPVAR##HAVE_}"
OPTS="$OPTS $NEWVAR"
eval "USER_$NEWVAR=no"
2017-11-18 03:08:36 +00:00
done < 'qb/config.params.sh'
#OPTS contains all available options in config.params.sh - used to speedup
#things in opt_exists()
2019-02-03 23:49:35 +00:00
while [ $# -gt 0 ]; do
case "$1" in
--prefix=*) PREFIX=${1##--prefix=};;
--global-config-dir=*|--sysconfdir=*) GLOBAL_CONFIG_DIR="${1#*=}";;
--bindir=*) BIN_DIR="${1#*=}";;
--build=*) BUILD="${1#*=}";;
--datarootdir=*) SHARE_DIR="${1#*=}";;
--docdir=*) DOC_DIR="${1#*=}";;
--host=*) CROSS_COMPILE=${1##--host=}-;;
--mandir=*) MAN_DIR="${1#*=}";;
--enable-*)
2016-01-28 23:48:11 +00:00
opt_exists "${1##--enable-}" "$1"
eval "HAVE_$opt=yes"
eval "USER_$opt=yes"
;;
--disable-*)
2016-01-28 23:48:11 +00:00
opt_exists "${1##--disable-}" "$1"
eval "HAVE_$opt=no"
2017-01-16 20:06:46 +00:00
eval "HAVE_NO_$opt=yes"
;;
--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\""
;;
-h|--help) print_help; exit 0;;
--) break ;;
'') : ;;
*) die 1 "Unknown option $1";;
esac
shift
done
2010-12-30 01:52:02 +00:00
}
. qb/config.params.sh
2010-12-30 01:52:02 +00:00
parse_input "$@"