# definitions

VERSION = 0.9.16
PKG_DIST = diogenes-$(VERSION)
LIB_DIST = libdiogenes-$(VERSION)

PKG_FILES = AUTHORS ChangeLog COPYING README Makefile \
            cvs.pl style.css
	    
PKG_DIRS = config htdocs include locale po templates

LIB_FILES = COPYING
LIB_BASE = include/diogenes

VCS_FILTER = ! -name .arch-ids ! -name CVS

# global targets

build: pkg-build lib-build

dist: clean pkg-dist lib-dist

clean:
	rm -rf locale include/diogenes.globals.inc.php

%: %.in Makefile
	sed -e 's,@VERSION@,$(VERSION),g' $< > $@


# diogenes package targets

pkg-build: include/diogenes.globals.inc.php
	make -C po

pkg-dist: pkg-build
	rm -rf $(PKG_DIST) $(PKG_DIST).tar.gz
	mkdir $(PKG_DIST)
	cp -a $(PKG_FILES) $(PKG_DIST)
	for dir in `find $(PKG_DIRS) -type d $(VCS_FILTER)`; \
	do \
          mkdir -p $(PKG_DIST)/$$dir; \
	  find $$dir -type f -maxdepth 1 -exec cp {} $(PKG_DIST)/$$dir \; ; \
	done
	tar czf $(PKG_DIST).tar.gz $(PKG_DIST)
	rm -rf $(PKG_DIST)


# diogenes library targets

lib-build:

lib-dist: lib-build
	rm -rf $(LIB_DIST)
	mkdir $(LIB_DIST)
	cp -a $(LIB_FILES) $(LIB_DIST)
	for dir in `cd $(LIB_BASE) && find -type d $(VCS_FILTER)`; \
	do \
          mkdir -p $(LIB_DIST)/$$dir; \
	  find $(LIB_BASE)/$$dir -type f -maxdepth 1 -exec cp {} $(LIB_DIST)/$$dir \; ; \
	done
	tar czf $(LIB_DIST).tar.gz $(LIB_DIST)
	rm -rf $(LIB_DIST)


.PHONY: build dist clean pkg-build pkg-dist lib-build lib-dist

