

clean-local-dist:

install-data-hook-dist:

uninstall-data-hook-dist:

stamp-version:
	cd $(srcdir); \
	$(top_srcdir)/config/sand.sh -v -s '@version .*$$' -r "@version $(PACKAGE_VERSION)" $(HEADERS)
	subdirlist='$(SUBDIRS)'; for subdir in $$subdirlist; do \
          echo "Visiting $$subdir"; \
          (cd $$subdir && $(MAKE) stamp-time) \
          || eval $$failcom; \
        done; 

stamp-time:
	cd $(srcdir); \
	$(top_srcdir)/config/sand.sh -v -s '@date .*$$' -r "@date `date '+%F %X'`" $(HEADERS)
	subdirlist='$(SUBDIRS)'; for subdir in $$subdirlist; do \
          echo "Visiting $$subdir"; \
          (cd $$subdir && $(MAKE) stamp-version) \
          || eval $$failcom; \
        done; 

stamp: stamp-build stamp-time stamp-version

stamp-build:
	@cp $(top_srcdir)/configure.ac $(top_srcdir)/configure.ac.orig
	@DATE=`date '+%y.%m.%d'` && \
	cat $(top_srcdir)/configure.ac.orig | \
	$(SED) "s/AC_INIT\([^,]*\),[ ]*\[\([^]]*\)[ ]*\]\(.*\)/AC_INIT\1,[$$DATE]\3/" > $(top_srcdir)/configure.ac


svn-add:
	cd $(srcdir); \
        for i in $(HEADERS) $(srcdir)/Makefile.am $(dist_python_SCRIPTS) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(SUBDIRS) $(DATA); do \
          if ! svn list $$i 2> /dev/null; then \
             if test -d $$i; then \
                svn add -N $$i;  \
             else \
                if test `basename $$i` != $$i; then\
                  k=.; \
                  for j in `dirname $$i | tr / ' '`; do \
                   k=$$k/$$j; \
                   svn add -N $$k; \
                  done \
                fi; \
                svn add $$i;  \
             fi; \
          else \
             echo already added $$i; \
          fi; \
        done;
	echo do $(SUBDIRS)
	subdirlist='$(SUBDIRS)'; for subdir in $$subdirlist; do \
          echo "Visiting $$subdir"; \
          (cd $$subdir && $(MAKE) svn-add) \
          || eval $$failcom; \
        done; 



svn-dist: svn-add
	cd $(srcdir); 

svn-commit:
	svn ci

svn-ci:
	svn ci -m ""


source-list:
	@if test "x$$SRCTMPFILE" == "x"; then \
             # source_list_tmpfile=`mktemp --tmpdir=\`pwd\``; \
             echo "Please provide a filename with an absolute path, e.g:"; \
             echo '  make source-list SRCTMPFILE=`pwd`/myfiles.txt'; \
             exit -1; \
        else \
             source_list_tmpfile=$$SRCTMPFILE; \
        fi; \
        if test "x$(LISTDIR)" == "x"; then :> $$source_list_tmpfile; fi; \
        for i in $(HEADERS) $(srcdir)/Makefile.am $(dist_python_SCRIPTS) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(DATA); do \
          echo -n ".$(LISTDIR)/$$i " >> $$source_list_tmpfile; \
        done; \
        for subdir in $(SUBDIRS); do \
          (cd $$subdir && $(MAKE) source-list LISTDIR=$(LISTDIR)/$$subdir SRCTMPFILE=$$source_list_tmpfile) \
          || eval $$failcom; \
        done; \
        if test "x$(LISTDIR)" == "x"; then echo "Wrote $$source_list_tmpfile"; fi; 
         


deps:
	@for i in $(patsubst %,$(DEPDIR)/%.Po, $(basename $(SOURCES))); do \
           test -z $$i || :> $$i; \
   done;


RPM_INSTALLROOT         = /instroot

rpm-spec:
	$(SED) -e "s,@NAME@,${PACKAGE_TARNAME}," \
            -e "s,@VER@,${PACKAGE_VERSION}," \
            -e "s,@REL@,${PACKAGE_RELEASE}," \
            -e "s,@USER@,$$USERNAME," \
            -e "s,@EMAIL@,$$USEREMAIL," \
            -e "s,@PREFIX@,$(RPM_INSTALLROOT)," \
            $(top_srcdir)/config/template.spec.in > $(top_builddir)/config/${PACKAGE_NAME}.spec

rpm-build:
	 rpmbuild -ba --clean --define "tanbuild" \
                      --define "_topdir $(abs_top_builddir)/rpm" \
                      --define "_srcrpmdir $(abs_top_builddir)" \
                      --define "_rpmdir $(abs_top_builddir)" \
                      --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
                      --define "_sourcedir $(abs_top_builddir)" \
                       $(top_builddir)/config/$(PACKAGE_NAME).spec
	 rm -rf $(abs_top_builddir)/rpm


rpm: stamp-build dist rpm-spec 
	 $(MAKE) rpm-build


DEBSOURCES =  $(PACKAGE_NAME)-$(VERSION)
DEBSOURCESDIR = $(top_srcdir)/DEBSOURCES

deb-ctl:
	if test -d $(DEBSOURCESDIR); then \
             rm -rf $(DEBSOURCESDIR);  \
        fi; 
	mkdir -p $(DEBSOURCESDIR);
	$(TARPRG) -xzvf  ./$(PACKAGE_TARNAME)-$(VERSION).tar.gz
	$(MVPRG) $(PACKAGE_TARNAME)-$(VERSION) $(DEBSOURCESDIR)/
	$(UNSETPRG) INSROOT; \
	$(UNSETPRG) LD_LIBRARY_PATH;\
	cd $(DEBSOURCESDIR)/$(PACKAGE_TARNAME)-$(VERSION);\
	if test -d "debian"; then \
		$(RMPRG) -rfv debian;\
        fi; \
	printf "\n" | $(DEBMAKE) -c GPL -e $(USEREMAIL) -n  -m -p $(PACKAGE_TARNAME);
	$(SED) -i "/^Build-Depends/c `grep ^Build-Depends ${top_builddir}/config/control.in` " \
		 $(DEBSOURCESDIR)/$(PACKAGE_TARNAME)-$(VERSION)/debian/control 
	$(SED) -i "/^Depends/c `grep ^Depends ${top_builddir}/config/control.in` " \
		$(DEBSOURCESDIR)/$(PACKAGE_TARNAME)-$(VERSION)/debian/control 

deb: stamp dist deb-ctl
	cd $(DEBSOURCESDIR)/$(PACKAGE_TARNAME)-$(VERSION);\
	unset INSROOT; \
	unset LD_LIBRARY_PATH;\
	$(DPKGBUILDPKG) -rfakeroot -us -uc -tc
