#
#	Global values
MODULE=IkiWiki::Plugin::sar
DEBIAN_PACKAGE=ikiwiki-plugin-sar
DESTDIR ?= /tmp

#
#	Test program
DEBUG=t/sar.t
ARGS=

#
#	Source modules (all .pm files under the lib directory)
MODULES=$(shell find lib -name "*.pm")
BINARIES=$(wildcard bin/*.pl)
EXAMPLES=$(wildcard examples/*.p[lm])
TESTS=$(wildcard t/*.t)
CHECK_SOURCES=$(MODULES) $(BINARIES) $(EXAMPLES) $(DEBUG)


#
#	External tools
PERL ?= perl -Ilib
PERL_CHECK ?= $(PERL) -cw
PERL_DEBUG ?= $(PERL) -I. -d:ptkdb 
PROVE=$(shell which prove) -Ilib
INSTALL=$(shell which install)
DEBUILD=debuild -uc -us 

#
#	Do nothing by default
all:

clean:
	-$(PERL) Build distclean

#
#	Check syntax
.PHONY: check $(CHECK_SOURCES)

check:	$(CHECK_SOURCES)

$(CHECK_SOURCES):
	$(PERL_CHECK) $@

#
#	Test programs
test:	
	$(PROVE) -v t/

#
#	Debug program
debug:		check $(DEBUG)
	$(PERL_DEBUG) $(DEBUG) $(ARGS)

run:	check $(DEBUG)
	$(PERL) $(DEBUG) $(ARGS)

#
#	Build the perl package
build:		Build

Build:		Build.PL
	$(PERL) Build.PL installdirs=vendor

binary:		build
	$(PERL) Build 

dist:	binary
	$(PERL) Build dist

#
#	Install the perl package
install:	test binary
	$(PERL) Build install destdir=$(DESTDIR)

#
#	Debian package
deb:
	$(DEBUILD) 


#
#	Releasing
release:	deb	dist
	debrelease -t taquiones

