#
#	SCCSID	@(#)Makefile	1.16 85/07/20
#
ASSEMBLER	= BSD_4
CFLAGS		= -O
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 \
		  DecodeName.c DecodeNum.c \
		  EchoArgs.c EncodeName.c EncodeNum.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 \
		  MakeErrFile.c NodeName.c NumericArg.c \
		  RdStats.c ReadCom.c ReadFile.c Report.c \
		  Rstats.c SMdate.c SetDmnActive.c SetRaw.c SetUser.c \
		  SplitArg.c StripEnv.c SysWarn.c \
		  TimeString.c Trace.c UniqueName.c UniqueUid.c ValidChars.c \
		  Version.c \
		  Warn.c WrStats.c WriteCom.c \
		  concat.c crc.c max.c min.c \
		  newstr.c newnstr.c sleep.c \
		  strccmp.c strclr.c strcpyend.c ticks.c
OBJECTS		= AddCom.o CopyFile.o CopyFrComF.o DaemonActive.o \
		  DecodeName.o DecodeNum.o \
		  EchoArgs.o EncodeName.o EncodeNum.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 \
		  MakeErrFile.o NodeName.o NumericArg.o \
		  RdStats.o ReadCom.o ReadFile.o Report.o \
		  Rstats.o SMdate.o SetDmnActive.o SetRaw.o SetUser.o \
		  SplitArg.o StripEnv.o SysWarn.o \
		  TimeString.o Trace.o UniqueName.o UniqueUid.o ValidChars.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 \
		  strccmp.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)` ; \
			ar m $@ MakeLock.o ; \
		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
DecodeName.o:	../$(INC)/messagename.h
DecodeNum.o:	../$(INC)/messagename.h
EncodeName.o:	../$(INC)/messagename.h
EncodeNum.o:	../$(INC)/messagename.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)/messagename.h ../$(INC)/spool.h
UniqueUid.o:	../$(INC)/messagename.h ../$(INC)/spool.h
WrStats.o:	../$(INC)/stats.h
WriteCom.o:	../$(INC)/command.h

version:
		@$(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:		Makefile llib-$(LIB) $(HEADERS) $(CFILES)
		$(PRFORMATTER) Makefile llib-$(LIB) $(HEADERS) $(CFILES) | $(PRSPOOL)

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

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

FRC:
