## Absolute path to the Perl interpreter 
PERL	=	/usr/bin/perl

## Target directory for installing WWSympa
INSTALLDIR	=	/home/sympa/wwsympa

## User and group used by Sympa
USER    =       sympa
GROUP   =       sympa

## Emplacement du fichier de configuration de WWSympa
CONFIG	=	/etc/wwsympa.conf

## Bin directory for Sympa
## This directory contains perl modules of Sympa
SYMPADIR	=	/home/sympa/bin

##---------- STOP ---------- STOP ---------- STOP ---------- STOP ----------
##
## You should not modify anything after this line.

SUBSTSRC	=	wwsympa.fcgi bounced.pl archived.pl \
			wws-lib.pl bounce-lib.pl Marc.pm

SRC		=	dico mhonarc-ressources.default mhonarc-ressources.fr \
			mhonarc-ressources.us mime.types 

install: makedir $(SUBSTSRC) subst installtemplates installsrc chown

makedir:
	@if [ ! -d $(INSTALLDIR) ]; then \
		echo "Creating required directory $(INSTALLDIR)"; \
		mkdir $(INSTALLDIR); \
	fi
	@if [ ! -d $(INSTALLDIR)/templates ]; then \
		echo "Creating required directory $(INSTALLDIR)/templates"; \
		mkdir $(INSTALLDIR)/templates; \
	fi
	@if [ ! -d $(INSTALLDIR)/Marc ]; then \
		echo "Creating required directory $(INSTALLDIR)/Marc"; \
		mkdir $(INSTALLDIR)/Marc; \
	fi

installsrc:
	@echo "Installing sources..."
	cp $(SRC) $(INSTALLDIR)
	cp Marc/Search.pm $(INSTALLDIR)/Marc
	chmod 755 $(INSTALLDIR)/* $(INSTALLDIR)/Marc/Search.pm

installtemplates:
	@echo "Installing templates..."
	cp -R templates/* $(INSTALLDIR)/templates
	chmod -R 644 $(INSTALLDIR)/templates/*
	chmod -R 755 $(INSTALLDIR)/templates/help

subst:
	@echo "Doing multiple substitutions while installing ..."
	@( \
		PERL=$(PERL) \
		UMASK=0755 \
		INSTALLDIR=$(INSTALLDIR) \
		SYMPADIR=$(SYMPADIR)\
		CONFIG=$(CONFIG) \
		$(PERL) ./subst.pl $(SUBSTSRC) \
	)

chown:
	chown -R $(USER).$(GROUP) $(INSTALLDIR)








