File: qb.params.sh

package info (click to toggle)
retroarch 1.20.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 75,736 kB
  • sloc: ansic: 1,207,646; cpp: 104,166; objc: 8,567; asm: 6,624; python: 3,776; makefile: 2,838; sh: 2,786; xml: 1,408; perl: 393; javascript: 10
file content (157 lines) | stat: -rw-r--r-- 4,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# 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()
{
	_opt="$1"
	shift 1
	printf '  %-26s  %s\n' "$_opt" "$@"
}

print_help()
{	cat << EOF
====================
 Quickbuild script
====================
Package: $PACKAGE_NAME

General environment variables:
  CC:         C compiler
  CFLAGS:     C compiler flags
  CXX:        C++ compiler
  CXXFLAGS:   C++ compiler flags
  LDFLAGS:    Linker flags

General options:
EOF
	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 "--build=BUILD"            "The build system (no-op)"
	print_help_option "--host=HOST"              "Cross-compile with HOST-gcc instead of gcc"
	print_help_option "--help"                   "Show this help"

	printf %s\\n '' 'Default for custom toggle options can be yes, no, or auto.'
	print_help_option 'Disable option is shown:' 'Default is yes'
	print_help_option 'Enable option is shown:'  'Default is no'
	print_help_option 'Both options are shown:'  'Default is auto (included if the necessary library is present)'
	printf %s\\n '' 'Custom options:'

	while read -r VAR _ COMMENT; do
		case "$VAR" in
			'C89_'*|'CXX_'*) continue;;
			*)
			TMPVAR="${VAR%=*}"
			VAL="${VAR#*=}"
			VAR="$(printf %s "${TMPVAR#HAVE_}" | tr '[:upper:]' '[:lower:]')"
			case "$VAL" in
				'yes'*)
					print_help_option "--disable-$VAR" "Disable  $COMMENT";;
				'no'*)
					print_help_option "--enable-$VAR" "Enable   $COMMENT";;
				'auto'*)
					print_help_option "--enable-$VAR" "Enable   $COMMENT"
					print_help_option "--disable-$VAR" "Disable  $COMMENT";;
				*)
					print_help_option "--with-$VAR" "Config   $COMMENT";;
			esac
		esac
	done < 'qb/config.params.sh'
}

opt_exists() # $opt is returned if exists in OPTS
{	opt="$(printf %s "$1" | tr '[:lower:]' '[:upper:]')"
	err="$2"
	eval "set -- $OPTS"
	for OPT do [ "$opt" = "$OPT" ] && return; done
	die 1 "Unknown option $err"
}

parse_input() # Parse stuff :V
{	BUILD=''
	OPTS=''
	CONFIG_OPTS=''
	config_opts='./configure'

	while read -r VAR _; do
		TMPVAR="${VAR%=*}"
		NEWVAR="${TMPVAR##HAVE_}"
		OPTS="${OPTS} $NEWVAR"
		case "$TMPVAR" in
			HAVE_*) CONFIG_OPTS="${CONFIG_OPTS} $NEWVAR" ;;
		esac
		eval "USER_$NEWVAR=auto"
	done < 'qb/config.params.sh'
	#OPTS contains all available options in config.params.sh - used to speedup
	#things in opt_exists()

	while [ $# -gt 0 ]; do
		config_opts="${config_opts} $1"
		case "$1" in
			--prefix=*) PREFIX=${1##--prefix=};;
			--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-*)
				opt_exists "${1##--enable-}" "$1"
				eval "HAVE_$opt=yes"
				eval "USER_$opt=yes"
			;;
			--disable-*)
				opt_exists "${1##--disable-}" "$1"
				eval "HAVE_$opt=no"
				eval "USER_$opt=no"
				add_opt "NO_$opt" yes
			;;
			--with-*)
				arg="${1##--with-}"
				val="${arg##*=}"
				opt_exists "${arg%%=*}" "$1"
				eval "$opt=\"$val\""
			;;
			-h|--help) print_help; exit 0;;
			--) break ;;
			'') : ;;
			*) die 1 "Unknown option $1";;
		esac
		shift
	done

	cat > config.log << EOF
Command line invocation:

  \$ ${config_opts}

## ----------- ##
## Core Tests. ##
## ----------- ##

EOF
}

. qb/config.params.sh

parse_input "$@"