# $Id: Makefile.am,v 1.17 2003/08/19 07:22:22 crosser Exp $
 
# $Log: Makefile.am,v $
# Revision 1.17  2003/08/19 07:22:22  crosser
# clean autogenerated .c files
#
# Revision 1.16  2003/08/14 12:50:31  crosser
# Memory leak in the client code (ilya@glas.net)
# Changes to recent autoconf/automake (woods@weird.com)
# use pidfile() if it exists (woods@weird.com)
#
# Revision 1.15  2001/09/23 12:42:10  crosser
# cleaner security warnings
# More preport ChangeLog dependency (I hope)
#
# Revision 1.14  2001/07/20 08:50:13  crosser
# dependency for ChangeLog
#
# Revision 1.13  2001/07/20 08:47:15  crosser
# run cvs2cl
# change version
# unixd params
#
# Revision 1.12  2001/05/28 21:43:25  crosser
# tune .cvsignore, provision for ChangeLog
#
# Revision 1.11  2000/03/28 20:44:00  crosser
# build Makefile.PL for the perl5 module by configure
#
# Revision 1.10  1999/11/26 17:18:57  crosser
# tune for sunos4
#
# Revision 1.9  1999/10/03 21:18:03  crosser
# First (probably) working version with new run time config parser.
# Also added listenq parameter (backlog size for listen()) and
# renamed wtest to whoson (and with man page).  Release 2.00beta1.
#
# Revision 1.8  1999/08/30 14:21:40  crosser
# Make shared library
#
# Revision 1.7  1999/08/19 17:58:14  crosser
# Mention new files in Makefile.am
#
# Revision 1.6  1999/08/19 17:22:13  crosser
# Move to new config scheme (does not work yet)
#
# Revision 1.5  1999/08/04 21:08:10  crosser
# Add hooks to install and uninstall
#
# Revision 1.4  1999/08/03 07:21:01  crosser
# add options to Makefile
#
# Revision 1.3  1999/07/30 23:25:09  crosser
# Automakifying clenups
#
# Revision 1.2  1999/07/27 17:14:59  crosser
# cleaning
#
# Revision 1.1  1999/07/27 16:49:13  crosser
# Initial revision
#

AUTOMAKE_OPTIONS = foreign

sbin_PROGRAMS = whosond whoson
lib_LTLIBRARIES = libwhoson.la
include_HEADERS = whoson.h
man_MANS = whoson.conf.5 whoson.3 whoson.8 whosond.8

## Documentation says that you can inlcude directories in EXTRA_DIST
## but this is not true.  If you do that, "make dist" fails because
## "distdir" target depends on the dir object and cannot create it.
## Or somesuch.  Anyway, it does not work.  So, include all files.
EXTRA_DIST = whoson.ms whoson.txt fix.pl whoson.conf $(man_MANS) \
		WHOSON/Changes WHOSON/MANIFEST WHOSON/Makefile.PL.in \
		WHOSON/WHOSON.pm WHOSON/WHOSON.xs WHOSON/test.pl \
		ChangeLog

noinst_HEADERS = whosond.h report.h serv_common.h lhash.h checkperm.h \
			rtconfig.h rtc_begin.h rtc_middle.h rtc_end.h \
			serv_tcp_cfg.h serv_unix_cfg.h serv_unixd_cfg.h \
			serv_udp_cfg.h serv_common_cfg.h clnt_common.h \
			clnt_udp_cfg.h clnt_unixd_cfg.h clnt_tcp_cfg.h \
			clnt_unix_cfg.h getopt.h

whoson_SOURCES = whoson.c
whoson_LDADD = $(lib_LTLIBRARIES)
whoson_LDFLAGS = -static

whosond_SOURCES = whosond.c mainloop.c servlist.c lhash.c serv_common.c
EXTRA_whosond_SOURCES = serv_tcp.c serv_unix.c serv_unixd.c serv_udp.c
whosond_LDADD = $(lib_LTLIBRARIES) @LIBOBJS@ @SERV_CONN_OBJ@
## Documentation days that dependencies are created automatically from
## LDADD but this is not true.  So we have to specify then explicitely.
## The same for LIBADD below.
whosond_DEPENDENCIES = @SERV_CONN_OBJ@

libwhoson_la_SOURCES = clnt_common.c rtconfig.c clntlist.c checkperm.c
EXTRA_libwhoson_la_SOURCES = clnt_tcp.c clnt_unix.c clnt_unixd.c clnt_udp.c
libwhoson_la_LIBADD = @CLNT_CONN_OBJ@
libwhoson_la_DEPENDENCIES = @CLNT_CONN_OBJ@
libwhoson_la_LDFLAGS = -version-info 0:0:0

MAN3XTRA = wso_version.3 wso_login.3 wso_logout.3 wso_query.3

CLEANFILES = clntlist.c servlist.c

install-data-hook:
	if test -f $(DEFAULT_CONFIG); then \
		$(ECHO) "$(DEFAULT_CONFIG) exists, not overwritten"; \
	else \
		$(INSTALL_DATA) $(srcdir)/whoson.conf $(DEFAULT_CONFIG); \
	fi; \
	for f in $(MAN3XTRA); do \
		rm -f $(DESTDIR)$(man3dir)/$$f; \
		$(LN) $(DESTDIR)$(man3dir)/whoson.3 $(DESTDIR)$(man3dir)/$$f; \
	done

uninstall-local:
	rm -f $(DEFAULT_CONFIG); \
	for f in $(MAN3XTRA); do \
		rm -f $(DESTDIR)$(man3dir)/$$f; \
	done

whoson.txt: whoson.ms
	${NROFF} -ms ${srcdir}/whoson.ms | ${PERL} ${srcdir}/fix.pl >whoson.txt

servlist.c: Makefile
	( \
		echo '#include "sys/types.h"'; \
		echo '#include "whosond.h"'; \
		echo '#include "rtconfig.h"'; \
		echo ""; \
		for f in @CONNECTORS@; do \
			echo "extern struct _cfgdesc desc_wso_serv_$${f}_cfg;"; \
			echo "extern struct _evdesc $${f}_serv_init(void *priv);"; \
			echo ""; \
		done; \
		echo "extern struct _cfgdesc desc_wso_serv_global_cfg;"; \
		echo "extern struct _evdesc global_serv_init(void *priv);"; \
		echo ""; \
		echo ""; \
		echo "struct _cfgrec wso_cfglist[] = {"; \
		for f in @CONNECTORS@; do \
			echo "	{\"$$f\",&desc_wso_serv_$${f}_cfg,{$${f}_serv_init}},"; \
		done; \
		echo "	{\"global\",&desc_wso_serv_global_cfg,{global_serv_init}},"; \
		echo "	{(void*)0,(void*)0,{(void*)0}}"; \
		echo "};"; \
	) >servlist.c

clntlist.c: Makefile
	( \
		echo '#include "sys/types.h"'; \
		echo '#include "whosond.h"'; \
		echo '#include "rtconfig.h"'; \
		echo ""; \
		for f in @CONNECTORS@; do \
			echo "extern struct _cfgdesc desc_wso_clnt_$${f}_cfg;"; \
			echo "extern struct _evdesc wso_$${f}_clnt_connect(void *priv);"; \
			echo ""; \
		done; \
		echo ""; \
		echo "struct _cfgrec wso_cfglist[] = {"; \
		for f in @CONNECTORS@; do \
			echo "	{\"$$f\",&desc_wso_clnt_$${f}_cfg,{wso_$${f}_clnt_connect}},"; \
		done; \
		echo "	{(void*)0,(void*)0,{(void*)0}}"; \
		echo "};"; \
	) >clntlist.c

# This leads to circular dependency.  Fortunately this is not a problem
# at least for GNU make, and this target is only used for "make dist".
# Let me know if it causes troubles for you.
ChangeLog: $(DISTFILES)
	$(CVS2CL)


syntax highlighted by Code2HTML, v. 0.9.1