Update the scripts from DeforaOS configure

This commit is contained in:
Pierre Pronchery 2020-01-12 09:53:17 +01:00
parent b41bf76bc6
commit b14346db41
5 changed files with 97 additions and 39 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2011-2019 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -25,8 +25,8 @@
#variables #variables
CONFIGSH="${0%/pkgconfig.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
DEBUG="_debug" DEBUG="_debug"
DEVNULL="/dev/null" DEVNULL="/dev/null"
PROGNAME="pkgconfig.sh" PROGNAME="pkgconfig.sh"
@ -35,6 +35,7 @@ INSTALL="install -m 0644"
MKDIR="mkdir -m 0755 -p" MKDIR="mkdir -m 0755 -p"
RM="rm -f" RM="rm -f"
SED="sed" SED="sed"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
@ -66,7 +67,7 @@ _usage()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciuO:P:" name; do
case $name in case $name in
c) c)
clean=1 clean=1
@ -79,6 +80,9 @@ while getopts "ciuP:" name; do
install=0 install=0
uninstall=1 uninstall=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
P) P)
PREFIX="$OPTARG" PREFIX="$OPTARG"
;; ;;
@ -89,7 +93,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 0 ]; then
_usage _usage
exit $? exit $?
fi fi
@ -103,6 +107,16 @@ if [ -z "$VERSION" ]; then
_error "The VERSION variable needs to be set" _error "The VERSION variable needs to be set"
exit $? exit $?
fi 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" PKGCONFIG="$PREFIX/lib/pkgconfig"
exec 3>&1 exec 3>&1
@ -136,10 +150,10 @@ while [ $# -gt 0 ]; do
if [ "$PREFIX" != "/usr" ]; then if [ "$PREFIX" != "/usr" ]; then
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}" RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
case $(uname -s) in case $(uname -s) in
Darwin) "Darwin")
RPATH="-Wl,-rpath,\${libdir}" RPATH="-Wl,-rpath,\${libdir}"
;; ;;
SunOS) "SunOS")
RPATH="-Wl,-R\${libdir}" RPATH="-Wl,-R\${libdir}"
;; ;;
esac esac
@ -148,10 +162,19 @@ while [ $# -gt 0 ]; do
#create #create
source="${target#$OBJDIR}" source="${target#$OBJDIR}"
source="${source}.in" source="${source}.in"
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \ ([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") || exit 2
-e "s;@VERSION@;$VERSION;" \ $DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \
-e "s;@PREFIX@;$PREFIX;" \ -e "s;@VERSION@;$VERSION;g" \
-e "s;@RPATH@;$RPATH;" \ -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" -- "$source" > "$target"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
$DEBUG $RM -- "$target" $DEBUG $RM -- "$target"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2012-2017 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -114,7 +114,7 @@ _usage()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -123,6 +123,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -137,7 +140,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi
@ -167,7 +170,7 @@ while [ $# -gt 0 ]; do
xpath="string(/refentry/refmeta/manvolnum)" xpath="string(/refentry/refmeta/manvolnum)"
section=$($XMLLINT --xpath "$xpath" "$source") section=$($XMLLINT --xpath "$xpath" "$source")
if [ $? -eq 0 -a -n "$section" ]; then if [ $? -eq 0 -a -n "$section" ]; then
instdir="$DATADIR/man/html$section" instdir="$MANDIR/html$section"
fi fi
;; ;;
pdf) pdf)

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2012-2017 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -72,7 +72,7 @@ _usage()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -81,6 +81,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -95,7 +98,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2010-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2010-2017 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -112,7 +112,7 @@ _gettext_pot()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -121,6 +121,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -135,7 +138,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2017 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2017-2019 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -32,6 +32,7 @@ DATE="date"
DEBUG="_debug" DEBUG="_debug"
FIND="find" FIND="find"
GREP="grep" GREP="grep"
MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
@ -40,7 +41,7 @@ TR="tr"
#fixme #fixme
_fixme() _fixme()
{ {
ret=0 res=0
$DATE $DATE
echo echo
@ -59,55 +60,61 @@ _fixme()
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do for filename in $($FIND "../$subdir" -type f | $SORT); do
callback= callback=
case "$filename" in ext=${filename##*/}
*.asm|*.S) ext=${ext%.in}
ext=${ext##*.}
case "$ext" in
asm|S)
callback="_fixme_asm" callback="_fixme_asm"
;; ;;
*.c|*.h|*.js) c|cc|cpp|cxx|h|js)
callback="_fixme_c" callback="_fixme_c"
;; ;;
*.conf|*.sh) conf|sh)
callback="_fixme_sh" callback="_fixme_sh"
;; ;;
htm|html|xml)
callback="_fixme_xml"
;;
esac esac
[ -n "$callback" ] || continue [ -n "$callback" ] || continue
$callback "$filename" 2>&1 ($callback "$filename") 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$PROGNAME: $filename: FAIL" 1>&2 echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2 res=2
fi fi
done done
done done
return $ret return $res
} }
_fixme_asm() _fixme_asm()
{ {
retc=0 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\*.*\(TODO\|XXX\)' "$filename" $GREP -nH '/\*.*\(TODO\|XXX\)' "$filename"
#failures #failures
$GREP -nH '/\*.*FIXME' "$filename" && retc=2 $GREP -nH '/\*.*FIXME' "$filename" && res=2
return $retc return $res
} }
_fixme_c() _fixme_c()
{ {
retc=0 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename" $GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename"
#failures #failures
$GREP -nH '/\(/\|\*\).*FIXME' "$filename" && retc=2 $GREP -nH '/\(/\|\*\).*FIXME' "$filename" && res=2
return $retc return $res
} }
_fixme_sh() _fixme_sh()
{ {
retsh=0 res=0
filename="$1" filename="$1"
#XXX avoid matching the regexp #XXX avoid matching the regexp
comment="#" comment="#"
@ -115,8 +122,21 @@ _fixme_sh()
#warnings #warnings
$GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename" $GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename"
#failures #failures
$GREP -nH "$comment.*FIXME" "$filename" && retsh=2 $GREP -nH "$comment.*FIXME" "$filename" && res=2
return $retsh return $res
}
_fixme_xml()
{
res=0
filename="$1"
#XXX limited to a single line
#warnings
$GREP -nH '<!--.*\(TODO\|XXX\)' "$filename"
#failures
$GREP -nH '<!--.*FIXME' "$filename" && res=2
return $res
} }
@ -169,9 +189,15 @@ fi
[ $clean -ne 0 ] && exit 0 [ $clean -ne 0 ] && exit 0
exec 3>&1 exec 3>&1
ret=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
dirname="${target%/*}"
shift shift
_fixme > "$target" || exit 2 if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_fixme > "$target" || ret=$?
done done
exit $ret