#
# $Id: Makefile,v 1.2 1993/01/07 23:14:50 wcp Exp $
#
# Copyright (C) 1992	Walter Pelissero
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 1, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

#
# $Log: Makefile,v $
# Revision 1.2  1993/01/07  23:14:50  wcp
# Added listen shell script, and moved tcl scripts under appropriate
# directory ("scripts").
#
# Revision 1.1  1993/01/06  18:23:05  wcp
# Initial revision
#
# Revision 1.2  1992/07/07  16:51:47  wally
# Added class2 and zyxel senders.
# Ps2pbm is a C program now.
# Minor fixes.
#
# Revision 1.1  1992/04/28  16:13:28  wally
# Initial revision
#
#

CC = gcc
CFLAGS = -O3 -Wall \
	 -DLIB_DIR=\"$(LIBDIR)\" -DETC_DIR=\"$(ETCDIR)\" \
	 -DTMP_DIR=\"$(TMPDIR)\" -DBIN_DIR=\"$(BINDIR)\" \
	 -DPBMPLUS=\"$(PBMPLUS)\"
LDFLAGS = -s
LIBS = -ltcl
INSTALL = /usr/bin/install
BINDIR = /usr/local/bin
ETCDIR = /usr/local/etc
LIBDIR = /usr/local/lib/mgetty
TMPDIR = /tmp
PBMPLUS = /usr/local/pbmplus

BINARIES = localize mgetty c2rec record play # xgetty
SCRIPTS = printfax listen

%: %.sh
	sed -e "`localize`" $< > $@

all: $(BINARIES) $(SCRIPTS)

($SCRIPTS): localize

#
# Binary executables
#
c2rec: c2rec.o common.o modemio.o zyxel.o
record: record.o common.o modemio.o zyxel.o voice.o
play: play.o common.o modemio.o zyxel.o voice.o
xgetty: xgetty.o
mgetty: mgetty.o common.o locks.o temp.o modemio.o
	gcc $(LDFLAGS) mgetty.o common.o locks.o temp.o modemio.o $(LIBS) -o mgetty

#
# Object modules
#
c2rec.o : c2rec.c common.h config.h modemio.h zyxel.h 
common.o : common.c 
localize.o : localize.c 
locks.o : locks.c common.h config.h 
mgetty.o : mgetty.c common.h config.h modemio.h 
modemio.o : modemio.c common.h config.h 
play.o : play.c common.h config.h modemio.h zyxel.h voice.h 
record.o : record.c common.h config.h modemio.h zyxel.h voice.h 
temp.o : temp.c common.h config.h 
voice.o : voice.c voice.h common.h config.h modemio.h zyxel.h 
xgetty.o : xgetty.c 
zyxel.o : zyxel.c common.h config.h modemio.h zyxel.h 

#
# Miscellaneous
#
install: all
	-mkdir $(LIBDIR) && chmod 755 $(LIBDIR)
	-mkdir $(LIBDIR)/ttys && chmod 755 $(LIBDIR)/ttys
	$(INSTALL) -m 644 -o bin -g bin scripts/*.tcl $(LIBDIR)/ttys
	$(INSTALL) -m 711 -o bin -g bin c2rec record play $(LIBDIR)
	$(INSTALL) -m 755 -o bin -g bin printfax $(LIBDIR)
	$(INSTALL) -m 755 -o bin -g bin listen $(LIBDIR)
	-mkdir $(ETCDIR) && chmod 755 $(ETCDIR)
	$(INSTALL) -m 700 -o bin -g bin mgetty $(ETCDIR)
	-mkdir $(LIBDIR)/sound && chmod 755 $(LIBDIR)/sound
	$(INSTALL) -m 644 -o bin -g bin sound/* $(LIBDIR)/sound

install_xenix: install
	[ -f /etc/Getty ] || mv /etc/getty /etc/Getty
	$(INSTALL) -m 700 -o bin -g bin xgetty /etc/getty

clean:
	$(RM) *.o faxem core a.out *.a lp-model $(SCRIPTS) $(BINARIES) \
	      c2rec mgetty

dist: clean
	$(RM) *~ \#*\#
	rcsclean

.PHONY: clean dist all install install_xenix
