# Hey! Emacs, let's edit this file in -*- makefile -*- mode!
#
# This file is part of TUA.
#
# Makefile for "The Uucp Analyzer"
# lele@nautilus.sublink.org
#

SHELL =	/bin/sh

#### Start of system configuration section. ####

srcdir=@srcdir@
VPATH=@srcdir@

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

CC=@CC@ @DEFS@
YACC=@YACC@

prefix=/usr/local
exec_prefix=${prefix}
lib_prefix=${prefix}

# Where to install executables.
bindir=$(exec_prefix)/bin

# Where to install tua.pcd
libdir=${lib_prefix}/lib

# Extension for man pages.
manext=1

# Where to install man pages.
mandir=$(prefix)/man/man${manext}

# Where to install info file
infodir=${prefix}/info

# Set the options for the compiler and the linker
C_FLAGS = -O2 @MORE_CFLAGS@
LD_FLAGS = 

# GLOB ALIAS:
# Uncomment the next two definition if you want glob aliases on Users,
# Systems and Ports.
GLOB_ALIASES = -DGLOB_ALIASES
GLOB_ALIAS_STUFF = globalias.o wildmat.o

# TCL SUPPORT:
# If you have TCL - the "Tool Command Language" -, and you wanna be
# able to configure TUA at run-time using it, uncomment the next
# definitions and change the pathname of the TCL Library and Includes.
#
# Keep in mind that doing so the TUA binary will be three/four times
# bigger... ;-)
# TCL_INCLUDE_DIR = /usr/local/include
# TCL_SUPPORT = -DUSE_TCL -I$(TCL_INCLUDE_DIR)
# TCL_LIB = /usr/local/lib/libtcl.a
# TCL_STUFF = tcl_supp.o

# GNU Readline Library SUPPORT:
# If you have installed the GNU Readline Library, and you like the ability
# of editing the line while in Interactive Mode, uncomment the next
# definitions, and choose the correct terminfo/termcap library.
#
# Again, using this package will add about 100KB to the TUA binary...
#
# TERMCAP_LIB = -lcurses	 # SysV
# TERMCAP_LIB = -ltermcap # BSD
# READLINE_LIBS = /usr/local/lib/libreadline.a $(TERMCAP_LIB)
# READLINE_SUPPORT = -DUSE_READLINE
# READLINE_STUFF = readl_supp.o

# SoftChip Btree Library Support:
# If you like TUA use the more sophisticated binary tree library
# by Paul Sander <sander!paul@Atherton.COM>, uncomment the following
# definition. Of course, you must have already installed this library
# in order to TUA compiled.
#
# Again again, using this package TUA will be _maybe_ faster at sites with
# huge amounts of connection, but surely _fatter_ everywhere!
#
#SOFTCHIP_SUPPORT = -DUSE_SOFTCHIP_BTREE
#SOFTCHIP_LIB = /usr/local/lib/libbtree.a

LIBS = @LIBS@ $(TCL_LIB) $(READLINE_LIBS) ${SOFTCHIP_LIB} 
CFLAGS = $(C_FLAGS) $(GLOB_ALIASES) $(TCL_SUPPORT) $(READLINE_SUPPORT) \
	${SOFTCHIP_SUPPORT} -DLIBDIR=\"${libdir}\"
LDFLAGS = $(LD_FLAGS) 

HDB_O = procuucico.o procuucp.o procuux.o procuuxqt.o procxfer.o uucicolog.o xferentry.o
TAYLOR_O = log.o proclog.o procstats.o stats.o

OBJS = $(GLOB_ALIAS_STUFF) $(READLINE_STUFF) $(TCL_STUFF) ${HDB_O} ${TAYLOR_O} \
	@ALLOCA@ commtree.o compat.o daytree.o debug.o getopt.o julian.o \
	pcdl.o pcdl_gram.o phonesw.o portalias.o porttree.o process.o prochist.o \
	reports.o sysalias.o systree.o tmparse.o trees.o tua.o useralias.o usertree.o

HDB_S = hdb/ChangeLog hdb/Makefile \
	hdb/procuucico.c hdb/procuucp.c hdb/procuux.c hdb/procuuxqt.c \
	hdb/procxfer.c hdb/tua_4_hdb.h hdb/uucicolog.c hdb/xferentry.c 

TAYLOR_S = taylor/ChangeLog taylor/Makefile taylor/log.c \
	taylor/proclog.c taylor/procstats.c taylor/stats.c \
	taylor/tua_4_taylor.h

SOURCES = ansidecl.h commtree.c compat.c config.h.in customize.h daytree.c \
	debug.c debug.h getopt.c getopt.h globalias.h julian.c alloca.c \
	patchlevel.h pcdl.c pcdl.h pcdl_gram.y pcdl_gram.c phonesw.c \
	portalias.c porttree.c process.c prochist.c \
	globalias.c readl_supp.c reports.c sysalias.c systree.c tcl_supp.c \
	tmparse.c trees.c trees.h tua.c tua.h useralias.c usertree.c wildmat.c \
	${HDB_S} ${TAYLOR_S}

DOCS =	COPYING ChangeLog INSTALL MANIFEST PROJECTS README \
	doc/ChangeLog doc/Makefile doc/README doc/gpl.texinfo \
	doc/rluser.texinfo doc/tua.1l doc/tua.info doc/tua.man doc/tua.texinfo \
	doc/wildmat.3 

OTHERS = Makefile.in configure.in acconfig.h TUA_init.ex \
	taylor/TaylorLogsPatch.diff tua.pcd

SHARF = $(DOCS) $(SOURCES) ${OTHERS} TUA.tiff configure

all:	Makefile hdb_stuff taylor_stuff tua

.PHONY:	hdb_stuff
hdb_stuff:
	@echo "Compiling HDB Uucp related sources..."
	@( cd hdb; ${MAKE} CC="${CC}" CFLAGS="-I.. ${CFLAGS}" OBJS="${HDB_O}";)
	@echo

.PHONY:	taylor_stuff
taylor_stuff:
	@echo "compiling Taylor Uucp related sources..."
	@( cd taylor; ${MAKE} CC="${CC}" CFLAGS="-I.. ${CFLAGS}" OBJS="${TAYLOR_O}";)
	@echo
	@echo "and common ones..."

tua:	$(OBJS)
	@echo
	@echo "Linking..."
	$(CC) $(LDFLAGS) -o tua $(OBJS) $(LIBS)

.PHONY:	info
info:
	( cd doc; ${MAKE} tua.info)

.PHONY:	dvi
dvi:
	( cd doc; ${MAKE} tua.dvi)

.PHONY:	docs
docs:	info

.PHONY:	install
install: all docs
	${INSTALL_PROGRAM} tua ${bindir} 
	${INSTALL_DATA} doc/tua.info ${infodir}/tua.info
	${INSTALL_DATA} doc/tua.man ${mandir}/tua.${manext}
	${INSTALL_DATA} tua.pcd ${libdir}/tua.pcd

.PHONY:	check
check:	tua
	./tua

$(OBJS):	tua.h config.h customize.h
commtree.o daytree.o portalias.o porttree.o:	trees.h
process.o sysalias.o systree.o trees.o useralias.o usertree.o:	trees.h
portalias.o useralias.o sysalias.o globalias.o: globalias.h

.PHONY:	release
release:	dist
	@REL=`perl -ne 'print $$1 if /RELEASE.*"(.*)"/;' patchlevel.h`; \
	echo $$REL > .last_dist_version

.PHONY:	dist
dist:	manifest ${SHARF} 
	@REL=`perl -ne 'print $$1 if /RELEASE.*"(.*)"/;' patchlevel.h`; \
	rm -rf tua-$$REL; \
	mkdir tua-$$REL tua-$$REL/hdb tua-$$REL/taylor tua-$$REL/doc ;\
	for f in ${SHARF} ; do ln $$f tua-$$REL/$$f; done; \
	gtar cvzhf tua-$$REL.tar.gz tua-$$REL; \
	rm -rf tua-$$REL

.PHONY:	patch
patch:	manifest ${SHARF} 
	@if [ -z "$$LAST_REL" ]; then LAST_REL=`cat .last_dist_version`; fi; \
	REL=`perl -ne 'print $$1 if /RELEASE.*"(.*)"/;' patchlevel.h`; \
	if [ "$$LAST_REL" = "$$REL" ]; then \
	   echo "Must update patchlevel.h first!"; \
	else \
	   echo "Creating patch file from version $$LAST_REL to $$REL..."; \
	   rm -rf tua-$$REL tua-$$LAST_REL; \
	   mkdir tua-$$REL tua-$$REL/hdb tua-$$REL/taylor tua-$$REL/doc ;\
	   for f in ${SHARF} ; do ln $$f tua-$$REL/$$f; done; \
	   gtar -xzf ~/.BACKUPS/tua-$$LAST_REL.tar.gz; \
	   makepatch -newman tua-$$REL/MANIFEST -oldman tua-$$LAST_REL/MANIFEST tua-$$LAST_REL tua-$$REL > tua-$$LAST_REL-$$REL.patch; \
	   [ -f tua-$$LAST_REL-$$REL.patch ] && gzip tua-$$LAST_REL-$$REL.patch; \
	   rm -rf tua-$$REL tua-$$LAST_REL; \
	fi

.PHONY:	shar
shar:	manifest $(SHARF)
	@rm -f tua.shar.*
	@shar -c -o tua.shar -M -L50 $(SHARF)

doc/tua.1l: doc/tua.man
	@(cd doc; groff -Tascii -man tua.man > tua.1l)

doc/tua.info: doc/tua.texinfo
	@(cd doc; makeinfo --no-split tua.texinfo)

Makefile: Makefile.in config.status
	${SHELL} config.status

config.status: configure
	${SHELL} config.status --recheck

configure: configure.in
	autoconf

config.h.in: configure.in
	autoheader

.PHONY:	manifest
manifest:
	@rm -f MANIFEST
	@for f in ${SHARF} ; do echo $$f; done | sort > MANIFEST

.PHONY:	clean
clean:
	rm -f *.o core tua.shar.* tua *~ 
	(cd hdb; ${MAKE} clean)
	(cd doc; ${MAKE} clean)
	(cd taylor; ${MAKE} clean)

.PHONY:	distclean
distclean: clean
	rm -f config.h Makefile config.status config.tstamp TAGS pcdl_gram.c
	rm -f tua-*.tar.gz tua-*.patch tua-*.patch.gz
	(cd doc; ${MAKE} distclean)

TAGS:
	etags *.[ch]
	(cd hdb; ${MAKE} TAGS)
	(cd taylor; ${MAKE} TAGS)

pcdl_gram.c:	pcdl_gram.y
	${YACC} pcdl_gram.y
	mv y.tab.c pcdl_gram.c


syntax highlighted by Code2HTML, v. 0.9.1