2019-07-27 16:58:17 +00:00
|
|
|
# add_opt
|
|
|
|
# $1 = HAVE_$1
|
|
|
|
# $2 = value ['auto', 'no' or 'yes', checked only if non-empty]
|
|
|
|
add_opt()
|
|
|
|
{ setval="$(eval "printf %s \"\$USER_$1\"")"
|
|
|
|
[ "${2:-}" ] && ! match "$setval" no yes && eval "HAVE_$1=\"$2\""
|
|
|
|
|
|
|
|
for opt in $(printf %s "$CONFIG_OPTS"); do
|
|
|
|
case "$opt" in
|
|
|
|
"$1") return 0 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
CONFIG_OPTS="${CONFIG_OPTS} $1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# print_help_option
|
|
|
|
# $1 = option
|
|
|
|
# $@ = description
|
|
|
|
print_help_option()
|
2015-06-17 16:05:26 +00:00
|
|
|
{
|
|
|
|
_opt="$1"
|
|
|
|
shift 1
|
2017-10-24 06:41:52 +00:00
|
|
|
printf ' %-26s %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"
|
2018-02-11 17:35:58 +00:00
|
|
|
print_help_option "--sysconfdir=PATH" "System wide config file prefix"
|
2018-02-08 19:49:31 +00:00
|
|
|
print_help_option "--bindir=PATH" "Binary install directory"
|
2018-02-04 21:06:58 +00:00
|
|
|
print_help_option "--datarootdir=PATH" "Read-only data install directory"
|
2018-02-10 16:30:20 +00:00
|
|
|
print_help_option "--docdir=PATH" "Documentation install directory"
|
2018-02-08 19:49:31 +00:00
|
|
|
print_help_option "--mandir=PATH" "Manpage install directory"
|
2017-11-22 23:21:12 +00:00
|
|
|
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"
|
|
|
|
|
2019-01-20 16:08:02 +00:00
|
|
|
printf %s\\n '' 'Custom options:'
|
2015-06-17 16:05:26 +00:00
|
|
|
|
2019-07-29 13:53:57 +00:00
|
|
|
while read -r VAR _ COMMENT; do
|
2016-01-29 17:57:21 +00:00
|
|
|
case "$VAR" in
|
2019-07-29 13:53:57 +00:00
|
|
|
'C89_'*|'CXX_'*) continue;;
|
2012-06-12 20:16:16 +00:00
|
|
|
*)
|
2019-07-29 13:53:57 +00:00
|
|
|
TMPVAR="${VAR%=*}"
|
|
|
|
VAL="${VAR#*=}"
|
|
|
|
VAR="$(printf %s "${TMPVAR#HAVE_}" | tr '[:upper:]' '[:lower:]')"
|
2016-01-29 17:57:21 +00:00
|
|
|
case "$VAL" in
|
|
|
|
'yes'*)
|
2019-07-29 13:53:57 +00:00
|
|
|
print_help_option "--disable-$VAR" "Disable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
'no'*)
|
2019-07-29 13:53:57 +00:00
|
|
|
print_help_option "--enable-$VAR" "Enable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
'auto'*)
|
2019-07-29 13:53:57 +00:00
|
|
|
print_help_option "--enable-$VAR" "Enable $COMMENT"
|
|
|
|
print_help_option "--disable-$VAR" "Disable $COMMENT";;
|
2016-01-29 17:57:21 +00:00
|
|
|
*)
|
2019-07-29 13:53:57 +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
|
2019-01-20 16:08:02 +00:00
|
|
|
{ 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
|
2017-10-22 07:33:27 +00:00
|
|
|
die 1 "Unknown option $err"
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 20:05:14 +00:00
|
|
|
parse_input() # Parse stuff :V
|
2019-02-08 20:28:15 +00:00
|
|
|
{ BUILD=''
|
|
|
|
OPTS=''
|
2019-07-27 16:58:17 +00:00
|
|
|
CONFIG_OPTS=''
|
2019-06-02 13:43:16 +00:00
|
|
|
config_opts='./configure'
|
|
|
|
|
2019-02-08 20:28:15 +00:00
|
|
|
while read -r VAR _; do
|
2017-11-18 03:08:36 +00:00
|
|
|
TMPVAR="${VAR%=*}"
|
2019-02-10 18:15:33 +00:00
|
|
|
NEWVAR="${TMPVAR##HAVE_}"
|
2019-07-27 16:58:17 +00:00
|
|
|
OPTS="${OPTS} $NEWVAR"
|
2019-07-28 00:40:12 +00:00
|
|
|
case "$TMPVAR" in
|
|
|
|
HAVE_*) CONFIG_OPTS="${CONFIG_OPTS} $NEWVAR" ;;
|
2019-07-27 16:58:17 +00:00
|
|
|
esac
|
2019-05-14 03:11:52 +00:00
|
|
|
eval "USER_$NEWVAR=auto"
|
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
|
|
|
|
2019-02-08 19:59:28 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2019-06-02 13:43:16 +00:00
|
|
|
config_opts="${config_opts} $1"
|
2012-06-02 20:05:14 +00:00
|
|
|
case "$1" in
|
|
|
|
--prefix=*) PREFIX=${1##--prefix=};;
|
2019-11-01 05:53:12 +00:00
|
|
|
--sysconfdir=*) GLOBAL_CONFIG_DIR="${1#*=}";;
|
2018-02-08 19:49:31 +00:00
|
|
|
--bindir=*) BIN_DIR="${1#*=}";;
|
2017-11-22 23:21:12 +00:00
|
|
|
--build=*) BUILD="${1#*=}";;
|
2018-02-04 21:06:58 +00:00
|
|
|
--datarootdir=*) SHARE_DIR="${1#*=}";;
|
2018-02-10 16:30:20 +00:00
|
|
|
--docdir=*) DOC_DIR="${1#*=}";;
|
2012-12-08 23:20:55 +00:00
|
|
|
--host=*) CROSS_COMPILE=${1##--host=}-;;
|
2018-02-08 19:49:31 +00:00
|
|
|
--mandir=*) MAN_DIR="${1#*=}";;
|
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"
|
2019-01-30 00:17:06 +00:00
|
|
|
eval "USER_$opt=yes"
|
2012-06-02 20:05:14 +00:00
|
|
|
;;
|
|
|
|
--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"
|
2019-05-14 03:11:52 +00:00
|
|
|
eval "USER_$opt=no"
|
2019-07-28 14:56:44 +00:00
|
|
|
add_opt "NO_$opt" yes
|
2012-06-02 20:05:14 +00:00
|
|
|
;;
|
|
|
|
--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;;
|
2019-02-08 19:59:28 +00:00
|
|
|
--) break ;;
|
|
|
|
'') : ;;
|
2017-10-22 07:33:27 +00:00
|
|
|
*) die 1 "Unknown option $1";;
|
2012-06-02 20:05:14 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2019-06-02 13:43:16 +00:00
|
|
|
|
|
|
|
cat > config.log << EOF
|
|
|
|
Command line invocation:
|
|
|
|
|
|
|
|
\$ ${config_opts}
|
|
|
|
|
|
|
|
## ----------- ##
|
|
|
|
## Core Tests. ##
|
|
|
|
## ----------- ##
|
|
|
|
|
|
|
|
EOF
|
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
|
|
|
|
2017-10-22 07:33:27 +00:00
|
|
|
parse_input "$@"
|