#
#	SCCSID	@(#)Makefile	1.8 84/10/22
#
ASSEMBLER	= BSD_4
CFLAGS		= -O -K
DEBUG		= -DEBUG=2

BIN		= Bin
INC		= Include
LIB		= Lib

LIBRARY		= ../$(BIN)/$(LIB).a

INCLUDE		= -I../$(INC)

CONFIG		=
DFLAGS		= $(DEBUG) $(CONFIG)
LFLAGS		= $(INCLUDE) $(DFLAGS)

AR		= /bin/ar ru
DELTA		= sccs delta
GREP		= /bin/grep
GET		= sccs get
LINT		= lint -p -u -x
RM		= /bin/rm -f
RANLIB		= /bin/ranlib
LORDER		= /usr/bin/lorder
TSORT		= /usr/bin/tsort

CFILES		= AddCom.c CopyFile.c CopyFrComF.c DaemonActive.c \
		  EchoArgs.c Error.c ExPipeO.c ExecPipe.c \
		  Execute.c ExpandArgs.c ExpandString.c Fatal.c FreeCom.c \
		  GetErrFile.c GetHandler.c GetUid.c GetUser.c \
		  InList.c Locking.c MakeLock.c Malloc.c MatchString.c \
		  NodeName.c RdStats.c ReadCom.c ReadFile.c Report.c \
		  Rstats.c SMdate.c SetDmnActive.c SetRaw.c SetUser.c \
		  SplitArg.c SysWarn.c \
		  TimeString.c Trace.c UniqueName.c Version.c \
		  Warn.c WrStats.c WriteCom.c \
		  concat.c crc.c max.c min.c \
		  newstr.c newnstr.c sleep.c strclr.c strcpyend.c ticks.c
OBJECTS		= AddCom.o CopyFile.o CopyFrComF.o DaemonActive.o \
		  EchoArgs.o Error.o ExPipeO.o ExecPipe.o \
		  Execute.o ExpandArgs.o ExpandString.o Fatal.o FreeCom.o \
		  GetErrFile.o GetHandler.o GetUid.o GetUser.o \
		  InList.o Locking.o MakeLock.o Malloc.o MatchString.o \
		  NodeName.o RdStats.o ReadCom.o ReadFile.o Report.o \
		  Rstats.o SMdate.o SetDmnActive.o SetRaw.o SetUser.o \
		  SplitArg.o SysWarn.o \
		  TimeString.o Trace.o UniqueName.o Version.o \
		  Warn.o WrStats.o WriteCom.o \
		  concat.o crc.o crcs.o max.o min.o \
		  newstr.o newnstr.o sleep.o strclr.o strcpyend.o ticks.o
HEADERS		=

NAME		= Library
PRSPOOLER	= sendfile -Aaprinter -e'-b' piers:basset -n
PRSPOOL		= $(PRSPOOLER)$(NAME)
PRFORMATTER	= pr -l66 -w132 -f -n3

.c.o:
		$(CC) $(CFLAGS) $(INCLUDE) $(DFLAGS) -c $<

.s.o:
		$(CC) -c $<

.DEFAULT:
		$(GET) SCCS/s.$<

$(LIBRARY):	$(OBJECTS)
		@-{ \
		set -x ; \
		if [ ! -r $@ ] ; \
		then \
			$(AR) $@ `$(LORDER) *.o | $(TSORT)` ; \
		else \
			$(AR) $@ $? ; \
		fi; \
		}
		$(RANLIB) $@

crcs.s:		crc.c ../$(INC)/global.h $(FRC)
		@-if [ "$(ASSEMBLER)"x = x ] ; \
		then \
			set -x ; \
			$(CC) -DAS -E $(INCLUDE) $(DFLAGS) crc.c | $(GREP) -v '^# [0-9]' >$@ ; \
		else \
			set -x ; \
			$(CC) -DAS -D$(ASSEMBLER) -E $(INCLUDE) $(DFLAGS) crc.c | $(GREP) -v '^# [0-9]' >$@ ; \
		fi

$(OBJECTS):	../$(INC)/global.h $(FRC)

AddCom.o:	../$(INC)/command.h
DaemonActive.o:	../$(INC)/Stream.h ../$(INC)/command.h ../$(INC)/spool.h
FreeCom.o:	../$(INC)/command.h
GetHandler.o:	../$(INC)/handlers.h
GetUid.o:	../$(INC)/Passwd.h
GetUser.o:	../$(INC)/Passwd.h
RdStats.o:	../$(INC)/stats.h
ReadCom.o:	../$(INC)/command.h
Rstats.o:	../$(INC)/stats.h
SetUser.o:	../$(INC)/Passwd.h
UniqueName.o:	../$(INC)/spool.h
WrStats.o:	../$(INC)/stats.h
WriteCom.o:	../$(INC)/command.h

version:
		@$(RM) Version.o
		@$(GET) -e Version.c >/dev/null
		@$(DELTA) -y Version.c >/dev/null
		@$(GET) Version.c >/dev/null

llib:		llib-$(LIB).ln

llib-$(LIB).ln:	llib-$(LIB) ../$(INC)/global.h ../$(INC)/Passwd.h
		-/lib/cpp $(LFLAGS) -C llib-$(LIB) \
		| /usr/lib/lint/lint1 -v >llib-$(LIB).ln

lint:		lint.out llib
		more lint.out

lint.out:	$(HEADERS) $(CFILES)
		$(LINT) $(LFLAGS) $(CFILES) >lint.out 2>&1

cyntax:		cyntax.out
		more cyntax.out

cyntax.out:	$(HEADERS) $(CFILES)
		-cyntax $(LFLAGS) $(CFILES) >cyntax.out 2>&1

print:		$(HEADERS) $(CFILES)
		$(PRFORMATTER) Makefile llib-$(LIB) $(HEADERS) $(CFILES) | $(PRSPOOL)

clean:
		$(RM) $(OBJECTS) crcs.s lint.out cyntax.out

clobber:	clean
		$(RM) llib-$(LIB).ln

FRC:
