#-
# Copyright (c)1996-2005 by Hartmut Brandt
# 	All rights reserved.
#
# Author: Harti Brandt <harti@freebsd.org>
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Begemot: libbegemot/Makefile.in,v 1.23 2005/06/01 07:50:27 brandt_h Exp $
#

@SET_MAKE@

VPATH	= @srcdir@
prefix	= @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
mandir = @mandir@
srcdir	= @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@

# There is a problem with autoconf, libtool and cygwin. Autoconf defines
# top_builddir with trailing slashes or (in the top directory to be empty).
# AM_PROG_LIBTOOL generates a libtool macro that references
# $(top_builddir)/libtool. This is wrong because this should be
# $(top_builddir)libtool. But this fails on cygwin, because cygwin seems
# to have a libtool somewhere in the path. So fix the empty top_builddir
# here and ignore the extra slashes.
ifeq "$(top_builddir)" ""
top_builddir += ./
endif

INSTALL	= @INSTALL@
INSTALL_PROG = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

LIBTOOL = @LIBTOOL@

MKINSTALLDIRS = $(top_srcdir)/config/mkinstalldirs

CC	= @CC@
CFLAGS	= @CFLAGS@
LDFLAGS	= @LDFLAGS@
DEFS	= @DEFS@

BEGEMOT_MAJOR = @BEGEMOT_MAJOR@
BEGEMOT_MINOR = @BEGEMOT_MINOR@

# manual section suffix. If you change this, you must also change the
# section prefixes in the man files also.
MSECT = l

# source files
SRC =	panic.c xalloc.c xrealloc.c prstat.c strsave.c xstrsave.c warn.c \
	readline.c error.c cstrc.c cstrd.c getfields.c strnlen.c bug.c \
	inform.c strtrimsp.c _common_err.c rpoll.c frame.c verb.c xfree.c \
	strnchr.c
MSRC =	intro Intro panic xalloc xrealloc prstat strsave xstrsave warn \
	readline error geterrorcnt getwarncnt cstrc cstrd getfields getmfields \
	setfields strnlen bug inform strtrimsp set_errmode rpoll poll_register \
	poll_unregister poll_start_timer poll_stop_timer poll_dispatch \
	frame frame_read frame_write framefd_read framefd_write verb xfree \
	strnchr

# library name
LIB = libbegemot.la

# include files to install
HDR =
LHDR = rpoll.h begemot.h

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

WARN += -Wall -W -Wshadow -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -g -I. -I$(srcdir) $(DEFS) $(WARN) -Wp,-MD,.deps/$(*F).d
LDFLAGS += -g

OBJ = $(SRC:.c=.lo)
DEPS = $(SRC:%.c=.deps/%.d)

SYSLIBS = @SYSLIBS@

all: $(LIB)

$(LIB) : $(OBJ)
	$(LIBTOOL) --mode=link $(CC) $(LDLAGS) -o $@ $(OBJ) -rpath $(exec_prefix)/lib -version-info ${BEGEMOT_MAJOR}:${BEGEMOT_MINOR} $(SYSLIBS)

.SUFFIXES: .lo
.c.lo:
	@test -d .deps || mkdir .deps >/dev/null 2>&1
	$(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) -o $@ $<

install:
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)
	$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(MSECT)

	$(LIBTOOL) --mode=install $(BSD_INSTALL_DATA) $(LIB) $(DESTDIR)$(libdir)

#	for file in $(HDR) ; do \
#		$(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(includedir) ;\
#	done
	for file in $(LHDR) ; do \
		$(BSD_INSTALL_DATA) $$file $(DESTDIR)$(includedir) ;\
	done
#	for file in $(MSRC) ; do \
#		$(INSTALL_DATA) $(srcdir)/$$file.man $(DESTDIR)$(mandir)/man$(MSECT)/$$file.$(MSECT) ;\
#	done

clean:
	-rm -f *.o *.lo *.la *.core core *~ .depend polltest stattest frame verbtest
	-rm -rf .libs .deps

distclean: clean
	-rm -f config.cache config.log config.status Makefile libtool
	-rm -f begemot.h rpoll.h
	-rm -rf autom4te.cache

veryclean: distclean
	-rm -f configure aclocal.m4

tests: polltest stattest verbtest frame

polltest:
	$(LIBTOOL) --mode=link $(CC) -o polltest $(CFLAGS) -DTESTME $(srcdir)/rpoll.c libbegemot.la

stattest:
	$(LIBTOOL) --mode=link $(CC) -o stattest $(CFLAGS) -DTEST $(srcdir)/prstat.c libbegemot.la

verbtest:
	$(LIBTOOL) --mode=link $(CC) -o verbtest $(CFLAGS) -DTEST $(srcdir)/verb.c libbegemot.la

frame:
	$(LIBTOOL) --mode=link $(CC) -o frame $(CFLAGS) -DTEST $(srcdir)/frame.c libbegemot.la

LIBTOOL_DEPS = @LIBTOOL_DEPS@
$(LIBTOOL): $(LIBTOOL_DEPS)
	$(SHELL) ./config.status --recheck

-include $(DEPS)

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

dist:
	@( set -e -x ; \
	  version=`cat VERSION` ; \
	  mkdir /tmp/libbegemot-$$version ; \
	  cp -Rp . /tmp/libbegemot-$$version ; \
	  cd /tmp/libbegemot-$$version ; \
	  find . -name CVS -type d | xargs rm -rf ; \
	  rm -f conf ; \
	  aclocal ; \
	  autoconf ; \
	  gmake distclean ; \
	  cd /tmp ; \
	  tar cvf - libbegemot-$$version | gzip -v9 >libbegemot-$$version.tar.gz )

cvs-stat:
	cvs status `find . -type f | grep -v CVS` | grep Status | grep -v Up-to


syntax highlighted by Code2HTML, v. 0.9.1