# Authors: Bas van der Vlies & Michel Jouvin
# Date   : 13 Jan 2005
# Desc.  : Simple Makefile
#
# SVN INFO:
#      $Id: Makefile.in 332 2010-03-24 10:09:47Z bas $
#
#
prefix=@prefix@
EXEC_PREFIX=@exec_prefix@/bin
PYTHON_BIN=@PYTHON@
CONFIG=@sysconfdir@

# User names 
#
TRAC_USER=@trac_user@
MTA_USER=@mta_user@
INSTALL_USER=@install_user@
DEBUG=@DEBUG@

TRAC_SCRIPT_NAME=email2trac

CC=@CC@
INSTALL=./install-sh
CFLAGS=-DMTA_USER=\"$(MTA_USER)\" -DTRAC_USER=\"$(TRAC_USER)\" -DTRAC_SCRIPT_NAME=\"$(TRAC_SCRIPT_NAME)\" -DTRAC_SCRIPT_PATH=\"$(EXEC_PREFIX)\" -DDEBUG=$(DEBUG)

PYTHON_FILES=delete_spam.py email2trac.py
WRAPPER_SRC=run_email2trac.c run_email2trac.h

all: run_email2trac

run_email2trac: $(WRAPPER_SRC) Makefile
	$(CC) $(CFLAGS) -o $@ run_email2trac.c

install: all install-conf
	$(INSTALL) -d $(DESTDIR)$(EXEC_PREFIX)
	for script in $(PYTHON_FILES) ; \
	do \
          name=`basename $$script '.py'` ;\
	  $(INSTALL) -m 755 -o $(INSTALL_USER) $$script  $(DESTDIR)$(EXEC_PREFIX)/$$name ;\
	done

	$(INSTALL) -m 4111 -o  $(INSTALL_USER) run_email2trac $(DESTDIR)$(EXEC_PREFIX)

install-conf:
	if [ ! -f  $(DESTDIR)/$(CONFIG)/email2trac.conf ] ; \
	then \
		$(INSTALL) -c -m 644 -o $(INSTALL_USER) email2trac.conf $(DESTDIR)/$(CONFIG)/email2trac.conf ;\
	fi
 
clean:
	rm run_email2trac

distclean:
	rm run_email2trac email2trac.py delete_spam.py config.log config.status Makefile
