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 SUBDIRS = data 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-xmleditor.desktop \ $(PACKAGE)-$(VERSION)/data/deforaos-xmleditor.desktop \
$(PACKAGE)-$(VERSION)/data/project.conf \ $(PACKAGE)-$(VERSION)/data/project.conf \
@ -43,10 +44,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 = XMLEditor.pot fr.mo TARGETS = $(OBJDIR)XMLEditor.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)
XMLEditor.pot: POTFILES $(OBJDIR)XMLEditor.pot: POTFILES
./gettext.sh -P "$(PREFIX)" -- "XMLEditor.pot" ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)XMLEditor.pot"
fr.mo: XMLEditor.pot fr.po $(OBJDIR)fr.mo: $(OBJDIR)XMLEditor.pot fr.po
./gettext.sh -P "$(PREFIX)" -- "fr.mo" ./gettext.sh -P "$(PREFIX)" -- "$(OBJDIR)fr.mo"
clean: clean:
$(RM) -- $(XMLEditor.pot_OBJS) $(fr.mo_OBJS) $(RM) -- $(XMLEditor.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=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 PREFIX = /usr/local
DESTDIR = DESTDIR =
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
@ -18,21 +19,21 @@ INSTALL = install
all: $(TARGETS) 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_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
xmleditor_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) xmleditor_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
xmleditor: $(xmleditor_OBJS) $(OBJDIR)xmleditor: $(xmleditor_OBJS)
$(CC) -o xmleditor $(xmleditor_OBJS) $(xmleditor_LDFLAGS) $(CC) -o $(OBJDIR)xmleditor $(xmleditor_OBJS) $(xmleditor_LDFLAGS)
callbacks.o: callbacks.c callbacks.h xmleditor.h $(OBJDIR)callbacks.o: callbacks.c callbacks.h xmleditor.h
$(CC) $(xmleditor_CFLAGS) -c callbacks.c $(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)callbacks.o -c callbacks.c
xmleditor.o: xmleditor.c callbacks.h xmleditor.h ../config.h $(OBJDIR)xmleditor.o: xmleditor.c callbacks.h xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -c xmleditor.c $(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)xmleditor.o -c xmleditor.c
main.o: main.c xmleditor.h ../config.h $(OBJDIR)main.o: main.c xmleditor.h ../config.h
$(CC) $(xmleditor_CFLAGS) -c main.c $(CC) $(xmleditor_CFLAGS) -o $(OBJDIR)main.o -c main.c
clean: clean:
$(RM) -- $(xmleditor_OBJS) $(RM) -- $(xmleditor_OBJS)
@ -42,7 +43,7 @@ distclean: clean
install: $(TARGETS) install: $(TARGETS)
$(MKDIR) $(DESTDIR)$(BINDIR) $(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 xmleditor $(DESTDIR)$(BINDIR)/xmleditor $(INSTALL) -m 0755 $(OBJDIR)xmleditor $(DESTDIR)$(BINDIR)/xmleditor
uninstall: uninstall:
$(RM) -- $(DESTDIR)$(BINDIR)/xmleditor $(RM) -- $(DESTDIR)$(BINDIR)/xmleditor