Import the latest scripts from DeforaOS configure

This commit is contained in:
Pierre Pronchery 2019-12-18 05:15:03 +01:00
parent 8acda27d28
commit 32dad51dcc
6 changed files with 80 additions and 35 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2011-2017 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
#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
@ -106,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
@ -139,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
@ -152,10 +163,18 @@ while [ $# -gt 0 ]; do
source="${target#$OBJDIR}"
source="${source}.in"
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") || exit 2
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \
-e "s;@VERSION@;$VERSION;" \
-e "s;@PREFIX@;$PREFIX;" \
-e "s;@RPATH@;$RPATH;" \
$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"

View File

@ -170,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)

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$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
#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 '<!--.*\(TODO\|XXX\)' "$filename"
#failures
$GREP -nH '<!--.*FIXME' "$filename" && res=2
return $res
}
@ -169,9 +189,15 @@ fi
[ $clean -ne 0 ] && exit 0
exec 3>&1
ret=0
while [ $# -gt 0 ]; do
target="$1"
dirname="${target%/*}"
shift
_fixme > "$target" || exit 2
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_fixme > "$target" || ret=$?
done
exit $ret

View File

@ -32,7 +32,7 @@ PROJECTCONF="../project.conf"
DATE="date"
DEBUG="_debug"
FIND="find"
HTMLLINT="xmllint --html"
HTMLLINT="xmllint --html --nonet"
SORT="sort -n"
TR="tr"
@ -58,7 +58,7 @@ _htmllint()
done < "$PROJECTCONF"
for subdir in $subdirs; do
[ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -iname '*.html' -o -iname '*.htm' | $SORT); do
for filename in $($FIND "../$subdir" -type f -a \( -iname '*.html' -o -iname '*.htm' \) | $SORT); do
$DEBUG $HTMLLINT "$filename" 2>&1 > "$DEVNULL"
if [ $? -eq 0 ]; then
echo "$filename:"

View File

@ -34,7 +34,7 @@ DEBUG="_debug"
FIND="find"
SORT="sort -n"
TR="tr"
XMLLINT="xmllint"
XMLLINT="xmllint --nonet"
#functions
@ -58,7 +58,7 @@ _xmllint()
done < "$PROJECTCONF"
for subdir in $subdirs; do
[ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -name '*.xml' -o -name '*.xsl' | $SORT); do
for filename in $($FIND "../$subdir" -type f -a \( -name '*.xml' -o -name '*.xsl' \) | $SORT); do
$DEBUG $XMLLINT "$filename" 2>&1 > "$DEVNULL"
if [ $? -eq 0 ]; then
echo "$filename:"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2012-2017 Pierre Pronchery <khorben@defora.org>
#Copyright (c) 2012-2019 Pierre Pronchery <khorben@defora.org>
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
@ -36,7 +36,6 @@ LIBEXECDIR=
MANDIR=
PROGNAME="subst.sh"
SYSCONFDIR=
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#executables
CHMOD="chmod"
DATE="date"
@ -46,6 +45,7 @@ INSTALL="install"
MKDIR="mkdir -m 0755 -p"
RM="rm -f"
SED="sed"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions
@ -125,8 +125,8 @@ _subst()
-e "s;@LIBDIR@;$LIBDIR;g" \
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
-e "s;@MANDIR@;$MANDIR;g" \
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
-e "s;@PWD@;$PWD;g" \
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
-- "$source" > "$target"
if [ $? -ne 0 ]; then
$RM -- "$target" 2> "$DEVNULL"