From b14346db41d0cebfe5281ba9e4f1bf1451d206e0 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 12 Jan 2020 09:53:17 +0100 Subject: [PATCH] Update the scripts from DeforaOS configure --- data/pkgconfig.sh | 43 +++++++++++++++++++++++-------- doc/docbook.sh | 11 +++++--- doc/gtkdoc.sh | 9 ++++--- po/gettext.sh | 9 ++++--- tests/fixme.sh | 64 +++++++++++++++++++++++++++++++++-------------- 5 files changed, 97 insertions(+), 39 deletions(-) diff --git a/data/pkgconfig.sh b/data/pkgconfig.sh index 83479f5..0dba39f 100755 --- a/data/pkgconfig.sh +++ b/data/pkgconfig.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2011-2015 Pierre Pronchery +#Copyright (c) 2011-2019 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -25,8 +25,8 @@ #variables +CONFIGSH="${0%/pkgconfig.sh}/../config.sh" PREFIX="/usr/local" -[ -f "../config.sh" ] && . "../config.sh" DEBUG="_debug" DEVNULL="/dev/null" PROGNAME="pkgconfig.sh" @@ -35,6 +35,7 @@ INSTALL="install -m 0644" MKDIR="mkdir -m 0755 -p" RM="rm -f" SED="sed" +[ -f "$CONFIGSH" ] && . "$CONFIGSH" #functions @@ -66,7 +67,7 @@ _usage() clean=0 install=0 uninstall=0 -while getopts "ciuP:" name; do +while getopts "ciuO:P:" name; do case $name in c) clean=1 @@ -79,6 +80,9 @@ while getopts "ciuP:" name; do install=0 uninstall=1 ;; + O) + export "${OPTARG%%=*}"="${OPTARG#*=}" + ;; P) PREFIX="$OPTARG" ;; @@ -89,7 +93,7 @@ while getopts "ciuP:" name; do esac done shift $(($OPTIND - 1)) -if [ $# -eq 0 ]; then +if [ $# -lt 0 ]; then _usage exit $? fi @@ -103,6 +107,16 @@ if [ -z "$VERSION" ]; then _error "The VERSION variable needs to be set" exit $? fi +[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin" +[ -z "$DATADIR" ] && DATADIR="$PREFIX/share" +[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include" +[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib" +[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec" +[ -z "$MANDIR" ] && MANDIR="$DATADIR/man" +if [ -z "$SYSCONFDIR" ]; then + SYSCONFDIR="$PREFIX/etc" + [ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc" +fi PKGCONFIG="$PREFIX/lib/pkgconfig" exec 3>&1 @@ -136,10 +150,10 @@ while [ $# -gt 0 ]; do if [ "$PREFIX" != "/usr" ]; then RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}" case $(uname -s) in - Darwin) + "Darwin") RPATH="-Wl,-rpath,\${libdir}" ;; - SunOS) + "SunOS") RPATH="-Wl,-R\${libdir}" ;; esac @@ -148,10 +162,19 @@ while [ $# -gt 0 ]; do #create source="${target#$OBJDIR}" source="${source}.in" - $DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \ - -e "s;@VERSION@;$VERSION;" \ - -e "s;@PREFIX@;$PREFIX;" \ - -e "s;@RPATH@;$RPATH;" \ + ([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") || exit 2 + $DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \ + -e "s;@VERSION@;$VERSION;g" \ + -e "s;@PREFIX@;$PREFIX;g" \ + -e "s;@BINDIR@;$BINDIR;g" \ + -e "s;@DATADIR@;$DATADIR;g" \ + -e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \ + -e "s;@LIBDIR@;$LIBDIR;g" \ + -e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \ + -e "s;@MANDIR@;$MANDIR;g" \ + -e "s;@PWD@;$PWD;g" \ + -e "s;@RPATH@;$RPATH;g" \ + -e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \ -- "$source" > "$target" if [ $? -ne 0 ]; then $DEBUG $RM -- "$target" diff --git a/doc/docbook.sh b/doc/docbook.sh index 620374f..b247959 100755 --- a/doc/docbook.sh +++ b/doc/docbook.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2012-2015 Pierre Pronchery +#Copyright (c) 2012-2017 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -114,7 +114,7 @@ _usage() clean=0 install=0 uninstall=0 -while getopts "ciuP:" name; do +while getopts "ciO:uP:" name; do case "$name" in c) clean=1 @@ -123,6 +123,9 @@ while getopts "ciuP:" name; do uninstall=0 install=1 ;; + O) + export "${OPTARG%%=*}"="${OPTARG#*=}" + ;; u) install=0 uninstall=1 @@ -137,7 +140,7 @@ while getopts "ciuP:" name; do esac done shift $((OPTIND - 1)) -if [ $# -eq 0 ]; then +if [ $# -lt 1 ]; then _usage exit $? fi @@ -167,7 +170,7 @@ while [ $# -gt 0 ]; do xpath="string(/refentry/refmeta/manvolnum)" section=$($XMLLINT --xpath "$xpath" "$source") if [ $? -eq 0 -a -n "$section" ]; then - instdir="$DATADIR/man/html$section" + instdir="$MANDIR/html$section" fi ;; pdf) diff --git a/doc/gtkdoc.sh b/doc/gtkdoc.sh index b32791c..776e280 100755 --- a/doc/gtkdoc.sh +++ b/doc/gtkdoc.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2012-2015 Pierre Pronchery +#Copyright (c) 2012-2017 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -72,7 +72,7 @@ _usage() clean=0 install=0 uninstall=0 -while getopts "ciuP:" name; do +while getopts "ciO:uP:" name; do case "$name" in c) clean=1 @@ -81,6 +81,9 @@ while getopts "ciuP:" name; do uninstall=0 install=1 ;; + O) + export "${OPTARG%%=*}"="${OPTARG#*=}" + ;; u) install=0 uninstall=1 @@ -95,7 +98,7 @@ while getopts "ciuP:" name; do esac done shift $((OPTIND - 1)) -if [ $# -eq 0 ]; then +if [ $# -lt 1 ]; then _usage exit $? fi diff --git a/po/gettext.sh b/po/gettext.sh index 5bb7c9b..5f07dc2 100755 --- a/po/gettext.sh +++ b/po/gettext.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2010-2015 Pierre Pronchery +#Copyright (c) 2010-2017 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -112,7 +112,7 @@ _gettext_pot() clean=0 install=0 uninstall=0 -while getopts "ciuP:" name; do +while getopts "ciO:uP:" name; do case "$name" in c) clean=1 @@ -121,6 +121,9 @@ while getopts "ciuP:" name; do uninstall=0 install=1 ;; + O) + export "${OPTARG%%=*}"="${OPTARG#*=}" + ;; u) install=0 uninstall=1 @@ -135,7 +138,7 @@ while getopts "ciuP:" name; do esac done shift $(($OPTIND - 1)) -if [ $# -eq 0 ]; then +if [ $# -lt 1 ]; then _usage exit $? fi diff --git a/tests/fixme.sh b/tests/fixme.sh index b006fd0..f4c921c 100755 --- a/tests/fixme.sh +++ b/tests/fixme.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2017 Pierre Pronchery +#Copyright (c) 2017-2019 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -32,6 +32,7 @@ DATE="date" DEBUG="_debug" FIND="find" GREP="grep" +MKDIR="mkdir -p" SORT="sort -n" TR="tr" @@ -40,7 +41,7 @@ TR="tr" #fixme _fixme() { - ret=0 + res=0 $DATE echo @@ -59,55 +60,61 @@ _fixme() [ -d "../$subdir" ] || continue for filename in $($FIND "../$subdir" -type f | $SORT); do callback= - case "$filename" in - *.asm|*.S) + ext=${filename##*/} + ext=${ext%.in} + ext=${ext##*.} + case "$ext" in + asm|S) callback="_fixme_asm" ;; - *.c|*.h|*.js) + c|cc|cpp|cxx|h|js) callback="_fixme_c" ;; - *.conf|*.sh) + conf|sh) callback="_fixme_sh" ;; + htm|html|xml) + callback="_fixme_xml" + ;; esac [ -n "$callback" ] || continue - $callback "$filename" 2>&1 + ($callback "$filename") 2>&1 if [ $? -ne 0 ]; then echo "$PROGNAME: $filename: FAIL" 1>&2 - ret=2 + res=2 fi done done - return $ret + return $res } _fixme_asm() { - retc=0 + res=0 filename="$1" #warnings $GREP -nH '/\*.*\(TODO\|XXX\)' "$filename" #failures - $GREP -nH '/\*.*FIXME' "$filename" && retc=2 - return $retc + $GREP -nH '/\*.*FIXME' "$filename" && res=2 + return $res } _fixme_c() { - retc=0 + res=0 filename="$1" #warnings $GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename" #failures - $GREP -nH '/\(/\|\*\).*FIXME' "$filename" && retc=2 - return $retc + $GREP -nH '/\(/\|\*\).*FIXME' "$filename" && res=2 + return $res } _fixme_sh() { - retsh=0 + res=0 filename="$1" #XXX avoid matching the regexp comment="#" @@ -115,8 +122,21 @@ _fixme_sh() #warnings $GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename" #failures - $GREP -nH "$comment.*FIXME" "$filename" && retsh=2 - return $retsh + $GREP -nH "$comment.*FIXME" "$filename" && res=2 + return $res +} + +_fixme_xml() +{ + res=0 + filename="$1" + + #XXX limited to a single line + #warnings + $GREP -nH '