diff options
author | Gaël Bonithon <trash.paradise@protonmail.com> | 2020-10-02 13:01:59 +0200 |
---|---|---|
committer | Gaël Bonithon <trash.paradise@protonmail.com> | 2020-10-03 09:14:40 +0200 |
commit | ec0295a92ba60a9cf258eb90013e3d993d09b5c4 (patch) | |
tree | d938ef922ede16741a80c359b5b7e60cc8b5ef92 /scripts | |
parent | 72483f0e80a4241893711f6431d53def515e5b6d (diff) | |
download | xfce4-dev-tools-ec0295a92ba60a9cf258eb90013e3d993d09b5c4.tar.gz |
xdt-autogen: Various small improvements
- quoting
- replace backticks with $()
- replace 'test "x$var"' with 'test "$var"'
- replace $(pwd) with $PWD
- simplify the command to search for languages
- do not use subshell when unneeded
- do not use redirection when unneeded
- directly test command exit codes instead of using $?
- readability (useless ";", indenting)
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/xdt-autogen.in | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/scripts/xdt-autogen.in b/scripts/xdt-autogen.in index 355b6df..e3a3a8a 100644 --- a/scripts/xdt-autogen.in +++ b/scripts/xdt-autogen.in @@ -122,7 +122,7 @@ lookup_configure_ac_in_files() ## ## check command-line args ## -if test "x$1" = "x--version" -o "x$1" = "x-V"; then +if test "$1" = "--version" -o "$1" = "-V"; then echo "$(basename "$0") $VERSION" exit 0 fi @@ -133,20 +133,20 @@ fi do_version_check() { test -z "$XDT_AUTOGEN_REQUIRED_VERSION" && return 0 - major=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f1` - test "$major" || return 1 - test $major -le $XDT_AUTOGEN_VERSION_MAJOR || return 1 - test $XDT_AUTOGEN_VERSION_MAJOR -gt $major && return 0 + major=$(echo "$XDT_AUTOGEN_REQUIRED_VERSION" | cut -d. -f1) + test -n "$major" || return 1 + test "$major" -le "$XDT_AUTOGEN_VERSION_MAJOR" || return 1 + test "$XDT_AUTOGEN_VERSION_MAJOR" -gt "$major" && return 0 - minor=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f2` - test "$minor" || return 1 - test $minor -le $XDT_AUTOGEN_VERSION_MINOR || return 1 - test $XDT_AUTOGEN_VERSION_MINOR -gt $minor && return 0 + minor=$(echo "$XDT_AUTOGEN_REQUIRED_VERSION" | cut -d. -f2) + test -n "$minor" || return 1 + test "$minor" -le "$XDT_AUTOGEN_VERSION_MINOR" || return 1 + test "$XDT_AUTOGEN_VERSION_MINOR" -gt "$minor" && return 0 - micro=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f3` - test "$micro" || return 1 - test $micro -le $XDT_AUTOGEN_VERSION_MICRO || return 1 - test $XDT_AUTOGEN_VERSION_MICRO -gt $micro && return 0 + micro=$(echo "$XDT_AUTOGEN_REQUIRED_VERSION" | cut -d. -f3) + test -n "$micro" || return 1 + test "$micro" -le "$XDT_AUTOGEN_VERSION_MICRO" || return 1 + test "$XDT_AUTOGEN_VERSION_MICRO" -gt "$micro" && return 0 return 0 } @@ -170,7 +170,7 @@ XDG_DATA_DIRS="${XDG_DATA_HOME}:${XDG_DATA_DIRS}" export XDG_DATA_DIRS XDG_DATA_HOME -MASTER_DIR=`pwd`; test -z "${MASTER_DIR}" && MASTER_DIR="." +MASTER_DIR=$PWD; test -z "${MASTER_DIR}" && MASTER_DIR="." ## ## First we do some substitutions to generate configure.{ac,in} if necessary @@ -183,16 +183,16 @@ for configure_ac_in_file in $CONFIGURE_AC_IN_FILES; do # first generate a revision id if test -d .git; then - revision=`git rev-parse --short HEAD` + revision=$(git rev-parse --short HEAD) fi - if test "x$revision" = "x"; then + if test -z "$revision"; then revision="UNKNOWN" fi # find out what languages we support - linguas=$(echo $(for i in "$conf_dir"/po/*.po; do test -e "$i" && basename -- "$i" .po; done) | tr -d '\n') conf_dir=$(dirname "$configure_ac_file") + linguas=$(find "$conf_dir/po" -type f -name '*.po' -printf "%f " | sed 's/\.po//g') # and do the substitution tmp=$(basename "${configure_ac_in_file}") @@ -205,7 +205,7 @@ dnl EOF sed -e "s/@REVISION@/${revision}/g" \ -e "s/@LINGUAS@/${linguas}/g" \ - < "$configure_ac_in_file" >> "$configure_ac_file" + "$configure_ac_in_file" >> "$configure_ac_file" done @@ -219,10 +219,10 @@ CONFIGURE_AC_FILES=$(lookup_configure_ac_files "$MASTER_DIR") ## ## Check for a suitable make ## -if test x"${MAKE}" = x""; then - if (type gmake) >/dev/null 2>/dev/null; then +if test -z "${MAKE}"; then + if type gmake >/dev/null 2>/dev/null; then MAKE="gmake" - elif (type make) >/dev/null 2>/dev/null; then + elif type make >/dev/null 2>/dev/null; then MAKE="make" else cat >&2 <<EOF @@ -293,7 +293,7 @@ if test "$1" = "clean"; then # "${configure_ac_file}" # ) # for translation in $translations; do -# rm -f "${directory}/po/${translation}.gmo"; +# rm -f "${directory}/po/${translation}.gmo" # done rm -f "${directory}"/po/*.gmo; done @@ -307,8 +307,7 @@ fi ## if test -z "${XDT_PROG_AUTOCONF}"; then test -z "${AUTOCONF_VERSION}" && i=autoconf || i=autoconf-${AUTOCONF_VERSION} - (${i} --version) </dev/null >/dev/null 2>&1 && - XDT_PROG_AUTOCONF=${i} + ${i} --version </dev/null >/dev/null 2>&1 && XDT_PROG_AUTOCONF=${i} fi test -z "${XDT_PROG_AUTOCONF}" && { @@ -329,16 +328,16 @@ IFS=$special_IFS for configure_ac_file in $CONFIGURE_AC_FILES; do IFS=$default_IFS if $EGREP -q "^(AC|IT)_PROG_INTLTOOL" "${configure_ac_file}"; then - (${XDT_PROG_INTLTOOLIZE} --version) </dev/null >/dev/null 2>&1 || { + ${XDT_PROG_INTLTOOLIZE} --version </dev/null >/dev/null 2>&1 || { cat >&2 <<EOF xdt-autogen: You must have "intltool" installed on your system. You can download the source tarball from ftp://ftp.gnome.org/pub/GNOME/. EOF exit 1 - }; - break; - fi; + } + break + fi done IFS=$special_IFS @@ -353,7 +352,7 @@ xdt-autogen: It is recommended to use IT_PROG_INTLTOOL([0.35.0]) more information. EOF - fi; + fi done @@ -383,23 +382,23 @@ xdt-autogen: It is recommended to use LT_PREREQ([@VERSION_LIBTOOL@]) and EOF runlibtoolize=1 - fi; + fi if grep -q "^LT_PREREQ" "${configure_ac_file}"; then runlibtoolize=1 - fi; + fi - if test $runlibtoolize -eq 1; then - (${XDT_PROG_LIBTOOLIZE} --version) </dev/null >/dev/null 2>&0 || { + if test "$runlibtoolize" -eq 1; then + ${XDT_PROG_LIBTOOLIZE} --version </dev/null >/dev/null 2>&1 || { cat >&2 <<EOF xdt-autogen: You must have "libtool" installed on your system. Download the appropriate package for your distribution, or get the source tarball at ftp://ftp.gnu.org/pub/gnu/. EOF exit 1 - }; - break; - fi; + } + break + fi done @@ -412,15 +411,15 @@ for configure_ac_file in $CONFIGURE_AC_FILES; do IFS=$default_IFS directory=$(dirname "${configure_ac_file}") if test -d "${directory}/po"; then - (${XDT_PROG_GLIB_GETTEXTIZE} --version) </dev/null >/dev/null 2>&1 || { + ${XDT_PROG_GLIB_GETTEXTIZE} --version </dev/null >/dev/null 2>&1 || { cat >&2 <<EOF xdt-autogen: You must have "glib2" installed. You can get if from ftp://ftp.gtk.org/pub/gtk/. EOF exit 1 - }; - break; - fi; + } + break + fi done @@ -432,15 +431,15 @@ IFS=$special_IFS for configure_ac_file in $CONFIGURE_AC_FILES; do IFS=$default_IFS if grep -q "^GTK_DOC_CHECK" "${configure_ac_file}"; then - (${XDT_PROG_GTKDOCIZE} --version) </dev/null >/dev/null 2>&1 || { + ${XDT_PROG_GTKDOCIZE} --version </dev/null >/dev/null 2>&1 || { cat >&2 <<EOF xdt-autogen: You must have "gtk-doc" installed. You can get if from http://www.gtk.org/gtk-doc/. EOF exit 1 - }; - break; - fi; + } + break + fi done @@ -449,8 +448,7 @@ done ## if test -z "${XDT_PROG_ACLOCAL}"; then test -z "${ACLOCAL_VERSION}" && i=aclocal || i=aclocal-${ACLOCAL_VERSION} - (${i} --version) </dev/null >/dev/null 2>&1 && - XDT_PROG_ACLOCAL=${i} + ${i} --version </dev/null >/dev/null 2>&1 && XDT_PROG_ACLOCAL=${i} fi test -z "${XDT_PROG_ACLOCAL}" && { @@ -471,9 +469,9 @@ IFS=$special_IFS for configure_ac_file in $CONFIGURE_AC_FILES; do IFS=$default_IFS if $EGREP -q "^A(M|C)_CONFIG_HEADER" "${configure_ac_file}"; then - test -z "${AUTOHEADER_VERSION}" && i=autoheader || i=autoheader-${AUTOHEADER_VERSION} - (${i} --version) </dev/null >/dev/null 2>&1 && - XDT_PROG_AUTOHEADER=${i} + test -z "${AUTOHEADER_VERSION}" && i=autoheader \ + || i=autoheader-${AUTOHEADER_VERSION} + ${i} --version </dev/null >/dev/null 2>&1 && XDT_PROG_AUTOHEADER=${i} test -z "${XDT_PROG_AUTOHEADER}" && { cat >&2 <<EOF @@ -482,9 +480,9 @@ xdt-autogen: You must have "autoconf" installed (which includes the ftp://ftp.gnu.org/pub/gnu/. EOF exit 1 - }; - break; - fi; + } + break + fi done @@ -493,8 +491,7 @@ done ## if test -z "${XDT_PROG_AUTOMAKE}"; then test -z "${AUTOMAKE_VERSION}" && i=automake || i=automake-${AUTOMAKE_VERSION} - (${i} --version) </dev/null >/dev/null 2>&1 && - XDT_PROG_AUTOMAKE=${i} + ${i} --version </dev/null >/dev/null 2>&1 && XDT_PROG_AUTOMAKE=${i} fi test -z "${XDT_PROG_AUTOMAKE}" && { @@ -511,7 +508,7 @@ EOF ## Check for configure flags ## test -z "${XDT_CONFIGURE_FLAGS}" && XDT_CONFIGURE_FLAGS="--enable-maintainer-mode" -CONFIGURE_FLAGS="${XDT_CONFIGURE_FLAGS} $@" +CONFIGURE_FLAGS="${XDT_CONFIGURE_FLAGS} $*" ## @@ -535,39 +532,42 @@ for configure_ac_file in ${CONFIGURE_AC_FILES}; do if test -d "${source_dir}/po"; then if test ! -f "${source_dir}/aclocal.m4"; then - (echo "Creating ${source_dir}/aclocal.m4..." && - echo "dnl Auto-generated by xdt-autogen" > "${source_dir}/aclocal.m4") || exit 1 + echo "Creating ${source_dir}/aclocal.m4..." \ + && echo "dnl Auto-generated by xdt-autogen" > "${source_dir}/aclocal.m4" \ + || exit 1 fi - (echo "Running ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy..." && - ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy) || exit 1 + echo "Running ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy..." \ + && ${XDT_PROG_GLIB_GETTEXTIZE} --force --copy \ + || exit 1 if test -f "${source_dir}/aclocal.m4" -a ! -w "${source_dir}/aclocal.m4"; then - (echo "Making ${source_dir}/aclocal.m4 writable..." && - chmod u+w "${source_dir}/aclocal.m4") || exit 1 + echo "Making ${source_dir}/aclocal.m4 writable..." \ + && chmod u+w "${source_dir}/aclocal.m4" \ + || exit 1 fi fi if $EGREP -q "^(AC|IT)_PROG_INTLTOOL" "${configure_ac_file}"; then - (echo "Running ${XDT_PROG_INTLTOOLIZE} --automake --copy --force" && - cd "${source_dir}" && - ${XDT_PROG_INTLTOOLIZE} --automake --copy --force) || exit 1 + ( echo "Running ${XDT_PROG_INTLTOOLIZE} --automake --copy --force" \ + && cd "${source_dir}" \ + && ${XDT_PROG_INTLTOOLIZE} --automake --copy --force ) || exit 1 fi # patch the po/Makefile.in.in to take into account the setting of # XGETTEXT_ARGS properly if test -f "${source_dir}/po/Makefile.in.in"; then - grep -q '^XGETTEXT_ARGS[ ]*=[ ]*@XGETTEXT_ARGS@$' \ - "${source_dir}/po/Makefile.in.in" 2> /dev/null - if test $? -ne 0; then + if ! grep -q '^XGETTEXT_ARGS[ ]*=[ ]*@XGETTEXT_ARGS@$' \ + "${source_dir}/po/Makefile.in.in" + then echo "Patching file 'po/Makefile.in.in'" - sed \ + if sed \ -e 's/^\(XGETTEXT[ ]*=[ ]*@XGETTEXT@\)[ ]*$/\1 $(XGETTEXT_ARGS)/' \ -e 's/^\(MSGMERGE[ ]*=\)[ ]*\(INTLTOOL_EXTRACT=\)/\1 XGETTEXT_ARGS="$(XGETTEXT_ARGS)" \2/' \ -e 's/^\(GENPOT[ ]*=\)[ ]*\(INTLTOOL_EXTRACT=\)/\1 XGETTEXT_ARGS="$(XGETTEXT_ARGS)" \2/' \ -e "/^XGETTEXT = @XGETTEXT@/{ i\\ XGETTEXT_ARGS = @XGETTEXT_ARGS@ -}" < "${source_dir}/po/Makefile.in.in" > "${source_dir}/po/Makefile.in.in.tmp" - if test $? -eq 0; then +}" "${source_dir}/po/Makefile.in.in" > "${source_dir}/po/Makefile.in.in.tmp" + then mv -f "${source_dir}/po/Makefile.in.in.tmp" \ "${source_dir}/po/Makefile.in.in" || exit 1 fi @@ -616,11 +616,11 @@ done ## ## Run configure ## -if test x"${NOCONFIGURE}" = x""; then - (echo "Running ${MASTER_DIR}/configure ${CONFIGURE_FLAGS}..." && - cd "${MASTER_DIR}" && - ./configure ${CONFIGURE_FLAGS} && - echo "Now type \"make\" to compile.") || exit 1 +if test -z "${NOCONFIGURE}"; then + ( echo "Running ${MASTER_DIR}/configure ${CONFIGURE_FLAGS}..." \ + && cd "${MASTER_DIR}" \ + && ./configure ${CONFIGURE_FLAGS} \ + && echo "Now type \"make\" to compile." ) || exit 1 else echo "Skipping configure process." fi |