Index: trunk/minix/commands/make/Makefile
===================================================================
--- trunk/minix/commands/make/Makefile	(revision 9)
+++ 	(revision )
@@ -1,22 +1,0 @@
-# Makefile for make (!)
-
-CFLAGS = -O -Dunix -D_MINIX -D_POSIX_SOURCE
-CC = exec cc
-
-OBJ =	check.o input.o macro.o main.o make.o reader.o rules.o archive.o
-
-all:	make
-
-make :	$(OBJ)
-	$(CC) -i -o make $(OBJ)
-	install -S 330k make
-
-install:	/usr/bin/make
-
-/usr/bin/make:	make
-	install -c -o bin make $@
- 
-$(OBJ): h.h
-
-clean:
-	rm -f *.o *.bak core make
Index: trunk/minix/commands/make/archive.c
===================================================================
--- trunk/minix/commands/make/archive.c	(revision 9)
+++ 	(revision )
@@ -1,309 +1,0 @@
-/*	archive.c - archive support			Author: Kees J. Bot
- *								13 Nov 1993
- */
-#include "h.h"
-
-#ifdef unix
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#define arraysize(a)	(sizeof(a) / sizeof((a)[0]))
-#define arraylimit(a)	((a) + arraysize(a))
-
-/* ASCII ar header. */
-
-#define ASCII_ARMAG	"!<arch>\n"
-#define ASCII_SARMAG	8
-#define ASCII_ARFMAG	"`\n"
-
-struct ascii_ar_hdr {
-	char	ar_name[16];
-	char	ar_date[12];
-	char	ar_uid[6];
-	char	ar_gid[6];
-	char	ar_mode[8];
-	char	ar_size[10];
-	char	ar_fmag[2];
-};
-
-/* ACK ar header. */
-
-#define	ACK_ARMAG	0177545
-#define ACK_AALMAG	0177454
-
-struct ack_ar_hdr {
-	char		ar_name[14];
-	unsigned long	ar_date;
-	unsigned char	ar_uid;
-	unsigned char	ar_gid;
-	unsigned short	ar_mode;
-	unsigned long	ar_size;
-};
-
-typedef struct archname {
-	struct archname	*next;		/* Next on the hash chain. */
-	char		name[16];	/* One archive entry. */
-	time_t		date;		/* The timestamp. */
-	/* (no need for other attibutes) */
-} archname_t;
-
-static size_t namelen;			/* Max name length, 14 or 16. */
-
-#define HASHSIZE	(64 << sizeof(int))
-
-static archname_t *nametab[HASHSIZE];
-
-_PROTOTYPE( static int hash, (char *name) );
-_PROTOTYPE( static int searchtab, (char *name, time_t *date, int scan) );
-_PROTOTYPE( static void deltab, (void) );
-_PROTOTYPE( static long ar_atol, (char *s, size_t n) );
-_PROTOTYPE( static int read_ascii_archive, (int afd) );
-_PROTOTYPE( static int read_ack_archive, (int afd) );
-
-static char *lpar, *rpar;	/* Leave these at '(' and ')'. */
-
-int is_archive_ref(name) char *name;
-/* True if name is of the form "archive(file)". */
-{
-  char *p = name;
-
-  while (*p != 0 && *p != '(' && *p != ')') p++;
-  lpar = p;
-  if (*p++ != '(') return 0;
-
-  while (*p != 0 && *p != '(' && *p != ')') p++;
-  rpar = p;
-  if (*p++ != ')') return 0;
-
-  return *p == 0;
-}
-
-static int hash(name) char *name;
-/* Compute a hash value out of a name. */
-{
-	unsigned h = 0;
-	unsigned char *p = (unsigned char *) name;
-	int n = namelen;
-
-	while (*p != 0) {
-		h = h * 0x1111 + *p++;
-		if (--n == 0) break;
-	}
-
-	return h % arraysize(nametab);
-}
-
-static int searchtab(name, date, scan) char *name; time_t *date; int scan;
-/* Enter a name to the table, or return the date of one already there. */
-{
-	archname_t **pnp, *np;
-	int cmp = 1;
-
-	pnp = &nametab[hash(name)];
-
-	while ((np = *pnp) != NULL
-			&& (cmp = strncmp(name, np->name, namelen)) > 0) {
-		pnp= &np->next;
-	}
-
-	if (cmp != 0) {
-		if (scan) {
-			errno = ENOENT;
-			return -1;
-		}
-		if ((np = (archname_t *) malloc(sizeof(*np))) == NULL)
-			fatal("No memory for archive name cache",(char *)0,0);
-		strncpy(np->name, name, namelen);
-		np->date = *date;
-		np->next = *pnp;
-		*pnp = np;
-	}
-	if (scan) *date = np->date;
-	return 0;
-}
-
-static void deltab()
-/* Delete the name cache, a different library is to be read. */
-{
-	archname_t **pnp, *np, *junk;
-
-	for (pnp = nametab; pnp < arraylimit(nametab); pnp++) {
-		for (np = *pnp; np != NULL; ) {
-			junk = np;
-			np = np->next;
-			free(junk);
-		}
-		*pnp = NULL;
-	}
-}
-
-static long ar_atol(s, n) char *s; size_t n;
-/* Transform a string into a number.  Ignore the space padding. */
-{
-  long l= 0;
-
-  while (n > 0) {
-	if (*s != ' ') l= l * 10 + (*s - '0');
-	s++;
-	n--;
-  }
-  return l;
-}
-
-static int read_ascii_archive(afd)
-int afd;
-/* Read a modern ASCII type archive. */
-{
-  struct ascii_ar_hdr hdr;
-  off_t pos= 8;
-  char *p;
-  time_t date;
-
-  namelen = 16;
-
-  for (;;) {
-	if (lseek(afd, pos, SEEK_SET) == -1) return -1;
-
-	switch (read(afd, &hdr, sizeof(hdr))) {
-	case sizeof(hdr):
-		break;
-	case -1:
-		return -1;
-	default:
-		return 0;
-	}
-
-	if (strncmp(hdr.ar_fmag, ASCII_ARFMAG, sizeof(hdr.ar_fmag)) != 0) {
-		errno= EINVAL;
-		return -1;
-	}
-
-	/* Strings are space padded! */
-	for (p= hdr.ar_name; p < hdr.ar_name + sizeof(hdr.ar_name); p++) {
-		if (*p == ' ') {
-			*p= 0;
-			break;
-		}
-	}
-
-	/* Add a file to the cache. */
-	date = ar_atol(hdr.ar_date, sizeof(hdr.ar_date));
-	searchtab(hdr.ar_name, &date, 0);
-
-	pos+= sizeof(hdr) + ar_atol(hdr.ar_size, sizeof(hdr.ar_size));
-	pos= (pos + 1) & (~ (off_t) 1);
-  }
-}
-
-static int read_ack_archive(afd)
-int afd;
-/* Read an ACK type archive. */
-{
-  unsigned char raw_hdr[14 + 4 + 1 + 1 + 2 + 4];
-  struct ack_ar_hdr hdr;
-  off_t pos= 2;
-  time_t date;
-
-  namelen = 14;
-
-  for (;;) {
-	if (lseek(afd, pos, SEEK_SET) == -1) return -1;
-
-	switch (read(afd, raw_hdr, sizeof(raw_hdr))) {
-	case sizeof(raw_hdr):
-		break;
-	case -1:
-		return -1;
-	default:
-		return 0;
-	}
-
-	/* Copy the useful fields from the raw bytes transforming PDP-11
-	 * style numbers to native format.
-	 */
-	memcpy(hdr.ar_name, raw_hdr + 0, 14);
-	hdr.ar_date=	  (long) raw_hdr[14 + 1] << 24
-			| (long) raw_hdr[14 + 0] << 16
-			| (long) raw_hdr[14 + 3] <<  8
-			| (long) raw_hdr[14 + 2] <<  0;
-	hdr.ar_size=	  (long) raw_hdr[22 + 1] << 24
-			| (long) raw_hdr[22 + 0] << 16
-			| (long) raw_hdr[22 + 3] <<  8
-			| (long) raw_hdr[22 + 2] <<  0;
-
-	/* Add a file to the cache. */
-	date = hdr.ar_date;
-	searchtab(hdr.ar_name, &date, 0);
-
-	pos= (pos + 26 + hdr.ar_size + 1) & (~ (off_t) 1);
-  }
-}
-
-int archive_stat(name, stp) char *name; struct stat *stp;
-/* Search an archive for a file and return that file's stat info. */
-{
-  int afd;
-  int r= -1;
-  char magic[8];
-  char *file;
-  static dev_t ardev;
-  static ino_t arino = 0;
-  static time_t armtime;
-
-  if (!is_archive_ref(name)) { errno = EINVAL; return -1; }
-  *lpar= 0;
-  *rpar= 0;
-  file= lpar + 1;
-
-  if (stat(name, stp) < 0) goto bail_out;
-
-  if (stp->st_ino != arino || stp->st_dev != ardev) {
-	/* Either the first (and probably only) library, or a different
-	 * library.
-	 */
-	arino = stp->st_ino;
-	ardev = stp->st_dev;
-	armtime = stp->st_mtime;
-	deltab();
-
-	if ((afd= open(name, O_RDONLY)) < 0) goto bail_out;
-
-	switch (read(afd, magic, sizeof(magic))) {
-	case 8:
-		if (strncmp(magic, ASCII_ARMAG, 8) == 0) {
-			r= read_ascii_archive(afd);
-			break;
-		}
-		if ((magic[0] & 0xFF) == ((ACK_AALMAG >> 0) & 0xFF)
-			&& (magic[1] & 0xFF) == ((ACK_AALMAG >> 8) & 0xFF)
-		) {
-			r= read_ack_archive(afd);
-			break;
-		}
-		/*FALL THROUGH*/
-	default:
-		errno = EINVAL;
-		/*FALL THROUGH*/
-	case -1:
-		/* r= -1 */;
-	}
-	{ int e= errno; close(afd); errno= e; }
-  } else {
-	/* Library is cached. */
-	r = 0;
-  }
-
-  if (r == 0) {
-	/* Search the cache. */
-	r = searchtab(file, &stp->st_mtime, 1);
-	if (stp->st_mtime > armtime) stp->st_mtime = armtime;
-  }
-
-bail_out:
-  /* Repair the name(file) thing. */
-  *lpar= '(';
-  *rpar= ')';
-  return r;
-}
-#endif
Index: trunk/minix/commands/make/build
===================================================================
--- trunk/minix/commands/make/build	(revision 9)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!/bin/sh
-make clean
-make && make install
Index: trunk/minix/commands/make/check.c
===================================================================
--- trunk/minix/commands/make/check.c	(revision 9)
+++ 	(revision )
@@ -1,128 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   c h e c k . c
- *
- *  debugging stuff: Check structures for make.
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 23.08.89 adapted to new name tree structure                   RAL
- *   3 30.08.89 indention changed                                    PSH,RAL
- *   4 06.09.89 prt output redirected to stdout                      RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-#include "h.h"
-
-
-/*
- *	Prints out the structures as defined in memory.  Good for check
- *	that you make file does what you want (and for debugging make).
- */
-void prt()
-{
-  register struct name   *np;
-  register struct depend *dp;
-  register struct line   *lp;
-  register struct cmd    *cp;
-  register struct macro  *mp;
-
-  register int   		i;
-
-  for (mp = macrohead; mp; mp = mp->m_next)
-	printf("%s = %s\n", mp->m_name, mp->m_val);
-
-  putchar('\n');
-
-  for (i = 0; i <= maxsuffarray ; i++)
-	    for (np = suffparray[i]->n_next; np; np = np->n_next)
-	    {
-		if (np->n_flag & N_DOUBLE)
-			printf("%s::\n", np->n_name);
-		else
-			printf("%s:\n", np->n_name);
-		if (np == firstname)
-			printf("(MAIN NAME)\n");
-		for (lp = np->n_line; lp; lp = lp->l_next)
-		{
-			putchar(':');
-			for (dp = lp->l_dep; dp; dp = dp->d_next)
-				printf(" %s", dp->d_name->n_name);
-			putchar('\n');
-
-			for (cp = lp->l_cmd; cp; cp = cp->c_next)
-#ifdef os9
-				printf("-   %s\n", cp->c_cmd);
-#else
-				printf("-\t%s\n", cp->c_cmd);
-#endif
-			putchar('\n');
-		}
-		putchar('\n');
-	    }
-}
-
-
-/*
- *	Recursive routine that does the actual checking.
- */
-void check(np)
-struct name *np;
-{
-  register struct depend *dp;
-  register struct line   *lp;
-
-
-	if (np->n_flag & N_MARK)
-		fatal("Circular dependency from %s", np->n_name,0);
-
-	np->n_flag |= N_MARK;
-
-	for (lp = np->n_line; lp; lp = lp->l_next)
-		for (dp = lp->l_dep; dp; dp = dp->d_next)
-			check(dp->d_name);
-
-	np->n_flag &= ~N_MARK;
-}
-
-
-/*
- *	Look for circular dependancies.
- *	ie.
- *		a: b
- *		b: a
- *	is a circular dep
- */
-void circh()
-{
-  register struct name *np;
-  register int          i;
-
-
-  for (i = 0; i <= maxsuffarray ; i++)
-	   for (np = suffparray[i]->n_next; np; np = np->n_next)
-		check(np);
-}
-
-
-/*
- *	Check the target .PRECIOUS, and mark its dependentd as precious
- */
-void precious()
-{
-  register struct depend *dp;
-  register struct line   *lp;
-  register struct name   *np;
-
-
-  if (!((np = newname(".PRECIOUS"))->n_flag & N_TARG))
-	return;
-
-  for (lp = np->n_line; lp; lp = lp->l_next)
-	for (dp = lp->l_dep; dp; dp = dp->d_next)
-		dp->d_name->n_flag |= N_PREC;
-}
Index: trunk/minix/commands/make/h.h
===================================================================
--- trunk/minix/commands/make/h.h	(revision 9)
+++ 	(revision )
@@ -1,319 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   h . h
- *
- *  include file for make
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 23.08.89 LZ increased,N_EXISTS added,suffix as macro added    RAL
- *   3 30.08.89 macro flags added, indention changed                 PSH,RAL
- *   4 03.09.89 fixed LZ eliminated, struct str added,...            RAL
- *   5 06.09.89 TABCHAR,M_MAKE added                                 RAL
- *   6 09.09.89 tos support added, EXTERN,INIT,PARMS added           PHH,RAL
- *   7 17.09.89 __STDC__ added, make1 decl. fixed , N_EXEC added     RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-#ifdef unix
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <utime.h>
-#include <stdio.h>
-#include <limits.h>
-#endif
-
-#ifdef eon
-#include <sys/stat.h>
-#include <sys/err.h>
-#endif
-
-#ifdef os9
-#include <time.h>
-#include <os9.h>
-#include <modes.h>
-#include <direct.h>
-#include <errno.h>
-#endif
-
-#ifdef tos
-struct DOSTIME {short time,date; };     /* time structure of TOS */
-
-#ifdef LATTICE
-#include <error.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <osbind.h>
-#endif /* LATTICE */
-
-#ifdef TURBO
-#include <tos.h>
-#include <errno.h>
-#include <string.h>
-#endif /* TURBO */
-
-#endif /* tos */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <assert.h>
-
-#ifdef eon
-#define MNOENT ER_NOTF
-#else
-#define MNOENT ENOENT
-#endif
-
-#ifndef uchar
-#ifdef os9
-#define uchar  char
-#define void   int
-#define fputc  putc
-#else
-#define uchar  unsigned char
-#endif
-#endif
-
-#define bool   uchar
-#ifndef time_t
-#define time_t long
-#endif
-#define TRUE   (1)
-#define FALSE  (0)
-#define max(a,b) ((a)>(b)?(a):(b))
-
-#ifdef unix
-#define DEFN1   "makefile"
-#define DEFN2   "Makefile"
-#endif
-#ifdef eon
-#define DEFN1   "makefile"
-#define DEFN2   "Makefile"
-#endif
-#ifdef tos
-#define DEFN1   "makefile."
-#define DEFN2   (char *)0
-#endif
-#ifdef os9
-#define DEFN1   "makefile"
-#define DEFN2   (char *)0
-#endif
-
-
-#ifdef os9
-#define TABCHAR ' '
-#else
-#define TABCHAR '\t'
-#endif
-
-#define LZ1	(2048)		/*  Initial input/expand string size  */
-#define LZ2	(256)		/*  Initial input/expand string size  */
-
-
-
-/*
- *	A name.  This represents a file, either to be made, or existant
- */
-
-struct name
-{
-  struct name  *n_next;		/* Next in the list of names */
-  char         *n_name;		/* Called */
-  struct line  *n_line;		/* Dependencies */
-  time_t        n_time;		/* Modify time of this name */
-  uchar         n_flag;		/* Info about the name */
-};
-
-#define N_MARK    0x01			/* For cycle check */
-#define N_DONE    0x02			/* Name looked at */
-#define N_TARG    0x04			/* Name is a target */
-#define N_PREC    0x08			/* Target is precious */
-#define N_DOUBLE  0x10			/* Double colon target */
-#define N_EXISTS  0x20			/* File exists */
-#define N_ERROR   0x40			/* Error occured */
-#define N_EXEC    0x80			/* Commands executed */
-
-/*
- *	Definition of a target line.
- */
-struct	line
-{
-  struct line    *l_next;		/* Next line (for ::) */
-  struct depend  *l_dep;		/* Dependents for this line */
-  struct cmd     *l_cmd;		/* Commands for this line */
-};
-
-
-/*
- *	List of dependents for a line
- */
-struct	depend
-{
-  struct depend  *d_next;		/* Next dependent */
-  struct name    *d_name;		/* Name of dependent */
-};
-
-
-/*
- *	Commands for a line
- */
-struct	cmd
-{
-  struct cmd  *c_next;		/* Next command line */
-  char        *c_cmd;		/* Command line */
-};
-
-
-/*
- *	Macro storage
- */
-struct	macro
-{
-  struct macro *m_next;	/* Next variable */
-  char *m_name;		/* Called ... */
-  char *m_val;		/* Its value */
-  uchar m_flag;		/* Infinite loop check */
-};
-
-
-#define M_MARK		0x01	/* for infinite loop check */
-#define M_OVERRIDE	0x02	/* command-line override */
-#define M_MAKE		0x04	/* for MAKE macro */
-
-/*
- *	String
- */
-struct	str
-{
-  char **ptr;		/* ptr to real ptr. to string */
-  int    len;		/* length of string */
-  int    pos;		/* position */
-};
-
-
-/* Declaration, definition & initialization of variables */
-
-#ifndef EXTERN
-#define EXTERN extern
-#endif
-
-#ifndef INIT
-#define INIT(x)
-#endif
-
-extern int    errno;
-extern char **environ;
-
-EXTERN char *myname;
-EXTERN bool  domake   INIT(TRUE);  /*  Go through the motions option  */
-EXTERN bool  ignore   INIT(FALSE); /*  Ignore exit status option      */
-EXTERN bool  conterr  INIT(FALSE); /*  continue on errors  */
-EXTERN bool  silent   INIT(FALSE); /*  Silent option  */
-EXTERN bool  print    INIT(FALSE); /*  Print debuging information  */
-EXTERN bool  rules    INIT(TRUE);  /*  Use inbuilt rules  */
-EXTERN bool  dotouch  INIT(FALSE); /*  Touch files instead of making  */
-EXTERN bool  quest    INIT(FALSE); /*  Question up-to-dateness of file  */
-EXTERN bool  useenv   INIT(FALSE); /*  Env. macro def. overwrite makefile def.*/
-EXTERN bool  dbginfo  INIT(FALSE); /*  Print lot of debugging information */
-EXTERN bool  ambigmac INIT(TRUE);  /*  guess undef. ambiguous macros (*,<) */
-EXTERN struct name  *firstname;
-EXTERN char         *str1;
-EXTERN char         *str2;
-EXTERN struct str    str1s;
-EXTERN struct str    str2s;
-EXTERN struct name **suffparray; /* ptr. to array of ptrs. to name chains */
-EXTERN int           sizesuffarray INIT(20); /* size of suffarray */
-EXTERN int           maxsuffarray INIT(0);   /* last used entry in suffarray */
-EXTERN struct macro *macrohead;
-EXTERN bool          expmake; /* TRUE if $(MAKE) has been expanded */
-EXTERN char	    *makefile;     /*  The make file  */
-EXTERN int           lineno;
-
-#ifdef tos
-#ifdef LATTICE
-EXTERN int _mneed INIT(60000);    /* VERY important for TOS with LATTICE C*/
-#endif /* LATTICE */
-#endif /* tos */
-#ifdef eon
-#define MEMSPACE  (16384)
-EXTERN unsigned  memspace = MEMSPACE;
-#endif
-
-#define  suffix(name)   strrchr(name,(int)'.')
-
-EXTERN int _ctypech;
-#define mylower(x)  (islower(_ctypech=(x)) ? _ctypech :tolower(_ctypech))
-#define myupper(x)  (isupper(_ctypech=(x)) ? _ctypech :toupper(_ctypech))
-
-/* Prototypes. */
-struct sgtbuf;
-
-/* check.c */
-_PROTOTYPE(void prt, (void));
-_PROTOTYPE(void check, (struct name *np ));
-_PROTOTYPE(void circh, (void));
-_PROTOTYPE(void precious, (void));
-
-/* input.c */
-_PROTOTYPE(void init, (void));
-_PROTOTYPE(void strrealloc, (struct str *strs ));
-_PROTOTYPE(struct name *newname, (char *name ));
-_PROTOTYPE(struct name *testname, (char *name ));
-_PROTOTYPE(struct depend *newdep, (struct name *np, struct depend *dp ));
-_PROTOTYPE(struct cmd *newcmd, (char *str, struct cmd *cp ));
-_PROTOTYPE(void newline, (struct name *np, struct depend *dp, struct cmd *cp, 
-								   int flag ));
-_PROTOTYPE(void input, (FILE *fd ));
-
-/* macro.c */
-_PROTOTYPE(struct macro *getmp, (char *name ));
-_PROTOTYPE(char *getmacro, (char *name ));
-_PROTOTYPE(struct macro *setmacro, (char *name, char *val ));
-_PROTOTYPE(void setDFmacro, (char *name, char *val ));
-_PROTOTYPE(void doexp, (struct str *to, char *from ));
-_PROTOTYPE(void expand, (struct str *strs ));
-
-/* main.c */
-_PROTOTYPE(void main, (int argc, char **argv ));
-_PROTOTYPE(void setoption, (char option ));
-_PROTOTYPE(void usage, (void));
-_PROTOTYPE(void fatal, (char *msg, char *a1, int a2 ));
-
-/* make.c */
-_PROTOTYPE(int dosh, (char *string, char *shell ));
-_PROTOTYPE(int makeold, (char *name ));
-_PROTOTYPE(void docmds1, (struct name *np, struct line *lp ));
-_PROTOTYPE(void docmds, (struct name *np ));
-_PROTOTYPE(int Tosexec, (char *string ));
-_PROTOTYPE(time_t mstonix, (unsigned int date, unsigned int time ));
-_PROTOTYPE(void getmdate, (int fd, struct sgtbuf *tbp ));
-_PROTOTYPE(time_t cnvtime, (struct sgtbuf *tbp ));
-_PROTOTYPE(void modtime, (struct name *np ));
-_PROTOTYPE(void touch, (struct name *np ));
-_PROTOTYPE(int make, (struct name *np, int level ));
-_PROTOTYPE(void make1, (struct name *np, struct line *lp, struct depend *qdp, 
-					char *basename, char *inputname ));
-_PROTOTYPE(void implmacros, (struct name *np, struct line *lp, 
-					char **pbasename, char **pinputname ));
-_PROTOTYPE(void dbgprint, (int level, struct name *np, char *comment ));
-
-/* reader.c */
-_PROTOTYPE(void error, (char *msg, char *a1 ));
-_PROTOTYPE(bool getline, (struct str *strs, FILE *fd ));
-_PROTOTYPE(char *gettok, (char **ptr ));
-
-/* rules.c */
-_PROTOTYPE(bool dyndep, (struct name *np, char **pbasename,char **pinputname));
-_PROTOTYPE(void makerules, (void));
-
-/* archive.c */
-_PROTOTYPE(int is_archive_ref, (char *name));
-_PROTOTYPE(int archive_stat, (char *name, struct stat *stp));
Index: trunk/minix/commands/make/input.c
===================================================================
--- trunk/minix/commands/make/input.c	(revision 9)
+++ 	(revision )
@@ -1,439 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   i n p u t . c
- *
- *  Parse a makefile
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 23.08.89 new name tree structure introduced to speed up make,
- *              testname introduced to shrink the memory usage       RAL
- *   3 30.08.89 indention changed                                    PSH,RAL
- *   4 03.09.89 fixed LZ eliminated                                  RAL
- *   5 06.09.89 ; command added                                      RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-
-#include "h.h"
-
-
-static struct name *lastrrp;
-static struct name *freerp = (struct name *)NULL;
-
-void init()
-{
-  if( (suffparray = (struct name **) malloc( sizesuffarray *
-           sizeof(struct name *)))  == (struct name **) NULL)
-     fatal("No memory for suffarray",(char *)0,0);
-  if ((*suffparray = (struct name *)malloc(sizeof (struct name)))
-                          == (struct name *)0)
-     fatal("No memory for name",(char *)0,0);
-  (*suffparray)->n_next = (struct name *)0;
-
-  if ((str1 = (char *) malloc(LZ1)) == ((char *)0))
-     fatal("No memory for str1",(char *)0,0);
-  str1s.ptr = &str1;
-  str1s.len = LZ1;
-  if ((str2 = (char *) malloc(LZ2)) == (char *)0)
-     fatal("No memory for str2",(char *)0,0);
-  str2s.ptr = &str2;
-  str2s.len = LZ2;
-}
-
-void strrealloc(strs)
-struct str *strs;
-{
-  strs->len *= 2;
-  *strs->ptr = (char *) realloc(*strs->ptr, strs->len + 16);
-  if(*strs->ptr == (char *) NULL)
-       fatal("No memory for string reallocation",(char *)0,0);
-}
-
-/*
- *	Intern a name.  Return a pointer to the name struct
- */
-struct name *newname(name)
-char *name;
-{
-  register struct name *rp;
-  register struct name *rrp;
-  register char        *cp;
-
-  register int           i;
-  register char         *suff;   /* ptr. to suffix in current name */
-  register struct name **sp;     /* ptr. to ptr. to chain of names */
-
-  if ( (suff = suffix(name)) != (char *)NULL) {
-     for (i = 1, sp = suffparray, sp++;
-          i <= maxsuffarray && strcmp(suff, (*sp)->n_name) != 0;
-          sp++,i++);
-     if (i > maxsuffarray) {
-        if ( i >= sizesuffarray) { /* must realloc suffarray */
-           sizesuffarray *= 2;
-           if( (suffparray = (struct name **) realloc((char *) suffparray,
-                sizesuffarray * sizeof(struct name *))) == (struct name **) NULL)
-              fatal("No memory for suffarray",(char *)0,0);
-        }
-        maxsuffarray++;
-        sp = &suffparray[i];
-        if ((*sp = (struct name *)malloc(sizeof (struct name)))
-                                   == (struct name *)0)
-           fatal("No memory for name",(char *)0,0);
-        (*sp)->n_next = (struct name *)0;
-        if ((cp = (char *) malloc(strlen(suff)+1)) == (char *)0)
-           fatal("No memory for name",(char *)0,0);
-        strcpy(cp, suff);
-        (*sp)->n_name = cp;
-     }
-  }
-  else
-     sp = suffparray;
-
-  for ( rp = (*sp)->n_next, rrp = *sp; rp; rp = rp->n_next, rrp = rrp->n_next )
-     if (strcmp(name, rp->n_name) == 0)  return rp;
-
-  if ( freerp ==  (struct name *)NULL) {
-     if ((rp = (struct name *)malloc(sizeof (struct name))) == (struct name *)0)
-        fatal("No memory for name",(char *)0,0);
-  }
-  else  {
-     rp = freerp;
-     freerp =  (struct name *)NULL;
-  }
-  rrp->n_next = rp;
-  rp->n_next = (struct name *)0;
-  if ((cp = (char *) malloc(strlen(name)+1)) == (char *)0)
-     fatal("No memory for name",(char *)0,0);
-  strcpy(cp, name);
-  rp->n_name = cp;
-  rp->n_line = (struct line *)0;
-  rp->n_time = (time_t)0;
-  rp->n_flag = 0;
-  lastrrp = rrp;
-
-  return rp;
-}
-
-/*
- *     Test a name.
- *     If the name already exists return the ptr. to its name structure.
- *     Else if the file exists 'intern' the name and return the ptr.
- *     Otherwise don't waste memory and return a NULL pointer
- */
-struct name *testname(name)
-char *name;
-{
-  register struct name *rp;
-
-  lastrrp = (struct name *)NULL;
-  rp = newname( name);
-  if (rp->n_line || rp->n_flag & N_EXISTS)
-     return(rp);
-  modtime(rp);
-  if (rp->n_flag & N_EXISTS)
-     return(rp);
-  if (lastrrp != (struct name *)NULL) {
-     free (rp->n_name);
-     lastrrp->n_next = (struct name *)NULL;
-     freerp = rp;
-  }
-  return((struct name *)NULL);
-}
-
-
-
-/*
- *	Add a dependant to the end of the supplied list of dependants.
- *	Return the new head pointer for that list.
- */
-struct depend *newdep(np, dp)
-struct name   *np;
-struct depend *dp;
-{
-  register struct depend *rp;
-  register struct depend *rrp;
-
-
-  if ((rp = (struct depend *)malloc(sizeof (struct depend)))
-          == (struct depend *)0)
-	fatal("No memory for dependant",(char *)0,0);
-  rp->d_next = (struct depend *)0;
-  rp->d_name = np;
-
-  if (dp == (struct depend *)0)  return rp;
-
-  for (rrp = dp; rrp->d_next; rrp = rrp->d_next) ;
-
-  rrp->d_next = rp;
-
-  return dp;
-}
-
-
-/*
- *	Add a command to the end of the supplied list of commands.
- *	Return the new head pointer for that list.
- */
-struct cmd *newcmd(str, cp)
-char       *str;
-struct cmd *cp;
-{
-  register struct cmd *rp;
-  register struct cmd *rrp;
-  register char       *rcp;
-
-
-  if (rcp = strrchr(str, '\n'))  *rcp = '\0';	/*  Loose newline  */
-
-  while (isspace(*str))  str++;
-
-  if (*str == '\0')  return cp;		/*  If nothing left, the exit  */
-
-  if ((rp = (struct cmd *)malloc(sizeof (struct cmd))) == (struct cmd *)0)
-	fatal("No memory for command",(char *)0,0);
-  rp->c_next = (struct cmd *)0;
-  if ((rcp = (char *) malloc(strlen(str)+1)) == (char *)0)
-	fatal("No memory for command",(char *)0,0);
-  strcpy(rcp, str);
-  rp->c_cmd = rcp;
-
-  if (cp == (struct cmd *)0)  return rp;
-
-  for (rrp = cp; rrp->c_next; rrp = rrp->c_next) ;
-
-  rrp->c_next = rp;
-
-  return cp;
-}
-
-
-/*
- *	Add a new 'line' of stuff to a target.  This check to see
- *	if commands already exist for the target.  If flag is set,
- *	the line is a double colon target.
- *
- *	Kludges:
- *	i)  If the new name begins with a '.', and there are no dependents,
- *	    then the target must cease to be a target.  This is for .SUFFIXES.
- *	ii) If the new name begins with a '.', with no dependents and has
- *	    commands, then replace the current commands.  This is for
- *	    redefining commands for a default rule.
- *	Neither of these free the space used by dependents or commands,
- *	since they could be used by another target.
- */
-
-void newline(np, dp, cp, flag)
-struct name   *np;
-struct depend *dp;
-struct cmd    *cp;
-int            flag;
-{
-  bool                  hascmds = FALSE;  /*  Target has commands  */
-  register struct line *rp;
-  register struct line *rrp;
-
-
-  /* Handle the .SUFFIXES case */
-  if (np->n_name[0] == '.' && !dp && !cp) {
-	for (rp = np->n_line; rp; rp = rrp) {
-		rrp = rp->l_next;
-		free(rp);
-	}
-	np->n_line = (struct line *)0;
-	np->n_flag &= ~N_TARG;
-	return;
-  }
-
-  /* This loop must happen since rrp is used later. */
-  for ( rp = np->n_line, rrp = (struct line *)0; rp; rrp = rp, rp = rp->l_next)
-	if (rp->l_cmd)  hascmds = TRUE;
-
-  if (hascmds && cp && !(np->n_flag & N_DOUBLE))
-	/* Handle the implicit rules redefinition case */
-	if (np->n_name[0] == '.' && dp == (struct depend *)0) {
-		np->n_line->l_cmd = cp;
-		return;
-	}
-	else
-		error("Commands defined twice for target %s", np->n_name);
-  if (np->n_flag & N_TARG)
-	if (!(np->n_flag & N_DOUBLE) != !flag)		/* like xor */
-		error("Inconsistent rules for target %s", np->n_name);
-
-  if ((rp = (struct line *)malloc(sizeof (struct line))) == (struct line *)0)
-	fatal("No memory for line",(char *)0,0);
-  rp->l_next = (struct line *)0;
-  rp->l_dep = dp;
-  rp->l_cmd = cp;
-
-  if (rrp)
-         rrp->l_next = rp;
-  else
-         np->n_line = rp;
-
-  np->n_flag |= N_TARG;
-  if (flag)  np->n_flag |= N_DOUBLE;
-}
-
-
-/*
- *	Parse input from the makefile, and construct a tree structure
- *	of it.
- */
-void input(fd)
-FILE *fd;
-{
-  char          *p;		/*  General  */
-  char          *q;
-  register char *a;
-  struct name   *np;
-  struct depend *dp;
-  struct cmd    *cp;
-  bool dbl;
-
-
-  if (getline(&str1s, fd))  return;	/*  Read the first line  */
-
-  for(;;) {
-	if (*str1 == TABCHAR)	/*  Rules without targets  */
-		error("Rules not allowed here",(char *)0);
-
-	p = str1;
-
-	while (isspace(*p))  p++;	/*  Find first target  */
-
-
-	while (((q = strchr(p, '=')) != (char *)0) &&
-	    (p != q) && (q[-1] == '\\'))	/*  Find value */
-	{
-		a = q - 1;	/*  Del \ chr; move rest back  */
-		p = q;
-		while(*a++ = *q++)
-			;
-	}
-
-	if (q != (char *)0) {
-
-		*q++ = '\0';		/*  Separate name and val  */
-		while (isspace(*q))
-			q++;
-		if (p = strrchr(q, '\n'))
-			*p = '\0';
-
-		p = str1;
-		if ((a = gettok(&p)) == (char *)0)
-			error("No macro name",(char *)0);
-
-		setmacro(a, q);
-
-		if (getline(&str1s, fd))
-			return;
-		continue;
-	}
-
-	/* include? */
-	p = str1;
-	while (isspace(*p)) p++;
-	if (strncmp(p, "include", 7) == 0 && isspace(p[7])) {
-		char *old_makefile = makefile;
-		int old_lineno = lineno;
-		FILE *ifd;
-
-		p += 8;
-		memmove(str1, p, strlen(p)+1);
-		expand(&str1s);
-		p = str1;
-		while (isspace(*p)) p++;
-
-		if ((q = malloc(strlen(p)+1)) == (char *)0)
-			fatal("No memory for include",(char *)0,0);
-
-		strcpy(q, p);
-		p = q;
-		while ((makefile = gettok(&q)) != (char *)0) {
-			if ((ifd = fopen(makefile, "r")) == (FILE *)0)
-				fatal("Can't open %s: %s", makefile, errno);
-			lineno = 0;
-			input(ifd);
-			fclose(ifd);
-		}
-		free(p);
-		makefile = old_makefile;
-		lineno = old_lineno;
-
-		if (getline(&str1s, fd))
-			return;
-		continue;
-	}
-
-	/* Search for commands on target line --- do not expand them ! */
-	q = str1;
-	cp = (struct cmd *)0;
-	if ((a = strchr(q, ';')) != (char *)0) {
-		*a++ = '\0';	/*  Separate dependents and commands */
-		if ( a) cp = newcmd(a, cp);
-	}
-
-	expand(&str1s);
-	p = str1;
-
-	while (isspace(*p)) p++;
-
-	while (((q = strchr(p, ':')) != (char *)0) &&
-	    (p != q) && (q[-1] == '\\'))	/*  Find dependents  */
-	{
-		a = q - 1;	/*  Del \ chr; move rest back  */
-		p = q;
-		while(*a++ = *q++) ;
-	}
-
-	if (q == (char *)0)
-		error("No targets provided",(char *)0);
-
-	*q++ = '\0';	/*  Separate targets and dependents  */
-
-	if (*q == ':') {		/* Double colon */
-		dbl = 1;
-		q++;
-	}
-	else
-		dbl = 0;
-
-	for (dp = (struct depend *)0; ((p = gettok(&q)) != (char *)0);)
-				/*  get list of dep's */
-	{
-		np = newname(p);		/*  Intern name  */
-		dp = newdep(np, dp);		/*  Add to dep list */
-	}
-
-	*((q = str1) + strlen(str1) + 1) = '\0';
-		/*  Need two nulls for gettok (Remember separation)  */
-
-	if (getline(&str2s, fd) == FALSE) {		/*  Get commands  */
-		while (*str2 == TABCHAR) {
-			cp = newcmd(&str2[0], cp);
-			if (getline(&str2s, fd))
-				break;
-		}
-	}
-
-	while ((p = gettok(&q)) != (char *)0)	/* Get list of targ's */
-	{
-		np = newname(p);		/*  Intern name  */
-		newline(np, dp, cp, dbl);
-		if (!firstname && p[0] != '.')
-			firstname = np;
-	}
-
-	if (feof(fd))				/*  EOF?  */
-		return;
-
-	while (strlen(str2) >= str1s.len) strrealloc(&str1s);
-	strcpy(str1, str2);
-  }
-}
Index: trunk/minix/commands/make/macro.c
===================================================================
--- trunk/minix/commands/make/macro.c	(revision 9)
+++ 	(revision )
@@ -1,197 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   m a c r o . c
- *
- *  Macro control for make
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 23.08.89 Error message corrected                              RAL
- *   3 30.08.89 macro flags added, indention ch.                     PSH,RAL
- *   4 03.09.89 fixed LZ eliminated, doexp(...) changed              RAL
- *   5 06.09.89 M_MAKE added, setDFmacro added                       RAL
- *   6 20.09.89 work around for Minix PC ACK bug                     BE,RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-#include "h.h"
-
-
-static char   buf[256];
-
-struct macro *getmp(name)
-char *name;
-{
-  register struct macro *rp;
-
-  for (rp = macrohead; rp; rp = rp->m_next)
-		if (strcmp(name, rp->m_name) == 0)
-			return rp;
-  return (struct macro *)0;
-}
-
-
-char *getmacro(name)
-char *name;
-{
-  struct macro *mp;
-
-  if (mp = getmp(name))
-		return mp->m_val;
-/*	else*/
-		return "";
-}
-
-
-struct macro *setmacro(name, val)
-char *name;
-char *val;
-{
-  register struct macro *rp;
-  register char         *cp;
-
-
-		/*  Replace macro definition if it exists  */
-  for (rp = macrohead; rp; rp = rp->m_next)
-	if (strcmp(name, rp->m_name) == 0) {
-		if(rp->m_flag & M_OVERRIDE) return rp;	/* mustn't change */
-		free(rp->m_val);	/*  Free space from old  */
-		break;
-		}
-
-	if (!rp)		/*  If not defined, allocate space for new  */
-	{
-		if ((rp = (struct macro *)malloc(sizeof (struct macro)))
-					 == (struct macro *)0)
-			fatal("No memory for macro",(char *)0,0);
-
-		rp->m_next = macrohead;
-		macrohead = rp;
-		rp->m_flag = FALSE;
-
-		if ((cp = (char *) malloc(strlen(name)+1)) == (char *)0)
-			fatal("No memory for macro",(char *)0,0);
-		strcpy(cp, name);
-		rp->m_name = cp;
-	}
-
-	if ((cp = (char *) malloc(strlen(val)+1)) == (char *)0)
-		fatal("No memory for macro",(char *)0,0);
-	strcpy(cp, val);		/*  Copy in new value  */
-	rp->m_val = cp;
-
-  return rp;
-}
-
-
-void setDFmacro(name, val)
-char *name;
-char *val;
-{
-  char        *c,*tmp;
-  int          len;
-  static char  filename[]="@F";
-  static char  dirname[] ="@D";
-
-  setmacro(name,val);
-  *filename = *name;
-  *dirname  = *name;
-  /* Null string -- not defined macro */
-  if ( !(*val)) {
-     setmacro(filename,"");
-     setmacro(dirname,"");
-     return;
-  }
-  if (!(c = strrchr(val,(int)'/'))) {
-     setmacro(filename,val);
-     setmacro(dirname,"./");
-     return;
-  }
-  setmacro(filename,c+1);
-  len = c - val + 1;
-  if((tmp = (char *) malloc(len + 1)) == (char *) 0)
-     fatal("No memory for tmp",(char *)0,0);
-  strncpy(tmp,val,len);
-  tmp[len] = '\0';
-  setmacro(dirname,tmp);
-  free(tmp);
-  return;
-}
-
-/*
- *	Do the dirty work for expand
- */
-void doexp(to, from)
-struct str *to;
-char  *from;
-{
-  register char *rp;
-  register char *p;
-  char *q;
-  struct macro *mp;
-
-
-  rp = from;
-  p  = &(*to->ptr)[to->pos];
-  while (*rp) {
-	if (*rp != '$') {
-		*p++ = *rp++;
-		to->pos++;
-	}
-	else {
-		q = buf;
-		if (*++rp == '{')
-			while (*++rp && *rp != '}')
-				*q++ = *rp;
-		else if (*rp == '(')
-			while (*++rp && *rp != ')')
-				*q++ = *rp;
-		else if (!*rp) {
-			*p++ = '$';
-			to->pos++;
-			goto bail;
-		}
-		else
-			*q++ = *rp;
-		*q = '\0';
-		if (*rp)
-			rp++;
-		if (!(mp = getmp(buf)))
-			mp = setmacro(buf, "");
-		if (mp->m_flag & M_MARK)
-			fatal("Infinitely recursive macro %s", mp->m_name,0);
-		mp->m_flag |= M_MARK;
-		if ( mp->m_flag & M_MAKE) expmake = TRUE;
-		doexp(to, mp->m_val);
-		p = &(*to->ptr)[to->pos];
-		mp->m_flag &= ~M_MARK;
-	}
-  bail:
-	if (to->pos >= to->len) {
-		strrealloc(to);
-		p = &(*to->ptr)[to->pos];
-	}
-  }
-  *p = '\0';
-}
-
-
-/*
- *	Expand any macros in str.
- */
-void expand(strs)
-struct str *strs;
-{
-  char  *a;
-
-  if ((a = (char *) malloc(strlen(*strs->ptr)+1)) == (char *)0)
-     fatal("No memory for temporary string",(char *)0,0);
-  strcpy(a, *strs->ptr);
-  strs->pos = 0;
-  doexp(strs, a);
-  free(a);
-}
Index: trunk/minix/commands/make/main.c
===================================================================
--- trunk/minix/commands/make/main.c	(revision 9)
+++ 	(revision )
@@ -1,288 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   m a i n . c
- *
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 01.07.89 strcmp(makefile,..) only if makefile a valid ptr.    RAL
- *   3 23.08.89 initname() added                                     RAL
- *   4 30.08.89 argument parsing impr., indention ch., macro fl. add.PSH,RAL
- *   5 03.09.89 k-option added, initname -> init changed             RAL
- *   6 06.09.89 environment, MAKEFLAGS, e,d,a options added,         RAL
- *   7 09.09.89 tos support added, fatal args added, fopen makefile  PHH,RAL
- *   8 17.09.89 setoptions fixed for __STDC__                        RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-/*
- *	make:
- *
- *	-a try to guess undefined ambiguous macros (*,<)
- *	-d print debugging info
- *	-e environment macro def. overwrite makefile def.
- *	-f makefile name
- *	-i ignore exit status
- *	-k continue on errors
- *	-n pretend to make
- *	-p print all macros & targets
- *	-q question up-to-dateness of target.  Return exit status 1 if not
- *	-r don't not use inbuilt rules
- *	-s make silently
- *	-t touch files instead of making them
- *	-m Change memory requirements (EON only)
- */
-
-#define EXTERN
-#define INIT(x) = x
-#define INITARRAY
-#include "h.h"
-
-static char version[]= "2.0";
-
-static FILE *ifd;           /*  Input file desciptor  */
-static char *ptrmakeflags;
-
-/* There must be enough 'space' for all possible flags ! */
-static char  makeflags[] = "MAKEFLAGS=                    ";
-
-void main(argc, argv)
-int    argc;
-char **argv;
-{
-  register char        *p;		/*  For argument processing  */
-  int                   estat = 0;	/*  For question  */
-  register struct name *np;
-  struct macro         *mp;
-  int                   targc;		/* temporary for multiple scans */
-  char                **targv;
-  char                **nargv;		/* for removing items from argv */
-  char                **envp;      /* enivironment ptr */
-
-
-  ptrmakeflags = &makeflags[10];
-  myname = (argc-- < 1) ? "make" : *argv++;
-#ifdef tos
-  myname = "Make";
-#endif
-
-  targc = argc;
-  targv = nargv = argv;
-  while (targc--) {
-	if((p = strchr(*targv, '=')) != (char *)NULL) {
-		*p = '\0';
-		mp = setmacro(*targv, p + 1);
-		mp->m_flag |= M_OVERRIDE;
-		--argc;
-	} else
-		*nargv++ = *targv;
-
-	++targv;
-  }
-
-  targc = argc;
-  targv = nargv = argv;
-  while (targc--) {
-	if (**targv == '-') {
-		--argc;
-		p = *targv++;
-		while (*++p != '\0') {
-			switch(mylower(*p)) {
-			case 'f':	/*  Alternate file name  */
-				if (*++p == '\0') {
-					--argc;
-					if (targc-- == 0)
-						usage();
-					p = *targv++;
-				}
-				makefile = p;
-				goto end_of_args;
-#ifdef eon
-			case 'm':	/*  Change space requirements  */
-				if (*++p == '\0') {
-					--argc;
-					if (targc-- <= 0)
-						usage();
-					p = *targv++;
-				}
-				memspace = atoi(p);
-				goto end_of_args;
-#endif
-			default :
-				setoption(*p);
-				break;
-			}
-		}
-	end_of_args:;
-	} else
-		*nargv++ = *targv++;
-  }
-
-  /* evaluate and update environment MAKEFLAGS */
-  if((p =getenv("MAKEFLAGS")) != (char *)0)
-	while(*p) setoption(*p++);
-  for( p = ptrmakeflags; !isspace((int)*p); p++) ;
-  *p = '\0';
-  putenv(makeflags);
-
-
-#ifdef eon
-  if (initalloc(memspace) == 0xffff)  /*  Must get memory for alloc  */
-	fatal("Cannot initalloc memory",(char *)0,0);
-#endif
-
-  if (makefile && strcmp(makefile, "-") == 0)  /*   use stdin as makefile  */
-	ifd = stdin;
-  else if (!makefile) {    /*  If no file, then use default */
-	if ((ifd = fopen(makefile = DEFN1, "r")) == (FILE *)0) {
-		if (errno != MNOENT || !DEFN2)
-			fatal("Can't open %s: %s", DEFN1, errno);
-		else if ((ifd = fopen(makefile = DEFN2, "r")) == (FILE *)0)
-			fatal("Can't open %s: %s", DEFN2, errno);
-	}
-  }
-  else if ((ifd = fopen(makefile, "r")) == (FILE *)0)
-	fatal("Can't open %s: %s", makefile, errno);
-
-  init();
-
-  makerules();
-
-  mp = setmacro("MAKE", myname);
-  mp->m_flag |= M_MAKE;
-  setmacro("$", "$");
-
-  /* set environment macros */
-  envp = environ; /* get actual environment ptr. */
-  while (*envp) {
-	if((p = strchr(*envp, '=')) != (char *)NULL) {
-		*p = '\0';
-		mp = setmacro(*envp, p + 1);
-		*p = '=';
-		if (useenv) mp->m_flag |= M_OVERRIDE;
-	} else
-		fatal("invalid environment: %s",*envp,0);
-
-	++envp;
-  }
-
-  input(ifd);	/*  Input all the gunga  */
-  fclose(ifd);	/*  Finished with makefile  */
-  lineno = 0;	/*  Any calls to error now print no line number */
-
-  if (print)
-	prt();	/*  Print out structures  */
-
-  np = newname(".SILENT");
-  if (np->n_flag & N_TARG)  silent = TRUE;
-
-  np = newname(".IGNORE");
-  if (np->n_flag & N_TARG)  ignore = TRUE;
-
-  precious();
-
-  if (!firstname)
-	fatal("No targets defined",(char *)0,0);
-
-  circh();	/*  Check circles in target definitions  */
-
-  if (!argc)
-	estat = make(firstname, 0);
-  else
-	while (argc--) {
-		estat |= make(newname(*argv++), 0);
-	}
-
-  if (quest)
-	exit(estat);
-  else
-		exit(0);
-}
-
-#ifdef __STDC__
-void setoption(char option)
-#else
-void setoption(option)
-char option;
-#endif
-{
-  register char *c;
-
-  option = mylower(option);
-  switch(option) {
-	case 'n':	/*  Pretend mode  */
-		domake = FALSE;
-		break;
-	case 'i':	/*  Ignore fault mode  */
-		ignore = TRUE;
-		break;
-	case 'k':	/*  Continue on errror  */
-		conterr = TRUE;
-		break;
-	case 's':	/*  Silent about commands  */
-		silent = TRUE;
-		break;
-	case 'p':
-		print = TRUE;
-		break;
-	case 'r':
-		rules = FALSE;
-		break;
-	case 't':
-		dotouch = TRUE;
-		break;
-	case 'q':
-		quest = TRUE;
-		break;
-	case 'e':
-		useenv = TRUE;
-		break;
-	case 'd':
-		dbginfo = TRUE;
-		break;
-	case 'a':
-		ambigmac = TRUE;
-		break;
-	default:	/*  Wrong option  */
-		usage();
-  }
-  for( c = ptrmakeflags; !isspace((int)*c); c++)
-	if ( *c == option) return;
-  *c = option;
-}
-
-void usage()
-{
-  fprintf(stderr, "Syntax: %s [{options | macro=val | target}]\n", myname);
-  fprintf(stderr, "Function: maintaining computer programs      V%s\n",version);
-  fprintf(stderr, "Options : -a : try to guess undefined ambiguous macros (*,<)\n");
-  fprintf(stderr, "          -d : print debugging information\n");
-  fprintf(stderr, "          -e : environment macro def. overwrite makefile def.\n");
-  fprintf(stderr, "          -f filename : makefile name (default: makefile, Makefile)\n");
-  fprintf(stderr, "          -i : ignore exit status of executed commands\n");
-  fprintf(stderr, "          -k : continue with unrelated branches on errors\n");
-  fprintf(stderr, "          -n : pretend to make\n");
-  fprintf(stderr, "          -p : print all macros & targets\n");
-  fprintf(stderr, "          -q : question up-to-dateness of target\n");
-  fprintf(stderr, "          -r : don't use inbuilt rules\n");
-  fprintf(stderr, "          -s : make silently\n");
-  fprintf(stderr, "          -t : touch files instead of making them\n");
-  fprintf(stderr, "Environment: MAKEFLAGS\n");
-  exit(1);
-}
-
-
-void fatal(msg, a1, a2)
-char *msg;
-char *a1;
-int   a2;
-{
-  fprintf(stderr, "%s: ", myname);
-  fprintf(stderr, msg, a1, strerror(a2));
-  fputc('\n', stderr);
-  exit(1);
-}
Index: trunk/minix/commands/make/make.c
===================================================================
--- trunk/minix/commands/make/make.c	(revision 9)
+++ 	(revision )
@@ -1,782 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   m a k e . c
- *
- *  Do the actual making for make plus system dependent stuff
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 01.07.89 $<,$* bugs fixed                                     RAL
- *   3 23.08.89 (time_t)time((time_t*)0) bug fixed, N_EXISTS added   RAL
- *   4 30.08.89 leading sp. in cmd. output eliminated, indention ch. PSH,RAL
- *   5 03.09.89 :: time fixed, error output -> stderr, N_ERROR intr.
- *              fixed LZ elimintaed                                  RAL
- *   6 07.09.89 implmacro, DF macros,debug stuff added               RAL
- *   7 09.09.89 tos support added                                    PHH,RAL
- *   8 17.09.89 make1 arg. fixed, N_EXEC introduced                  RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *     18.05.90 fixed -n bug with silent rules.  (Now echos them.)   PAN
- *
- *************************************************************************/
-
-#include "h.h"
-#include <sys/wait.h>
-#include <unistd.h>
-
-_PROTOTYPE(static void tellstatus, (FILE *out, char *name, int status));
-
-static bool  execflag;
-
-/*
- *	Exec a shell that returns exit status correctly (/bin/esh).
- *	The standard EON shell returns the process number of the last
- *	async command, used by the debugger (ugg).
- *	[exec on eon is like a fork+exec on unix]
- */
-int dosh(string, shell)
-char *string;
-char *shell;
-{
-  int number;
-
-#ifdef unix
-  return system(string);
-#endif
-#ifdef tos
-  return Tosexec(string);
-#endif
-#ifdef eon
-  return ((number = execl(shell, shell,"-c", string, 0)) == -1) ?
-	-1:	/* couldn't start the shell */
-	wait(number);	/* return its exit status */
-#endif
-#ifdef os9
-  int	status, pid;
-
-  strcat(string, "\n");
-  if ((number = os9fork(shell, strlen(string), string, 0, 0, 0)) == -1)
-	return -1;		/* Couldn't start a shell */
-  do {
-	if ((pid = wait(&status)) == -1)
-		return -1;	/* child already died!?!? */
-  } while (pid != number);
-
-  return status;
-#endif
-}
-
-
-#ifdef unix
-/*
- *    Make a file look very outdated after an error trying to make it.
- *    Don't remove, this keeps hard links intact.  (kjb)
- */
-int makeold(name) char *name;
-{
-  struct utimbuf a;
-
-  a.actime = a.modtime = 0;	/* The epoch */
-
-  return utime(name, &a);
-}
-#endif
-
-
-static void tellstatus(out, name, status)
-FILE *out;
-char *name;
-int status;
-{
-  char cwd[PATH_MAX];
-
-  fprintf(out, "%s in %s: ",
-	name, getcwd(cwd, sizeof(cwd)) == NULL ? "?" : cwd);
-
-  if (WIFEXITED(status)) {
-	fprintf(out, "Exit code %d", WEXITSTATUS(status));
-  } else {
-	fprintf(out, "Signal %d%s",
-		WTERMSIG(status), status & 0x80 ? " - core dumped" : "");
-  }
-}
-
-
-/*
- *	Do commands to make a target
- */
-void docmds1(np, lp)
-struct name *np;
-struct line *lp;
-{
-  register char       *q;
-  register char       *p;
-  register struct cmd *cp;
-  bool                 ssilent;
-  bool                 signore;
-  int                  estat;
-  char                *shell;
-
-
-  if (*(shell = getmacro("SHELL")) == '\0')
-#ifdef eon
-	shell = ":bin/esh";
-#endif
-#ifdef unix
-	shell = "/bin/sh";
-#endif
-#ifdef os9
-	shell = "shell";
-#endif
-#ifdef tos
-	shell = "DESKTOP";      /* TOS has no shell */
-#endif
-
-  for (cp = lp->l_cmd; cp; cp = cp->c_next) {
-	execflag = TRUE;
-	strcpy(str1, cp->c_cmd);
-	expmake = FALSE;
-	expand(&str1s);
-	q = str1;
-	ssilent = silent;
-	signore = ignore;
-	while ((*q == '@') || (*q == '-')) {
-		if (*q == '@')	   /*  Specific silent  */
-			ssilent = TRUE;
-		else		   /*  Specific ignore  */
-			signore = TRUE;
-		if (!domake) putchar(*q);  /* Show all characters. */
-		q++;		   /*  Not part of the command  */
-	}
-
-	for (p=q; *p; p++) {
-		if (*p == '\n' && p[1] != '\0') {
-			*p = ' ';
-			if (!ssilent || !domake)
-				fputs("\\\n", stdout);
-		}
-		else if (!ssilent || !domake)
-			putchar(*p);
-	}
-	if (!ssilent || !domake)
-		putchar('\n');
-
-	if (domake || expmake) {	/*  Get the shell to execute it  */
-		fflush(stdout);
-		if ((estat = dosh(q, shell)) != 0) {
-		    if (estat == -1)
-			fatal("Couldn't execute %s", shell,0);
-		    else if (signore) {
-			tellstatus(stdout, myname, estat);
-			printf(" (Ignored)\n");
-		    } else {
-			tellstatus(stderr, myname, estat);
-			fprintf(stderr, "\n");
-			if (!(np->n_flag & N_PREC))
-#ifdef unix
-			    if (makeold(np->n_name) == 0)
-				fprintf(stderr,"%s: made '%s' look old.\n", myname, np->n_name);
-#else
-			    if (unlink(np->n_name) == 0)
-				fprintf(stderr,"%s: '%s' removed.\n", myname, np->n_name);
-#endif
-			if (!conterr) exit(estat != 0);
-			np->n_flag |= N_ERROR;
-			return;
-		    }
-		}
-	}
-  }
-}
-
-
-void docmds(np)
-struct name *np;
-{
-  register struct line *lp;
-
-  for (lp = np->n_line; lp; lp = lp->l_next)
-	docmds1(np, lp);
-}
-
-#ifdef tos
-/*
- *      execute the command submitted by make,
- *      needed because TOS has no internal shell,
- *      so we use Pexec to do the job
- *        v 1.1 of 10/sep/89 by yeti
- */
-
-#define DELM1 ';'
-#define DELM2 ' '
-#define DELM3 ','
-
-int Tosexec(string)
-char *string;
-{
-  register char *help, *help2, c;
-  register unsigned char l=1;
-  char progname[80], command[255], plain[15];
-  static char **envp,*env;
-  register int error,i;
-
-  /* generate strange TOS environment (RAL) */
-  for ( i = 0, envp = environ; *envp; envp++) i += strlen(*envp) +1;
-  if ((env = malloc(i+1)) == (char *)0)
-     fatal("No memory for TOS environment",(char *)0,0);
-  for ( envp = environ, help = env; *envp; envp++) {
-     strcpy ( help, *envp);
-     while ( *(help++)) ;
-  }
-  *help = '\0';
-
-  help = progname;
-  while((*help++=*string++) != ' '); /* progname is command name */
-  *--help = '\0';
-
-  l = strlen(string);             /* build option list */
-  command[0] = l;                 /* TOS likes it complicated */
-  strcpy(&command[1],string);
-  if ((error = (int) Pexec(0,progname,command,env)) != -33) {
-    free(env);
-    return(error);
-  }
-
-  /* could'nt find program, try to search the PATH */
-  if((help=strrchr(progname,'\\')) != (char *) 0)  /* just the */
-          strcpy(plain,++help);                     /* name     */
-  else if((help=strrchr(progname,'/')) != (char *) 0)
-          strcpy(plain,++help);
-  else if((help=strrchr(progname,':')) != (char *) 0)
-          strcpy(plain,++help);
-  else
-          strcpy(plain,progname);
-
-  if(*(help=getmacro("PATH")) == '\0') {
-    free(env);
-    return(-33);
-  }
-  c = 1;
-  while(c)
-  {       help2 = &progname[-1];
-          i = 0;
-          while((c=*help++) != '\0' && i<80 && c != DELM1
-                 && c != DELM2 && c != DELM3)
-                  *++help2 = c, i++;
-          *++help2 = '\\';
-          strcpy(++help2,plain);
-          if((error=(int) Pexec(0,progname,command,env))!=-33) {
-                  free(env);
-                  return(error);
-          }
-  }
-  free(env);
-  return(-33);
-}
-
-
-/* (stolen from ZOO -- thanks to Rahul Dehsi)
-Function mstonix() accepts an MSDOS format date and time and returns
-a **IX format time.  No adjustment is done for timezone.
-*/
-
-time_t mstonix (date, time)
-unsigned int date, time;
-{
-   int year, month, day, hour, min, sec, daycount;
-   time_t longtime;
-   /* no. of days to beginning of month for each month */
-   static int dsboy[12] = { 0, 31, 59, 90, 120, 151, 181, 212,
-                              243, 273, 304, 334};
-
-   if (date == 0 && time == 0)			/* special case! */
-      return (0L);
-
-   /* part of following code is common to zoolist.c */
-   year  =  (((unsigned int) date >> 9) & 0x7f) + 1980;
-   month =  ((unsigned int) date >> 5) & 0x0f;
-   day   =  date        & 0x1f;
-
-   hour =  ((unsigned int) time >> 11)& 0x1f;
-   min   =  ((unsigned int) time >> 5) & 0x3f;
-   sec   =  ((unsigned int) time & 0x1f) * 2;
-
-/* DEBUG and leap year fixes thanks to Mark Alexander <uunet!amdahl!drivax!alexande>*/
-#ifdef DEBUG
-   printf ("mstonix:  year=%d  month=%d  day=%d  hour=%d  min=%d  sec=%d\n",
-         year, month, day, hour, min, sec);
-#endif
-   /* Calculate days since 1970/01/01 */
-   daycount = 365 * (year - 1970) +    /* days due to whole years */
-               (year - 1969) / 4 +     /* days due to leap years */
-               dsboy[month-1] +        /* days since beginning of this year */
-               day-1;                  /* days since beginning of month */
-
-   if (year % 4 == 0 &&
-       year % 400 != 0 && month >= 3)  /* if this is a leap year and month */
-      daycount++;                      /* is March or later, add a day */
-
-   /* Knowing the days, we can find seconds */
-   longtime = daycount * 24L * 60L * 60L    +
-          hour * 60L * 60L   +   min * 60   +    sec;
-	return (longtime);
-}
-#endif /* tos */
-
-#ifdef os9
-/*
- *	Some stuffing around to get the modified time of a file
- *	in an os9 file system
- */
-void getmdate(fd, tbp)
-int fd;
-struct sgtbuf *tbp;
-{
-  struct registers     regs;
-  static struct fildes fdbuf;
-
-
-  regs.rg_a = fd;
-  regs.rg_b = SS_FD;
-  regs.rg_x = &fdbuf;
-  regs.rg_y = sizeof (fdbuf);
-
-  if (_os9(I_GETSTT, &regs) == -1) {
-	errno = regs.rg_b & 0xff;
-	return -1;
-  }
-  if (tbp)
-  {
-	_strass(tbp, fdbuf.fd_date, sizeof (fdbuf.fd_date));
-	tbp->t_second = 0;	/* Files are only acurate to mins */
-  }
-  return 0;
-}
-
-
-/*
- *	Kludge routine to return an aproximation of how many
- *	seconds since 1980.  Dates will be in order, but will not
- *	be lineer
- */
-time_t cnvtime(tbp)
-struct sgtbuf *tbp;
-{
-  long acc;
-
-  acc = tbp->t_year - 80;		/* Baseyear is 1980 */
-  acc = acc * 12 + tbp->t_month;
-  acc = acc * 31 + tbp->t_day;
-  acc = acc * 24 + tbp->t_hour;
-  acc = acc * 60 + tbp->t_minute;
-  acc = acc * 60 + tbp->t_second;
-
-  return acc;
-}
-
-
-/*
- *	Get the current time in the internal format
- */
-void time(tp)
-time_t *tp;
-{
-  struct sgtbuf tbuf;
-
-
-  if (getime(&tbuf) < 0)
-	return -1;
-
-  if (tp)
-	*tp = cnvtime(&tbuf);
-
-  return 0;
-}
-#endif
-
-
-/*
- *	Get the modification time of a file.  If the first
- *	doesn't exist, it's modtime is set to 0.
- */
-void modtime(np)
-struct name *np;
-{
-#ifdef unix
-  struct stat info;
-  int r;
-
-  if (is_archive_ref(np->n_name)) {
-	r = archive_stat(np->n_name, &info);
-  } else {
-	r = stat(np->n_name, &info);
-  }
-  if (r < 0) {
-	if (errno != ENOENT)
-		fatal("Can't open %s: %s", np->n_name, errno);
-
-	np->n_time = 0L;
-	np->n_flag &= ~N_EXISTS;
-  } else {
-	np->n_time = info.st_mtime;
-	np->n_flag |= N_EXISTS;
-  }
-#endif
-#ifdef tos
-  struct DOSTIME fm;
-  int fd;
-
-  if((fd=Fopen(np->n_name,0)) < 0) {
-        np->n_time = 0L;
-	np->n_flag &= ~N_EXISTS;
-  }
-  else {
-        Fdatime(&fm,fd,0);
-        Fclose(fd);
-        np->n_time = mstonix((unsigned int)fm.date,(unsigned int)fm.time);
-        np->n_flag |= N_EXISTS;
-  }
-#endif
-#ifdef eon
-  struct stat  info;
-  int          fd;
-
-  if ((fd = open(np->n_name, 0)) < 0) {
-	if (errno != ER_NOTF)
-		fatal("Can't open %s: %s", np->n_name, errno);
-
-	np->n_time = 0L;
-	np->n_flag &= ~N_EXISTS;
-  }
-  else if (getstat(fd, &info) < 0)
-	fatal("Can't getstat %s: %s", np->n_name, errno);
-  else {
-	np->n_time = info.st_mod;
-	np->n_flag |= N_EXISTS;
-  }
-
-  close(fd);
-#endif
-#ifdef os9
-  struct sgtbuf  info;
-  int            fd;
-
-  if ((fd = open(np->n_name, 0)) < 0) {
-  if (errno != E_PNNF)
-		fatal("Can't open %s: %s", np->n_name, errno);
-
-	np->n_time = 0L;
-	np->n_flag &= ~N_EXISTS;
-  }
-  else if (getmdate(fd, &info) < 0)
-	fatal("Can't getstat %s: %s", np->n_name, errno);
-  else {
-	np->n_time = cnvtime(&info);
-	np->n_flag |= N_EXISTS;
-  }
-
-  close(fd);
-#endif
-}
-
-
-/*
- *	Update the mod time of a file to now.
- */
-void touch(np)
-struct name *np;
-{
-  char  c;
-  int   fd;
-
-  if (!domake || !silent) printf("touch(%s)\n", np->n_name);
-
-  if (domake) {
-#ifdef unix
-	struct utimbuf   a;
-
-	a.actime = a.modtime = time((time_t *)NULL);
-	if (utime(np->n_name, &a) < 0)
-		printf("%s: '%s' not touched - non-existant\n",
-				myname, np->n_name);
-#endif
-#ifdef tos
-        struct DOSTIME fm;
-        int fd;
-
-        if((fd=Fopen(np->n_name,0)) < 0) {
-                printf("%s: '%s' not touched - non-existant\n",
-                                myname, np->n_name);
-        }
-        else {
-                fm.date = Tgetdate();
-                fm.time = Tgettime();
-                Fdatime(&fm,fd,1);
-                Fclose(fd);
-        }
-#endif
-#ifdef eon
-	if ((fd = open(np->n_name, 0)) < 0)
-		printf("%s: '%s' not touched - non-existant\n",
-				myname, np->n_name);
-	else
-	{
-		uread(fd, &c, 1, 0);
-		uwrite(fd, &c, 1);
-	}
-	close(fd);
-#endif
-#ifdef os9
-	/*
-	 *	Strange that something almost as totally useless
-	 *	as this is easy to do in os9!
-	 */
-	if ((fd = open(np->n_name, S_IWRITE)) < 0)
-		printf("%s: '%s' not touched - non-existant\n",
-				myname, np->n_name);
-	close(fd);
-#endif
-  }
-}
-
-
-/*
- *	Recursive routine to make a target.
- */
-int make(np, level)
-struct name *np;
-int          level;
-{
-  register struct depend  *dp;
-  register struct line    *lp;
-  register struct depend  *qdp;
-  time_t  now, t, dtime = 0;
-  bool    dbgfirst     = TRUE;
-  char   *basename  = (char *) 0;
-  char   *inputname = (char *) 0;
-
-  if (np->n_flag & N_DONE) {
-     if(dbginfo) dbgprint(level,np,"already done");
-     return 0;
-  }
-
-  modtime(np);		/*  Gets modtime of this file  */
-
-  while (time(&now) == np->n_time) {
-     /* Time of target is equal to the current time.  This bothers us, because
-      * we can't tell if it needs to be updated if we update a file it depends
-      * on within a second.  So wait until the second is over.
-      */
-     usleep(10000);
-  }
-
-  if (rules) {
-     for (lp = np->n_line; lp; lp = lp->l_next)
-        if (lp->l_cmd)
-           break;
-     if (!lp)
-        dyndep(np,&basename,&inputname);
-  }
-
-  if (!(np->n_flag & (N_TARG | N_EXISTS))) {
-     fprintf(stderr,"%s: Don't know how to make %s\n", myname, np->n_name);
-     if (conterr) {
-        np->n_flag |= N_ERROR;
-        if (dbginfo) dbgprint(level,np,"don't know how to make");
-        return 0;
-     }
-     else  exit(1);
-  }
-
-  for (qdp = (struct depend *)0, lp = np->n_line; lp; lp = lp->l_next) {
-     for (dp = lp->l_dep; dp; dp = dp->d_next) {
-        if(dbginfo && dbgfirst) {
-           dbgprint(level,np," {");
-           dbgfirst = FALSE;
-        }
-        make(dp->d_name, level+1);
-        if (np->n_time < dp->d_name->n_time)
-           qdp = newdep(dp->d_name, qdp);
-        dtime = max(dtime, dp->d_name->n_time);
-        if (dp->d_name->n_flag & N_ERROR) np->n_flag |= N_ERROR;
-        if (dp->d_name->n_flag & N_EXEC ) np->n_flag |= N_EXEC;
-     }
-     if (!quest && (np->n_flag & N_DOUBLE) &&
-           (np->n_time < dtime || !( np->n_flag & N_EXISTS))) {
-        execflag = FALSE;
-        make1(np, lp, qdp, basename, inputname); /* free()'s qdp */
-        dtime = 0;
-        qdp = (struct depend *)0;
-        if(execflag) np->n_flag |= N_EXEC;
-     }
-  }
-
-  np->n_flag |= N_DONE;
-
-  if (quest) {
-     t = np->n_time;
-     np->n_time = now;
-     return (t < dtime);
-  }
-  else if ((np->n_time < dtime || !( np->n_flag & N_EXISTS))
-               && !(np->n_flag & N_DOUBLE)) {
-     execflag = FALSE;
-     make1(np, (struct line *)0, qdp, basename, inputname); /* free()'s qdp */
-     np->n_time = now;
-     if ( execflag) np->n_flag |= N_EXEC;
-  }
-  else if ( np->n_flag & N_EXEC ) {
-     np->n_time = now;
-  }
-
-  if (dbginfo) {
-     if(dbgfirst) {
-        if(np->n_flag & N_ERROR)
-              dbgprint(level,np,"skipped because of error");
-        else if(np->n_flag & N_EXEC)
-              dbgprint(level,np,"successfully made");
-        else  dbgprint(level,np,"is up to date");
-     }
-     else {
-        if(np->n_flag & N_ERROR)
-              dbgprint(level,(struct name *)0,"} skipped because of error");
-        else if(np->n_flag & N_EXEC)
-              dbgprint(level,(struct name *)0,"} successfully made");
-        else  dbgprint(level,(struct name *)0,"} is up to date");
-     }
-  }
-  if (level == 0 && !(np->n_flag & N_EXEC))
-     printf("%s: '%s' is up to date\n", myname, np->n_name);
-
-  if(basename)
-     free(basename);
-  return 0;
-}
-
-
-void make1(np, lp, qdp, basename, inputname)
-struct name *np;
-struct line *lp;
-register struct depend *qdp;
-char        *basename;
-char        *inputname;
-{
-  register struct depend *dp;
-  size_t l1, l2;
-
-  if (dotouch)
-    touch(np);
-  else if (!(np->n_flag & N_ERROR)) {
-    strcpy(str1, "");
-
-    if(!inputname) {
-       inputname = str1;  /* default */
-       if (ambigmac) implmacros(np,lp,&basename,&inputname);
-    }
-    setDFmacro("<",inputname);
-
-    if(!basename)
-       basename = str1;
-    setDFmacro("*",basename);
-
-    for (dp = qdp; dp; dp = qdp) {
-       l1= strlen(str1);
-       l2= strlen(dp->d_name->n_name);
-       while (l1 + 1 + l2 +1 > str1s.len)
-       		strrealloc(&str1s);
-       if (strlen(str1))
-          strcat(str1, " ");
-       strcat(str1, dp->d_name->n_name);
-       qdp = dp->d_next;
-       free(dp);
-    }
-    setmacro("?", str1);
-    setDFmacro("@", np->n_name);
-
-    if (lp)		/* lp set if doing a :: rule */
-       docmds1(np, lp);
-    else
-       docmds(np);
-  }
-}
-
-void implmacros(np,lp, pbasename,pinputname)
-struct name *np;
-struct line *lp;
-char        **pbasename;		/*  Name without suffix  */
-char        **pinputname;
-{
-  struct line   *llp;
-  register char *p;
-  register char *q;
-  register char *suff;				/*  Old suffix  */
-  int            baselen;
-  struct depend *dp;
-  bool           dpflag = FALSE;
-
-  /* get basename out of target name */
-  p = str2;
-  q = np->n_name;
-  suff = suffix(q);
-  while ( *q && (q < suff || !suff)) *p++ = *q++;
-  *p = '\0';
-  if ((*pbasename = (char *) malloc(strlen(str2)+1)) == (char *)0 )
-     fatal("No memory for basename",(char *)0,0);
-  strcpy(*pbasename,str2);
-  baselen = strlen(str2);
-
-  if ( lp)
-     llp = lp;
-  else
-     llp = np->n_line;
-
-  while (llp) {
-     for (dp = llp->l_dep; dp; dp = dp->d_next) {
-        if( strncmp(*pbasename,dp->d_name->n_name,baselen) == 0) {
-           *pinputname = dp->d_name->n_name;
-           return;
-        }
-        if( !dpflag) {
-           *pinputname = dp->d_name->n_name;
-           dpflag = TRUE;
-        }
-     }
-     if (lp) break;
-     llp = llp->l_next;
-  }
-
-#if NO_WE_DO_WANT_THIS_BASENAME
-  free(*pbasename);  /* basename ambiguous or no dependency file */
-  *pbasename = (char *)0;
-#endif
-  return;
-}
-
-void dbgprint(level,np,comment)
-int          level;
-struct name *np;
-char        *comment;
-{
-  char *timep;
-
-  if(np) {
-     timep = ctime(&np->n_time);
-     timep[24] = '\0';
-     fputs(&timep[4],stdout);
-  }
-  else fputs("                    ",stdout);
-  fputs("   ",stdout);
-  while(level--) fputs("  ",stdout);
-  if (np) {
-     fputs(np->n_name,stdout);
-     if (np->n_flag & N_DOUBLE) fputs("  :: ",stdout);
-     else                       fputs("  : ",stdout);
-  }
-  fputs(comment,stdout);
-  putchar((int)'\n');
-  fflush(stdout);
-  return;
-}
-
Index: trunk/minix/commands/make/reader.c
===================================================================
--- trunk/minix/commands/make/reader.c	(revision 9)
+++ 	(revision )
@@ -1,134 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   r e a d e r . c
- *
- *  Read in makefile
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 23.08.89 cast to NULL added                                   RAL
- *   3 30.08.89 indention changed                                    PSH,RAL
- *   4 03.09.89 fixed LZ eliminated                                  RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-#include "h.h"
-
-
-/*
- *	Syntax error handler.  Print message, with line number, and exits.
- */
-void error(msg, a1)
-char *msg;
-char *a1;
-{
-  fprintf(stderr, "%s: ", myname);
-  fprintf(stderr, msg, a1);
-  if (lineno)  fprintf(stderr, " in %s near line %d", makefile, lineno);
-  fputc('\n', stderr);
-  exit(1);
-}
-
-
-/*
- *	Read a line into the supplied string.  Remove
- *	comments, ignore blank lines. Deal with	quoted (\) #, and
- *	quoted newlines.  If EOF return TRUE.
- *
- *	The comment handling code has been changed to leave comments and
- *	backslashes alone in shell commands (lines starting with a tab).
- *	This is not what POSIX wants, but what all makes do.  (KJB)
- */
-bool getline(strs, fd)
-struct str *strs;
-FILE *fd;
-{
-  register char *p;
-  char          *q;
-  int            c;
-
-  for (;;) {
-	strs->pos = 0;
-	for (;;) {
-		do {
-			if (strs->pos >= strs->len)
-				strrealloc(strs);
-			if ((c = getc(fd)) == EOF)
-				return TRUE;		/* EOF */
-			(*strs->ptr)[strs->pos++] = c;
-		} while (c != '\n');
-
-		lineno++;
-
-		if (strs->pos >= 2 && (*strs->ptr)[strs->pos - 2] == '\\') {
-			(*strs->ptr)[strs->pos - 2] = '\n';
-			strs->pos--;
-		} else {
-			break;
-		}
-	}
-
-	if (strs->pos >= strs->len)
-		strrealloc(strs);
-	(*strs->ptr)[strs->pos] = '\0';
-
-	p = q =  *strs->ptr;
-	while (isspace(*q)) q++;
-	if (*p != '\t' || *q == '#') {
-		while (((q = strchr(p, '#')) != (char *)0) &&
-		    (p != q) && (q[-1] == '\\'))
-		{
-			char	*a;
-
-			a = q - 1;	/*  Del \ chr; move rest back  */
-			p = q;
-			while (*a++ = *q++)
-				;
-		}
-		if (q != (char *)0)
-			{
-			q[0] = '\n';
-			q[1] = '\0';
-		}
-	}
-
-	p = *strs->ptr;
-	while (isspace(*p))	/*  Checking for blank  */
-		p++;
-
-	if (*p != '\0')
-		return FALSE;
-  }
-}
-
-
-/*
- *	Get a word from the current line, surounded by white space.
- *	return a pointer to it. String returned has no white spaces
- *	in it.
- */
-char  *gettok(ptr)
-register char **ptr;
-{
-  register char *p;
-
-
-  while (isspace(**ptr))	/*  Skip spaces  */
-	(*ptr)++;
-
-  if (**ptr == '\0')	/*  Nothing after spaces  */
-	return ((char *)NULL);
-
-  p = *ptr;		/*  word starts here  */
-
-  while ((**ptr != '\0') && (!isspace(**ptr)))
-	(*ptr)++;	/*  Find end of word  */
-
-  *(*ptr)++ = '\0';	/*  Terminate it  */
-
-  return(p);
-}
Index: trunk/minix/commands/make/rules.c
===================================================================
--- trunk/minix/commands/make/rules.c	(revision 9)
+++ 	(revision )
@@ -1,314 +1,0 @@
-/*************************************************************************
- *
- *  m a k e :   r u l e s . c
- *
- *  Control of the implicit suffix rules
- *========================================================================
- * Edition history
- *
- *  #    Date                         Comments                       By
- * --- -------- ---------------------------------------------------- ---
- *   1    ??                                                         ??
- *   2 01.07.89 $<,$* bugs fixed, impl. r. ending in expl. r. added  RAL
- *   3 23.08.89 suffix as macro, testname intr., algorithem to find
- *              source dep. made more intelligent (see Readme3)      RAL
- *   4 30.08.89 indention changed                                    PSH,RAL
- *   5 03.09.89 fixed LZ eliminated                                  RAL
- *   6 07.09.89 rules of type '.c', .DEFAULT added, dep. search impr.RAL
- * ------------ Version 2.0 released ------------------------------- RAL
- *
- *************************************************************************/
-
-#include "h.h"
-
-
-/*
- *	Dynamic dependency.  This routine applies the suffis rules
- *	to try and find a source and a set of rules for a missing
- *	target.  If found, np is made into a target with the implicit
- *	source name, and rules.  Returns TRUE if np was made into
- *	a target.
- */
-bool dyndep(np,pbasename,pinputname)
-struct name  *np;
-char        **pbasename;		/*  Name without suffix  */
-char        **pinputname;
-{
-  register char *p;
-  register char *q;
-  register char *suff;				/*  Old suffix  */
-  struct name   *op = (struct name *)0,*optmp;	/*  New dependent  */
-  struct name   *sp;				/*  Suffix  */
-  struct line   *lp,*nlp;
-  struct depend *dp,*ndp;
-  struct cmd    *cmdp;
-  char          *newsuff;
-  bool           depexists = FALSE;
-
-
-  p = str1;
-  q = np->n_name;
-  suff = suffix(q);
-  while (*q && (q < suff || !suff)) *p++ = *q++;
-  *p = '\0';
-  if ((*pbasename = (char *) malloc(strlen(str1)+1)) == (char *)0 )
-     fatal("No memory for basename",(char *)0,0);
-  strcpy(*pbasename,str1);
-  if ( !suff) suff = p - str1 + *pbasename;  /* set suffix to nullstring */
-
-  if (!((sp = newname(".SUFFIXES"))->n_flag & N_TARG))  return FALSE;
-
-  /* search all .SUFFIXES lines */
-  for (lp = sp->n_line; lp; lp = lp->l_next)
-     /* try all suffixes */
-     for (dp = lp->l_dep; dp; dp = dp->d_next) {
-        /* compose implicit rule name (.c.o)...*/
-        newsuff = dp->d_name->n_name;
-        while (strlen(suff)+strlen(newsuff)+1 >= str1s.len) strrealloc(&str1s);
-        p = str1;
-        q = newsuff;
-        while (*p++ = *q++) ;
-        p--;
-        q = suff;
-        while (*p++ = *q++) ;
-        /* look if the rule exists */
-        sp = newname(str1);
-        if (sp->n_flag & N_TARG) {
-           /* compose resulting dependency name */
-           while (strlen(*pbasename) + strlen(newsuff)+1 >= str1s.len)
-              strrealloc(&str1s);
-           q = *pbasename;
-           p = str1;
-           while (*p++ = *q++) ;
-           p--;
-           q = newsuff;
-           while (*p++ = *q++) ;
-           /* test if dependency file or an explicit rule exists */
-           if ((optmp= testname(str1)) != (struct name *)0) {
-              /* store first possible dependency as default */
-              if ( op == (struct name *)0) {
-                 op = optmp;
-                 cmdp = sp->n_line->l_cmd;
-              }
-              /* check if testname is an explicit dependency */
-              for ( nlp=np->n_line; nlp; nlp=nlp->l_next) {
-                 for( ndp=nlp->l_dep; ndp; ndp=ndp->d_next) {
-                    if ( strcmp( ndp->d_name->n_name, str1) == 0) {
-                       op = optmp;
-                       cmdp = sp->n_line->l_cmd;
-                       ndp = (struct depend *) 0;
-                       goto found2;
-                    }
-                    depexists = TRUE;
-                 }
-              }
-              /* if no explicit dependencies : accept testname */
-              if (!depexists)  goto found;
-           }
-        }
-     }
-
-  if ( op == (struct name *)0) {
-     if( np->n_flag & N_TARG) {     /* DEFAULT handling */
-        if (!((sp = newname(".DEFAULT"))->n_flag & N_TARG))  return FALSE;
-        if (!(sp->n_line)) return FALSE;
-        cmdp = sp->n_line->l_cmd;
-        for ( nlp=np->n_line; nlp; nlp=nlp->l_next) {
-           if ( ndp=nlp->l_dep) {
-              op = ndp->d_name;
-              ndp = (struct depend *)0;
-              goto found2;
-           }
-        }
-        newline(np, (struct depend *)0, cmdp, 0);
-        *pinputname = (char *)0;
-        *pbasename  = (char *)0;
-        return TRUE;
-     }
-  else return FALSE;
-  }
-
-found:
-  ndp = newdep(op, (struct depend *)0);
-found2:
-  newline(np, ndp, cmdp, 0);
-  *pinputname = op->n_name;
-  return TRUE;
-}
-
-
-/*
- *	Make the default rules
- */
-void makerules()
-{
-  struct cmd    *cp;
-  struct name   *np;
-  struct depend *dp;
-
-
-#ifdef eon
-  setmacro("BDSCC", "asm");
-  /*	setmacro("BDSCFLAGS", "");	*/
-  cp = newcmd("$(BDSCC) $(BDSCFLAGS) -n $<", (struct cmd *)0);
-  np = newname(".c.o");
-  newline(np, (struct depend *)0, cp, 0);
-
-  setmacro("CC", "c");
-  setmacro("CFLAGS", "-O");
-  cp = newcmd("$(CC) $(CFLAGS) -c $<", (struct cmd *)0);
-  np = newname(".c.obj");
-  newline(np, (struct depend *)0, cp, 0);
-
-  setmacro("M80", "asm -n");
-  /*	setmacro("M80FLAGS", "");	*/
-  cp = newcmd("$(M80) $(M80FLAGS) $<", (struct cmd *)0);
-  np = newname(".mac.o");
-  newline(np, (struct depend *)0, cp, 0);
-
-  setmacro("AS", "zas");
-  /*	setmacro("ASFLAGS", "");	*/
-  cp = newcmd("$(ZAS) $(ASFLAGS) -o $@ $<", (struct cmd *)0);
-  np = newname(".as.obj");
-  newline(np, (struct depend *)0, cp, 0);
-
-  np = newname(".as");
-  dp = newdep(np, (struct depend *)0);
-  np = newname(".obj");
-  dp = newdep(np, dp);
-  np = newname(".c");
-  dp = newdep(np, dp);
-  np = newname(".o");
-  dp = newdep(np, dp);
-  np = newname(".mac");
-  dp = newdep(np, dp);
-  np = newname(".SUFFIXES");
-  newline(np, dp, (struct cmd *)0, 0);
-#endif
-
-#ifdef tos
-#define unix
-#endif
-
-/*
- *	Some of the UNIX implicit rules
- */
-
-#ifdef unix
-
-  setmacro("CC", "cc");
-  setmacro("CFLAGS", "");
-
-  cp = newcmd("$(CC) -S $(CFLAGS) $<", (struct cmd *)0);
-  np = newname(".c.s");
-  newline(np, (struct depend *)0, cp, 0);
-
-  cp = newcmd("$(CC) -c $(CFLAGS) $<", (struct cmd *)0);
-  np = newname(".c.o");
-  newline(np, (struct depend *)0, cp, 0);
-
-#if this_rule_is_a_bit_too_much_of_a_good_thing
-#ifdef MINIXPC
-  cp = newcmd("$(CC) $(CFLAGS) -i -o $@ $<", (struct cmd *)0);
-#else
-  cp = newcmd("$(CC) $(CFLAGS) -o $@ $<", (struct cmd *)0);
-#endif /* MINIXPC */
-  np = newname(".c");
-  newline(np, (struct depend *)0, cp, 0);
-#endif
-
-  cp = newcmd("$(CC) -c $(CFLAGS) $<", (struct cmd *)0);
-  np = newname(".s.o");
-  newline(np, (struct depend *)0, cp, 0);
-
-  setmacro("YACC", "yacc");
-  /*setmacro("YFLAGS", "");	*/
-  cp = newcmd("$(YACC) $(YFLAGS) $<", (struct cmd *)0);
-  cp = newcmd("mv y.tab.c $@", cp);
-  np = newname(".y.c");
-  newline(np, (struct depend *)0, cp, 0);
-
-  cp = newcmd("$(YACC) $(YFLAGS) $<", (struct cmd *)0);
-  cp = newcmd("$(CC) $(CFLAGS) -c y.tab.c", cp);
-  cp = newcmd("mv y.tab.o $@", cp);
-  np = newname(".y.o");
-  cp = newcmd("rm y.tab.c", cp);
-  newline(np, (struct depend *)0, cp, 0);
-
-  setmacro("FLEX", "flex");
-  cp = newcmd("$(FLEX) $(FLEX_FLAGS) $<", (struct cmd *)0);
-  cp = newcmd("mv lex.yy.c $@", cp);
-  np = newname(".l.c");
-  newline(np, (struct depend *)0, cp, 0);
-
-  cp = newcmd("$(FLEX) $(FLEX_FLAGS) $<", (struct cmd *)0);
-  cp = newcmd("$(CC) $(CFLAGS) -c lex.yy.c", cp);
-  cp = newcmd("mv lex.yy.o $@", cp);
-  np = newname(".l.o");
-  cp = newcmd("rm lex.yy.c", cp);
-  newline(np, (struct depend *)0, cp, 0);
-
-  np = newname(".o");
-  dp = newdep(np, (struct depend *)0);
-  np = newname(".s");
-  dp = newdep(np, dp);
-  np = newname(".c");
-  dp = newdep(np, dp);
-  np = newname(".y");
-  dp = newdep(np, dp);
-  np = newname(".l");
-  dp = newdep(np, dp);
-  np = newname(".SUFFIXES");
-  newline(np, dp, (struct cmd *)0, 0);
-
-#endif /* unix */
-
-
-#ifdef os9
-/*
- *	Fairlight use an enhanced version of the C sub-system.
- *	They have a specialised macro pre-processor.
- */
-  setmacro("CC", "cc");
-  setmacro("CFLAGS", "-z");
-  cp = newcmd("$(CC) $(CFLAGS) -r $<", (struct cmd *)0);
-
-  np = newname(".c.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".ca.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".a.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".o.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".mc.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".mca.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".ma.r");
-  newline(np, (struct depend *)0, cp, 0);
-  np = newname(".mo.r");
-  newline(np, (struct depend *)0, cp, 0);
-
-  np = newname(".r");
-  dp = newdep(np, (struct depend *)0);
-  np = newname(".mc");
-  dp = newdep(np, dp);
-  np = newname(".mca");
-  dp = newdep(np, dp);
-  np = newname(".c");
-  dp = newdep(np, dp);
-  np = newname(".ca");
-  dp = newdep(np, dp);
-  np = newname(".ma");
-  dp = newdep(np, dp);
-  np = newname(".mo");
-  dp = newdep(np, dp);
-  np = newname(".o");
-  dp = newdep(np, dp);
-  np = newname(".a");
-  dp = newdep(np, dp);
-  np = newname(".SUFFIXES");
-  newline(np, dp, (struct cmd *)0, 0);
-#endif
-}
