## Bourne Shell
SH	=	/bin/sh

## Indiquez ici le nom de votre compilateur C ANSI (cc ou gcc).
CC	=	gcc

## Options de compilation (vous pouvez utiliser l'optimiseur si vous le
## souhaitez, bien que cela n'aura quasiment aucun impact sur les performances
## du logiciel.
CFLAGS	=	-g

## Chemin absolu d'accs  votre interprteur Perl 5.003 (ou suprieur)
PERL	=	/usr/bin/perl

## Nom de l'utilisateur et du groupe utiliss pour le logiciel Sympa.
USER	=	sympa
GROUP	=	sympa

## Emplacement du fichier de configuration utilis par le programme C queue
## et par les programmes Perl
CONFIG	=	/etc/sympa.conf

## Root directory for Sympa ; use absolute path.
## Binaries are located under $DIR/bin ; this directory needs to be
## readable for everyone ; `queue' needs to be executable 
DIR	=	/home/sympa

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

BINDIR	=	$(DIR)/bin

CDEFS	=	-DCONFIG=\"$(CONFIG)\"

SRC	=	sympa.pl Archive.pm Commands.pm Conf.pm \
		Language.pm List.pm Log.pm mail.pl msg.pl \
		smtp.pm tools.pl Version.pm parser.pl \
		edit_list.conf

all: queue bouncequeue checkcpan

clean:
	rm queue
	rm bouncequeue

install: makedir subst $(SRC) queue bouncequeue installqueue installscenari installtemplates chown info


installtemplates:
	@echo "Installing default templates..."
	cp templates/*  $(DESTDIR)$(BINDIR)/templates
	chmod 444 $(DESTDIR)$(BINDIR)/templates/*

installscenari:
	@echo "Installing default scenari..."
	cp scenari/* $(DESTDIR)$(BINDIR)/scenari
	chmod 444 $(DESTDIR)$(BINDIR)/scenari/*

installqueue:
	@echo "Installing Queue binary..."
	cp queue $(DESTDIR)$(BINDIR)
	@echo "Installing BounceQueue binary..."
	cp bouncequeue $(DESTDIR)$(BINDIR)
	chmod 4755 $(DESTDIR)$(BINDIR)/queue $(DESTDIR)$(BINDIR)/bouncequeue

makedir:
	@if [ ! -d $(DESTDIR)$(BINDIR) ]; then \
		echo "Creating required directory $(DESTDIR)$(BINDIR)"; \
		mkdir $(DESTDIR)$(BINDIR); \
	fi
	@if [ ! -d $(DESTDIR)$(BINDIR)/scenari ]; then \
		echo "Creating required directory $(DESTDIR)$(BINDIR)/scenari"; \
		mkdir $(DESTDIR)$(BINDIR)/scenari; \
	fi
	@if [ ! -d $(DESTDIR)$(BINDIR)/templates ]; then \
		echo "Creating required directory $(DESTDIR)$(BINDIR)/templates"; \
		mkdir $(DESTDIR)$(BINDIR)/templates; \
	fi
	chmod 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(BINDIR)/scenari $(DESTDIR)$(BINDIR)/templates

queue: queue.c Makefile
	$(CC) $(CFLAGS) $(CDEFS) -o queue queue.c

bouncequeue: bouncequeue.c Makefile
	$(CC) $(CFLAGS) $(CDEFS) -o bouncequeue bouncequeue.c

subst:
	@echo "Doing multiple substitutions while installing ..."
	@( \
		PERL=$(PERL) \
		UMASK=0755 \
		DIR=$(DIR) \
		BINDIR=$(BINDIR)\
		CONFIG=$(CONFIG) \
		$(PERL) ./subst.pl $(SRC) \
	)

chown:
	chown -R $(USER).$(GROUP) $(DESTDIR)$(BINDIR)

## Dpendances
queue:		queue.c Makefile

bouncequeue:	bouncequeue.c Makefile

checkcpan: 
	@echo "Checking needed CPAN modules ..."
	$(PERL) ./check_perl_modules.pl

info:
	@echo ""
	@echo "If you wish, you can contact the authors sympa-users-request@cru.fr"
	@echo "Thanks to provide release number, operating system and langage used."
	@echo ""










