CC = @CC@

CFLAGS = -Wall @CFLAGS@
SSLCFLAGS = @SSLCFLAGS@

CCDLFLAGS = @CCDLFLAGS@
LDFLAGS = @LDFLAGS@
LDDLFLAGS = @LDDLFLAGS@

LIBS = @LIBS@
SSLLIBS = @SSLLIBS@

EXE_EXT = @EXEEXT@
SHLIBEXT = .so

SPAMC_FILES = spamc/spamc.c

QMAIL_SPAMC_FILES = spamc/qmail-spamc.c

LIBSPAMC_FILES = spamc/libspamc.c spamc/utils.c


all:
	cd .. && $(MAKE) -f spamc/Makefile everything

clean:
	cd .. && $(MAKE) clean


everything: spamc/spamc$(EXE_EXT) spamc/qmail-spamc$(EXE_EXT)
	true


spamc/libspamc$(SHLIBEXT): $(LIBSPAMC_FILES)
	$(CC) $(CCDLFLAGS) $(LIBSPAMC_FILES) \
		-o $@ $(LDDLFLAGS) $(LIBS)

spamc/libsslspamc$(SHLIBEXT): $(LIBSPAMC_FILES)
	$(CC) $(SSLCFLAGS) $(CCDLFLAGS) $(LIBSPAMC_FILES) \
		-o $@ $(LDDLFLAGS) $(SSLLIBS) $(LIBS)

spamc/spamc$(EXE_EXT): $(SPAMC_FILES) $(LIBSPAMC_FILES)
	$(CC) $(SSLCFLAGS) $(CFLAGS) $(SPAMC_FILES) $(LIBSPAMC_FILES) \
		-o $@ $(LDFLAGS) $(SSLLIBS) $(LIBS)

spamc/qmail-spamc$(EXE_EXT): $(QMAIL_SPAMC_FILES)
	$(CC) $(CFLAGS) $(QMAIL_SPAMC_FILES) \
		-o $@ $(LDFLAGS) $(LIBS)

