#
# Copyright (c) 1990-1993 Michael A. Cooper.
# This software may be freely distributed provided it is not sold for 
# profit and the author is credited appropriately.
#
# $Id: Makefile,v 6.8 1993/07/28 21:16:06 mcooper Exp mcooper $
#
# Makefile for QTerm
#
# To compile, run one of the following:
#
# 	COMMAND			SYSTEM TYPE
# 	make			4.x BSD
# 	make svr4		System V Release 4 (SVR4)
# 	make sysv		Older System V Releases (prior to SVR4)
#

#
# DIR is the main/top-level directory.
# If you change DIR, run "make reconfig".
#
DIR 	= /usr/local

#
# BIN is were the "qterm" binary gets installed.
#
BIN 	= $(DIR)/bin

#
# MAN is the directory where the "qterm.1" man page goes.
#
MAN 	= $(DIR)/man/man1

#
# TABFILE should be set to the location you want the qterm table
# file placed in.
#
TABFILE = $(DIR)/lib/qtermtab

#
# Name of your BSD-like install program.
# Use "./bsdinst.sh" if you don't have one.
#
INSTALL	= install

##############################################################################
#
# 	End of Normal system configuration
#
##############################################################################

#
# Add "-DSYSV" to OSDEFS below, if your system is Unix System V.
# Add "-D_POSIX_SOURCE" to OSDEFS below, if your system is POSIX compliant.
# Add "-DHAVE_VARARGS" if your system supports varargs.
# Add "-DOPT_COMPAT" if you want compatibility with old command line options.
#
OSDEFS	= -DHAVE_VARARGS

#
# On some System V (Releases up through 3) systems you will need 
# to add "-lPW" to LIBS.
#
# On System V Release 4 systems, like Solaris 2.x (SunOS 5.x), 
# you need "-lgen".
#
LIBS	=


CONFIGFILES	= Makefile qterm.1 options.3
HFILES		= config-data.h config.h options.h qterm.h version.h
OBJS 		= qterm.o aux.o table.o tty.o signals.o options.o
OPT		= -O
DEFS 		= -DTABFILE=\"$(TABFILE)\" $(OSDEFS)
CFLAGS 		= $(OPT) $(DEFS)

qterm: $(OBJS) $(HFILES)
	$(CC) $(CFLAGS) $(OBJS) -o qterm $(LIBS)

reconfig:
	-@for i in $(CONFIGFILES); do \
                echo ReConfiguring $$i...;\
		sed "s;/usr/usc;$(DIR);g" < $$i > $$i.tmp;\
		mv -f $$i.tmp $$i;\
        done

$(OBJS): $(HFILES)

clean:
	rm -f *.o core log *~ \#* qterm qterm.shar o $(OBJS)

#
# Install files
#
install: qterm qtermtab
	$(INSTALL) -c -m 755 qterm $(BIN)
	$(INSTALL) -c -m 644 qtermtab $(TABFILE)

install.man: qterm.1
	$(INSTALL) -c -m 644 qterm.1 $(MAN)

#
# OS submakes
#

#
# System V Release 4
#
svr4 SVR4 sunos5 SUNOS5 solaris2 SOLARIS2:
	make 'OSDEFS=-DSYSV -D_POSIX_SOURCE' LIBS=-lgen

#
# System V Releases up through 3
#
sysv SYSV hpux HPUX:
	make 'OSDEFS=-DSYSV -DHAVE_VARARGS' LIBS=-lPW
