# IRC II
# Written by Michael Sandrof (ms5n+@andrew.cmu.edu)
# Copyright (c) 1990
# All Rights Reserved

# The following _PROTO names are modified by sed from ../Makefile 

LIBS = -ltermcap /usr/tools/socks/0/lib/libsocks.a -lresolv
INSTALL_NAME = /usr/tools/irc/2.2.9/bin/ircII
HELP_DIR = /usr/tools/irc/2.2.9/lib/help
INSTALL_IRCSERV = /usr/tools/irc/2.2.9/bin/ircserv
INSTALL_WSERV = /usr/tools/irc/2.2.9/bin/wserv
CFLAGS = -g
LDFLAGS = 
RM = rm -f
CP = cp
LN = ln -s
CC = cc
MV = mv -f
LEX = lex
LEXLIB = -ll
CHMOD = chmod 755
IRCLIB = /usr/tools/irc/2.2.9/lib
IRCPATH = .:~/.irc:/usr/tools/irc/2.2.9/lib/script
DEFINES = -DSOCKS
TRANSLATION_PATH = /usr/tools/irc/2.2.9/lib/translation
PP_DEFS = 
PP_OBJS = 
PPS_DEFS = 


OBJECTS = alias.o crypt.o ctcp.o dcc.o edit.o exec.o flood.o funny.o help.o\
	history.o hold.o hook.o if.o ignore.o input.o irc.o ircaux.o keys.o\
	lastlog.o list.o log.o mail.o menu.o names.o newio.o notice.o notify.o\
	numbers.o output.o parse.o reg.o scandir.o screen.o server.o status.o\
	term.o translat.o vars.o whois.o window.o ${PP_OBJS}

SOURCES = alias.c crypt.c ctcp.c dcc.c edit.c exec.c flood.c funny.c help.c\
	history.c hold.c hook.c if.c ignore.c input.c irc.c ircaux.c keys.c\
	lastlog.c list.c log.c mail.c menu.c names.c newio.c notice.c notify.c\
	numbers.c output.c parse.c reg.c scandir.c server.c screen.c status.c\
	term.c translat.c vars.c whois.c window.c

IRCSERV_OBJECTS = ircserv.o

IRCSERV_SOURCES = ircserv.c

WSERV_OBJECTS = wserv.o wterm.o

WSERV_SOURCES = wserv.c term.c

all: irc

# got I hate typos.
clena: clean
.c.o:
	${CC} ${CFLAGS} ${DEFINES} ${PP_DEFS} -c $<

irc: ${OBJECTS}
	${CC} ${CFLAGS} ${LDFLAGS} ${DEFINES} -o irc ${OBJECTS} ${LIBS}
clean::
	${RM} irc ${OBJECTS}
install:: irc
	-${MV} ${INSTALL_NAME} ${INSTALL_NAME}.old
	${CP} irc ${INSTALL_NAME}
	@${CHMOD} ${INSTALL_NAME}

saber: ${SOURCES}
	#load ${CFLAGS} ${DEFINES} ${SOURCES} ${LIBS}

# .o files needing special compilation flags

irc.o: Makefile
	${CC} ${CFLAGS} ${DEFINES} -DIRCLIB=\"${IRCLIB}/\" -DIRCPATH=\"${IRCPATH}\" -c irc.c

vars.o: Makefile
	${CC} ${CFLAGS} ${DEFINES} -DDEFAULT_HELP_PATH=\"${HELP_DIR}\" -c vars.c

server.o: Makefile
	${CC} ${CFLAGS} ${DEFINES} -DIRCSERV_PATH=\"${INSTALL_IRCSERV}\" -c server.c

translat.o: Makefile
	${CC} ${CFLAGS} ${DEFINES} -DTRANSLATION_PATH=\"${TRANSLATION_PATH}/\" -c translat.c

screen.o: Makefile
	${CC} ${CFLAGS} ${DEFINES} -DWSERV_PATH=\"${INSTALL_WSERV}\" -c screen.c

# .h files generated from .proto files

count: count.c
	${CC} -o count -O count.c ${LEXLIB}

count.c: count.l
	rm -f count.c
	${LEX} count.l
	mv -f lex.yy.c count.c

clean::
	${RM} count count.c lex.yy.c

window.h: hold.h lastlog.h
	touch window.h

vars.h: vars.h.proto count
	${RM} $@
	./count < $@.proto > $@
hook.h: hook.h.proto count
	${RM} $@
	./count < $@.proto > $@
keys.h: keys.h.proto count
	${RM} $@
	./count < $@.proto > $@
clean::
	${RM} vars.h hook.h keys.h

# don't ask

config.h: ../config.h
	${RM} config.h
	${LN} ../config.h .
clean::
	${RM} config.h


# auxiliary programs

ircflush: ircflush.o
	${CC} ${CFLAGS} ${LDFLAGS} ${DEFINES} -o ircflush ircflush.o ${LIBS}
clean::
	${RM} ircflush ircflush.o

ircserv: ircserv.o newio.o
	${CC} ${CFLAGS} ${LDFLAGS} ${DEFINES} ${PPS_DEFS} -o ircserv ircserv.o newio.o ${LIBS}
clean::
	${RM} ircserv ircserv.o newio.o

wserv: ${WSERV_OBJECTS}
	${CC} ${CFLAGS} ${LDFLAGS} ${DEFINES} -o wserv ${WSERV_OBJECTS} ${LIBS}
clean::
	${RM} wserv wserv.o wterm.o wterm.c

# extra junk

clean::
	${RM} core a.out Makefile


# dependencies

alias.o: alias.c irc.h config.h alias.h status.h edit.h history.h vars.h \
	ircaux.h server.h window.h hold.h lastlog.h input.h names.h server.h \
	screen.h
crypt.o: crypt.c irc.h crypt.h vars.h ircaux.h list.h ctcp.h output.h
count.o: count.c crypt.c irc.h config.h crypt.h vars.h ircaux.h list.h ctcp.h
ctcp.o: ctcp.c irc.h config.h ircaux.h hook.h crypt.h ctcp.h vars.h server.h \
	status.h lastlog.h
dcc.o: dcc.c talkd.h irc.h config.h server.h ircaux.h whois.h lastlog.h ctcp.h \
	dcc.h hook.h vars.h
edit.o: edit.c irc.h config.h term.h server.h edit.h crypt.h vars.h ircaux.h \
	lastlog.h window.h hold.h whois.h hook.h input.h ignore.h keys.h \
	names.h alias.h history.h funny.h ctcp.h dcc.h translat.h screen.h
exec.o: exec.c irc.h config.h exec.h vars.h ircaux.h edit.h window.h hold.h \
	lastlog.h hook.h input.h server.h screen.h
file.o: file.c irc.h config.h
flood.o: flood.c irc.h config.h hook.h ircaux.h ignore.h flood.h vars.h
funny.o: funny.c irc.h config.h ircaux.h hook.h vars.h funny.h names.h \
	server.h lastlog.h
help.o: help.c irc.h config.h term.h server.h vars.h ircaux.h input.h \
	window.h hold.h lastlog.h screen.h
history.o: history.c irc.h config.h ircaux.h vars.h history.h
hold.o: hold.c irc.h config.h window.h hold.h lastlog.h vars.h input.h screen.h
hook.o: hook.c irc.h config.h hook.h vars.h ircaux.h alias.h list.h window.h \
	hold.h lastlog.h server.h
if.o: if.c irc.h config.h alias.h ircaux.h window.h hold.h lastlog.h vars.h
ignore.o: ignore.c irc.h config.h ignore.h ircaux.h list.h vars.h
input.o: input.c irc.h config.h input.h term.h alias.h vars.h ircaux.h screen.h
irc.o: irc.c irc.h config.h status.h vars.h input.h alias.h output.h term.h \
	exec.h window.h hold.h lastlog.h server.h hook.h keys.h ircaux.h\
	window.h screen.h
ircaux.o: ircaux.c irc.h config.h ircaux.h
ircflush.o: ircflush.c irc.h config.h Makefile
ircserv.o: ircserv.c Makefile
keys.o: keys.c irc.h config.h keys.h names.h ircaux.h window.h hold.h \
	lastlog.h output.h
lastlog.o: lastlog.c irc.h config.h lastlog.h window.h hold.h vars.h ircaux.h \
	screen.h
list.o: list.c irc.h config.h list.h ircaux.h
log.o: log.c irc.h config.h log.h vars.h ircaux.h
mail.o: mail.c irc.h config.h mail.h hook.h vars.h
menu.o: menu.c irc.h config.h menu.h list.h ircaux.h term.h window.h hold.h \
	lastlog.h input.h vars.h screen.h
names.o: names.c irc.h config.h ircaux.h names.h window.h hold.h lastlog.h \
	server.h list.h screen.h
newio.o: newio.c 
notice.o: notice.c irc.h config.h whois.h ctcp.h lastlog.h flood.h vars.h \
	ircaux.h hook.h ignore.h server.h
notify.o: notify.c irc.h config.h list.h notify.h ircaux.h whois.h hook.h \
	server.h
numbers.o: numbers.c irc.h config.h input.h ircaux.h vars.h lastlog.h hook.h \
	server.h whois.h numbers.h window.h
output.o: output.c irc.h config.h output.h vars.h input.h term.h lastlog.h \
	window.h hold.h hook.h ctcp.h
parse.o: parse.c irc.h config.h server.h names.h vars.h ctcp.h hook.h edit.h \
	ignore.h whois.h lastlog.h ircaux.h crypt.h term.h flood.h
reg.o: reg.c irc.h config.h ircaux.h
scandir.o: scandir.c irc.h config.h
screen.o: screen.c irc.h config.h menu.h window.h hold.h lastlog.h vars.h \
	server.h list.h term.h names.h ircaux.h input.h log.h hook.h dcc.h \
	translat.h screen.h
server.o: server.c irc.h config.h server.h ircaux.h whois.h lastlog.h window.h
status.o: status.c irc.h config.h term.h status.h server.h vars.h hook.h \
	input.h edit.h window.h hold.h lastlog.h mail.h names.h ircaux.h screen.h
term.o: term.c irc.h config.h term.h translat.h
translat.o: translat.c irc.h config.h vars.h translat.h ircaux.h digraph.inc screen.h
vars.o: vars.c irc.h config.h status.h window.h hold.h lastlog.h log.h \
	crypt.h history.h vars.h input.h ircaux.h whois.h translat.h
whois.o: whois.c irc.h config.h whois.h hook.h lastlog.h vars.h server.h \
	ignore.h ircaux.h notify.h numbers.h
window.o: window.c irc.h config.h menu.h window.h hold.h lastlog.h vars.h \
	server.h list.h term.h names.h ircaux.h input.h log.h hook.h dcc.h \
	translat.h screen.h
wserv.o: config.h
wterm.o: term.c config.h irc.h term.h
	${RM} wterm.c
	${LN} term.c wterm.c
	${CC} ${CFLAGS} ${DEFINES} -DSTTY_ONLY -c wterm.c
