#
# Makefile based on dman's
#

VERSION=$(shell cat version)

LDFLAGS += -shared

# I place the directory in exim/debian/local_scan. Adjust the path as needed
EXIM_SRC= ../../src
SUFF=-$(VERSION)

BUILDCFLAGS=-I$(EXIM_SRC) -DDLOPEN_LOCAL_SCAN -fPIC $(CFLAGS)

SONAME=$(subst .so,$(SUFF).so,local_scan_perl.so)
CNAME=local_scan.c

PLUGINDIR=$(DESTDIR)/usr/lib/exim4/local_scan

OBJECTS=$(SONAME)

all: Makefile $(OBJECTS)

Makefile: ../../build-exim4-daemon-heavy/Makefile Makefile.in
	grep ^PERL $< >> $@.new
	cat Makefile.in >> $@.new
	rm $@
	mv $@.new $@


$(SONAME) : $(CNAME)
	@echo "Building $@"
	$(PERL_CC) $(PERL_CCOPTS) $(BUILDCFLAGS) $(LDFLAGS) -o $@ $<
	chmod a+rx $(SONAME)

clean:	
	@-rm -f $(OBJECTS)

install: $(SONAME)
	install -m755 $< $(PLUGINDIR)
.PHONY : clean all install
