# IRC II - written by Michael Sandrof
# Copyright (c) 1991 - All Rights Reserved

# Full path and name of installed irc program
# 'make install' will compile and install the program
INSTALL_EXECUTABLE = /usr/local/bin/ircII

# Full path of the directory where the ircII library resides
# It should contain the script directory, the help
# directory, if you want it, and the other files.
# 'make installscript' will copy the scripts into it.
IRCII_LIBRARY = /usr/local/irc/lib

# Set the next line to the full path for installation of the ircserv program
# if you wish to use it. 
INSTALL_IRCSERV = /usr/local/bin/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 = /usr/local/bin/ircflush

# This program allows you to use screen/xterm's to put new irc windows
# on new screen/xterm windows.
INSTALL_WSERV = /usr/local/bin/wserv

# 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_DEFS = -DPRIV_PORT=667
# PP_OBJS = file.o
# PP_DEFS = -DPRIV_PORT_ULC

# Below are system specific setups.
# If your system is not included in the lines below, do some experimenting
# with the DEFINES 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
# (Xenix, AIX RT, some low end suns, 386BSD, linux and anything else
# based on the Intel 80x86 range of chips) 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 setup if you're using TERM, and want to use the internal TERM
# functions to handle sockets (i.e., you don't need to use tredir).
# YOU NEED TO EDIT THE PATH OF 'TERMDIR' TO THE CORRECT PATH IN ORDER FOR IT 
# TO WORK!
# If you don't want term to compress the server traffic, then take out the
# -DTERM_COMPRESS_ON.
TERMDIR = ../term
CFLAGS = -O6 -I- -I. -I${TERMDIR} 
LIBS = -ltermcap ${TERMDIR}/client.a
CC = gcc
DEFINES = -DTERM -DTERM_COMPRESS_ON

# This is the default setup that should work for BSD and similar systems.
# This also works for LINUX and for 386BSD.
# The BSD defaults should now work correctly with ULTRIX systems.
# LIBS = -ltermcap
# CC = cc
# DEFINES = 

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

# For Solaris 2 systems, use
# LIBS = -lsocket -lnsl -lelf -L/usr/ucblib -ltermcap -lucb
# CC = cc
# DEFINES = -DSVR4 -DSOLARIS

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

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

# For AIX/370 V1.0 use:
# LIBS = -lcurses -lbsd
# Some old AIX 370 systems can't grok '-DXA370 -Hxa' so you may have to
#  remove these.
# DEFINES = -D_BSD -DXA370 -DBROKEN_SCANF -Hxa
# Use this if you AIX370 does not have a broken implimentation of scanf()
# DEFINES = -D_BSD -DXA370 -Hxa

# Use the following set up for HPUX 8.0 systems
# (I'm told that hpux 8.0 has a buggy libmalloc)
# LIBS = -lcurses # -lmalloc
# DEFINES = -DHPUX

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

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

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

# For SGI Irix systems:
# DEFINES = -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
# DEFINES = -DMUNIX -D_AUX_SOURCE -I/usr/include/bsd

# For the ISC22 system:
# DEFINES = -DISC22 -D_AUX_SOURCE

# For Tektronix XD88:
# DEFINES = -DXD88 -D_AUX_SOURCE
# LIBS = -ltermcap

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

# Use the following for sysV and termio systems:
# DEFINES = -D_AUX_SOURCE

# Use the following for Sequent PTX or POSIX Complient Machines:
# CC = cc
# DEFINES= -DPOSIX -D_AUX_SOURCE
# LIBS= -lsocket -linet -lnsl -L/usr/local/lib -lbsd -lseq -lcurses

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

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

# 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 = ${IRCII_LIBRARY}/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 = ${IRCII_LIBRARY}/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_LOAD_PATH = .:~/.irc:${INSTALL_SCRIPT}

# Path for TRANSLATION variable.
TRANSLATION_PATH = ${IRCII_LIBRARY}/translation

# 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 = -g

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

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

RM = rm -f
CP = cp
LN = ln -s
CHMOD = chmod 755

all: source/Makefile
	cd source; make
	
installeverything: install installflush installserv installwserv \
	installscript installtranslation

everything: all ircflush ircserv wserv

source/Makefile: source/Makefile.proto Makefile
	@${RM} source/Makefile
	sed -e 's;INSTALL_NAME_PROTO;${INSTALL_EXECUTABLE};'\
	    -e 's;LIBS_PROTO;${LIBS};'\
	    -e 's;CFLAGS_PROTO;${CFLAGS};'\
	    -e 's;LDFLAGS_PROTO;${LDFLAGS};'\
	    -e 's;RM_PROTO;${RM};'\
	    -e 's;CP_PROTO;${CP};'\
	    -e 's;LN_PROTO;${LN};'\
	    -e 's;CC_PROTO;${CC};'\
	    -e 's;DEFINES_PROTO;${DEFINES};'\
	    -e 's;IRCLIB_PROTO;${IRCII_LIBRARY};'\
	    -e 's;IRCPATH_PROTO;${IRC_LOAD_PATH};'\
	    -e 's;CHMOD_PROTO;${CHMOD};'\
	    -e 's;HELP_PROTO;${HELP_DIR};' \
	    -e 's;INSTALL_IRCSERV_PROTO;${INSTALL_IRCSERV};'\
	    -e 's;INSTALL_WSERV_PROTO;${INSTALL_WSERV};'\
	    -e 's;TRANSLATION_PROTO;${TRANSLATION_PATH};'\
	    -e 's;PP_DEFS_PROTO;${PP_DEFS};'\
	    -e 's;PP_OBJS_PROTO;${PP_OBJS};'\
	    -e 's;PPS_DEFS_PROTO;${PPS_DEFS};'\
	 	source/Makefile.proto > source/Makefile 

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

install: all
	${CP} source/irc ${INSTALL_EXECUTABLE}
	@${CHMOD} ${INSTALL_EXECUTABLE}

installscript:
	-mkdir ${INSTALL_SCRIPT}
	chmod -x script/*
	-cp ${INSTALL_SCRIPT}/local script
	cp script/* ${INSTALL_SCRIPT}
	chmod 644 ${INSTALL_SCRIPT}/*

installtranslation:
	-mkdir ${TRANSLATION_PATH}
	chmod -x translation/*
	cp translation/* ${TRANSLATION_PATH}
	chmod 644 ${TRANSLATION_PATH}/*

installserv: ircserv
	${CP} source/ircserv ${INSTALL_IRCSERV}
	@${CHMOD} ${INSTALL_IRCSERV}

installflush: ircflush
	${CP} source/ircflush ${INSTALL_IRCFLUSH}
	@${CHMOD} ${INSTALL_IRCFLUSH}

installwserv: wserv
	${CP} source/wserv ${INSTALL_WSERV}
	@${CHMOD} ${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.

clean:
	@if [ -f source/Makefile ]; then cd source; make clean; fi

lint:
	@if [ -f source/Makefile ]; then cd source; make lint; fi

dist: clean
	mv config.h ..
	mv config.h.orig config.h
	( PWD=`pwd`; VERSION_DIR=`basename ${PWD}`; cd ..; tar cf ${VERSION_DIR}.tar $VERSION_DIR; compress $VERSION_DIR.tar; )
	mv config.h config.h.orig
	mv ../config.h .
