# $Cambridge: hermes/src/prayer/lib/Makefile,v 1.14 2010/07/08 09:34:25 dpc22 Exp $ 

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

ifeq ($(strip $(SSL_ENABLE)), true)
  SSL_DEFS       = -DSSL_ENABLE
  ifeq ($(strip $(SESSION_CACHE_ENABLE)), true)
    # Berkeley DB required for SSL session cache.
    SSL_DEFS    += -DSESSION_CACHE_ENABLE
    DB_DEFS      = -DDB_ENABLE
  endif
  TARGETS=lib_withssl.a lib_nossl.a
else
  TARGETS=lib_nossl.a
endif

# Enable SYSV mutex
ifeq ($(strip $(MUTEX_SEMAPHORE)), true)
  MUTEX_DEF = -DMUTEX_SEMAPHORE
endif

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

MYCFLAGS  = $(BASECFLAGS)

OBJS= \
  pool.o assoc.o list.o buffer.o str.o memblock.o mystring.o iostream.o \
  misc.o ipaddr.o os.o process.o utf8.o html.o \
  mymutex.o setproctitle.o cdb.o template.o template_parse.o \
  template_compile.o template_expand.o template_vals.o

WITHSSL_OBJS = ssl.o mydb_db3.o mydb.o raven_wls_response.o

NOSSL_OBJS = no_ssl.o

all: $(TARGETS)

lib_withssl.a: $(OBJS) $(WITHSSL_OBJS)
	rm -f lib_withssl.a
	ar q lib_withssl.a $(OBJS) $(WITHSSL_OBJS)

lib_nossl.a: $(OBJS) $(NOSSL_OBJS)
	rm -f lib_nossl.a
	ar q lib_nossl.a $(OBJS) $(NOSSL_OBJS)

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

os.o: os.c
	$(CC) $(MYCFLAGS) -c $(OS_DEFS) $<

ssl.o: ssl.c *.h Makefile
	$(CC) $(MYCFLAGS) $(SSL_INCLUDE) $(SSL_DEFS) -c $<

raven_wls_response.o: raven_wls_response.c *.h Makefile
	$(CC) $(MYCFLAGS) $(SSL_INCLUDE) $(SSL_DEFS) -c $<


# mydb_db3.o: need to add DB_DEFS
mydb_db3.o: mydb_db3.c *.h Makefile
	$(CC) $(MYCFLAGS) $(DB_INCLUDE) $(DB_DEFS) -c $<

mymutex.o:  mymutex.c mymutex_sem.c mymutex_file.c
	$(CC) $(MYCFLAGS) $(MUTEX_DEF) -c $<

clean:
	rm -f lib.o $(OBJS) $(WITHSSL_OBJS) $(NOSSL_OBJS) *~ \#*\# $(TARGETS)

