#	Copyright (c) 1992 AT&T - All rights reserved.
#
#	Prototype BSDi Makefile for sam
#	Courtesy of Boyd Roberts
#
#	Define operating system type: -DBSDi
#
#	Additionally, -D_POSIX_SOURCE (or its equivalent) may be specified
#	if your compiler supports posix-compatible compilation
OS=-DBSDi

#	add -Iincludedir for any include directories that need to be searched
#	for posix header files (for UMIPS, add -I/usr/include/posix)
INCS=-I../include -I/usr/include/posix

#	Set the name of the environment variable containing the user's home directory
HOMEDIR=HOME

#	RSAMNAME and TERMNAME contain the names of the files containing the
#	sam and samterm executables, respectively.  SAMDIR is the directory
#	where sam is to be installed.  SAMSAVEDIR is the name of the directory
#	where the samsave file restoration script is stored.
RSAMNAME=sam
TERMNAME=/usr/bin/samterm
SAMDIR=/usr/bin
SAMSAVEDIR=/usr/bin

#	Set TMP to a good place for tmp files (with lots of room)
TMP=/var/tmp

#	Set SHELLNAME and SHELLPATH to the name of a shell and the pathname
#	of its executable
SHELLNAME=sh
SHELLPATH=/bin/sh

#	Set RXNAME and RXPATHNAME to the name of the remote execution command
#	and the pathname of its executable
RXNAME=rsh
RXPATHNAME=/usr/bin/rsh

SAMSAVE=/bin/sh\\n$(SAMSAVEDIR)/samsave

CFLAGS=$(OS) -D_LIBXG_EXTENSION $(INCS)

SYSFLAGS=  -DHOMEDIR=\"$(HOMEDIR)\" -DRSAMNAME=\"$(RSAMNAME)\" \
		-DTERMNAME=\"$(TERMNAME)\" -DTMP=\"$(TMP)\" \
		-DSHELLNAME=\"$(SHELLNAME)\" -DSHELLPATH=\"$(SHELLPATH)\" \
		-DRXNAME=\"$(RXNAME)\" -DRXPATHNAME=\"$(RXPATHNAME)\" \
		-DSAMSAVE=\"$(SAMSAVE)\"

LIB=../libframe/libframe.a ../libXg/libXg.a
CC=cc

OBJ=sam.o address.o buffer.o cmd.o disc.o error.o file.o io.o \
	list.o mesg.o moveto.o multi.o rasp.o regexp.o shell.o \
	string.o sys.o unix.o xec.o

all:    sam

sam:	$(OBJ) $(LIB)
	$(CC) -o sam $(OBJ) $(LIB)

clean:
	rm -f *.o core

nuke:	clean
	rm -f sam

install:	sam
	cp sam $(SAMDIR)/$(RSAMNAME)
	cp samsave $(SAMSAVEDIR)/samsave
	chmod +x $(SAMSAVEDIR)/samsave

$(OBJ):	sam.h ../include/u.h ../include/libc.h errors.h mesg.h

cmd.o:	parse.h
xec.o:	parse.h

unix.o:	sam.h ../include/u.h ../include/libc.h errors.h mesg.h
	$(CC) -c $(CFLAGS) $(SYSFLAGS) unix.c
