Added support for building with OBJDIR

This commit is contained in:
Pierre Pronchery 2014-11-04 00:23:36 +01:00
parent 5beba30df1
commit b9e93428b1
8 changed files with 97 additions and 44 deletions

View File

@ -3,7 +3,8 @@ VERSION = 0.0.0
SUBDIRS = data doc po src SUBDIRS = data doc po src
RM = rm -f RM = rm -f
LN = ln -f LN = ln -f
TAR = tar -czvf TAR = tar
MKDIR = mkdir -m 0755 -p
all: subdirs all: subdirs
@ -20,7 +21,7 @@ distclean:
dist: dist:
$(RM) -r -- $(PACKAGE)-$(VERSION) $(RM) -r -- $(PACKAGE)-$(VERSION)
$(LN) -s -- . $(PACKAGE)-$(VERSION) $(LN) -s -- . $(PACKAGE)-$(VERSION)
@$(TAR) $(PACKAGE)-$(VERSION).tar.gz -- \ @$(TAR) -czvf $(PACKAGE)-$(VERSION).tar.gz -- \
$(PACKAGE)-$(VERSION)/data/Makefile \ $(PACKAGE)-$(VERSION)/data/Makefile \
$(PACKAGE)-$(VERSION)/data/deforaos-installer.desktop \ $(PACKAGE)-$(VERSION)/data/deforaos-installer.desktop \
$(PACKAGE)-$(VERSION)/data/project.conf \ $(PACKAGE)-$(VERSION)/data/project.conf \
@ -46,10 +47,21 @@ dist:
$(PACKAGE)-$(VERSION)/project.conf $(PACKAGE)-$(VERSION)/project.conf
$(RM) -- $(PACKAGE)-$(VERSION) $(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: install:
@for i in $(SUBDIRS); do (cd "$$i" && $(MAKE) install) || exit; done @for i in $(SUBDIRS); do (cd "$$i" && $(MAKE) install) || exit; done
uninstall: uninstall:
@for i in $(SUBDIRS); do (cd "$$i" && $(MAKE) uninstall) || exit; done @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,3 +1,4 @@
OBJDIR =
PREFIX = /usr/local PREFIX = /usr/local
DESTDIR = DESTDIR =
MKDIR = mkdir -m 0755 -p MKDIR = mkdir -m 0755 -p

View File

@ -1,4 +1,5 @@
TARGETS = installer.1 installer.html TARGETS = $(OBJDIR)installer.1 $(OBJDIR)installer.html
OBJDIR =
PREFIX = /usr/local PREFIX = /usr/local
DESTDIR = DESTDIR =
RM = rm -f RM = rm -f
@ -9,11 +10,11 @@ INSTALL = install
all: $(TARGETS) all: $(TARGETS)
installer.1: installer.xml $(OBJDIR)installer.1: installer.xml
./docbook.sh -P "$(PREFIX)" -- "installer.1" ./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)installer.1"
installer.html: installer.css.xml installer.xml manual.css.xml $(OBJDIR)installer.html: installer.css.xml installer.xml manual.css.xml
./docbook.sh -P "$(PREFIX)" -- "installer.html" ./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)installer.html"
clean: clean:
$(RM) -- $(installer.1_OBJS) $(installer.html_OBJS) $(RM) -- $(installer.1_OBJS) $(installer.html_OBJS)
@ -24,8 +25,8 @@ distclean: clean
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: $(TARGETS) install: $(TARGETS)
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "installer.1" ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)installer.1"
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "installer.html" ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)installer.html"
uninstall: uninstall:
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "installer.1" ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "installer.1"

View File

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

View File

@ -1,4 +1,5 @@
TARGETS = Installer.pot fr.mo TARGETS = $(OBJDIR)Installer.pot $(OBJDIR)fr.mo
OBJDIR =
PREFIX = /usr/local PREFIX = /usr/local
DESTDIR = DESTDIR =
RM = rm -f RM = rm -f
@ -9,11 +10,11 @@ INSTALL = install
all: $(TARGETS) all: $(TARGETS)
Installer.pot: POTFILES $(OBJDIR)Installer.pot: POTFILES
./gettext.sh -P "$(PREFIX)" -- "Installer.pot" ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)Installer.pot"
fr.mo: Installer.pot fr.po $(OBJDIR)fr.mo: $(OBJDIR)Installer.pot fr.po
./gettext.sh -P "$(PREFIX)" -- "fr.mo" ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)fr.mo"
clean: clean:
$(RM) -- $(Installer.pot_OBJS) $(fr.mo_OBJS) $(RM) -- $(Installer.pot_OBJS) $(fr.mo_OBJS)
@ -24,7 +25,7 @@ distclean: clean
$(RM) -- $(TARGETS) $(RM) -- $(TARGETS)
install: $(TARGETS) install: $(TARGETS)
./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo" ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)fr.mo"
uninstall: uninstall:
./gettext.sh -P "$(DESTDIR)$(PREFIX)" -u -- "fr.mo" ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -u -- "fr.mo"

View File

@ -70,9 +70,12 @@ _gettext_mo()
{ {
package="$1" package="$1"
lang="$2" lang="$2"
potfile="$3"
pofile="$4"
mofile="$5"
_gettext_po "$package" "$lang" || return 1 _gettext_po "$package" "$lang" "$potfile" "$pofile" || return 1
$DEBUG $MSGFMT -c -v -o "$lang.mo" "$lang.po" || return 1 $DEBUG $MSGFMT -c -v -o "$mofile" "$pofile" || return 1
} }
@ -81,11 +84,13 @@ _gettext_po()
{ {
package="$1" package="$1"
lang="$2" lang="$2"
potfile="$3"
pofile="$4"
if [ -f "$lang.po" ]; then if [ -f "$pofile" ]; then
$DEBUG $MSGMERGE -U "$lang.po" "$package.pot" || return 1 $DEBUG $MSGMERGE -U "$pofile" "$potfile" || return 1
else else
$DEBUG $MSGINIT -l "$lang" -o "$lang.po" -i "$package.pot" \ $DEBUG $MSGINIT -l "$lang" -o "$pofile" -i "$potfile" \
|| return 1 || return 1
fi fi
} }
@ -95,8 +100,9 @@ _gettext_po()
_gettext_pot() _gettext_pot()
{ {
package="$1" package="$1"
potfile="$2"
$DEBUG $XGETTEXT -d "$package" -o "$package.pot" --keyword="_" \ $DEBUG $XGETTEXT -d "$package" -o "$potfile" --keyword="_" \
--keyword="N_" -f "$POTFILES" || return 1 --keyword="N_" -f "$POTFILES" || return 1
} }
@ -142,7 +148,8 @@ fi
LOCALEDIR="$PREFIX/share/locale" LOCALEDIR="$PREFIX/share/locale"
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
lang="${target%%.mo}" source="${target#$OBJDIR}"
lang="${source%%.mo}"
lang="${lang%%.po}" lang="${lang%%.po}"
shift shift
@ -168,13 +175,32 @@ while [ $# -gt 0 ]; do
#create #create
case "$target" in case "$target" in
*.mo) *.mo)
_gettext_mo "$PACKAGE" "$lang" || exit 2 #XXX may not match
if [ -n "$OBJDIR" ]; then
potfile="$OBJDIR/$PACKAGE.pot"
else
potfile="$PACKAGE.pot"
fi
mofile="$target"
pofile="${source%%.mo}.po"
_gettext_mo "$PACKAGE" "$lang" "$potfile" "$pofile" \
"$mofile" || exit 2
;; ;;
*.po) *.po)
_gettext_po "$PACKAGE" "$lang" || exit 2 #XXX may not match
if [ -n "$OBJDIR" ]; then
potfile="$OBJDIR/$PACKAGE.pot"
else
potfile="$PACKAGE.pot"
fi
pofile="$target"
_gettext_po "$PACKAGE" "$lang" "$potfile" "$pofile" \
|| exit 2
;; ;;
*.pot) *.pot)
_gettext_pot "${target%%.pot}" || exit 2 package="${source%%.pot}"
potfile="$target"
_gettext_pot "$package" "$potfile" || exit 2
;; ;;
*) *)
exit 2 exit 2

View File

@ -10,4 +10,4 @@ depends=POTFILES
type=script type=script
script=./gettext.sh script=./gettext.sh
install= install=
depends=Installer.pot,fr.po depends=$(OBJDIR)Installer.pot,fr.po

View File

@ -1,4 +1,5 @@
TARGETS = installer TARGETS = $(OBJDIR)installer
OBJDIR =
PREFIX = /usr/local PREFIX = /usr/local
DESTDIR = DESTDIR =
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
@ -17,18 +18,18 @@ INSTALL = install
all: $(TARGETS) all: $(TARGETS)
installer_OBJS = installer.o main.o installer_OBJS = $(OBJDIR)installer.o $(OBJDIR)main.o
installer_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) installer_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
installer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) installer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
installer: $(installer_OBJS) $(OBJDIR)installer: $(installer_OBJS)
$(CC) -o installer $(installer_OBJS) $(installer_LDFLAGS) $(CC) -o $(OBJDIR)installer $(installer_OBJS) $(installer_LDFLAGS)
installer.o: installer.c installer.h ../config.h $(OBJDIR)installer.o: installer.c installer.h ../config.h
$(CC) -D PREFIX=\"$(PREFIX)\" $(installer_CFLAGS) -c installer.c $(CC) -D PREFIX=\"$(PREFIX)\" $(installer_CFLAGS) -o $(OBJDIR)installer.o -c installer.c
main.o: main.c installer.h ../config.h $(OBJDIR)main.o: main.c installer.h ../config.h
$(CC) $(installer_CFLAGS) -c main.c $(CC) $(installer_CFLAGS) -o $(OBJDIR)main.o -c main.c
clean: clean:
$(RM) -- $(installer_OBJS) $(RM) -- $(installer_OBJS)
@ -38,7 +39,7 @@ distclean: clean
install: $(TARGETS) install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(BINDIR) $(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 installer $(DESTDIR)$(BINDIR)/installer $(INSTALL) -m 0755 $(OBJDIR)installer $(DESTDIR)$(BINDIR)/installer
uninstall: uninstall:
$(RM) -- $(DESTDIR)$(BINDIR)/installer $(RM) -- $(DESTDIR)$(BINDIR)/installer