# Makefile for cyrus library
# 
# @configure_input@
# 
# Copyright (c) 1994-2008 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 legal
#    details, please contact
#      Carnegie Mellon University
#      Center for Technology Transfer and Enterprise Creation
#      4615 Forbes Avenue
#      Suite 302
#      Pittsburgh, PA  15213
#      (412) 268-7393, fax: (412) 268-7395
#      innovation@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.77 2010/06/28 12:06:31 brong Exp $

# Authorization namespace.
AUTH=auth.o auth_krb.o auth_unix.o auth_krb5.o auth_pts.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)/cyr_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)/signals.h \
	$(srcdir)/util.h $(srcdir)/xstrlcpy.h $(srcdir)/xstrlcat.h \
	$(srcdir)/xmalloc.h $(srcdir)/imapurl.h \
	$(srcdir)/cyrusdb.h $(srcdir)/iptostring.h $(srcdir)/rfc822date.h \
	$(srcdir)/libcyr_cfg.h $(srcdir)/byteorder64.h \
	$(srcdir)/md5.h $(srcdir)/crc32.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 signals.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 byteorder64.o \
	xstrlcat.o xstrlcpy.o crc32.o

LIBCYRM_HDRS = $(srcdir)/hash.h $(srcdir)/mpool.h $(srcdir)/xmalloc.h \
	$(srcdir)/xstrlcat.h $(srcdir)/xstrlcpy.h $(srcdir)/util.h \
	$(srcdir)/strhash.h $(srcdir)/libconfig.h $(srcdir)/assert.h \
	imapopts.h $(srcdir)/crc32.h
LIBCYRM_OBJS = libconfig.o imapopts.o hash.o mpool.o xmalloc.o strhash.o \
	xstrlcat.o xstrlcpy.o assert.o util.o signals.o crc32.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.pl charset/*.t charset/unifix.txt charset/UnicodeData.txt
	@echo "### Building chartables..."
	rm -f chartable.c
	perl ./mkchartable.pl \
	 -m $(srcdir)/charset/unifix.txt \
	 -m $(srcdir)/charset/UnicodeData.txt \
	 $(srcdir)/charset/*.t \
	 > chartable.c \
	 || (rm -f chartable.c && exit 1)
	@echo "### Done building chartables."

clean:
	rm -f *.o *.a chartable.c Makefile.bak 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.
