# IRC II - written by Michael Sandrof
# Copyright (c) 1991 - All Rights Reserved
# Modified by Matthew Green, 1993.
#
# @(#)$Id: Makefile.in,v 1.22 1994/10/15 03:04:50 mrg Stab $

# targets recognised by this makefile:
#   all, everything	- compiles ircii, ircserv, ircflush and wserv
#   ircserv		- compiles ircserv
#   ircflush		- compiles ircflush
#   wserv		- compiles wserv
#   install		- installs ircii, ircserv, ircflush and wserv the scripts
#			  and the translation tables.
#   installirc		- installs ircii
#   installserv		- installs ircserv
#   installwserv	- installs wserv
#   installflush	- installs ircflush
#   installscript 	- installs the scripts
#   installtranslation	- installs the translation tables
#   installeverything   - all of the above
#   clean               - remove all .o files, core, and binaries
#   disclean            - remove all files geneated by compilation/installation.

prefix = /usr/local
exec_prefix = $(prefix)
bindir = @bindir@

# Where the ircII binary will be installed.
# 'make install' will compile and install the program
INSTALL_IRC = $(bindir)/irc

# Where the ircII library will be.  Generally this is the place that
# you put the scripts, help pages and translation tables.  It is
# very important that you set this correctly.
IRCLIB = @IRCLIB@

# Set this to the lex you want to use, and if they lex uses a library.

LEX = @LEX@
LEXLIB = @LEXLIB@

CC = @CC@
DEFS = @DEFS@
LIBS = @LIBS@

# Set this to -g if you want to be able to debug the client, otherwise
# use -O to have the compiler do some optimization instead.
CFLAGS = -O

# Uncomment this if you want the binary to be striped.
# LDFLAGS = -s

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                                   #
#  this section should now be obsolete with gnu autoconf stuff...   #
#                                                                   #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Below are system specific setups.
# If your system is not included in the lines below, do some experimenting
# with the DEFS and program code, then if you happen to make it work
# properly, mail about the changes you had to make, include system type
# and version, so it can be included into ircII distribution.

# Note that if you are using a machine with a segmented architecture you will
# need to compile in the large or huge memory model. This is not included
# in the flags below, so you'll need to check the manual entry for cc
# to find out and insert them below.

# This is the default setup that should work for BSD and similar systems.
# This means, SunOS (if there is a real resolver in libc), Ultrix, Linux,
# 386BSD (duh), OSF/1, Dynix (not Dynix/ptx).

# LIBS = -ltermcap
# CC = cc
# DEFS = 

# For sunos systems, use
# LIBS = -ltermcap -lresolv
# CC = cc
# DEFS =

# For Solaris 2 systems, use
# LIBS = -lsocket -lnsl -lelf -ltermcap
# CC = cc
# DEFS = -DSVR4 -DSOLARIS

# For DG/UX Aviion machines, use
# LIBS = -lcurses -ldgc -lnsl
# DEFS = -DHAVE_STRING_H

# For IBM RS6000 systems running AIX 3.1 or 3.2, the following will work
# LIBS = -lcurses
# CC = c89 -D_ALL_SOURCE
# DEFS = -DPOSIX

# For IBM RTs running AIX 2.2.1, use the following:
# LIBS = -lcurses
# DEFS = -D_RT -DUSE_TERMIO -DBSD_INCLUDES

# For AIX/370 V1.0 use:
# LIBS = -lcurses
# DEFS = -D_BSD -DAIX_370

# For HP/UX 80 and 9.0,
# LIBS = -lcurses

# For HPUX 7.0 systems:
# LIBS = -lcurses -lBSD -lPW
# DEFS = -DHPUX -DHPUX70

# For Apollo systems (10.2 and upwards) use the following with BSD defaults:
# DEFS = -Asys,bsd4.3

# Use one of the following for mips systems:
# Choice 1, if your system has the wait3() call
# DEFS = -systype bsd43
# Choice 2, if your system has the wait2() call
# DEFS = -systype bsd43 -Duse_wait2
#
# Or, if you only have sysv installed, use one of the following:
# DEFS = -DMIPS_SYSV
# DEFS = -DMIPS_SYSV -Duse_wait2

# For SGI Irix systems:
# DEFS = -I/usr/include/bsd
# Use the following for SGI Irix systems not running Yellow Pages
# LIBS = -lcurses -lPW -lbsd -lc
# Use the following for SGI Irix systems running Yellow Pages
# LIBS = -lsun -lcurses -lPW -lbsd -lc

# Use the following for MUNIX systems:
# LIBS = -lcurses -lresolv -lbsd -lc
# DEFS = -DMUNIX -DUSE_TERMIO -I/usr/include/bsd

# For the ISC22 system:
# DEFS = -DISC22 -DUSE_TERMIO

# for ISC 3.0 systems,
# DEFS = -DISC30 -UBSDWAIT

# For Tektronix XD88:
# DEFS = -DXD88 -DUSE_TERMIO
# LIBS = -ltermcap

# For Dell System V Release 4
# DEFS= -DSVR4
# LIBS= -lsocket -lnsl -lxtermcap
# SHELL= /bin/sh

# Use the following for sysV and termio systems:
# DEFS = -DUSE_TERMIO
# LIBS = -lcurses

# Use the following for Sequent PTX or POSIX Complient Machines:
# CC = cc
# DEFS= -DDYNIXPTX
# LIBS= -lsocket -linet -lnsl -lseq -lcurses

# Use the following for SCO Unix 3.2v4.0 and ODT/2.0
# CC = cc -quiet
# DEFS = -DSCO -DUSE_TERMIO
# LIBS = -lsocket -ltermcap

# Use the following for NeXT, running NeXTstep 3.0.
# CC = cc
# LIBS = -ltermcap
# DEFS = -DNeXT -bsd

# Use the following for Cray UNICOS systems.
# CC = cc
# LIBS = 
# DEFS = -DUNICOS

## You probably don't need to change anything below this line

# Uncomment the following if you want a secure IRC which binds to a
# privileged port. This feature is completely useless in the current
# IRC environment, but in the future some servers may use privileged
# port systems to verify users connecting to them. The value of
# PRIV_PORT determines the minimum port number to use.
# If you modify these (including uncommenting them) you will need to
# touch config.h
#
# If you are on a system where test-suid works, you can simply define
# PP_DEFS to be PRIV_PORT_ULC and irc will change effective UID back
# to a normal user immediately, and change to root when binding a port.
# This feature is undocumented, but is known to work on Sun, MIPS and
# Apollo (Cos we've tested them already).
# PP_DEFINES = -DPRIV_PORT=667
# PP_OBJS = file.o
# PP_DEFINES = -DPRIV_PORT_ULC

# Full path of the directory for ircII help files.  
# The help files are not within the source distribution, if you don't have
# them and want them, check out your nearest ircII archive.
# You may comment HELP_DIR, then the ircIIhelp service will be used.
# If you don't comment it out and want to use the IRCIIHelp service anyway,
# you must make sure that the directory doesn't exist.
HELP_DIR = $(IRCLIB)/help

# Full path of the directory in which to copy the
# IRCII scripts supplied with the code.  These scripts
# may be loaded by using the LOAD command in IRCII.
INSTALL_SCRIPT = $(IRCLIB)/script

# Default setting for IRC_PATH where irc will look for
# its script files if the environment variable is undefined.
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
# the Makefile, but it can contain multiple path elements
# separated by colons. The path MUST lead to an existing directory,
# because the 'global' script is expected to be found there.
IRC_PATH = ~/.irc:$(INSTALL_SCRIPT):.

# Path for TRANSLATION variable.
TRANS_PATH = $(IRCLIB)/translation

# Set the next line to the full path for installation of the ircserv program
# if you wish to use it. 
INSTALL_IRCSERV = $(bindir)/ircserv

# This little program is necessary to have an interactive shell
# in a window of ircII. The 'shell' script uses it, so also update
# the path in there, if you want to enable this.
INSTALL_IRCFLUSH = $(bindir)/ircflush

# This program allows you to use screen/xterm's to put new irc windows
# on new screen/xterm windows.
INSTALL_WSERV = $(bindir)/wserv

## You shouldn't have to change anything below here

srcdir = .

RM = rm -f
LN = ln -s
CP = cp
MV = mv
INSTALL = ./bsdinstall -c -m 755
INSTALL_DATA = ../bsdinstall -c -m 644

VERSION = @VERSION@

SHELL = /bin/sh
MAKE = make $(MFLAGS)
MFLAGS ='CC=$(CC)'					\
	'CFLAGS=$(CFLAGS)'				\
	'DEFS=$(DEFS)'					\
	'HELP_DIR=$(HELP_DIR)'				\
	'INSTALL_IRC=$(INSTALL_IRC)'			\
	'INSTALL_IRCSERV=$(INSTALL_IRCSERV)'		\
	'INSTALL_WSERV=$(INSTALL_WSERV)'		\
	'IRCLIB=$(IRCLIB)'				\
	'IRCPATH=$(IRC_PATH)'				\
	'LDFLAGS=$(LDFLAGS)'				\
	'LEX=$(LEX)'					\
	'LEXLIB=$(LEXLIB)'				\
	'LIBS=$(LIBS)'					\
	'LN=$(LN)'					\
	'PP_DEFS=$(PP_DEFS)'				\
	'PP_OBJS=$(PP_OBJS)'				\
	'PPS_DEFS=$(PPS_DEFS)'				\
	'RM=$(RM)'					\
	'TRANS_DIR=$(TRANS_PATH)'

all: irc ircserv ircflush wserv

install: all installbin installscript installtranslation

irc: source/Makefile Makefile
	@cd source; $(MAKE) all

installeverything: install installflush installserv installwserv \
	installscript installtranslation

everything: all ircflush ircserv wserv

ircserv: source/Makefile
	@cd source; $(MAKE) ircserv

ircflush: source/ircflush.c source/Makefile
	@cd source; $(MAKE) ircflush

wserv: source/wserv.c source/term.c source/Makefile
	@cd source; $(MAKE) wserv

installbin: installirc installserv installflush installwserv

installirc: irc installdirs
	$(INSTALL) source/irc $(INSTALL_IRC)-$(VERSION)
	@if test -f $(INSTALL_IRC).old; then $(RM) $(INSTALL_IRC).old; fi
	@if test -f $(INSTALL_IRC); then $(MV) $(INSTALL_IRC) $(INSTALL_IRC).old; fi
	$(RM) $(INSTALL_IRC)
	$(LN) $(INSTALL_IRC)-$(VERSION) $(INSTALL_IRC)

installscript: installdirs
	-chmod -x script/*
	-@(								\
		if test -f $(INSTALL_SCRIPT)/local; then		\
			if test -f script/local; then 			\
				$(MV) script/local script/local.orig;	\
			fi;						\
		fi							\
	)
	cd script; for i in *; do $(INSTALL_DATA) $$i $(INSTALL_SCRIPT); done

installtranslation: installdirs
	-chmod -x translation/*
	cd translation; for i in *; do $(INSTALL_DATA) $$i $(TRANS_PATH); done

installserv: ircserv installdirs
	$(INSTALL) source/ircserv $(INSTALL_IRCSERV)

installflush: ircflush installdirs
	$(INSTALL) source/ircflush $(INSTALL_IRCFLUSH)

installwserv: wserv installdirs
	$(INSTALL) source/wserv $(INSTALL_WSERV)

installhelp:
	@echo Help files are no more within this package.  You
	@echo can probably get them from the same place you got
	@echo this source from.

installdirs:
	@-if test ! -d $(IRCLIB); then mkdir -p $(IRCLIB); chmod go+rx $(IRCLIB); fi
	@-if test ! -d $(bindir); then mkdir -p $(bindir); chmod go+rx $(bindir); fi
	@-if test ! -d $(TRANS_PATH); then mkdir -p $(TRANS_PATH); chmod go+rx $(TRANS_PATH); fi
	@-if test ! -d $(INSTALL_SCRIPT); then mkdir -p $(INSTALL_SCRIPT); chmod go+rx $(INSTALL_SCRIPT); fi

clena: clean
clean:
	@-if test -f source/Makefile; then cd source; $(MAKE) clean; fi

distclean: clean
	$(RM) Makefile source/Makefile source/sig.inc config.status easyinst.status include/defs.h

lint:
	@if test -f source/Makefile; then cd source; $(MAKE) lint; fi

dist: distclean
	( 								\
		cd ..;							\
		tar --exclude RCS -z -c -f ircii-$(VERSION).tar.z ircii-$(VERSION);	\
	)
