diff --git a/Makefile b/Makefile index 85d84e9..b4e7dbf 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ VERSION = 0.0.0 SUBDIRS = data doc po src 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)/data/Makefile \ $(PACKAGE)-$(VERSION)/data/deforaos-installer.desktop \ $(PACKAGE)-$(VERSION)/data/project.conf \ @@ -46,10 +47,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 diff --git a/data/Makefile b/data/Makefile index 9c879fe..d561a66 100644 --- a/data/Makefile +++ b/data/Makefile @@ -1,3 +1,4 @@ +OBJDIR = PREFIX = /usr/local DESTDIR = MKDIR = mkdir -m 0755 -p diff --git a/doc/Makefile b/doc/Makefile index 39f5eb4..a5983a4 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,4 +1,5 @@ -TARGETS = installer.1 installer.html +TARGETS = $(OBJDIR)installer.1 $(OBJDIR)installer.html +OBJDIR = PREFIX = /usr/local DESTDIR = RM = rm -f @@ -9,11 +10,11 @@ INSTALL = install all: $(TARGETS) -installer.1: installer.xml - ./docbook.sh -P "$(PREFIX)" -- "installer.1" +$(OBJDIR)installer.1: installer.xml + ./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)installer.1" -installer.html: installer.css.xml installer.xml manual.css.xml - ./docbook.sh -P "$(PREFIX)" -- "installer.html" +$(OBJDIR)installer.html: installer.css.xml installer.xml manual.css.xml + ./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)installer.html" clean: $(RM) -- $(installer.1_OBJS) $(installer.html_OBJS) @@ -24,8 +25,8 @@ distclean: clean $(RM) -- $(TARGETS) install: $(TARGETS) - ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "installer.1" - ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "installer.html" + ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)installer.1" + ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)installer.html" uninstall: ./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "installer.1" diff --git a/doc/docbook.sh b/doc/docbook.sh index 0caaa39..fda4e2d 100755 --- a/doc/docbook.sh +++ b/doc/docbook.sh @@ -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 diff --git a/po/Makefile b/po/Makefile index 035f384..ff057bb 100644 --- a/po/Makefile +++ b/po/Makefile @@ -1,4 +1,5 @@ -TARGETS = Installer.pot fr.mo +TARGETS = $(OBJDIR)Installer.pot $(OBJDIR)fr.mo +OBJDIR = PREFIX = /usr/local DESTDIR = RM = rm -f @@ -9,11 +10,11 @@ INSTALL = install all: $(TARGETS) -Installer.pot: POTFILES - ./gettext.sh -P "$(PREFIX)" -- "Installer.pot" +$(OBJDIR)Installer.pot: POTFILES + ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)Installer.pot" -fr.mo: Installer.pot fr.po - ./gettext.sh -P "$(PREFIX)" -- "fr.mo" +$(OBJDIR)fr.mo: $(OBJDIR)Installer.pot fr.po + ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)fr.mo" clean: $(RM) -- $(Installer.pot_OBJS) $(fr.mo_OBJS) @@ -24,7 +25,7 @@ distclean: clean $(RM) -- $(TARGETS) install: $(TARGETS) - ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo" + ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)fr.mo" uninstall: ./gettext.sh -P "$(DESTDIR)$(PREFIX)" -u -- "fr.mo" diff --git a/po/gettext.sh b/po/gettext.sh index 11a8805..c3ae919 100755 --- a/po/gettext.sh +++ b/po/gettext.sh @@ -70,9 +70,12 @@ _gettext_mo() { package="$1" lang="$2" + potfile="$3" + pofile="$4" + mofile="$5" - _gettext_po "$package" "$lang" || return 1 - $DEBUG $MSGFMT -c -v -o "$lang.mo" "$lang.po" || return 1 + _gettext_po "$package" "$lang" "$potfile" "$pofile" || return 1 + $DEBUG $MSGFMT -c -v -o "$mofile" "$pofile" || return 1 } @@ -81,11 +84,13 @@ _gettext_po() { package="$1" lang="$2" + potfile="$3" + pofile="$4" - if [ -f "$lang.po" ]; then - $DEBUG $MSGMERGE -U "$lang.po" "$package.pot" || return 1 + if [ -f "$pofile" ]; then + $DEBUG $MSGMERGE -U "$pofile" "$potfile" || return 1 else - $DEBUG $MSGINIT -l "$lang" -o "$lang.po" -i "$package.pot" \ + $DEBUG $MSGINIT -l "$lang" -o "$pofile" -i "$potfile" \ || return 1 fi } @@ -95,8 +100,9 @@ _gettext_po() _gettext_pot() { 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 } @@ -142,7 +148,8 @@ fi LOCALEDIR="$PREFIX/share/locale" while [ $# -gt 0 ]; do target="$1" - lang="${target%%.mo}" + source="${target#$OBJDIR}" + lang="${source%%.mo}" lang="${lang%%.po}" shift @@ -168,13 +175,32 @@ while [ $# -gt 0 ]; do #create case "$target" in *.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) - _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) - _gettext_pot "${target%%.pot}" || exit 2 + package="${source%%.pot}" + potfile="$target" + _gettext_pot "$package" "$potfile" || exit 2 ;; *) exit 2 diff --git a/po/project.conf b/po/project.conf index 3df8276..3ffa210 100644 --- a/po/project.conf +++ b/po/project.conf @@ -10,4 +10,4 @@ depends=POTFILES type=script script=./gettext.sh install= -depends=Installer.pot,fr.po +depends=$(OBJDIR)Installer.pot,fr.po diff --git a/src/Makefile b/src/Makefile index 03c033b..bf72dd7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,5 @@ -TARGETS = installer +TARGETS = $(OBJDIR)installer +OBJDIR = PREFIX = /usr/local DESTDIR = BINDIR = $(PREFIX)/bin @@ -17,18 +18,18 @@ INSTALL = install all: $(TARGETS) -installer_OBJS = installer.o main.o +installer_OBJS = $(OBJDIR)installer.o $(OBJDIR)main.o installer_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) installer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -installer: $(installer_OBJS) - $(CC) -o installer $(installer_OBJS) $(installer_LDFLAGS) +$(OBJDIR)installer: $(installer_OBJS) + $(CC) -o $(OBJDIR)installer $(installer_OBJS) $(installer_LDFLAGS) -installer.o: installer.c installer.h ../config.h - $(CC) -D PREFIX=\"$(PREFIX)\" $(installer_CFLAGS) -c installer.c +$(OBJDIR)installer.o: installer.c installer.h ../config.h + $(CC) -D PREFIX=\"$(PREFIX)\" $(installer_CFLAGS) -o $(OBJDIR)installer.o -c installer.c -main.o: main.c installer.h ../config.h - $(CC) $(installer_CFLAGS) -c main.c +$(OBJDIR)main.o: main.c installer.h ../config.h + $(CC) $(installer_CFLAGS) -o $(OBJDIR)main.o -c main.c clean: $(RM) -- $(installer_OBJS) @@ -38,7 +39,7 @@ distclean: clean install: $(TARGETS) $(MKDIR) $(DESTDIR)$(BINDIR) - $(INSTALL) -m 0755 installer $(DESTDIR)$(BINDIR)/installer + $(INSTALL) -m 0755 $(OBJDIR)installer $(DESTDIR)$(BINDIR)/installer uninstall: $(RM) -- $(DESTDIR)$(BINDIR)/installer