# cfgstoragemaker: MRTG config generator for storage monitoring via SNMP
# Copyright (C) 2001, 2002 LibertySurf Telecom, Cyril Bouthors
# 
# This program 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 2 of the License, or
# (at your option) any later version.
# 
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

include Config.mk

all:;

DIRS = $(mandir) $(TEMPLATEDIR) $(bindir)

install: \
	$(DIRS) \
	$(mandir)/cfgstoragemaker.1 \
	$(bindir)/cfgstoragemaker \
	$(TEMPLATEDIR)/body.tpl \
	$(TEMPLATEDIR)/header.tpl

$(mandir)/cfgstoragemaker.1: cfgstoragemaker.1
	install -m 644 -o $(OWN) -g $(GRP) $< $@

$(bindir)/cfgstoragemaker: cfgstoragemaker
	install -o $(OWN) -g $(GRP) $< $@

$(TEMPLATEDIR)/body.tpl: templates/body.tpl
	install -m 644 -o $(OWN) -g $(GRP) $< $@

$(TEMPLATEDIR)/header.tpl: templates/header.tpl
	install -m 644 -o $(OWN) -g $(GRP) $< $@

$(DIRS):
	mkdir -p $@

distclean clean: 
	$(RM) config.log config.cache config.status Config.mk

configure: configure.in
	autoconf

################################################################

DIST_LIST = \
	AUTHORS \
	configure \
	configure.in \
	COPYING \
	ChangeLog \
	Config.mk.in \
	Makefile \
	README \
	cfgstoragemaker.1 \
	cfgstoragemaker \
	templates/body.tpl \
	templates/header.tpl

# VERSION have to be specified on command line
DIST_NAME = cfgstoragemaker
DIST_EXTS = tar.bz2 tar.gz
DIST = $(DIST_NAME)-$(VERSION)
DISTS = $(DIST_EXTS:%=$(DIST_NAME)-$(VERSION).%)
TAR = tar
TAR_BZ2 = -cvjf
TAR_GZ = -cvzf

dist: $(DISTS:%=../%)

../$(DIST).tar.bz2: ../$(DIST_NAME)-$(VERSION) $(DIST_LIST)
	cd .. && $(TAR) $(TAR_BZ2) $(@F) $(DIST_LIST:%=$(DIST_NAME)-$(VERSION)/%)

../$(DIST).tar.gz: ../$(DIST_NAME)-$(VERSION) $(DIST_LIST)
	cd .. && $(TAR) $(TAR_GZ) $(@F) $(DIST_LIST:%=$(DIST_NAME)-$(VERSION)/%)

../$(DIST_NAME)-$(VERSION):
	ln -s $(DIST_NAME) $@
