## @file
##
## $Id: makefile.am 7 2010-03-01 14:55:44Z marc $
##
##       1         2         3         4         5         6         7         8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890

SUBDIRS = qbrowserlib designer

qbrowserlibdir=${includedir}/qbrowserlib
qbrowserlib_HEADERS = @srcdir@/qbrowserlib/*.hxx

if !MINGW32
if MAC
AM_CPPFLAGS += -I/opt/local/include
# -I/Library/OpenSC/include
AM_LDFLAGS = -L/opt/local/lib
# -F/System/Library/Frameworks/PCSC.framework
else
# AM_CPPFLAGS += -I/usr/include/PCSC
endif
endif

mypkgdir = ${datarootdir}/@PACKAGENAME@
mypkg_SCRIPTS = 
mypkg_DATA = @PACKAGENAME@.xpm resources/@PACKAGENAME@.png

applicationsdir = ${datarootdir}/applications
dist_applications_DATA = @PACKAGENAME@.desktop

EXTRA_DIST = @srcdir@/resources @srcdir@/*.cxx @srcdir@/*.hxx	\
             @srcdir@/*.ui @srcdir@/*.ts @srcdir@/*.qrc

LANGS = en de fr it
ALL_SRC = ${top_srcdir}/src/*.[ch]xx ${top_srcdir}/src/*.ui $(shell find ${top_srcdir}/src/resources -name .svn -prune -o \( -type f -o -type l \) -print)

QMAKE_PROJECT = qmake.pro
QMAKE_MAKEFILE = makefile.qmake

bin_SCRIPTS = swissbrowser
QMAKE_TARGET = ${bin_SCRIPTS}

TARGETS = ${QMAKE_TARGET}

all: ${TARGETS} $(LANGS:%=@PACKAGENAME@_%.ts)

rebuild-ts: $(LANGS)
	${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}

${LANGS}: ${ALL_SRC}
	-rm @PACKAGENAME@_$@.qm
	svn revert @PACKAGENAME@_$@.ts
	mv @PACKAGENAME@_$@.ts translation.old
	${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}
	mv @PACKAGENAME@_$@.ts translation.new
	echo '<?xml version="1.0" encoding="utf-8"?>' > @PACKAGENAME@_$@.ts
	echo '<!DOCTYPE TS>' >> @PACKAGENAME@_$@.ts
	echo '<TS version="2.0" language="'$@'">' >> @PACKAGENAME@_$@.ts
	xqilla merge-translation.xquery >> @PACKAGENAME@_$@.ts
	echo '</TS>' >> @PACKAGENAME@_$@.ts
	rm translation.old translation.new

print:
	@echo "LANGS=${LANGS}"
	@echo "ALL_SRC=${ALL_SRC}"
	@echo "QMAKE=${QMAKE}"
	@echo "QMAKE_OPTIONS=${QMAKE_OPTIONS}"
	@echo "QMAKE_MAKEFILE=${QMAKE_MAKEFILE}"
	@echo "QMAKE_TARGET=${QMAKE_TARGET}"
	@echo "TARGETS=${TARGETS}"


@PACKAGENAME@_%.qm: ${top_srcdir}/src/@PACKAGENAME@_%.ts
	${LRELEASE} $< -qm $@

%.xpm: resources/%.png
	convert $< $@ || cp $< $@

%.ts: ${ALL_SRC}
	${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}

${QMAKE_MAKEFILE}: ${QMAKE_PROJECT} ${ALL_SRC}
	${QMAKE} -o $@ $<

${QMAKE_TARGET}: ${QMAKE_MAKEFILE} ${ALL_SRC} $(LANGS:%=@PACKAGENAME@_%.qm)
	make -f ${QMAKE_MAKEFILE}

install-data-local:
	${mkinstalldirs} ${DESTDIR}${bindir}
	for file in ${QMAKE_TARGET}{,.app,.exe}; do \
	  if test -d $$file; then \
	    rsync -a --delete $$file ${DESTDIR}${bindir}/; \
	  elif test -e $$file; then \
	    ${INSTALL} $$file ${DESTDIR}${bindir}; \
	  fi; \
	done

uninstall-local:
	-rm -r ${DESTDIR}${bindir}/${QMAKE_TARGET}*

clean-local:
	-rm -r ${QMAKE_TARGET}{,.app,.exe}

CLEANFILES = ${TARGETS} ${TARGETS:%=%.exe} $(LANGS:%=@PACKAGENAME@_%.qm) \
             *.o *.obj qrc_*.cpp ui_*.h moc_*.cpp \
	     ${QMAKE_TARGET} object_script.swissbrowser \
	     @PACKAGENAME@.xpm
MAINTAINERCLEANFILES = makefile.in ${QMAKE_MAKEFILE}
