# $Cambridge: hermes/src/prayer/accountd/Makefile,v 1.12 2011/06/15 13:17:48 dpc22 Exp $
# Prayer - a Webmail Interface
#
# Copyright (c) University of Cambridge 2000 - 2002
# See the file NOTICE for conditions of use and distribution.

ifeq ($(strip $(RPM_BUILD)), true)
include ../Config-RPM
else
include ../Config
endif

BASECFLAGS += -I../lib

# Enable Electric Fence
ifeq ($(strip $(FENCE_ENABLE)), true)
  BASECFLAGS += $(FENCE_INCLUDE)
  BASE_LIBS  += $(FENCE_LIBS)
endif

# Add PAM if backend needs pam
ifeq ($(strip $(ACCOUNTD_PAM_ENABLE)), true)
  BASE_INCLUDE      += $(PAM_INCLUDE)
  BASE_LIBS         += $(PAM_LIBS)
  ACCOUNTD_AUTH_DEFS += -DACCOUNTD_PAM_ENABLE=1
endif

ifeq ($(strip $(RAVEN_ENABLE)), true)
  ACCOUNTD_AUTH_DEFS += -DRAVEN_ENABLE=1
  ACCOUNTD_SSL_ENABLE=true
endif

MYCFLAGS  = $(BASECFLAGS)
MYLDFLAGS = $(BASELDFLAGS) 
MYLIBS    = $(BASE_LIBS)

ifeq ($(strip $(ACCOUNTD_SSL_ENABLE)), true)
  SSL_LIB  = ../lib/lib_withssl.a
  MYLIBS += $(SSL_LIBS)
  ifeq ($(strip $(SESSION_CACHE_ENABLE)), true)
    # Berkeley DB required for SSL session cache.
    MYLIBS    += $(DB_LIBS)
  endif
else
  SSL_LIB  = ../lib/lib_nossl.a
endif


all: prayer-accountd

########################################################################

OBJS = config.o log.o \
 password.o fullname.o quota.o file.o mail.o \
 filter.o checksum.o authenticate.o $(SSL_LIB)

prayer-accountd: $(OBJS) accountd.o
	$(CC) $(MYLDFLAGS) -o prayer-accountd accountd.o $(OBJS) $(MYLIBS)

test: test.o $(OBJS)
	$(CC) $(MYLDFLAGS) -o test test.o $(OBJS) $(MYLIBS)

# Default build rule
%.o: %.c *.h Makefile
	$(CC) $(MYCFLAGS) -c $<

accountd.o: accountd.c *.h Makefile
	$(CC) $(MYCFLAGS) -c \
	  -DACCOUNTD_CONFIG_FILE=\"$(ACCOUNTD_CONFIG_FILE)\" $<

authenticate.o: authenticate.c *.h Makefile
	$(CC) $(MYCFLAGS) -c $(ACCOUNTD_AUTH_DEFS) $<

clean:
	-rm -f prayer-accountd test core *.o *~ \#*\# 

install:
	$(INSTALL) -m 755 -o ${RO_USER} -g ${RW_GROUP} \
	prayer-accountd ${BROOT}${BIN_DIR}

