# Makefile for cyrus library
# 
# @configure_input@
# 
# Copyright (c) 1998-2000 Carnegie Mellon University.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer. 
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
#
# 3. The name "Carnegie Mellon University" must not be used to
#    endorse or promote products derived from this software without
#    prior written permission. For permission or any other legal
#    details, please contact  
#      Office of Technology Transfer
#      Carnegie Mellon University
#      5000 Forbes Avenue
#      Pittsburgh, PA  15213-3890
#      (412) 268-4387, fax: (412) 268-7395
#      tech-transfer@andrew.cmu.edu
#
# 4. Redistributions of any form whatsoever must retain the following
#    acknowledgment:
#    "This product includes software developed by Computing Services
#     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
#
# CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# $Id: Makefile.in,v 1.62 2004/05/28 18:03:04 rjs3 Exp $

# Authorization namespace.
AUTH=auth_@WITH_AUTH@.o

# ACL interpretation.  Only one choice for now:
ACL=acl_afs.o

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@

CC = @CC@

INSTALL = @INSTALL@
RANLIB = @RANLIB@

DEFS = @DEFS@ @LOCALDEFS@
CPPFLAGS = -I.. @CPPFLAGS@ @COM_ERR_CPPFLAGS@ @SASLFLAGS@
LIBS = @LIBS@

MAKEDEPEND_CFLAGS = @CFLAGS@
CFLAGS = @CFLAGS@ @PERL_CCCDLFLAGS@
LDFLAGS = @LDFLAGS@

SHELL = /bin/sh
MAKEDEPEND = @MAKEDEPEND@

prefix = @prefix@
exec_prefix = @exec_prefix@
cyrus_prefix = @cyrus_prefix@

libdir = @libdir@

BUILTSOURCES = imapopts.h imapopts.c

LIBCYR_HDRS = $(srcdir)/acl.h $(srcdir)/assert.h $(srcdir)/auth.h \
	$(srcdir)/bsearch.h $(srcdir)/charset.h $(srcdir)/glob.h \
	$(srcdir)/gmtoff.h $(srcdir)/imclient.h $(srcdir)/imparse.h \
	$(srcdir)/lock.h $(srcdir)/map.h $(srcdir)/mkgmtime.h \
	$(srcdir)/nonblock.h $(srcdir)/parseaddr.h $(srcdir)/prot.h \
	$(srcdir)/retry.h $(srcdir)/sysexits.h $(srcdir)/strhash.h \
	$(srcdir)/lsort.h $(srcdir)/stristr.h \
	$(srcdir)/util.h $(srcdir)/xmalloc.h $(srcdir)/imapurl.h \
	$(srcdir)/cyrusdb.h $(srcdir)/iptostring.h $(srcdir)/rfc822date.h \
	$(srcdir)/libcyr_cfg.h

LIBCYR_OBJS = acl.o bsearch.o charset.o glob.o retry.o util.o \
	libcyr_cfg.o mkgmtime.o prot.o parseaddr.o imclient.o imparse.o \
	lsort.o stristr.o rfc822date.o cyrusdb.o strhash.o \
	chartable.o imapurl.o nonblock_@WITH_NONBLOCK@.o lock_@WITH_LOCK@.o \
	gmtoff_@WITH_GMTOFF@.o map_@WITH_MAP@.o $(ACL) $(AUTH) \
	@LIBOBJS@ @CYRUSDB_OBJS@ \
	iptostring.o xmalloc.o wildmat.o

LIBCYRM_HDRS = $(srcdir)/hash.h $(srcdir)/mpool.h $(srcdir)/xmalloc.h \
	$(srcdir)/strhash.o $(srcdir)/libconfig.h $(srcdir)/assert.h \
	imapopts.h
LIBCYRM_OBJS = libconfig.o imapopts.o hash.o mpool.o xmalloc.o strhash.o \
	assert.o @IPV6_OBJS@

all: $(BUILTSOURCES) libcyrus_min.a libcyrus.a

install:
	$(srcdir)/../install-sh -d $(DESTDIR)$(libdir)
	$(INSTALL) -m 644 libcyrus.a $(DESTDIR)$(libdir)
	$(INSTALL) -m 644 libcyrus_min.a $(DESTDIR)$(libdir)
	 $(RANLIB) $(DESTDIR)$(libdir)/libcyrus.a
	for file in $(LIBCYR_HDRS); \
	do \
		$(INSTALL) -m 644 $$file $(DESTDIR)$(prefix)/include/cyrus || exit 1; \
	done
	for file in $(LIBCYRM_HDRS); \
	do \
		$(INSTALL) -m 644 $$file $(DESTDIR)$(prefix)/include/cyrus || exit 1; \
	done

.c.o:
	$(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) \
	$<

libcyrus.a: $(LIBCYR_OBJS)
	rm -f libcyrus.a
	ar cr libcyrus.a $(LIBCYR_OBJS)
	$(RANLIB) libcyrus.a

libcyrus_min.a: $(LIBCYRM_OBJS)
	rm -f libcyrus_min.a
	ar cr libcyrus_min.a $(LIBCYRM_OBJS)
	$(RANLIB) libcyrus_min.a

imapopts.c: imapoptions $(srcdir)/../tools/config2header
	$(srcdir)/../tools/config2header CC=$(CC) $(srcdir)/imapopts.c $(srcdir)/imapopts.h < $(srcdir)/imapoptions

imapopts.h: imapopts.c

chartable.c: mkchartable 
	@echo "### Building chartables..."
	rm -f chartable.c
	./mkchartable \
	 -m $(srcdir)/charset/unifix.txt	\
	 -m $(srcdir)/charset/unidata2.txt \
	 $(srcdir)/charset/*.t \
	 > chartable.c \
	 || (rm -f chartable.c && exit 1)
	@echo "### Done building chartables."
#	./mkchartable -m $(srcdir)/charset/unicode.map $(srcdir)/charset/*.t >x-chartables.h
#	mv x-chartables.h chartables.h

mkchartable: mkchartable.o xmalloc.o assert.o
	$(CC) $(LDFLAGS) -o mkchartable mkchartable.o xmalloc.o assert.o

clean:
	rm -f *.o *.a chartable.c Makefile.bak mkchartable makedepend.log \
	$(BUILTSOURCES)

distclean: clean
	rm -f Makefile

depend:
	${MAKEDEPEND} $(CPPFLAGS) $(DEFS) -I$(srcdir) $(MAKEDEPEND_CFLAGS) *.c $(srcdir)/*.c 1>makedepend.log 2>&1

# DO NOT DELETE THIS LINE -- make depend depends on it.
