Added support for OBJDIR (but does not pass "make distcheck")

This commit is contained in:
Pierre Pronchery 2014-11-03 23:09:08 +01:00
parent 0a02a37fff
commit 6ff4d2ec78
3 changed files with 38 additions and 14 deletions

View File

@ -3,7 +3,8 @@ VERSION = 0.0.0
SUBDIRS = doc
RM = rm -f
LN = ln -f
TAR = tar -czvf
TAR = tar
MKDIR = mkdir -m 0755 -p
all: subdirs
@ -20,7 +21,7 @@ distclean:
dist:
$(RM) -r -- $(PACKAGE)-$(VERSION)
$(LN) -s -- . $(PACKAGE)-$(VERSION)
@$(TAR) $(PACKAGE)-$(VERSION).tar.gz -- \
@$(TAR) -czvf $(PACKAGE)-$(VERSION).tar.gz -- \
$(PACKAGE)-$(VERSION)/doc/Makefile \
$(PACKAGE)-$(VERSION)/doc/docbook.sh \
$(PACKAGE)-$(VERSION)/doc/manual/manual.xml \
@ -31,10 +32,21 @@ dist:
$(PACKAGE)-$(VERSION)/project.conf
$(RM) -- $(PACKAGE)-$(VERSION)
distcheck: dist
$(TAR) -xzvf $(PACKAGE)-$(VERSION).tar.gz
$(MKDIR) -- $(PACKAGE)-$(VERSION)/objdir
$(MKDIR) -- $(PACKAGE)-$(VERSION)/destdir
(cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/")
(cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" DESTDIR="$$PWD/destdir" install)
(cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" DESTDIR="$$PWD/destdir" uninstall)
(cd "$(PACKAGE)-$(VERSION)" && $(MAKE) OBJDIR="$$PWD/objdir/" distclean)
(cd "$(PACKAGE)-$(VERSION)" && $(MAKE) dist)
$(RM) -r -- $(PACKAGE)-$(VERSION)
install:
@for i in $(SUBDIRS); do (cd "$$i" && $(MAKE) install) || exit; done
uninstall:
@for i in $(SUBDIRS); do (cd "$$i" && $(MAKE) uninstall) || exit; done
.PHONY: all subdirs clean distclean dist install uninstall
.PHONY: all subdirs clean distclean dist distcheck install uninstall

View File

@ -1,4 +1,5 @@
TARGETS = manual/manual.html
TARGETS = $(OBJDIR)manual/manual.html
OBJDIR =
PREFIX = /usr/local
DESTDIR =
RM = rm -f
@ -9,8 +10,8 @@ INSTALL = install
all: $(TARGETS)
manual/manual.html: manual/manual.xml manual/manual.xsl ../config.sh
./docbook.sh -P "$(PREFIX)" -- "manual/manual.html"
$(OBJDIR)manual/manual.html: manual/manual.xml manual/manual.xsl ../config.sh
./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)manual/manual.html"
clean:
$(RM) -- $(manual/manual.html_OBJS)

View File

@ -27,6 +27,7 @@
#variables
PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
PROGNAME="docbook.sh"
#executables
DEBUG="_debug"
FOP="fop"
@ -52,17 +53,24 @@ _docbook()
target="$1"
source="${target%.*}.xml"
[ -f "$source" ] || source="${source#$OBJDIR}"
ext="${target##*.}"
ext="${ext##.}"
case "$ext" in
html)
XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
[ -f "${target%.*}.css.xml" ] && XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
if [ -f "${target%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
elif [ -f "${source%.*}.css.xml" ]; then
XSLTPROC="$XSLTPROC --param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
fi
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
;;
pdf)
XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
$DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" &&
$DEBUG $FOP -fo "${target%.*}.fo" -pdf "$target"
@ -73,13 +81,13 @@ _docbook()
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
;;
*)
echo "$0: $target: Unknown type" 1>&2
_error "$target: Unknown type"
return 2
;;
esac
if [ $? -ne 0 ]; then
echo "$0: $target: Could not create page" 1>&2
_error "$target: Could not create page"
$RM -- "$target"
return 2
fi
@ -89,7 +97,7 @@ _docbook()
#error
_error()
{
echo "docbook.sh: $@" 1>&2
echo "$PROGNAME: $@" 1>&2
return 2
}
@ -97,7 +105,7 @@ _error()
#usage
_usage()
{
echo "Usage: docbook.sh [-c|-i|-u][-P prefix] target..." 1>&2
echo "Usage: $PROGNAME [-c|-i|-u][-P prefix] target..." 1>&2
return 1
}
@ -153,7 +161,8 @@ while [ $# -gt 0 ]; do
case "$ext" in
html)
instdir="$DATADIR/doc/$ext/$PACKAGE"
source="${target%.*}.xml"
source="${target#$OBJDIR}"
source="${source%.*}.xml"
xpath="string(/refentry/refmeta/manvolnum)"
section=$($XMLLINT --xpath "$xpath" "$source")
if [ $? -eq 0 -a -n "$section" ]; then
@ -167,7 +176,7 @@ while [ $# -gt 0 ]; do
instdir="$MANDIR/man$ext"
;;
*)
echo "$0: $target: Unknown type" 1>&2
_error "$target: Unknown type"
exit 2
;;
esac
@ -177,14 +186,16 @@ while [ $# -gt 0 ]; do
#uninstall
if [ "$uninstall" -eq 1 ]; then
target="${target#$OBJDIR}"
$DEBUG $RM -- "$instdir/$target" || exit 2
continue
fi
#install
if [ "$install" -eq 1 ]; then
source="${target#$OBJDIR}"
$DEBUG $MKDIR -- "$instdir" || exit 2
$DEBUG $INSTALL "$target" "$instdir/$target" || exit 2
$DEBUG $INSTALL "$target" "$instdir/$source" || exit 2
continue
fi