[comp.sources.misc] v15i055: dmake version 3.6

dvadura@watdragon.waterloo.edu (Dennis Vadura) (10/15/90)

Posting-number: Volume 15, Issue 55
Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
Archive-name: dmake-3.6/part03

#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file unix/bsd43/uw/startup.mk continued
#
CurArch=3
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file unix/bsd43/uw/startup.mk"
sed 's/^X//' << 'SHAR_EOF' >> unix/bsd43/uw/startup.mk
X   % : s.% ; get $@
X   .NOINFER : s.%
X.END
X
X# Recipe to make archive files.
X%$A :
X[
X   $(AR) $(ARFLAGS) $@ $?
X   $(RM) $(RMFLAGS) $?
X   ranlib $@
X]
X
X# DMAKE uses this recipe to remove intermediate targets
X.REMOVE :; $(RM) -f $<
X
X# AUGMAKE extensions for SYSV compatibility
X@B = $(@:b)
X@D = $(@:d)
X@F = $(@:f)
X*B = $(*:b)
X*D = $(*:d)
X*F = $(*:f)
X<B = $(<:b)
X<D = $(<:d)
X<F = $(<:f)
X?B = $(?:b)
X?F = $(?:f)
X?D = $(?:d)
X
X# Turn warnings back to previous setting.
X.SILENT := $(__.SILENT)
X
X# Local startup file if any
X.INCLUDE .IGNORE: "_startup.mk"
SHAR_EOF
echo "File unix/bsd43/uw/startup.mk is complete"
chmod 0640 unix/bsd43/uw/startup.mk || echo "restore of unix/bsd43/uw/startup.mk fails"
echo "x - extracting unix/bsd43/uw/make.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/uw/make.sh &&
Xmkdir objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O infer.c
Xmv infer.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O make.c
Xmv make.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O stat.c
Xmv stat.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O expand.c
Xmv expand.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O string.c
Xmv string.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O hash.c
Xmv hash.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dag.c
Xmv dag.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dmake.c
Xmv dmake.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O path.c
Xmv path.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O imacs.c
Xmv imacs.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O sysintf.c
Xmv sysintf.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O parse.c
Xmv parse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O getinp.c
Xmv getinp.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O quit.c
Xmv quit.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O basename.c
Xmv basename.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dump.c
Xmv dump.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O macparse.c
Xmv macparse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O rulparse.c
Xmv rulparse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O percent.c
Xmv percent.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O function.c
Xmv function.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/arlib.c
Xmv arlib.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/dirbrk.c
Xmv dirbrk.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/explode.c
Xmv explode.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/rmprq.c
Xmv rmprq.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/ruletab.c
Xmv ruletab.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/putenv.c
Xmv putenv.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/tempnam.c
Xmv tempnam.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/utime.c
Xmv utime.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/setvbuf.c
Xmv setvbuf.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/runargv.c
Xmv runargv.o objects
Xcc  -o dmake  objects/infer.o objects/make.o objects/stat.o objects/expand.o objects/string.o objects/hash.o objects/dag.o objects/dmake.o objects/path.o objects/imacs.o objects/sysintf.o objects/parse.o objects/getinp.o objects/quit.o objects/basename.o objects/dump.o objects/macparse.o objects/rulparse.o objects/percent.o objects/function.o objects/arlib.o objects/dirbrk.o objects/explode.o objects/rmprq.o objects/ruletab.o objects/putenv.o objects/tempnam.o objects/utime.o objects/setvbuf.o objects/run



argv.o -luw 
SHAR_EOF
chmod 0640 unix/bsd43/uw/make.sh || echo "restore of unix/bsd43/uw/make.sh fails"
echo "x - extracting unix/bsd43/uw/config.mk (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/uw/config.mk &&
X# This is the BSD 4.3 University of Waterloo (uw) UNIX configuration file
X# for DMAKE
X#	It simply modifies the values of LDLIBS to include libuw.a
X#	so that vfprintf can be found.
X#
X
XLDLIBS += -luw
X
X# install script for UW's /usr/software hierarchy...
Xinstall:
X	mkdir ../bin; strip ./dmake; mv ./dmake ../bin
X	chmod a+rx ../bin/dmake ../bin
X	mkdir ../lib; chmod a+rx ../lib
X	cp $(STARTUPFILE) ../lib
X	chmod a+r ../lib/startup.mk
SHAR_EOF
chmod 0640 unix/bsd43/uw/config.mk || echo "restore of unix/bsd43/uw/config.mk fails"
echo "x - extracting unix/bsd43/utime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/utime.c &&
X/*
X** change access and modify times of file
X*/
X#include <sys/types.h>
X#include <sys/time.h>
X#include <sys/stat.h>
X#include <sys/file.h>
X
Xint
Xutime(name, timep)
Xchar*	name;
Xtime_t	timep[2];
X{
X	struct timeval tv[2], *tvp;
X	struct stat buf;
X	int	fil;
X	char	data;
X
X	if (timep!=0)
X	{
X		tvp = tv, tv[0].tv_sec = timep[0], tv[1].tv_sec = timep[1];
X		if (utimes(name, tvp)==0)
X			return (0);
X	}
X
X	if (stat(name, &buf) != 0)
X		return (-1);
X	if (buf.st_size != 0)  {
X		if ((fil = open(name, O_RDWR, 0666)) < 0)
X			return (-1);
X		if (read(fil, &data, 1) < 1) {
X			close(fil);
X			return (-1);
X		}
X		lseek(fil, 0L, 0);
X		if (write(fil, &data, 1) < 1) {
X			close(fil);
X			return (-1);
X		}
X		close(fil);
X		return (0);
X	} else 	if ((fil = creat(name, 0666)) < 0) {
X		return (-1);
X	} else {
X		close(fil);
X		return (0);
X	}
X}
SHAR_EOF
chmod 0440 unix/bsd43/utime.c || echo "restore of unix/bsd43/utime.c fails"
echo "x - extracting unix/bsd43/tempnam.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/tempnam.c &&
X/*LINTLIBRARY*/
X#include <stdio.h>
X#include <string.h>
X#include <stdlib.h>
X
X#define max(A,B) (((A)<(B))?(B):(A))
X
Xextern char *mktemp();
Xextern int access();
X
Xstatic char *cpdir();
Xstatic char  *seed="AAA";
X
X/* BSD stdio.h doesn't define P_tmpdir, so let's do it here */
X#ifndef P_tmpdir
Xstatic char *P_tmpdir = "/tmp";
X#endif
X
Xchar *
Xtempnam(dir, prefix)
Xchar *dir;		/* use this directory please (if non-NULL) */
Xchar *prefix;		/* use this (if non-NULL) as filename prefix */
X{
X   register char *p, *q, *tmpdir;
X   int            tl=0, dl=0, pl;
X
X   pl = strlen(P_tmpdir);
X
X   if( (tmpdir = getenv("TMPDIR")) != NULL ) tl = strlen(tmpdir);
X   if( dir != NULL ) dl = strlen(dir);
X
X   if( (p = malloc((unsigned)(max(max(dl,tl),pl)+16))) == NULL )
X     return(NULL);
X
X   *p = '\0';
X
X   if( (tl == 0) || (access( cpdir(p, tmpdir), 3) != 0) )
X     if( (dl == 0) || (access( cpdir(p, dir), 3) != 0) )
X	if( access( cpdir(p, P_tmpdir),   3) != 0 )
X	   if( access( cpdir(p, "/tmp"),  3) != 0 )
X	      return(NULL);
X
X   (void) strcat(p, "/");
X   if(prefix)
X   {
X      *(p+strlen(p)+5) = '\0';
X      (void)strncat(p, prefix, 5);
X   }
X
X   (void)strcat(p, seed);
X   (void)strcat(p, "XXXXXX");
X
X   q = seed;
X   while(*q == 'Z') *q++ = 'A';
X   ++*q;
X
X   if(*mktemp(p) == '\0') return(NULL);
X   return(p);
X}
X
X
X
Xstatic char *
Xcpdir(buf, str)
Xchar *buf;
Xchar *str;
X{
X   char *p;
X
X   if(str != NULL)
X   {
X      (void) strcpy(buf, str);
X      p = buf - 1 + strlen(buf);
X      if(*p == '/') *p = '\0';
X   }
X
X   return(buf);
X}
SHAR_EOF
chmod 0440 unix/bsd43/tempnam.c || echo "restore of unix/bsd43/tempnam.c fails"
echo "x - extracting unix/bsd43/string.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/string.h &&
X/*
X** BSD does this wrong
X*/
X#include <strings.h>
X
X#define	strchr(str,c)	index(str,c)
X#define	strrchr(str,c)	rindex(str,c)
X
X#include "stdmacs.h"
Xextern	char*	strpbrk ANSI((char* src, char* any));
X
SHAR_EOF
chmod 0440 unix/bsd43/string.h || echo "restore of unix/bsd43/string.h fails"
echo "x - extracting unix/bsd43/stdlib.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/stdlib.h &&
X#ifndef _STDLIB_INCLUDED_
X#define _STDLIB_INCLUDED_
X
Xextern /*GOTO*/ _exit();
Xextern /*GOTO*/ exit();
Xextern /*GOTO*/ abort();
Xextern int system();
Xextern char *getenv();
Xextern char *calloc();
Xextern char *malloc();
Xextern char *realloc();
Xextern free();
Xextern int errno;
X
X#ifndef EIO
X#	include <errno.h>
X#endif
X
X#endif /* _STDLIB_INCLUDED_ */
SHAR_EOF
chmod 0440 unix/bsd43/stdlib.h || echo "restore of unix/bsd43/stdlib.h fails"
echo "x - extracting unix/bsd43/stdarg.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/stdarg.h &&
X/*
X * stdarg.h
X *
X * defines ANSI style macros for accessing arguments of a function which takes
X * a variable number of arguments
X *
X */
X
Xtypedef char *va_list;
X
X#if defined(sparc)
X# define va_alist __builtin_va_alist
X#endif
X# define va_dcl int va_alist
X# define va_start(list,v) list = (char *)&va_alist
X# define va_end(list)     list = NULL
X# define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1]
X
SHAR_EOF
chmod 0440 unix/bsd43/stdarg.h || echo "restore of unix/bsd43/stdarg.h fails"
echo "x - extracting unix/bsd43/startup.mk (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/startup.mk &&
X# Generic UNIX DMAKE startup file.  Customize to suit your needs.
X# Should work for both SYSV, and BSD 4.3
X# See the documentation for a description of internally defined macros.
X#
X# Disable warnings for macros redefined here that were given
X# on the command line.
X__.SILENT := $(.SILENT)
X.SILENT   := yes
X
X# Configuration parameters for DMAKE startup.mk file
X# Set these to NON-NULL if you wish to turn the parameter on.
X_HAVE_RCS	:= yes		# yes => RCS  is installed.
X_HAVE_SCCS	:= yes		# yes => SCCS is installed.
X
X# Applicable suffix definitions
XA := .a		# Libraries
XE :=		# Executables
XF := .f		# Fortran
XO := .o		# Objects
XP := .p		# Pascal
XS := .s		# Assembler sources
XV := ,v		# RCS suffix
X
X# Recipe execution configurations
XSHELL		:= /bin/sh
XSHELLFLAGS	:= -ce
XGROUPSHELL	:= $(SHELL)
XGROUPFLAGS	:= 
XSHELLMETAS	:= |();&<>?*][$$:\\#`'"
XGROUPSUFFIX	:=
XDIVFILE		 = $(TMPFILE)
X
X# Standard C-language command names and flags
X   CPP	   := /lib/cpp		# C-preprocessor
X   CC      := cc		# C-compiler and flags
X   CFLAGS  +=
X
X   AS      := as		# Assembler and flags
X   ASFLAGS += 
X
X   LD       = $(CC)		# Loader and flags
X   LDFLAGS +=
X   LDLIBS   =
X
X# Definition of $(MAKE) macro for recursive makes.
X   MAKE = $(MAKECMD) $(MFLAGS)
X
X# Definition of Print command for this system.
X   PRINT = lpr
X
X# Language and Parser generation Tools and their flags
X   YACC	  := yacc		# standard yacc
X   YFLAGS +=
X   YTAB	  := y.tab		# yacc output files name stem.
X
X   LEX	  := lex		# standard lex
X   LFLAGS +=
X   LEXYY  := lex.yy		# lex output file
X
X# Other Compilers, Tools and their flags
X   PC	:= pc			# pascal compiler
X   RC	:= f77			# ratfor compiler
X   FC	:= f77			# fortran compiler
X
X   CO	   := co		# check out for RCS
X   COFLAGS += -q
X
X   AR     := ar			# archiver
X   ARFLAGS+= ruv
X
X   RM	   := /bin/rm		# remove a file command
X   RMFLAGS +=
X
X# Implicit generation rules for making inferences.
X# We don't provide .yr or .ye rules here.  They're obsolete.
X# Rules for making *$O
X   %$O : %.c ; $(CC) $(CFLAGS) -c $<
X   %$O : %$P ; $(PC) $(PFLAGS) -c $<
X   %$O : %$S ; $(AS) $(ASFLAGS) $<
X   %$O : %.cl ; class -c $<
X   %$O : %.e %.r %.F %$F
X	$(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<
X
X# Executables
X   %$E : %$O ; $(LD) $(LDFLAGS) -o $@ $< $(LDLIBES)
X
X# lex and yacc rules
X   %.c : %.y ; $(YACC)  $(YFLAGS) $<; mv $(YTAB).c $@
X   %.c : %.l ; $(LEX)   $(LFLAGS) $<; mv $(LEXYY).c $@
X
X# This rule tells how to make *.out from it's immediate list of prerequisites
X# UNIX only.
X   %.out :; $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
X
X# RCS support
X.IF $(_HAVE_RCS)
X   % : %$V $$(@:d)RCS/$$(@:f)$V;- $(CO) $(COFLAGS) $@
X   .NOINFER : %$V $$(@:d)RCS/$$(@:f)$V
X.END
X
X# SCCS support
X.IF $(_HAVE_SCCS)
X   % : s.% ; get $@
X   .NOINFER : s.%
X.END
X
X# Recipe to make archive files.
X%$A :
X[
X   $(AR) $(ARFLAGS) $@ $?
X   $(RM) $(RMFLAGS) $?
X   ranlib $@
X]
X
X# DMAKE uses this recipe to remove intermediate targets
X.REMOVE :; $(RM) -f $<
X
X# AUGMAKE extensions for SYSV compatibility
X@B = $(@:b)
X@D = $(@:d)
X@F = $(@:f)
X*B = $(*:b)
X*D = $(*:d)
X*F = $(*:f)
X<B = $(<:b)
X<D = $(<:d)
X<F = $(<:f)
X?B = $(?:b)
X?F = $(?:f)
X?D = $(?:d)
X
X# Turn warnings back to previous setting.
X.SILENT := $(__.SILENT)
X
X# Local startup file if any
X.INCLUDE .IGNORE: "_startup.mk"
SHAR_EOF
chmod 0640 unix/bsd43/startup.mk || echo "restore of unix/bsd43/startup.mk fails"
echo "x - extracting unix/bsd43/setvbuf.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/setvbuf.c &&
X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/bsd43/RCS/setvbuf.c,v 1.1 90/10/06 12:06:11 dvadura Exp $
X-- SYNOPSIS -- setvbuf for BSD
X-- 
X-- DESCRIPTION
X-- 	A sysv call, standard BSD doesn't have this.
X--
X-- AUTHOR
X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
X--
X-- COPYRIGHT
X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
X-- 
X--      This program is free software; you can redistribute it and/or
X--      modify it under the terms of the GNU General Public License
X--      (version 1), as published by the Free Software Foundation, and
X--      found in the file 'LICENSE' included with this distribution.
X-- 
X--      This program is distributed in the hope that it will be useful,
X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X--      GNU General Public License for more details.
X-- 
X--      You should have received a copy of the GNU General Public License
X--      along with this program;  if not, write to the Free Software
X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X--
X-- LOG
X--     $Log:	setvbuf.c,v $
X * Revision 1.1  90/10/06  12:06:11  dvadura
X * dmake Release, Version 3.6
X * 
X*/
X
X#include <stdio.h>
X
Xsetvbuf(fp, bp, type, len_unused)
XFILE*	fp;
Xchar*	bp;
Xint	type;
Xint	len_unused;
X{
X   switch (type) {
X      case _IOLBF: setlinebuf(fp);   return;
X      case _IONBF: setbuf(fp, NULL); return;
X      default:     setbuf(fp, bp);   return;
X   }
X}
X
SHAR_EOF
chmod 0440 unix/bsd43/setvbuf.c || echo "restore of unix/bsd43/setvbuf.c fails"
echo "x - extracting unix/bsd43/runargv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/runargv.c &&
X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/bsd43/RCS/runargv.c,v 1.1 90/10/06 12:06:09 dvadura Exp $
X-- SYNOPSIS -- invoke a sub process.
X-- 
X-- DESCRIPTION
X-- 	Use the standard methods of executing a sub process.
X--
X-- AUTHOR
X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
X--
X-- COPYRIGHT
X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
X-- 
X--      This program is free software; you can redistribute it and/or
X--      modify it under the terms of the GNU General Public License
X--      (version 1), as published by the Free Software Foundation, and
X--      found in the file 'LICENSE' included with this distribution.
X-- 
X--      This program is distributed in the hope that it will be useful,
X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X--      GNU General Public License for more details.
X-- 
X--      You should have received a copy of the GNU General Public License
X--      along with this program;  if not, write to the Free Software
X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X--
X-- LOG
X--     $Log:	runargv.c,v $
X * Revision 1.1  90/10/06  12:06:09  dvadura
X * dmake Release, Version 3.6
X * 
X*/
X
X#include <signal.h>
X#include "extern.h"
X#include "sysintf.h"
X#include "alloc.h"
X
Xtypedef struct prp {
X   char *prp_cmd;
X   int   prp_group;
X   int   prp_ignore;
X   int   prp_last;
X   int	 prp_shell;
X   struct prp *prp_next;
X   char  *prp_dir;
X} RCP, *RCPPTR;
X
Xtypedef struct pr {
X   int		pr_valid;
X   int		pr_pid;
X   CELLPTR	pr_target;
X   HOWPTR	pr_how;
X   int		pr_ignore;
X   int		pr_last;
X   RCPPTR  	pr_recipe;
X   RCPPTR  	pr_recipe_end;
X} PR;
X
Xstatic PR  *_procs    = NIL(PR);
Xstatic int  _proc_cnt = 0;
Xstatic int  _abort_flg= FALSE;
Xstatic int  _use_i    = -1;
Xstatic int  _do_upd   = 0;
X
Xstatic  void	_add_child ANSI((int, CELLPTR, HOWPTR, int, int));
Xstatic  void	_attach_cmd ANSI((char *, int, int, CELLPTR, HOWPTR, int, int));
Xstatic  void    _finished_child ANSI((int, int));
Xstatic  int     _running ANSI((CELLPTR, HOWPTR));
X
Xint
Xrunargv(target, how, ignore, group, last, shell, cmd)
XCELLPTR target;
XHOWPTR  how;
Xint     ignore;
Xint	group;
Xint	last;
Xint     shell;
Xchar	*cmd;
X{
X   extern  int  errno;
X   extern  char *sys_errlist[];
X   int          pid;
X   char         **argv;
X
X   if( _running(target, how) /*&& Max_proc != 1*/ ) {
X      /* The command will be executed when the previous recipe
X       * line completes. */
X      _attach_cmd( cmd, group, ignore, target, how, last, shell );
X      return(1);
X   }
X
X   while( _proc_cnt == Max_proc )
X      if( Wait_for_child(FALSE, -1) == -1 )  Fatal( "Lost a child" );
X
X   argv = Pack_argv( group, shell, cmd );
X
X   switch( pid=fork() ){
X      int   wid;
X      int   status;
X
X   case -1: /* fork failed */
X      Error("%s: %s", argv[0], sys_errlist[errno]);
X      Handle_result(-1, ignore, _abort_flg, target);
X      return(-1);
X
X   case 0:  /* child */
X      execvp(argv[0], argv);
X      Continue = TRUE;   /* survive error message */
X      Error("%s: %s", argv[0], sys_errlist[errno]);
X      kill(getpid(), SIGTERM);
X      /*NOTREACHED*/
X
X   default: /* parent */
X      _add_child(pid, target, how, ignore, last);
X   }
X
X   return(1);
X}
X
X
Xint
XWait_for_child( abort_flg, pid )
Xint abort_flg;
Xint pid;
X{
X   int wid;
X   int status;
X   int waitchild;
X
X   waitchild = (pid == -1)? FALSE : Wait_for_completion;
X
X   do {
X      if( (wid = wait(&status)) == -1 ) return(-1);
X
X      _abort_flg = abort_flg;
X      _finished_child(wid, status);
X      _abort_flg = FALSE;
X   }
X   while( waitchild && pid != wid );
X
X   return(0);
X}
X
X
Xvoid
XClean_up_processes()
X{
X   register int i;
X
X   if( _procs != NIL(PR) ) {
X      for( i=0; i<Max_proc; i++ )
X	 if( _procs[i].pr_valid )
X	    kill(_procs[i].pr_pid, SIGTERM);
X
X      while( Wait_for_child(TRUE, -1) != -1 );
X   }
X}
X
X
Xstatic void
X_add_child( pid, target, how, ignore, last )
Xint	pid;
XCELLPTR target;
XHOWPTR  how;
Xint	ignore;
Xint     last;
X{
X   register int i;
X   register PR *pp;
X
X   if( _procs == NIL(PR) ) {
X      TALLOC( _procs, Max_proc, PR );
X   }
X
X   if( (i = _use_i) == -1 )
X      for( i=0; i<Max_proc; i++ )
X	 if( !_procs[i].pr_valid )
X	    break;
X
X   pp = _procs+i;
X
X   pp->pr_valid  = 1;
X   pp->pr_pid    = pid;
X   pp->pr_target = target;
X   pp->pr_how    = how;
X   pp->pr_ignore = ignore;
X   pp->pr_last   = last;
X
X   Current_target = NIL(HOW);
X
X   _proc_cnt++;
X
X   if( Wait_for_completion ) Wait_for_child( FALSE, pid );
X}
X
X
Xstatic void
X_finished_child(pid, status)
Xint	pid;
Xint	status;
X{
X   register int i;
X   register PR *pp;
X
X   for( i=0; i<Max_proc; i++ )
X      if( _procs[i].pr_valid && _procs[i].pr_pid == pid )
X	 break;
X
X   _procs[i].pr_valid = 0;
X   _proc_cnt--;
X
X   if( _procs[i].pr_recipe != NIL(RCP) && !_abort_flg ) {
X      RCPPTR rp = _procs[i].pr_recipe;
X      char   *dir;
X
X      Current_target = _procs[i].pr_how;
X      Handle_result( status, _procs[i].pr_ignore, FALSE, _procs[i].pr_target );
X      Current_target = NIL(HOW);
X
X      _procs[i].pr_recipe = rp->prp_next;
X
X      _use_i = i;
X      dir = _strdup(Get_current_dir());
X      Set_dir( rp->prp_dir );
X      runargv( _procs[i].pr_target, _procs[i].pr_how, rp->prp_ignore,
X      	       rp->prp_group, rp->prp_last, rp->prp_shell, rp->prp_cmd );
X      Set_dir(dir);
X      FREE(dir);
X      FREE(rp->prp_dir);
X      _use_i = -1;
X
X      FREE( rp->prp_cmd );
X      FREE( rp );
X
X      if( _proc_cnt == Max_proc ) Wait_for_child( FALSE, -1 );
X   }
X   else {
X      Unlink_temp_files( _procs[i].pr_how );
X      Handle_result(status,_procs[i].pr_ignore,_abort_flg,_procs[i].pr_target);
X
X      if( _procs[i].pr_last && !Doing_bang )
X	 Update_time_stamp( _procs[i].pr_target, _procs[i].pr_how );
X   }
X}
X
X
Xstatic int
X_running( cp, how )
XCELLPTR cp;
XHOWPTR  how;
X{
X   register int i;
X
X   if( !_procs ) return(FALSE);
X
X   for( i=0; i<Max_proc; i++ )
X      if( _procs[i].pr_valid &&
X	  _procs[i].pr_how == how &&
X	  _procs[i].pr_target == cp  )
X	 break;
X	 
X   return( i != Max_proc );
X}
X
X
Xstatic void
X_attach_cmd( cmd, group, ignore, cp, how, last, shell )
Xchar    *cmd;
Xint	group;
Xint     ignore;
XCELLPTR cp;
XHOWPTR  how;
Xint     last;
Xint     shell;
X{
X   register int i;
X   RCPPTR rp;
X
X   for( i=0; i<Max_proc; i++ )
X      if( _procs[i].pr_valid &&
X	  _procs[i].pr_how == how &&
X	  _procs[i].pr_target == cp  )
X	 break;
X
X   TALLOC( rp, 1, RCP );
X   rp->prp_cmd   = _strdup(cmd);
X   rp->prp_group = group;
X   rp->prp_ignore= ignore;
X   rp->prp_last  = last;
X   rp->prp_shell = shell;
X   rp->prp_dir   = _strdup(Get_current_dir());
X
X   if( _procs[i].pr_recipe == NIL(RCP) )
X      _procs[i].pr_recipe = _procs[i].pr_recipe_end = rp;
X   else {
X      _procs[i].pr_recipe_end->prp_next = rp;
X      _procs[i].pr_recipe_end = rp;
X   }
X}
SHAR_EOF
chmod 0440 unix/bsd43/runargv.c || echo "restore of unix/bsd43/runargv.c fails"
echo "x - extracting unix/bsd43/putenv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/putenv.c &&
X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/bsd43/RCS/putenv.c,v 1.1 90/10/06 12:06:07 dvadura Exp $
X-- SYNOPSIS -- my own putenv for BSD like systems.
X-- 
X-- DESCRIPTION
X-- 	This originally came from MKS, but I rewrote it to fix a bug with
X--	replacing existing strings, probably never happened but the code
X--	was wrong nonetheless.
X--
X-- AUTHOR
X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
X--
X-- COPYRIGHT
X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
X-- 
X--      This program is free software; you can redistribute it and/or
X--      modify it under the terms of the GNU General Public License
X--      (version 1), as published by the Free Software Foundation, and
X--      found in the file 'LICENSE' included with this distribution.
X-- 
X--      This program is distributed in the hope that it will be useful,
X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X--      GNU General Public License for more details.
X-- 
X--      You should have received a copy of the GNU General Public License
X--      along with this program;  if not, write to the Free Software
X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X--
X-- LOG
X--     $Log:	putenv.c,v $
X * Revision 1.1  90/10/06  12:06:07  dvadura
X * dmake Release, Version 3.6
X * 
X*/
X
X#include <stdio.h>
X#include <string.h>
X
Xint
Xputenv( str )/*
X===============
X   Take a string of the form NAME=value and stick it into the environment.
X   We do this by allocating a new set of pointers if we have to add a new
X   string and by replacing an existing pointer if the value replaces the value
X   of an existing string. */
Xchar *str;
X{
X   extern char **environ;		/* The current environment. */
X   static char **ourenv = NULL;		/* A new environment	    */
X   register char **p;
X   register char *q;
X   int      size;
X
X   /* First search the current environment and see if we can replace a
X    * string. */
X   for( p=environ; *p; p++ ) {
X      register char *s = str;
X
X      for( q = *p; *q && *s && *s == *q; q++, s++ )
X	 if( *s == '=' ) {
X	    *p = str;
X	    return(0);			/* replaced it so go away */
X	 }
X   }
X
X   /* Ok, can't replace a string so need to grow the environment. */
X   size = p - environ + 2;	/* size of new environment */
X				/* size of old is size-1   */
X
X   /* It's the first time, so allocate a new environment since we don't know
X    * where the old one is comming from. */
X   if( ourenv == NULL ) {
X      if( (ourenv = (char **) malloc( sizeof(char *)*size )) == NULL )
X	 return(1);
X
X      memcpy( (char *)ourenv, (char *)environ, (size-2)*sizeof(char *) );
X   }
X   else if( (ourenv = (char **)realloc( ourenv, size*sizeof(char *))) == NULL )
X      return(1);
X
X   ourenv[--size] = NULL;
X   ourenv[--size] = str;
X
X   environ = ourenv;
X   return(0);
X}
SHAR_EOF
chmod 0440 unix/bsd43/putenv.c || echo "restore of unix/bsd43/putenv.c fails"
echo "x - extracting unix/bsd43/make.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/make.sh &&
Xmkdir objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O infer.c
Xmv infer.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O make.c
Xmv make.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O stat.c
Xmv stat.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O expand.c
Xmv expand.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O string.c
Xmv string.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O hash.c
Xmv hash.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dag.c
Xmv dag.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dmake.c
Xmv dmake.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O path.c
Xmv path.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O imacs.c
Xmv imacs.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O sysintf.c
Xmv sysintf.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O parse.c
Xmv parse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O getinp.c
Xmv getinp.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O quit.c
Xmv quit.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O basename.c
Xmv basename.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O dump.c
Xmv dump.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O macparse.c
Xmv macparse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O rulparse.c
Xmv rulparse.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O percent.c
Xmv percent.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O function.c
Xmv function.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/arlib.c
Xmv arlib.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/dirbrk.c
Xmv dirbrk.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/explode.c
Xmv explode.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/rmprq.c
Xmv rmprq.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/ruletab.c
Xmv ruletab.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/putenv.c
Xmv putenv.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/tempnam.c
Xmv tempnam.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/utime.c
Xmv utime.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/setvbuf.c
Xmv setvbuf.o objects
Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/bsd43 -O unix/bsd43/runargv.c
Xmv runargv.o objects
Xcc  -o dmake  objects/infer.o objects/make.o objects/stat.o objects/expand.o objects/string.o objects/hash.o objects/dag.o objects/dmake.o objects/path.o objects/imacs.o objects/sysintf.o objects/parse.o objects/getinp.o objects/quit.o objects/basename.o objects/dump.o objects/macparse.o objects/rulparse.o objects/percent.o objects/function.o objects/arlib.o objects/dirbrk.o objects/explode.o objects/rmprq.o objects/ruletab.o objects/putenv.o objects/tempnam.o objects/utime.o objects/setvbuf.o objects/run



argv.o 
SHAR_EOF
chmod 0640 unix/bsd43/make.sh || echo "restore of unix/bsd43/make.sh fails"
echo "x - extracting unix/bsd43/config.mk (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/config.mk &&
X# This is the BSD 4.3 UNIX configuration file for DMAKE
X#	It simply modifies the values of SRC, and checks to see if
X#	OSENVIRONMENT is defined.  If so it includes the appropriate
X#	config.mk file.
X#
X# It also sets the values of .SOURCE.c and .SOURCE.h to include the local
X# directory.
X#
Xosrdir := $(OS)$(DIRSEPSTR)$(OSRELEASE)
X
X# The following sources are required for BSD4.3
XOSDSRC := putenv.c tempnam.c utime.c setvbuf.c runargv.c
XSRC    += $(OSDSRC)
X.SETDIR=$(osrdir) : $(OSDSRC)
X
X.SOURCE.h : $(osrdir)
X
X# Local configuration modifications for CFLAGS, there's local BSD includes
X# too.
XCFLAGS += -I$(osrdir)
X
X# See if we modify anything in the lower levels.
X.IF $(OSENVIRONMENT) != $(NULL)
X   .INCLUDE .IGNORE : $(osrdir)$(DIRSEPSTR)$(OSENVIRONMENT)$(DIRSEPSTR)config.mk
X.END
SHAR_EOF
chmod 0640 unix/bsd43/config.mk || echo "restore of unix/bsd43/config.mk fails"
echo "x - extracting unix/bsd43/config.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/bsd43/config.h &&
X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/bsd43/RCS/config.h,v 1.1 90/10/06 12:06:05 dvadura Exp $
X-- SYNOPSIS -- Configurarion include file.
X-- 
X-- DESCRIPTION
X-- 	There is one of these for each specific machine configuration.
X--	It can be used to further tweek the machine specific sources
X--	so that they compile.
X--
X-- AUTHOR
X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
X--
X-- COPYRIGHT
X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
X-- 
X--      This program is free software; you can redistribute it and/or
X--      modify it under the terms of the GNU General Public License
X--      (version 1), as published by the Free Software Foundation, and
X--      found in the file 'LICENSE' included with this distribution.
X-- 
X--      This program is distributed in the hope that it will be useful,
X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X--      GNU General Public License for more details.
X-- 
X--      You should have received a copy of the GNU General Public License
X--      along with this program;  if not, write to the Free Software
X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X--
X-- LOG
X--     $Log:	config.h,v $
X * Revision 1.1  90/10/06  12:06:05  dvadura
X * dmake Release, Version 3.6
X * 
X*/
X
X/* define this for configurations that don't have the coreleft function
X * so that the code compiles.  To my knowledge coreleft exists only on
X * Turbo C, but it is needed here since the function is used in many debug
X * macros. */
X#define coreleft() 0L
X
X/* Define the getcwd function that is used in the code, since BSD does
X * not have getcwd, but call it getwd instead. */
Xextern	char*	getwd ANSI((char*));
X#define	getcwd(buf,siz)	getwd(buf)
SHAR_EOF
chmod 0440 unix/bsd43/config.h || echo "restore of unix/bsd43/config.h fails"
echo "x - extracting unix/arlib.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > unix/arlib.c &&
X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/RCS/arlib.c,v 1.1 90/10/06 12:06:53 dvadura Exp $
X-- SYNOPSIS -- Unix archive manipulation code.
X-- 
X-- DESCRIPTION
X-- 	Originally this code was provided by Eric Gisin of MKS.  I took
X--	his code and completely rewrote it adding cacheing of lib members
X--	and other various optimizations.  I kept the overal functional
X--	idea of the library routines as they are similar to those in GNU
X--	make and felt it advantageous to maintain a similar interface.
X--
X-- AUTHOR
X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
X--
X-- COPYRIGHT
X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
X-- 
X--      This program is free software; you can redistribute it and/or
X--      modify it under the terms of the GNU General Public License
X--      (version 1), as published by the Free Software Foundation, and
X--      found in the file 'LICENSE' included with this distribution.
X-- 
X--      This program is distributed in the hope that it will be useful,
X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X--      GNU General Public License for more details.
X-- 
X--      You should have received a copy of the GNU General Public License
X--      along with this program;  if not, write to the Free Software
X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X--
X-- LOG
X--     $Log:	arlib.c,v $
X * Revision 1.1  90/10/06  12:06:53  dvadura
X * dmake Release, Version 3.6
X * 
X*/
X
X#include "extern.h"
X#include "sysintf.h"
X#include <ar.h>
X#include <stdio.h>
X
X/* By defining the defines below it is possible to configure the library
X * code for library cacheing/non-cacheing, ASCII archive headers, and a full
X * decode of the ar_hdr fields in the scan_ar function. */
X
X#define ASCARCH			1	/* ASCII time stored in archive	*/
X#define LC			1	/* Turn on library cacheing	*/
X#define DECODE_ALL_AR_FIELDS	0	/* decode only fields make needs*/
X
X#if LC
X#  define FOUND_MEMBER	FALSE
X#else
X#  define FOUND_MEMBER	TRUE
X#  define _cache_member(a, b, c)
X#  define _check_cache(a, b, c, d)	FALSE
X#endif
X
X#define	MAXFNAME	32	/* Longest file name in archive	*/
X#define	MAXMNAME	8	/* Max module name < MAXFNAME	*/
X
X
X/* This struct is used to pass the library and member information about the
X * routines that perform the library seeking/cacheing */
Xstruct ar_args {
X   char   *lib;
X   char   *member;
X   time_t time;
X};
X
X
Xtypedef struct AR {
X   char    ar_name[MAXFNAME+1];      /* File name */
X   long    ar_size;                  /* Size in bytes */
X   time_t  ar_time;                  /* Modification time */
X
X#ifdef DOS
X   char    ar_modname[MAXMNAME+1];   /* DOS module name */
X#endif
X
X#if DECODE_ALL_AR_FIELDS
X   uint16  ar_mode;         	     /* File mode */
X   uint16  ar_uid;            	     /* File owner */
X   uint16  ar_gid;                   /* File group owner */
X#endif
X} AR, *ARPTR;
X
X
Xstatic int ar_scan  ANSI((FILE *,
X			  int (*) ANSI((FILE *, struct AR *, struct ar_args *)),
X			  struct ar_args *));
Xstatic int ar_touch ANSI(( FILE *, time_t ));
Xstatic int time_function  ANSI(( FILE *, struct AR *, struct ar_args * ));
Xstatic int touch_function ANSI(( FILE *, struct AR *, struct ar_args * ));
X
X#if LC
Xstatic int _cache_member ANSI((char *, char *, time_t));
Xstatic int _check_cache  ANSI((char *, char *, time_t *, int));
X#endif
X
X/* decoded archive header */
Xstatic AR _ar;
X
X
Xtime_t
Xseek_arch(name, lib)/*
X======================
X   Look for module 'name' inside 'lib'.  If compiled with cacheing then first
X   check to see if the specified lib is cached.  If so then return that time
X   stamp instead of looking into the library. */
Xchar    *name;
Xchar 	*lib;
X{
X   FILE   *f;
X   int    rv;
X   time_t mtime;
X   struct ar_args args;
X
X   /* Check the cache first (if there is a cache) */
X   if( _check_cache(name, lib, &mtime, FALSE) )  return( mtime );
X
X   /* Open the lib file and perform the scan of the members, looking
X    * for our particular member.  If cacheing is enabled it will be
X    * taken care of automatically during the scan. */
X
X   args.lib    = lib;
X   args.member = name;
X   args.time   = (time_t)0L;
X
X   if( (f = fopen(lib, "r")) == NIL(FILE) ) return( (time_t)0L );
X   rv = ar_scan(f, time_function, &args );
X   fclose( f );
X
X   if( rv < 0 ) Fatal("(%s): Invalid library format", lib);
X
X   return( args.time );
X}
X
X
Xint
Xtouch_arch(name, lib)/*
X=======================
X   Look for module 'name' inside 'lib'.  If compiled with cacheing then first
X   check to see if the specified lib is cached.  If so then set that time
X   stamp and write it into the library.  Returns 0 on success, non-zero
X   on failure. */
Xchar   *name;
Xchar   *lib;
X{
X   FILE   *f;
X   int    rv;
X   struct ar_args args;
X
X   /* Open the lib file and perform the scan of the members, looking
X    * for our particular member.  If cacheing is enabled it will be
X    * taken care of automatically during the scan. */
X
X   args.lib    = lib;
X   args.member = name;
X   args.time   = (time_t)0L;
X
X   if( (f = fopen(lib, "r+")) == NIL(FILE) ) return( (time_t)1L );
X   rv = ar_scan(f, touch_function, &args );
X   fclose( f );
X
X   if( rv < 0 ) Fatal("(%s): Invalid library format", lib);
X
X   return( 0 );
X}
X
X
X
Xstatic int
Xtime_function(f, arp, argp)/*
X=============================
X   get library member's time, if it matches than return it in argp, if
X   cacheing is enabled than cache the library members also. */
XFILE           *f;      /* library file          */
Xstruct AR      *arp;    /* library member header */
Xstruct ar_args *argp;
X{
X   int rv = _cache_member( arp->ar_name, argp->lib, arp->ar_time );
X
X   if( strcmp(argp->member, arp->ar_name) == 0 ) {
X      argp->time = arp->ar_time;
X
X      if( arp->ar_time == 0 && !(Glob_attr & A_SILENT) )
X         Warning( "(%s): Can't extract library member timestamp; using EPOCH",
X	          argp->member);
X
X      return( rv );  /* 1 => no cacheing, 0 => cacheing */
X   }
X
X   return( FALSE ); /* continue scan */
X}
X
X
X
Xstatic int
Xtouch_function(f, arp, argp)/*
X==============================
X   Update library member's time stamp, and write new time value into cache
X   if required. */
XFILE           *f;      /* library file */
Xstruct AR      *arp;    /* library member header */
Xstruct ar_args *argp;
X{
X   extern time_t time ANSI(( time_t * ));
X   time_t now = time((time_t*) NULL);  /* Current time.		  */
X
X   if( strcmp(argp->member, arp->ar_name) == 0 ) {
X      _check_cache( argp->member, argp->lib, &now, TRUE );
X      ar_touch(f, now );
X
X      return( TRUE );
X   }
X
X   return( FALSE ); /* continue scan */
X}
X
X
X
X
Xstatic int
Xar_scan(f, function, arg)/*
X===========================
X   Scan the opened archive, and call the given function for each member found.
X   The function will be called with the file positioned at the beginning of
X   the member and it can read up to arp->ar_size bytes of the archive member.
X   If the function returns 1, we stop and return 1.  We return 0 at the end
X   of the archive, or -1 if the archive has invalid format.  This interface
X   is more general than required by "make", but it can be used by other
X   utilities.  */
Xregister FILE *f;
Xint      (*function) ANSI((FILE *, struct AR *, struct ar_args *));
Xstruct ar_args *arg;
X{
X   extern long atol ANSI((char *));
X   register char *p;
X   struct ar_hdr arhdr;   /* external archive header */
X   off_t         offset;  /* member seek offset      */
X
X#if ASCARCH
X   char magic[SARMAG];
X#else
X   unsigned short word;
X#endif
X
X   fseek( f, 0L, 0 );	/* Start at the beginning of the archive file */
X
X#if ASCARCH
X   fread( magic, sizeof(magic), 1, f );
X   if( strncmp(magic, ARMAG, SARMAG) != 0 ) return( -1 );
X#else
SHAR_EOF
echo "End of part 3"
echo "File unix/arlib.c is continued in part 4"
echo "4" > s2_seq_.tmp
exit 0