Added support for building with OBJDIR

This commit is contained in:
Pierre Pronchery 2014-11-04 00:40:58 +01:00
parent 7d481b3a6c
commit 02925ff461
6 changed files with 72 additions and 31 deletions

View File

@ -3,7 +3,8 @@ VERSION = 0.0.0
SUBDIRS = data 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-xmleditor.desktop \
$(PACKAGE)-$(VERSION)/data/project.conf \
@ -43,10 +44,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,3 +1,4 @@
OBJDIR =
PREFIX = /usr/local
DESTDIR =
MKDIR = mkdir -m 0755 -p

View File

@ -1,4 +1,5 @@
TARGETS = XMLEditor.pot fr.mo
TARGETS = $(OBJDIR)XMLEditor.pot $(OBJDIR)fr.mo
OBJDIR =
PREFIX = /usr/local
DESTDIR =
RM = rm -f
@ -9,11 +10,11 @@ INSTALL = install
all: $(TARGETS)
XMLEditor.pot: POTFILES
./gettext.sh -P "$(PREFIX)" -- "XMLEditor.pot"
$(OBJDIR)XMLEditor.pot: POTFILES
./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)XMLEditor.pot"
fr.mo: XMLEditor.pot fr.po
./gettext.sh -P "$(PREFIX)" -- "fr.mo"
$(OBJDIR)fr.mo: $(OBJDIR)XMLEditor.pot fr.po
./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)fr.mo"
clean:
$(RM) -- $(XMLEditor.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"

View File

@ -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

View File

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

View File

@ -1,4 +1,5 @@
TARGETS = xmleditor
TARGETS = $(OBJDIR)xmleditor
OBJDIR =
PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
@ -18,21 +19,21 @@ INSTALL = install
all: $(TARGETS)
xmleditor_OBJS = callbacks.o xmleditor.o main.o
xmleditor_OBJS = $(OBJDIR)callbacks.o $(OBJDIR)xmleditor.o $(OBJDIR)main.o
xmleditor_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
xmleditor_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
xmleditor: $(xmleditor_OBJS)
$(CC) -o xmleditor $(xmleditor_OBJS) $(xmleditor_LDFLAGS)
$(OBJDIR)xmleditor: $(xmleditor_OBJS)
$(CC) -o $(OBJDIR)xmleditor $(xmleditor_OBJS) $(xmleditor_LDFLAGS)
callbacks.o: callbacks.c callbacks.h xmleditor.h
$(CC) $(xmleditor_CFLAGS) -c callbacks.c
$(OBJDIR)callbacks.o: callbacks.c callbacks.h xmleditor.h
$(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)callbacks.o -c callbacks.c
xmleditor.o: xmleditor.c callbacks.h xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -c xmleditor.c
$(OBJDIR)xmleditor.o: xmleditor.c callbacks.h xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)xmleditor.o -c xmleditor.c
main.o: main.c xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -c main.c
$(OBJDIR)main.o: main.c xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)main.o -c main.c
clean:
$(RM) -- $(xmleditor_OBJS)
@ -42,7 +43,7 @@ distclean: clean
install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 xmleditor $(DESTDIR)$(BINDIR)/xmleditor
$(INSTALL) -m 0755 $(OBJDIR)xmleditor $(DESTDIR)$(BINDIR)/xmleditor
uninstall:
$(RM) -- $(DESTDIR)$(BINDIR)/xmleditor