#
# Copyright (C) 2010 Alexander Taler <dissent@0--0.org>
#

# This file is part of hsh.

# hsh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# hsh is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with hsh.  If not, see <http://www.gnu.org/licenses/>.
######################################################################

# Default

.PHONY : clean pydoc clean-pydoc test gendocs clean-gendocs clean-pkg

default : pydoc test gendocs

clean : clean-pydoc clean-gendocs clean-pkg

# Run Automated Tests

TESTS = $(wildcard src/hsh/test/test_*.py)

$(TESTS) :
	PYTHONPATH=src python $@

.PHONY : test $(TESTS)

test : $(TESTS)

# Generate Pydoc

.PHONY = pydoc clean-pydoc

PYDOC_OUT = pydoc

pydoc :
	/usr/bin/epydoc -v --no-sourcecode --simple-term -o $(PYDOC_OUT) -n hsh -u http://www.nongnu.org/hsh/ src/hsh

clean-pydoc :
	rm -rf  $(PYDOC_OUT)

# Documentation

doc/%.png : doc/%.dia
	dia --filter png --export $@ $<

doc/%.txt : doc/%.html
	egrep -v '[<>]' > $@ < $<

DIAS = $(wildcard doc/*.dia)
DOCS = $(wildcard doc/*.html)
GEN_DOCS = $(patsubst %.dia,%.png,$(DIAS)) $(patsubst %.html,%.txt,$(DOCS)) 

.PHONY : gendocs clean-gendocs

gendocs : $(GEN_DOCS)

clean-gendocs :
	rm -f $(GEN_DOCS)

# Package

.PHONY : pkg clean-pkg

pkg :
	bin/make_pkg.sh

clean-pkg :
	rm -rf hsh-1.*

