summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-09 16:27:03 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-09 16:31:33 (EDT)
commit598fd371adfa9d1a6b59d870342458e23c584db7 (patch)
tree2bf7ebdd77274a3c1bdd3f8e671ffa0d6ad86806
parent8cccff5322665d9c870f319f5122eeaa28331adc (diff)
Update configure.
Apply changes made to configure in opkbuild 3.0.0-alpha1
-rwxr-xr-xconfigure156
1 files changed, 111 insertions, 45 deletions
diff --git a/configure b/configure
index d74d3b6..2d6a814 100755
--- a/configure
+++ b/configure
@@ -23,17 +23,16 @@ package_name='opkhelper'
package_version='2.0.0'
package_description='opkg Build Helper Tools'
-srcdir=$(dirname "${0}")
-srcdir=$(cd ${srcdir} && pwd)
+srcdir="$(cd "${0%/*}" && pwd)"
prefix='/usr/local'
bindir='$(prefix)/bin'
-libdir='$(prefix)/lib/opkhelper'
+libdir='$(prefix)/share'
datadir='$(prefix)/share'
mandir='$(datadir)/man'
localedir='$(datadir)/locale'
-quiet=false
-missing_deps=false
+quiet='false'
+missing_deps='false'
dep_cmds='
sh
opkg
@@ -49,24 +48,58 @@ mandir
localedir
'
-features="${dep_cmds}"
+features="
+${dep_cmds}
+${dep_libs}
+${opt_dep_cmds}
+${opt_dep_libs}
+"
-subst_vars="package_name
+subst_vars="
+package_name
package_version
package_description
${long_opts_with_args}
-${dep_cmds}"
+${features}
+"
main()
{
parse_options "${@}"
+ shift ${optind}
+ if [ ${#} -ne 0 ]; then
+ print_usage
+ exit
+ fi
for dep in ${dep_cmds}; do
- dep_val=$(eval echo \$\{"${dep}"\})
+ dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')"
+ dep_val="$(eval echo \$\{"${dep_name}"\})"
+ if [ -z "${dep_val}" ]; then
+ find_dep_cmd "${dep}" || missing_deps='true'
+ fi
+ done
+ for dep in ${dep_libs}; do
+ dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')"
+ dep_val="$(eval echo \$\{"${dep_name}"\})"
+ if [ -z "${dep_val}" ]; then
+ find_dep_lib "${dep}" || missing_deps='true'
+ fi
+ done
+ for dep in ${opt_dep_cmds}; do
+ dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')"
+ dep_val="$(eval echo \$\{"${dep_name}"\})"
if [ -z "${dep_val}" ]; then
find_dep_cmd "${dep}"
fi
done
+ for dep in ${opt_dep_libs}; do
+ dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')"
+ dep_val="$(eval echo \$\{"${dep_name}"\})"
+ if [ -z "${dep_val}" ]; then
+ find_dep_lib "${dep}"
+ fi
+ done
if ${missing_deps}; then
cat <<EOF
@@ -91,30 +124,34 @@ print_usage()
print_help()
{
cat <<EOF
-\`configure' configures ${PACKAGE} ${VERSION} to adapt to many kinds of systems.
+\`configure' configures ${package_name} ${package_version} to adapt to many \
+kinds of systems.
$(print_usage)
Configuration:
- -h, --help display this help and exit
- -V, --version display version information and exit
- -q, --quiet do not print \`checking ...' messages
- --srcdir=SRCDIR find the scripts in SRCDIR
- default: configure dir
+ -h, --help display this help and exit
+ -V, --version display version information and exit
+ -q, --quiet do not print \`checking ...' messages
+ --srcdir=SRCDIR find the scripts in SRCDIR
+ default: configure dir
Installation directories:
- --prefix=PREFIX install files under PREFIX
- default: /usr/local
- --bindir=BINDIR install scripts in BINDIR
- default: PREFIX/bin
- --libdir=LIBDIR install library scripts in LIBDIR
- default: PREFIX/lib
- --datadir=DATADIR expect to find data in DATADIR
- default: PREFIX/share
- --mandir=MANDIR install manual pages in MANDIR
- default: DATADIR/man
- --localedir=LOCALEDIR install locales in LOCALEDIR
- default: DATADIR/man
+ --prefix=PREFIX install files under PREFIX
+ default: /usr/local
+ --bindir=BINDIR install scripts in BINDIR
+ default: PREFIX/bin
+ --libdir=LIBDIR install library scripts in LIBDIR
+ default: PREFIX/lib
+ --datadir=DATADIR expect to find data in DATADIR
+ default: PREFIX/share
+ --mandir=MANDIR install manual pages in MANDIR
+ default: DATADIR/man
+ --localedir=LOCALEDIR install locales in LOCALEDIR
+ default: DATADIR/locale
+
+Dependencies:
+ --with-sh=PATH use sh at PATH
EOF
}
@@ -133,12 +170,14 @@ EOF
parse_options()
{
+ optind=0
+
for _opt; do
# Handle arguments of "--opt arg" options.
if [ -n "${_prev}" ]; then
- eval "${_prev}=\$\{_opt\}"
- _prev=
+ eval "${_prev}"=\"\$\{_opt\}\"
+ _prev=''
continue
fi
@@ -147,10 +186,10 @@ parse_options()
*=*)
_optarg="${_opt#*=}"
_opt="${_opt%=*}"
- _optarg_set=true
+ _optarg_set='true'
;;
*)
- _optarg_set=false
+ _optarg_set='false'
;;
esac
@@ -168,7 +207,7 @@ parse_options()
exit 0
;;
-q|--quiet)
- quiet=true
+ quiet='true'
continue
;;
esac
@@ -178,16 +217,15 @@ parse_options()
--with-*)
_opt="${_opt#--with-}"
_opts="${features}"
- _type=package
+ _type='package'
;;
--*)
_opt="${_opt#--}"
_opts="${long_opts_with_args}"
- _type=option
+ _type='option'
;;
*)
- printf 'unrecognized option: %s\n' "${_opt}" >&2
- exit 1
+ break
;;
esac
@@ -199,11 +237,14 @@ EOF
exit 1
fi
if ${_optarg_set}; then
- eval ${_opt}=\$\{_optarg\}
+ _opt="$(printf '%s' "${_opt}" | tr -c '[a-z0-9]' '_')"
+ eval "${_opt}"=\"\$\{_optarg\}\"
else
_prev="${_opt}"
fi
+ optind=$(($optind + 1))
+
done
}
@@ -211,36 +252,61 @@ find_dep_cmd()
{
_dep="${1}"
- ${quiet} || printf 'checking for %s... ' "${dep}"
+ ${quiet} || printf 'checking for %s... ' "${_dep}"
- _old_ifs="${IFS}"
- IFS=:
+ IFS=':'
for _element in ${PATH}; do
+ unset IFS
: ${_element=-.}
if [ -f "${_element}/${_dep}" -a -x "${_element}/${_dep}" ]; then
${quiet} || printf '%s/%s\n' "${_element}" "${_dep}"
- eval "${_dep}=${_element}/${_dep}"
- IFS="${_old_ifs}"
+ eval "${_dep}"=\"${_element}/${_dep}\"
return 0
fi
done
- IFS="${_old_ifs}"
+ unset IFS
+
+ ${quiet} || printf 'not found\n'
+ return 1
+}
+
+find_dep_lib()
+{
+ _dep="${1}"
+
+ ${quiet} || printf 'checking for %s... ' "${_dep}"
+
+ IFS=':'
+
+ for _element in ${libdir}:${PATH}; do
+ unset IFS
+ : ${_element=-.}
+ if [ -f "${_element}/${_dep}" -a -x "${_element}/${_dep}" ]; then
+ ${quiet} || printf '%s/%s\n' "${_element}" "${_dep}"
+ eval "${_dep}"=\"${_element}/${_dep}\"
+ return 0
+ fi
+ done
+
+ unset IFS
+
${quiet} || printf 'not found\n'
- missing_deps=true
return 1
}
write_makefiles()
{
# Make a script to edit input makefiles.
- _sed_script=
+ _sed_script=''
for _var in ${subst_vars}; do
+ _var="$(printf '%s' "${_var}" | tr -c '[a-z0-9]' '_')"
_sed_script="${_sed_script}s&@${_var}@&$(eval echo \$\{"${_var}"\})&g;"
done
for _dir in . src lib locale man; do
+ mkdir -p "${_dir}"
sed "${_sed_script}" "${srcdir}/${_dir}/Makefile.in" >"${_dir}/Makefile"
done
}