CC = @CC@

CFLAGS = @CFLAGS@
SSLCFLAGS = @SSLCFLAGS@

CCCDLFLAGS = @CCCDLFLAGS@
LDFLAGS = @LDFLAGS@
LDDLFLAGS = @LDDLFLAGS@

LIBS = @LIBS@
SSLLIBS = @SSLLIBS@

EXE_EXT = @EXEEXT@
SHLIBEXT = .so

SPAMC_FILES = spamc/spamc.c spamc/getopt.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) $(CCCDLFLAGS) $(LIBSPAMC_FILES) \
		-o $@ $(LDDLFLAGS) $(LIBS)

spamc/libsslspamc$(SHLIBEXT): $(LIBSPAMC_FILES)
	$(CC) $(SSLCFLAGS) $(CCCDLFLAGS) $(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)

