BSD 4_4_Lite2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 25 May 1993 14:51:26 +0000 (06:51 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 25 May 1993 14:51:26 +0000 (06:51 -0800)
Work on file usr/src/contrib/mkmf/src/buildlist.c
Work on file usr/src/contrib/mkmf/src/Mkmf.c
Work on file usr/src/contrib/mkmf/src/badopt.c
Work on file usr/src/contrib/mkmf/src/editmf.c
Work on file usr/src/contrib/mkmf/src/dlist.c
Work on file usr/src/contrib/mkmf/src/depend.c
Work on file usr/src/contrib/mkmf/src/hash.c
Work on file usr/src/contrib/mkmf/src/getcwp.c
Work on file usr/src/contrib/mkmf/src/getproject.c
Work on file usr/src/contrib/mkmf/src/iolin.c
Work on file usr/src/contrib/mkmf/src/macro.c
Work on file usr/src/contrib/mkmf/src/mksrclist.c
Work on file usr/src/contrib/mkmf/src/misc.c
Work on file usr/src/contrib/mkmf/src/mustfopen.c
Work on file usr/src/contrib/mkmf/src/pathcat.c
Work on file usr/src/contrib/mkmf/src/mksymlink.c
Work on file usr/src/contrib/mkmf/src/optpath.c
Work on file usr/src/contrib/mkmf/src/rule.c
Work on file usr/src/contrib/mkmf/src/slappend.c
Work on file usr/src/contrib/mkmf/src/pperror.c
Work on file usr/src/contrib/mkmf/src/pathhead.c
Work on file usr/src/contrib/mkmf/src/slrm.c
Work on file usr/src/contrib/mkmf/src/slvect.c
Work on file usr/src/contrib/mkmf/src/slvtol.c
Work on file usr/src/contrib/mkmf/src/slsort.c
Work on file usr/src/contrib/mkmf/src/strpcpy.c
Work on file usr/src/contrib/mkmf/src/slinit.c
Work on file usr/src/contrib/mkmf/src/strsav.c
Work on file usr/src/contrib/mkmf/src/usage.c
Work on file usr/src/contrib/mkmf/src/warn.c
Work on file usr/src/contrib/mkmf/src/suffix.c
Work on file usr/src/contrib/mkmf/src/defaultsfx.h
Work on file usr/src/contrib/mkmf/src/defaultrul.h
Work on file usr/src/contrib/mkmf/src/hash.h
Work on file usr/src/contrib/mkmf/src/dir.h
Work on file usr/src/contrib/mkmf/src/getarg.h
Work on file usr/src/contrib/mkmf/src/dlist.h
Work on file usr/src/contrib/mkmf/src/null.h
Work on file usr/src/contrib/mkmf/src/path.h
Work on file usr/src/contrib/mkmf/src/inckey.h
Work on file usr/src/contrib/mkmf/src/macro.h
Work on file usr/src/contrib/mkmf/src/rule.h
Work on file usr/src/contrib/mkmf/src/target.h
Work on file usr/src/contrib/mkmf/src/stringx.h
Work on file usr/src/contrib/mkmf/src/slist.h
Work on file usr/src/contrib/mkmf/src/suffix.h
Work on file usr/src/contrib/mkmf/src/yesno.h
Work on file usr/src/contrib/mkmf/src/true.h

Synthesized-from: CSRG/cd3/4.4BSD-Lite2

48 files changed:
usr/src/contrib/mkmf/src/Mkmf.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/badopt.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/buildlist.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/defaultrul.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/defaultsfx.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/depend.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/dir.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/dlist.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/dlist.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/editmf.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/getarg.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/getcwp.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/getproject.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/hash.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/hash.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/inckey.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/iolin.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/macro.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/macro.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/misc.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/mksrclist.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/mksymlink.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/mustfopen.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/null.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/optpath.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/path.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/pathcat.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/pathhead.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/pperror.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/rule.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/rule.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/slappend.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/slinit.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/slist.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/slrm.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/slsort.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/slvect.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/slvtol.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/stringx.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/strpcpy.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/strsav.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/suffix.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/suffix.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/target.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/true.h [new file with mode: 0644]
usr/src/contrib/mkmf/src/usage.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/warn.c [new file with mode: 0644]
usr/src/contrib/mkmf/src/yesno.h [new file with mode: 0644]

diff --git a/usr/src/contrib/mkmf/src/Mkmf.c b/usr/src/contrib/mkmf/src/Mkmf.c
new file mode 100644 (file)
index 0000000..dbfc634
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: Mkmf.c,v 4.5 91/11/25 19:44:59 nicklin Exp $
+ *
+ * mkmf - makefile editor
+ *
+ * Author: Peter J. Nicklin
+ */
+#include "RELEASE.h"
+#include "Mkmf.h"
+#include "config.h"
+#include "getarg.h"
+#include "hash.h"
+#include "null.h"
+#include "path.h"
+#include "target.h"
+#include "slist.h"
+#include "suffix.h"
+#include "yesno.h"
+
+char *MAKEFILE = "C";                  /* default makefile template language */
+char OBJSFX[SUFFIXSIZE] = ".o";                /* default object suffix */
+char *PGN = "mkmf";                    /* program name */
+int AFLAG = NO;                                /* list .source files? */
+int CFLAG = YES;                       /* makefile creation message flag */
+int DEPEND = 1;                                /* dependency analysis? */
+int EFLAG = NO;                                /* environ. overrides makefile macros? */
+int FFLAG = NO;                                /* user-specified template pathname? */
+int LIBOBJ = 0;                                /* load object file into library? */
+int MKSYMLINK = 0;                     /* make symbolic links to current dir? */
+int SYSHDRS = NO;                      /* search system header files? */
+SLIST *HEADLIST;                       /* header file name list */
+SLIST *LIBLIST;                                /* library pathname list */
+SLIST *SRCLIST;                                /* source file name list */
+HASH *MDEFTABLE;                       /* macro definition table */
+
+char *DEFRULE[] =                      /* default preprocessor rules */
+       {
+#include "defaultrul.h"
+       NULL
+       };
+
+SUFFIX DEFSFX[] =                      /* default suffix list */
+       {
+#include "defaultsfx.h"
+       };
+
+MAPINCLUDE INCKEY[] =                  /* include style lookup table */
+       {
+#include "inckey.h"
+       };
+
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       char *mfname = NULL;            /* makefile name */
+       char mfpath[PATHSIZE];          /* makefile template pathname */
+       HASHBLK *htb;                   /* hash table block */
+       HASHBLK *htinstall();           /* install hash table entry */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int buildliblist();             /* build list of library pathnames */
+       int buildruletable();           /* build table of preprocessor rules */
+       int buildsfxtable();            /* build table of suffixes */
+       int buildsrclist();             /* build list of source file names */
+       int findmf();                   /* find makefile */
+       int status = 0;                 /* exit status */
+       int storemacro();               /* store macro definition */
+       short iflag = NO;               /* interactive flag */
+       TARGET target;                  /* type of makefile target */
+       void answer();                  /* install answer in macro def table */
+       void editmf();                  /* edit makefile */
+
+       target.type = target.dest = VUNKNOWN;
+
+       {
+       register char *s;               /* option pointer */
+       while (--argc > 0 && **++argv == '-')
+               {
+               for (s = argv[0]+1; *s != '\0'; s++)
+                       switch (*s)
+                               {
+                               case 'F':
+                                       MAKEFILE = GETARG(s);
+                                       if (MAKEFILE==NULL || *MAKEFILE=='\0')
+                                               {
+                                               warn("missing template name");
+                                               status = 1;
+                                               }
+                                       FFLAG = YES;
+                                       goto endfor;
+                               case 'L':
+                                       LIBOBJ = 1;
+                                       target.type = VLIBRARY;
+                                       break;
+                               case 'M':
+                                       MAKEFILE = GETARG(s);
+                                       if (MAKEFILE==NULL || *MAKEFILE=='\0')
+                                               {
+                                               warn("missing template name");
+                                               status = 1;
+                                               }
+                                       goto endfor;
+                               case 'S':
+                                       MKSYMLINK++;
+                                       break;
+                               case 'a':
+                                       AFLAG = YES;
+                                       break;
+                               case 'c':
+                                       CFLAG = NO;
+                                       break;
+                               case 'd':
+                                       /* turn OFF dependency analysis */
+                                       DEPEND = 0;
+                                       break;
+                               case 'e':
+                                       EFLAG = YES;
+                                       break;
+                               case 'f':
+                                       mfname = GETARG(s);
+                                       if (mfname == NULL || *mfname == '\0')
+                                               {
+                                               warn("missing makefile name");
+                                               status = 1;
+                                               }
+                                       goto endfor;
+                               case 'i':
+                                       iflag = YES;
+                                       break;
+                               case 'l':
+                                       target.type = VLIBRARY;
+                                       break;
+                               default:
+                                       badopt(**argv, *s);
+                                       status = 1;
+                                       goto endfor;
+                               }
+               endfor: continue;
+               }
+       }
+       
+       /* initialize macro definition table */
+       MDEFTABLE = htinit(MDEFTABLESIZE);
+
+       /* get command line macro definitions */
+       for (; argc > 0; argc--, argv++)
+               if (storemacro(*argv) == NO)
+                       {
+                       warns("%s not a macro definition", *argv);
+                       status = 1;
+                       }
+
+       if (status == 1)
+               {
+               usage("[-acdeilS] [-f makefile] [-F template] [-M language]\n       [macroname=value...]");
+               exit(1);
+               }
+
+       /*
+        * store macro definition placeholders that will be generated later
+        * unless specified on the command line
+        */
+       if (storedynmacro() == NO)
+               exit(1);
+
+
+       /* environment variables override makefile macro definitions */
+       if (EFLAG == YES)
+               {
+               if (storenvmacro() == NO)
+                       exit(1);
+               }
+
+
+       /* determine the makefile name */
+       if (mfname == NULL)
+               if ((htb = htlookup(MMAKEFILE, MDEFTABLE)) != NULL)
+                       mfname = htb->h_def;
+               else if (FILEXIST("makefile"))
+                       mfname = "makefile";
+               else if (FILEXIST("Makefile"))
+                       mfname = "Makefile";
+               else
+                       mfname = "Makefile";
+       if (htinstall(MMAKEFILE, mfname, VREADWRITE, MDEFTABLE) == NULL)
+               exit(1);
+
+
+       /* find the makefile (template) and load useful macro definitions */
+       if (target.type == VUNKNOWN)
+               {
+               if (htlookup(MPROGRAM, MDEFTABLE) != NULL)
+                       target.type = VPROGRAM;
+               else if (htlookup(MLIBRARY, MDEFTABLE) != NULL)
+                       target.type = VLIBRARY;
+               }
+       if (findmf(mfname, mfpath, &target) == NO)
+               exit(1);
+       
+       /* search system header files? */
+       if ((htb = htlookup(MSYSHDRS, MDEFTABLE)) != NULL)
+               SYSHDRS = YES;
+
+       /* interactive option */
+       if (iflag == YES)
+               {
+               if (htlookup(MPROGRAM, MDEFTABLE) == NULL &&
+                   htlookup(MLIBRARY, MDEFTABLE) == NULL)
+                       if (target.type == VPROGRAM)
+                               {
+                               printf("program name? ");
+                               answer(MPROGRAM, VREADWRITE);
+                               }
+                       else if (target.type == VLIBRARY)
+                               {
+                               printf("library name? ");
+                               answer(MLIBRARY, VREADWRITE);
+                               }
+               if (htlookup(MDESTDIR, MDEFTABLE) == NULL && target.dest == VDESTDIR)
+                       {
+                       printf("destination directory? ");
+                       answer(MDESTDIR, VREADWRITE);
+                       }
+               }
+
+       /* load environment variables into macro definitions */
+       if (EFLAG == NO)
+               {
+               if (storenvmacro() == NO)
+                       exit(1);
+               }
+
+       /* build the suffix table */
+       if (buildsfxtable() == NO)
+               exit(1);
+
+       /* build the rule table */
+       if (buildruletable() == NO)
+               exit(1);
+
+       /* build the source code and header file name lists */
+       if (buildsrclist() == NO)
+               exit(1);
+
+       /* build the library pathname list */
+       if (buildliblist() == NO)
+               exit(1);
+
+       /* edit makefile */
+       editmf(mfname, mfpath);
+
+       exit(0);
+}
diff --git a/usr/src/contrib/mkmf/src/badopt.c b/usr/src/contrib/mkmf/src/badopt.c
new file mode 100644 (file)
index 0000000..c189c2a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: badopt.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * badopt() places a "bad option" error message on the standard error
+ * output stream stderr.
+ */
+#include <stdio.h>
+#include "null.h"
+
+extern char *PGN;                      /* program name */
+
+badopt(sign, c)
+       char c;                         /* offending option */
+       char sign;                      /* '+' or '-' sign preceding option */
+{
+       if (PGN != NULL && *PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       fprintf(stderr, "bad option %c%c\n", sign, c);
+}
diff --git a/usr/src/contrib/mkmf/src/buildlist.c b/usr/src/contrib/mkmf/src/buildlist.c
new file mode 100644 (file)
index 0000000..3cdf065
--- /dev/null
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: buildlist.c,v 4.10 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Mkmf.h"
+#include "config.h"
+#include "dir.h"
+#include "hash.h"
+#include "null.h"
+#include "path.h"
+#include "slist.h"
+#include "stringx.h"
+#include "suffix.h"
+#include "yesno.h"
+
+extern SLIST *HEADLIST;                        /* header file name list */
+extern SLIST *SRCLIST;                 /* source file name list */
+
+/*
+ * buftolist() copies the items from a buffer to a singly-linked list.
+ * Returns integer YES if successful, otherwise NO.
+ */
+buftolist(buf, list)
+       char *buf;                      /* item buffer */
+       SLIST *list;                    /* receiving list */
+{
+       char *gettoken();               /* get next token */
+       char *slappend();               /* append file name to list */
+       char token[PATHSIZE];           /* item buffer */
+
+       while ((buf = gettoken(token, buf)) != NULL)
+               {
+               if (slappend(token, list) == NULL)
+                       return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * buildliblist() reads library pathnames from the LIBLIST macro
+ * definition, and adds them to the library pathname list. Libraries
+ * may be specified as `-lx'. Returns integer YES if successful,
+ * otherwise NO.
+ */
+buildliblist()
+{
+       char *getpath();                /* get next path */
+       char *getoption();              /* get library path option */
+       char *lp;                       /* library path pointer */
+       char lpath[PATHSIZE];           /* library path buffer */
+       extern SLIST *LIBLIST;          /* library pathname list */
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       HASHBLK *htb;                   /* hash table block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int libbuftolist();             /* load library pathnames into list */
+       SLIST *libpathlist;             /* library directory search path */
+
+       /* create the library search path list */
+       libpathlist = slinit();         
+
+       /* -L library path specification */
+       if (htlookup(MLDFLAGS, MDEFTABLE) != NULL)
+               {
+               lp = htdef(MDEFTABLE);
+               while ((lp = getoption(lpath, lp, "-L")) != NULL)
+                       {
+                       if (*lpath == '\0')
+                               { 
+                               warns("missing library in %s macro definition",
+                                      htkey(MDEFTABLE));
+                               break;
+                               }
+                       else    {
+                               strcat(lpath, "/lib");
+                               if (slappend(lpath, libpathlist) == NULL)
+                                       return(NO);
+                               }
+                       }
+               }
+
+       /* LPATH environment variable library path specification */
+       if (htlookup(MLPATH, MDEFTABLE) != NULL && *htdef(MDEFTABLE) != '\0')
+               {
+               lp = htdef(MDEFTABLE);
+               while ((lp = getpath(lpath, lp)) != NULL)
+                       {
+                       strcat(lpath, "/lib");
+                       if (slappend(lpath, libpathlist) == NULL)
+                               return(NO);
+                       }
+               }
+       else    {
+               if (slappend("/lib/lib", libpathlist) == NULL ||
+                   slappend("/usr/lib/lib", libpathlist) == NULL)              
+                       return(NO);
+               }
+
+       /* search for the libraries */
+       LIBLIST = NULL;
+       if ((htb = htlookup(MLIBLIST, MDEFTABLE)) != NULL)
+               {
+               LIBLIST = slinit();
+               if (libbuftolist(htb->h_def, libpathlist, LIBLIST) == NO)
+                       return(NO);
+               }
+       slrm(libpathlist);
+       htrm(MLIBLIST, MDEFTABLE);
+       return(YES);
+}
+
+
+
+/*
+ * buildsrclist() takes source and header file names from command line
+ * macro definitions or the current directory and appends them to source
+ * or header file name lists as appropriate. Returns integer YES if
+ * successful, otherwise NO.
+ */
+buildsrclist()
+{
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       extern int MKSYMLINK;           /* make symbolic links to current dir ?*/
+       HASHBLK *headhtb;               /* HEADERS macro hash table block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       HASHBLK *srchtb;                /* SOURCES macro hash table block */
+       int buftolist();                /* copy items from buffer to list */
+       int mksrclist();                /* compose a list of source files */
+       int mksymlink();                /* create symbolic source links */
+       int needhdr = 1;                /* need header file names */
+       int needsrc = 1;                /* need source file names */
+       int read_dir();                 /* read dir for source and headers */
+       int slsort();                   /* sort singly-linked list */
+       int uniqsrclist();              /* remove source dependencies */
+       SLIST *slinit();                /* initialize singly-linked list */
+
+       HEADLIST = slinit();
+       SRCLIST = slinit();
+
+       /* build lists from command line macro definitions */
+       if ((headhtb = htlookup(MHEADERS, MDEFTABLE)) != NULL &&
+            headhtb->h_val == VREADWRITE)
+               {
+               if (buftolist(headhtb->h_def, HEADLIST) == NO)
+                       return(NO);
+               needhdr = 0;
+               }
+       if ((srchtb = htlookup(MSOURCES, MDEFTABLE)) != NULL &&
+            srchtb->h_val == VREADWRITE)
+               {
+               if (buftolist(srchtb->h_def, SRCLIST) == NO)
+                       return(NO);
+               needsrc = 0;
+               }
+       
+       /* read directories to get source and header file names */
+       if (needhdr || needsrc)
+               {
+               if (MKSYMLINK)
+                       {
+                       if (mksymlink(needsrc, needhdr) == NO)
+                               return(NO);
+                       }
+               else    {
+                       if (mksrclist(needsrc, needhdr) == NO)
+                               return(NO);
+                       }
+               }
+
+       if (slsort(strcmp, HEADLIST) == NO)
+               return(NO);
+       if (slsort(strcmp, SRCLIST) == NO)
+               return(NO);
+       if (SLNUM(SRCLIST) > 0 && uniqsrclist() == NO)
+               return(NO);
+       return(YES);
+}
+
+
+
+/*
+ * expandlibpath() converts a library file specified by `-lx' into a full
+ * pathname. Directories are searched for the library in the form libx.a.
+ * An integer YES is returned if the library was found, otherwise NO.
+ */
+expandlibpath(libtoken, libpath, libpathlist)
+       char *libtoken;                 /* library file option */
+       char *libpath;                  /* library pathname */
+       SLIST *libpathlist;             /* library directory search path */
+{
+       char *lp;                       /* library pathname pointer */
+       char *strpcpy();                /* string copy and update pointer */
+       SLBLK *cblk;                    /* current list block */
+
+       libtoken += 2;                  /* skip -l option */
+       for (cblk = libpathlist->head; cblk != NULL; cblk = cblk->next)
+               {
+               lp = strpcpy(libpath, cblk->key);
+               lp = strpcpy(lp, libtoken);
+               (void) strpcpy(lp, ".a");
+               if (FILEXIST(libpath))
+                       {
+                       return(YES);
+                       }
+               }
+       return(NO);
+}
+
+
+
+/*
+ * libbuftolist() appends each library pathname specified in libbuf to
+ * the liblist library pathname list.
+ */
+libbuftolist(libmacrobuf, libpathlist, liblist)
+       char *libmacrobuf;              /* LIBS macro definition buffer */
+       SLIST *libpathlist;             /* library directory search path */
+       SLIST *liblist;                 /* library pathname list */
+{
+       char *gettoken();               /* get next token */
+       char libpath[PATHSIZE];         /* library pathname */
+       char libtoken[PATHSIZE];        /* library file option */
+       char *slappend();               /* append file name to list */
+       int expandlibpath();            /* -lx -> full library pathname */
+
+       while ((libmacrobuf = gettoken(libtoken, libmacrobuf)) != NULL)
+               {
+               if (libtoken[0] == '-' && libtoken[1] == 'l')
+                       {
+                       if (expandlibpath(libtoken, libpath, libpathlist) == NO)
+                               {
+                               warns("can't find library %s", libtoken);
+                               }
+                       else    {
+                               if (slappend(libpath, liblist) == NULL)
+                                       return(NO);
+                               }
+                       }
+               else    {
+                       if (slappend(libtoken, liblist) == NULL)
+                               return(NO);
+                       }
+               }
+       return(YES);
+}
+
+
+
+/*
+ * read_dir() reads filenames from the designated directory and adds them
+ * to the source or header file name lists as appropriate. Returns
+ * integer YES if successful, otherwise NO.
+ */
+read_dir(dirname, addfile, needsrc, needhdr)
+       char *dirname;                  /* specified directory name */
+       int (*addfile)();               /* function for adding source files */
+       int needsrc;                    /* need source file names */
+       int needhdr;                    /* need header file names */
+{
+       extern int AFLAG;               /* list .source files? */
+       char *suffix;                   /* pointer to file name suffix */
+       DIR *dirp;                      /* directory stream */
+       DIRENT *dp;                     /* directory entry pointer */
+       int lookupsfx();                /* get suffix type */
+       int sfxtyp;                     /* type of suffix */
+
+       if ((dirp = opendir(dirname)) == NULL)
+               {
+               warns("%s: can't open directory", dirname);
+               return(NO);
+               }
+       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
+               {
+               if ((suffix = strrchr(dp->d_name, '.')) == NULL ||
+                   (*dp->d_name == '.' && AFLAG == NO) ||
+                   (*dp->d_name == '#'))
+                       continue;
+               suffix++;
+               sfxtyp = lookupsfx(suffix);
+               if (sfxtyp == SFXSRC)
+                       {
+                       if (needsrc)
+                               {
+                               if (strncmp(dp->d_name, "s.", 2) == 0)
+                                       continue; /* skip SCCS files */
+                               if ((*addfile)(dirname, dp->d_name, 's') == NO)
+                                       return(NO);
+                               }
+                       }
+               else if (sfxtyp == SFXHEAD)
+                       {
+                       if (needhdr)
+                               {
+                               if (strncmp(dp->d_name, "s.", 2) == 0)
+                                       continue; /* skip SCCS files */
+                               if ((*addfile)(dirname, dp->d_name, 'h') == NO)
+                                       return(NO);
+                               }
+                       }
+               }
+       closedir(dirp);
+       return(YES);
+}
+
+
+
+/*
+ * uniqsrclist() scans the source file list and removes the names of
+ * any files that could have been generated by make rules from files
+ * in the same list. Returns NO if no source list or out of memory,
+ * otherwise YES.
+ */
+uniqsrclist()
+{
+       extern SLIST *SRCLIST;          /* source file name list */
+       register int cbi;               /* current block vector index */
+       register int fbi;               /* first matching block vector index */
+       register int lbi;               /* last block vector index */
+       int length;                     /* source file basename length */
+       SLBLK **slvect();               /* make linked list vector */
+       SLBLK **slv;                    /* ptr to singly-linked list vector */
+       void slvtol();                  /* convert vector to linked list */
+       void uniqsrcfile();             /* make source files dependency-free */
+
+       if ((slv = slvect(SRCLIST)) == NULL)
+               return(NO);
+       lbi = SLNUM(SRCLIST) - 1;
+       for (fbi=0, cbi=1; cbi <= lbi; cbi++)
+               {
+               length = strrchr(slv[cbi]->key, '.') - slv[cbi]->key + 1;
+               if (strncmp(slv[fbi]->key, slv[cbi]->key, length) == 0)
+                       {
+                       continue;       /* find end of matching block */
+                       }
+               else if (cbi - fbi > 1)
+                       {
+                       uniqsrcfile(fbi, cbi-fbi, slv);
+                       }
+               fbi = cbi;
+               }
+       if (cbi - fbi > 1)              /* do last matching block */
+               {
+               uniqsrcfile(fbi, cbi-fbi, slv);
+               }
+       slvtol(SRCLIST, slv);
+       return(YES);
+}
+
+
+
+/*
+ * uniqsrcfile() scans a block of source files and removes the names of
+ * any files that could have been generated by make rules from files
+ * in the same block. The names of a source file is removed by setting
+ * the pointer to the source file block to NULL in the vector. To maintain
+ * the transitive property of each rule, the name of the source file is
+ * still maintained in the singly-linked list.
+ */
+
+void
+uniqsrcfile(fbi, nb, slv)
+       register int fbi;               /* index to first matching block */
+       int nb;                         /* number of blocks */
+       SLBLK **slv;                    /* ptr to singly-linked list vector */
+{
+       register SLBLK *ibp;            /* block pointer (i-loop) */
+       register SLBLK *jbp;            /* block pointer (j-loop) */
+       register int i;                 /* i-loop index */
+       register int j;                 /* j-loop index */
+       char rule[2*SUFFIXSIZE+3];      /* rule buffer */
+       int lookuprule();               /* does source rule exist? */
+       int nu;                         /* number of unique blocks */
+       SLBLK *fbp;                     /* pointer to first block */
+       void makerule();                /* make a rule from two suffixes */
+
+       nu  = nb;
+       fbp = slv[fbi];
+
+       for (i=0, ibp=fbp; i < nb; i++, ibp=ibp->next)
+               {
+               for (j=0, jbp=fbp; j < nb; j++, jbp=jbp->next)
+                       {
+                       if (i != j && slv[fbi+j] != NULL)
+                               {
+                               makerule(rule, ibp->key, jbp->key);
+                               if (lookuprule(rule) == YES)
+                                       {
+                                       slv[fbi+j] = NULL;
+                                       if (--nu < 2) return;
+                                       }
+                               }
+                       }
+               }
+}
diff --git a/usr/src/contrib/mkmf/src/defaultrul.h b/usr/src/contrib/mkmf/src/defaultrul.h
new file mode 100644 (file)
index 0000000..f96e01b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: defaultrul.h,v 4.4 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Default rules
+ *
+ * Author: Peter J. Nicklin
+ */
+".y.c",        /* Yacc */
+".l.c",        /* Lex */
diff --git a/usr/src/contrib/mkmf/src/defaultsfx.h b/usr/src/contrib/mkmf/src/defaultsfx.h
new file mode 100644 (file)
index 0000000..e359a7a
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: defaultsfx.h,v 4.3 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Default suffixes
+ *
+ * Author: Peter J. Nicklin
+ */
+".c",   SFXSRC,  INCLUDE_C,      "C",   /* C */
+".cc",  SFXSRC,  INCLUDE_CXX,    "C++", /* C++ */
+".cxx", SFXSRC,  INCLUDE_CXX,    "C++", /* C++ */
+".cpp", SFXSRC,  INCLUDE_CXX,    "C++", /* C++ */
+".C",   SFXSRC,  INCLUDE_CXX,    "C++", /* C++ */
+".F",   SFXSRC,  INCLUDE_FORTRAN, "F",  /* Fortran */
+".f",   SFXSRC,  INCLUDE_FORTRAN, "F",  /* Fortran */
+".h",   SFXHEAD, INCLUDE_NONE,    NULL, /* header */
+".hxx", SFXHEAD, INCLUDE_NONE,    NULL, /* header */
+".hpp", SFXHEAD, INCLUDE_NONE,    NULL, /* header */
+".H",   SFXHEAD, INCLUDE_NONE,    NULL, /* header */
+".i",   SFXHEAD, INCLUDE_NONE,    NULL, /* Pascal include */
+".l",   SFXSRC,  INCLUDE_C,      "C",   /* Lex */
+".o",   SFXOBJ,  INCLUDE_NONE,    NULL, /* object */
+".p",   SFXSRC,  INCLUDE_PASCAL,  "P",  /* Pascal */
+".r",   SFXSRC,  INCLUDE_FORTRAN, "F",  /* Ratfor */
+".s",   SFXSRC,  INCLUDE_NONE,    NULL, /* Assembler */
+".y",   SFXSRC,  INCLUDE_C,      "C",   /* Yacc */
+NULL,   SFXNULL, INCLUDE_NONE,    NULL  /* mandatory last line */
diff --git a/usr/src/contrib/mkmf/src/depend.c b/usr/src/contrib/mkmf/src/depend.c
new file mode 100644 (file)
index 0000000..ab4200e
--- /dev/null
@@ -0,0 +1,909 @@
+/*
+ * Copyright (c) 1983, 1985, 1991, 1993 Peter J. Nicklin.
+ * Copyright (c) 1991, 1993 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: depend.c,v 4.10 93/05/25 21:17:49 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include <stdio.h>
+#include "Mkmf.h"
+#include "config.h"
+#include "dlist.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "path.h"
+#include "slist.h"
+#include "stringx.h"
+#include "yesno.h"
+
+#define CURINCLUDE             "./"
+#define TOLOWER(c)             (isupper(c) ? tolower(c) : (c))
+#define ISWHITESPACE(c)                (c == ' ' || c == '\t')
+#define SKIPWHITESPACE(c, f)   while ((c = getc(f))==' ' || c=='\t'); ungetc(c,f);
+#define USRINCLUDE             "/usr/include/"
+#define USRINCLUDECC           "/usr/include/CC/"
+
+/*
+ * Include file state
+ */
+#define NOTFOUND               0       /* not found anywhere */
+#define EXTERNAL               1       /* not found in current directory */
+#define INTERNAL               2       /* found in current directory */
+#define FROMRULE               3       /* derived from tranformation rule */
+#define SYSTEM                 4       /* a system header file */
+
+static char SYSINCLUDE[PATHSIZE];      /* /usr/include pathname buffer */
+static char SYSINCLUDECC[PATHSIZE];    /* /usr/include/CC pathname buffer */
+static int  SYSINCLUDELEN;             /* length of SYSINCLUDE */
+/*
+ * Include files are stored in hash tables by direct chaining (See
+ * p. 134 in `The C Programming Language' by Kernighan and Ritchie).
+ * Included include files are also added to a singly-linked list
+ * attached to the hash table entry for the include file.
+ */
+static HASH *C_INCLUDETABLE   = NULL;  /* C include file hash table */
+static HASH *CXX_INCLUDETABLE = NULL;  /* C++ include file hash table */
+static HASH *F_INCLUDETABLE   = NULL;  /* Fortran include file hash table */
+static HASH *P_INCLUDETABLE   = NULL;  /* Pascal include file hash table */
+/*
+ * Additional include directories are specified via the -I compiler
+ * command line option. These directories are stored in singly-linked lists.
+ * We also assume that the last look-up directory is "/usr/include".
+ */
+static SLIST *C_INCDIR;                        /* C include directories */
+static SLIST *CXX_INCDIR;              /* C++ include directories */
+static SLIST *F_INCDIR;                        /* Fortran include directories */
+static SLIST *P_INCDIR;                        /* Pascal include directories */
+
+SLIST *EXTLIST;                                /* external header file name list */
+SLIST *SYSLIST;                                /* system header file name list */
+
+extern char *PGN;                      /* program name */
+extern int  SYSHDRS;                   /* search system header files? */
+extern HASH *MDEFTABLE;                        /* macro definition table */
+
+/*
+ * addincdir() adds directories containing include files to the
+ * appropriate singly-linked list. The pathnames to the directories
+ * are derived from makefile macro definitions.
+ */
+void
+addincdir()
+{
+       char *slappend();               /* append to singly-linked list */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int cleanup();                  /* remove temporary makefile and exit */
+       void getI();                    /* get include directory pathnames */
+
+       /* initialize system include pathnames */
+       initsysinclude();
+
+       /* C CFLAGS macro */
+       if ((htb = htlookup(MCFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, C_INCDIR);
+       if (slappend(SYSINCLUDE, C_INCDIR) == NULL)
+               cleanup();
+       
+       /* C++ CXXFLAGS macro */
+       if ((htb = htlookup(MCXXFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, CXX_INCDIR);
+
+       /* C++ C++FLAGS macro */
+       if ((htb = htlookup(MCPXFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, CXX_INCDIR);
+
+       /* C++ CCFLAGS macro */
+       if ((htb = htlookup(MCCFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, CXX_INCDIR);
+
+       if (slappend(SYSINCLUDECC, CXX_INCDIR) == NULL ||
+           slappend(SYSINCLUDE,   CXX_INCDIR) == NULL)
+               cleanup();
+
+       /* Fortran FFLAGS macro */
+       if ((htb = htlookup(MFFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, F_INCDIR);
+       if (slappend(SYSINCLUDE, F_INCDIR) == NULL)
+               cleanup();
+
+       /* Pascal PFLAGS macro */
+       if ((htb = htlookup(MPFLAGS, MDEFTABLE)) != NULL)
+               getI(htb->h_key, htb->h_def, P_INCDIR);
+       if (slappend(SYSINCLUDE, P_INCDIR) == NULL)
+               cleanup();
+}
+
+
+
+/*
+ * findinclude() tries to find the pathname of an include file. Returns
+ * integer INTERNAL if found in the current directory, EXTERNAL if found
+ * somewhere else, FROMRULE if derived from a transformation rule,
+ * SYSTEM if a system header file, otherwise NOTFOUND.  The pathname
+ * is copied into incpath.
+ */
+#define LOCALDIR(f)    (strchr(f, _PSC) == NULL)
+#define ISYSINCLUDE(f) (strncmp(f, SYSINCLUDE, SYSINCLUDELEN) == 0)
+#define INCLUDETYPE(f) (LOCALDIR(f) ? INTERNAL : (ISYSINCLUDE(f) ? SYSTEM : EXTERNAL))
+
+findinclude(incpath, incname, lastname, type)
+       char *incpath;                  /* pathname receiving buffer */
+       register char *incname;         /* include file name */
+       char *lastname;                 /* file that includes incname */
+       int type;                       /* file type */
+{
+       register char *pp;              /* include file path pointer */
+       char *optpath();                /* optimize pathname */
+       char *pathcat();                /* pathname concatenation */
+       char *pathhead();               /* remove pathname tail */
+       char *strpcpy();                /* string copy and update pointer */
+       int applyrule();                /* apply transformation rules */
+       SLBLK *slb;                     /* singly-linked list block */
+       SLIST *slist;                   /* include directory list pointer */
+
+       /*
+        * look for an absolute include file name
+        */
+       if (*incname == '/')
+               {
+               strcpy(incpath, incname);
+               return(FILEXIST(incpath) ? INCLUDETYPE(incpath) : NOTFOUND);
+               }
+
+       /*
+        * search the current include directory for an #include file
+        * whose name is enclosed in " ", or see if it can be generated
+        * by a transformation rule in the current working directory.
+        */
+       if (*incname != '<')
+               {
+               if (LOCALDIR(lastname))
+                       {
+                       if (LOCALDIR(incname))
+                               {
+                               if (applyrule(incname, incpath) == YES)
+                                       return(FROMRULE);
+                               }
+                       strcpy(incpath, incname);
+                       if (FILEXIST(incpath))
+                               return(INCLUDETYPE(incpath));
+                       }
+               else    {
+                       strcpy(incpath, lastname);
+                       pathcat(incpath, pathhead(incpath), incname);
+                       optpath(incpath);
+                       if (FILEXIST(incpath))
+                               return(INCLUDETYPE(incpath));
+                       }
+               }
+
+       /*
+        * search directory list
+        */
+       switch (type)
+               {
+               case INCLUDE_C:
+                       slist = C_INCDIR;
+                       break;
+               case INCLUDE_CXX:
+                       slist = CXX_INCDIR;
+                       break;
+               case INCLUDE_FORTRAN:
+                       slist = F_INCDIR;
+                       break;
+               case INCLUDE_PASCAL:
+                       slist = P_INCDIR;
+                       break;
+               }
+       for (slb = slist->head; slb != NULL; slb = slb->next)
+               {
+               pp = strpcpy(incpath, slb->key);
+               if (*incname == '<')
+                       {
+                       pp = strpcpy(pp, incname+1);
+                       pp[-1] = '\0';
+                       }
+               else    {
+                       strcpy(pp, incname);
+                       }
+               optpath(incpath);
+               if (FILEXIST(incpath))
+                       return(INCLUDETYPE(incpath));
+               }
+
+       return(NOTFOUND);
+}
+
+
+
+/*
+ * getI() appends include directories found via the -I compiler option to
+ * a singly linked list.
+ */
+void
+getI(mnam, mdef, slist)
+       char *mnam;                     /* compiler options macro name */
+       char *mdef;                     /* compiler options macro definition */
+       SLIST *slist;                   /* singly-linked list */
+{
+       char *getoption();              /* get next token */
+       char incpath[PATHSIZE];         /* include directory pathname buffer */
+       char *slappend();               /* append to singly-linked list */
+       int cleanup();                  /* remove temporary makefile and exit */
+
+       while ((mdef = getoption(incpath, mdef, "-I")) != NULL)
+               {
+               if (*incpath == '\0')
+                       {
+                       warns("missing include directory in %s macro definition", mnam);
+                       break;
+                       }
+               else    {
+                       strcat(incpath, PATHSEP);
+                       if (slappend(incpath, slist) == NULL)
+                               cleanup();
+                       }
+               }
+}
+
+
+
+/*
+ * getinclude() fetchs an include file name from a line of source code.
+ * /usr/include '<' and '>' delimiters remain with the filename to
+ * distinguish it from an include file in a local directory. Returns
+ * NO if syntax error, otherwise YES.
+ */
+getinclude(incname, curname, lineno, ifp)
+       char *curname;                  /* current file name */
+       char *incname;                  /* include file name receiving buffer */
+       int lineno;                     /* current line number */
+       register FILE *ifp;             /* input stream */
+{
+       register char *ip;              /* include file name buffer pointer */
+       register int c;                 /* current character */
+
+       SKIPWHITESPACE(c, ifp);
+       for (ip = incname; (c = getc(ifp)) != EOF; ip++)
+               {
+               *ip = c;
+               if (c == '\n' || c == '\t' || c == ' ' ||
+                   c == ';'  || c == ','  || c == '$' )
+                       {
+                       ungetc(c, ifp);
+                       break;
+                       }
+               }
+       *ip = '\0';
+       if ((*incname == '<'  && ip[-1] != '>')  ||
+           (*incname == '\"' && ip[-1] != '\"') ||
+           (*incname == '\'' && ip[-1] != '\'') ||
+           (*incname == '('  && ip[-1] != ')'))
+               {
+               fprintf(stderr,
+                       "%s: \"%s\", line %d: bad include syntax for %s\n",
+                       PGN, curname, lineno, incname);
+               return(NO);
+               }
+       if (*incname == '\"' || *incname == '\'' || *incname == '(')
+               {
+               ip[-1] = '\0';
+               ip = incname + 1;
+               while (*incname++ = *ip++)
+                       continue;
+               }
+       return(YES);
+}
+
+
+
+/*
+ * inclink() stores a pointer to a hash table block (which contains
+ * include file information) somewhere. Returns a pointer to the somewhere,
+ * or calls cleanup() if out of memory.
+ */
+INCBLK *
+inclink(htb)
+       HASHBLK *htb;                   /* hash table block pointer to save */
+{
+       char *malloc();                 /* memory allocator */
+       INCBLK *iblk;                   /* pointer to new include chain block */
+       int cleanup();                  /* remove temporary makefile and exit */
+
+       if ((iblk = (INCBLK *) malloc(sizeof(INCBLK))) == NULL)
+               {
+               nocore();
+               cleanup();
+               }
+       iblk->i_loop = NO;
+       iblk->i_hblk = htb;
+       iblk->i_next = NULL;
+       return(iblk);
+}
+
+
+
+/*
+ * instalinclude() adds an include file name to the appropriate include
+ * file hash table. Returns a pointer to the hash table block, or calls
+ * cleanup() if out of memory.
+ */
+HASHBLK *
+instalinclude(incname, incpath, type)
+       char *incname;                  /* name of include file */
+       char *incpath;                  /* path to include file */
+       int type;                       /* type of source file */
+{
+       HASH *htinit();                 /* initialize hash table */
+       HASHBLK *htb;                   /* hash table block */
+       HASHBLK *htinstall();           /* install hash table entry */
+       int cleanup();                  /* remove temporary makefile and exit */
+       int ilen;                       /* include path length */
+
+       ilen = strlen(incpath);
+       switch (type)
+               {
+               case INCLUDE_C:
+                       if (C_INCLUDETABLE == NULL)
+                               {
+                               C_INCLUDETABLE = htinit(INCLUDETABLESIZE);
+                               }
+                       htb = htinstall(incname, incpath, ilen, C_INCLUDETABLE);
+                       break;
+               case INCLUDE_CXX:
+                       if (CXX_INCLUDETABLE == NULL)
+                               {
+                               CXX_INCLUDETABLE = htinit(INCLUDETABLESIZE);
+                               }
+                       htb = htinstall(incname, incpath, ilen, CXX_INCLUDETABLE);
+                       break;
+               case INCLUDE_FORTRAN:
+                       if (F_INCLUDETABLE == NULL)
+                               {
+                               F_INCLUDETABLE = htinit(INCLUDETABLESIZE);
+                               }
+                       htb = htinstall(incname, incpath, ilen, F_INCLUDETABLE);
+                       break;
+               case INCLUDE_PASCAL:
+                       if (P_INCLUDETABLE == NULL)
+                               {
+                               P_INCLUDETABLE = htinit(INCLUDETABLESIZE);
+                               }
+                       htb = htinstall(incname, incpath, ilen, P_INCLUDETABLE);
+                       break;
+               default:
+                       htb = NULL;
+                       break;
+               }
+       if (htb == NULL)
+               cleanup();
+       return(htb);
+}
+
+
+
+/*
+ * lookupinclude() returns a pointer to an include hash table block
+ * corresponding to incname and type. Returns null if not found.
+ */
+HASHBLK *
+lookupinclude(incname, type)
+       char *incname;                  /* name of include file */
+       int type;                       /* type of source file */
+{
+       HASH *includetable;             /* include file hash table */
+       HASHBLK *htlookup();            /* find hash table entry */
+
+       switch (type)
+               {
+               case INCLUDE_C:
+                       includetable = C_INCLUDETABLE;
+                       break;
+               case INCLUDE_CXX:
+                       includetable = CXX_INCLUDETABLE;
+                       break;
+               case INCLUDE_FORTRAN:
+                       includetable = F_INCLUDETABLE;
+                       break;
+               case INCLUDE_PASCAL:
+                       includetable = P_INCLUDETABLE;
+                       break;
+               default:
+                       includetable = NULL;
+                       break;
+               }
+       return((includetable == NULL) ? NULL : htlookup(incname, includetable));
+}
+
+
+
+/*
+ * mkdepend() creates include file dependencies for object files and installs
+ * them to dependency list dlp. Returns a pointer to the dependency list.
+ */
+DLIST *
+mkdepend()
+{
+       extern SLIST *SRCLIST;          /* source file name list */
+       char *suffix;                   /* suffix pointer */
+       DLBLK *dlappend();              /* append dependency list */
+       DLIST *dlinit();                /* initialize dependency list */
+       DLIST *dlist;                   /* dependency list */
+       INCBLK *ibp;                    /* pointer to chain of include files */
+       INCBLK *readC();                /* read C include-style files */
+       INCBLK *readF();                /* read Fortran include-style files */
+       INCBLK *readP();                /* read Pascal include-style files */
+       int cleanup();                  /* remove temporary makefile and exit */
+       int lookuptypeofinclude();      /* look up the brand of include */
+       int slsort();                   /* sort singly-linked list */
+       int type;                       /* source file type */
+       SLBLK *lbp;                     /* list block pointer */
+       SLIST *slinit();                /* initialize singly-linked list */
+       void addincdir();               /* add to list of include directories */
+       void rmprinttag();              /* remove "already printed" tags */
+
+       /* initialize include file look-up lists */
+       C_INCDIR   = slinit();
+       CXX_INCDIR = slinit();
+       F_INCDIR   = slinit();
+       P_INCDIR   = slinit();
+
+       /* add additional include directories */
+       addincdir();
+
+       /* initialize external and system header file name lists */
+       EXTLIST = slinit();
+       SYSLIST = slinit();
+
+       /* initialize dependency list */
+       dlist = dlinit();
+
+       for (lbp = SRCLIST->head; lbp != NULL; lbp = lbp->next)
+               {
+               suffix = strrchr(lbp->key, '.');
+               type = lookuptypeofinclude(++suffix);
+               switch (type)
+                       {
+                       case INCLUDE_C:
+                       case INCLUDE_CXX:
+                               ibp = readC(lbp->key, 0, lbp->key, type);
+                               break;
+                       case INCLUDE_FORTRAN:
+                               ibp = readF(lbp->key, 0, lbp->key, type);
+                               break;
+                       case INCLUDE_PASCAL:
+                               ibp = readP(lbp->key, 0, lbp->key, type);
+                               break;
+                       case INCLUDE_NONE:
+                               ibp = NULL;
+                               break;
+                       }
+               if (ibp != NULL)
+                       {
+                       if (dlappend(type, lbp, ibp, dlist) == NULL)
+                               cleanup();
+                       }
+               }
+       if (slsort(strcmp, EXTLIST) == NO || slsort(strcmp, SYSLIST) == NO)
+               cleanup();
+       return(dlist);
+}
+
+
+
+/*
+ * notfound() prints a "can't find" filename error message.
+ */
+void
+notfound(curname, lineno, incname)
+       char *curname;                  /* current file name */
+       char *incname;                  /* name of include file */
+       int lineno;                     /* current line number */
+{
+       if (PGN != NULL && *PGN != '\0')
+               {
+               fprintf(stderr, "%s: ", PGN);
+               }
+       if (*incname == '<')
+               {
+               fprintf(stderr, "\"%s\", line %d: can't find %s\n",
+                       curname, lineno, incname);
+               }
+       else    {
+               fprintf(stderr, "\"%s\", line %d: can't find \"%s\"\n",
+                       curname, lineno, incname);
+               }
+}
+
+
+
+/*
+ * readC() searches C files for included files. Returns a pointer to
+ * the chain of include files installed or found in the include file
+ * hash table, or null if no include files found.
+ */
+INCBLK *
+readC(lastfile, lastline, curname, type)
+       char *lastfile;                 /* parent file name */
+       int lastline;                   /* current line in parent file */
+       char *curname;                  /* current file name */
+       int type;                       /* file type */
+{
+       register char *p;               /* include string pointer */
+       register FILE *ifp;             /* input file stream */
+       register int c;                 /* current character */
+       char incname[PATHSIZE];         /* name of include file */
+       char incpath[PATHSIZE];         /* path to include file */
+       char *slappend();               /* append pathname to list */
+       FILE *fopen();                  /* open file */
+       HASHBLK *ftb;                   /* fromrule hash table entry block */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *instalinclude();       /* install include name in hash table */
+       HASHBLK *lookupinclude();       /* look up include in hash table */
+       INCBLK *i_head = NULL;          /* head of include chain */
+       INCBLK *i_tail = NULL;          /* tail of include chain */
+       INCBLK *inclink();              /* link include file hash blocks */
+       int cleanup();                  /* remove temporary makefile and exit */
+       int findinclude();              /* locate include file */
+       int getinclude();               /* get include name from input line */
+       int inctype;                    /* origin of include file */
+       int lineno = 1;                 /* current line number */
+       void notfound();                /* print "can't find" filename msg */
+
+       if ((ifp = fopen(curname, "r")) == NULL)
+               {
+               if (lastline > 0)
+                       fprintf(stderr, "%s: \"%s\", line %d: ", PGN,
+                               lastfile, lastline);
+               else
+                       fprintf(stderr, "%s: ", PGN);
+               perror(curname);
+               return(NULL);
+               }
+       while ((c = getc(ifp)) != EOF)
+               {
+               if (ISWHITESPACE(c))
+                       continue;
+               if (c != '#')
+                       goto nextline;
+               SKIPWHITESPACE(c, ifp);
+               for (p = "include"; (c = getc(ifp)) == *p && *p != '\0' ; p++)
+                       continue;
+               if (*p != '\0')
+                       goto nextline;
+               ungetc(c, ifp);
+               if (getinclude(incname, curname, lineno, ifp) == NO)
+                       goto nextline;
+               if ((htb = lookupinclude(incname, type)) == NULL)
+                       {
+                       inctype = findinclude(incpath, incname, curname, type);
+                       if (inctype == INTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == YES)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, SYSLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == NO)
+                               {
+                               goto nextline;
+                               }
+                       else if (inctype == EXTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, EXTLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == FROMRULE)
+                               {
+                               htb = instalinclude(incname, incname, type);
+                               ftb = instalinclude(incpath, incpath, type);
+                               }
+                       else    {
+                               notfound(curname, lineno, incname);
+                               goto nextline;
+                               }
+
+                       /* look for nested include files */
+                       htb->h_sub = readC(curname, lineno, incpath, type);
+
+                       if (inctype == FROMRULE)
+                               ftb->h_sub = htb->h_sub;
+                       }
+               if (i_tail == NULL)
+                       {
+                       i_head = i_tail = inclink(htb);
+                       }
+               else    {
+                       i_tail = i_tail->i_next = inclink(htb);
+                       }
+nextline:      while (c != '\n' && c != EOF)
+                       c = getc(ifp);
+               lineno++;
+               }
+       fclose(ifp);
+       return(i_head);
+}
+
+
+
+/*
+ * readF() searches Fortran files for included files. Returns a pointer
+ * to the chain of include files installed or found in the include file
+ * hash table, or null if no include files found.
+ */
+INCBLK *
+readF(lastfile, lastline, curname, type)
+       char *lastfile;                 /* parent file name */
+       int lastline;                   /* current line in parent file */
+       char *curname;                  /* current file name */
+       int type;                       /* file type */
+{
+       register char *p;               /* include string pointer */
+       register FILE *ifp;             /* input file stream */
+       register int c;                 /* current character */
+       char incname[PATHSIZE];         /* name of include file */
+       char incpath[PATHSIZE];         /* path to include file */
+       char *slappend();               /* append pathname to list */
+       FILE *fopen();                  /* open file */
+       HASHBLK *ftb;                   /* fromrule hash table entry block */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *instalinclude();       /* install include name in hash table */
+       HASHBLK *lookupinclude();       /* look up include in hash table */
+       INCBLK *i_head = NULL;          /* head of include chain */
+       INCBLK *i_tail = NULL;          /* tail of include chain */
+       INCBLK *inclink();              /* link include file hash blocks */
+       int cleanup();                  /* remove temporary makefile and exit */
+       int findinclude();              /* locate include file */
+       int getinclude();               /* get include name from input line */
+       int inctype;                    /* origin of include file */
+       int lineno = 1;                 /* current line number */
+       void notfound();                /* print "can't find" filename msg */
+
+       if ((ifp = fopen(curname, "r")) == NULL)
+               {
+               if (lastline > 0)
+                       fprintf(stderr, "%s: \"%s\", line %d: ", PGN,
+                               lastfile, lastline);
+               else
+                       fprintf(stderr, "%s: ", PGN);
+               perror(curname);
+               return(NULL);
+               }
+       while ((c = getc(ifp)) != EOF)
+               {
+               if (c == 'c' || c == 'C' || c == '*' || c == '\n')
+                       goto nextline;
+               while ((c = getc(ifp)) == ' ' || c == '\t' || c == '#' || c == '$')
+                       continue;
+               for (p = "include"; *p == TOLOWER(c) && *p != '\0'; p++)
+                       c = getc(ifp);
+               if (*p != '\0')
+                       goto nextline;
+               ungetc(c, ifp);
+               if (getinclude(incname, curname, lineno, ifp) == NO)
+                       goto nextline;
+               if ((htb = lookupinclude(incname, type)) == NULL)
+                       {
+                       inctype = findinclude(incpath, incname, curname, type);
+                       if (inctype == INTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == YES)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, SYSLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == NO)
+                               {
+                               goto nextline;
+                               }
+                       else if (inctype == EXTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, EXTLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == FROMRULE)
+                               {
+                               htb = instalinclude(incname, incname, type);
+                               ftb = instalinclude(incpath, incpath, type);
+                               }
+                       else    {
+                               notfound(curname, lineno, incname);
+                               goto nextline;
+                               }
+
+                       /* look for nested include files */
+                       htb->h_sub = readF(curname, lineno, incpath, type);
+
+                       if (inctype == FROMRULE)
+                               ftb->h_sub = htb->h_sub;
+                       }
+               if (i_tail == NULL)
+                       {
+                       i_head = i_tail = inclink(htb);
+                       }
+               else    {
+                       i_tail = i_tail->i_next = inclink(htb);
+                       }
+nextline:      while (c != '\n' && c != EOF)
+                       c = getc(ifp);
+               lineno++;
+               }
+       fclose(ifp);
+       return(i_head);
+}
+
+
+
+/*
+ * readP() searches Pascal files for included files. Returns a pointer
+ * to the chain of include files installed or found in the include file
+ * hash table, or null if no include files found.
+ */
+INCBLK *
+readP(lastfile, lastline, curname, type)
+       char *lastfile;                 /* parent file name */
+       int lastline;                   /* current line in parent file */
+       char *curname;                  /* current file name */
+       int type;                       /* file type */
+{
+       register char *p;               /* include string pointer */
+       register FILE *ifp;             /* input file stream */
+       register int c;                 /* current character */
+       char incname[PATHSIZE];         /* name of include file */
+       char incpath[PATHSIZE];         /* path to include file */
+       char *slappend();               /* append pathname to list */
+       FILE *fopen();                  /* open file */
+       HASHBLK *ftb;                   /* fromrule hash table entry block */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *instalinclude();       /* install include name in hash table */
+       HASHBLK *lookupinclude();       /* look up include in hash table */
+       INCBLK *i_head = NULL;          /* head of include chain */
+       INCBLK *i_tail = NULL;          /* tail of include chain */
+       INCBLK *inclink();              /* link include file hash blocks */
+       int cleanup();                  /* remove temporary makefile and exit */
+       int findinclude();              /* locate include file */
+       int getinclude();               /* get include name from input line */
+       int inctype;                    /* origin of include file */
+       int lineno = 1;                 /* current line number */
+       void notfound();                /* print "can't find" filename msg */
+
+       if ((ifp = fopen(curname, "r")) == NULL)
+               {
+               if (lastline > 0)
+                       fprintf(stderr, "%s: \"%s\", line %d: ", PGN,
+                               lastfile, lastline);
+               else
+                       fprintf(stderr, "%s: ", PGN);
+               perror(curname);
+               return(NULL);
+               }
+       while ((c = getc(ifp)) != EOF)
+               {
+               if (ISWHITESPACE(c))
+                       continue;
+               if (c != '#' && c != '$')
+                       goto nextline;
+               while ((c = getc(ifp)) == ' ' || c == '\t')
+                       continue;
+               for (p = "include"; *p == TOLOWER(c) && *p != '\0'; p++)
+                       c = getc(ifp);
+               if (*p != '\0')
+                       goto nextline;
+               ungetc(c, ifp);
+               if (getinclude(incname, curname, lineno, ifp) == NO)
+                       goto nextline;
+               if ((htb = lookupinclude(incname, type)) == NULL)
+                       {
+                       inctype = findinclude(incpath, incname, curname, type);
+                       if (inctype == INTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == YES)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, SYSLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == SYSTEM && SYSHDRS == NO)
+                               {
+                               goto nextline;
+                               }
+                       else if (inctype == EXTERNAL)
+                               {
+                               htb = instalinclude(incname, incpath, type);
+                               if (slappend(incpath, EXTLIST) == NULL)
+                                       cleanup();
+                               }
+                       else if (inctype == FROMRULE)
+                               {
+                               htb = instalinclude(incname, incname, type);
+                               ftb = instalinclude(incpath, incpath, type);
+                               }
+                       else    {
+                               notfound(curname, lineno, incname);
+                               goto nextline;
+                               }
+
+                       /* look for nested include files */
+                       htb->h_sub = readP(curname, lineno, incpath, type);
+
+                       if (inctype == FROMRULE)
+                               ftb->h_sub = htb->h_sub;
+                       }
+               if (i_tail == NULL)
+                       {
+                       i_head = i_tail = inclink(htb);
+                       }
+               else    {
+                       i_tail = i_tail->i_next = inclink(htb);
+                       }
+nextline:      while (c != '\n' && c != EOF)
+                       c = getc(ifp);
+               lineno++;
+               }
+       fclose(ifp);
+       return(i_head);
+}
+
+initsysinclude()
+{
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *htlookup();            /* find hash table entry */
+
+#ifdef _HasCompileSysType
+       if ((htb = htlookup(MCOMPILESYSTYPE, MDEFTABLE)) != NULL)
+               {
+               sprintf(SYSINCLUDE, "/%s", htb->h_def);
+               sprintf(SYSINCLUDECC, "/%s", htb->h_def);
+               }
+#endif
+
+        strcat(SYSINCLUDE, USRINCLUDE);
+        strcat(SYSINCLUDECC, USRINCLUDECC);
+       SYSINCLUDELEN = strlen(SYSINCLUDE)-1; /* length - last '/' */
+}
diff --git a/usr/src/contrib/mkmf/src/dir.h b/usr/src/contrib/mkmf/src/dir.h
new file mode 100644 (file)
index 0000000..d1ee453
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: dir.h,v 4.3 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Common directory header file
+ *
+ * Author: Peter J. Nicklin
+ */
+#ifndef DIR_H
+#define DIR_H
+
+#include "config.h"
+
+#ifdef _HasIncludeDirent
+#  include <dirent.h>
+   typedef struct dirent DIRENT;
+#endif
+
+#ifdef _HasIncludeSysDir
+#  include <sys/dir.h>
+   typedef struct direct DIRENT;
+#endif
+
+#ifdef _HasIncludeSysNdir
+#  include <sys/ndir.h>
+   typedef struct direct DIRENT;
+#endif
+
+#ifndef MAXNAMLEN
+#  define MAXNAMLEN 14
+#endif
+
+#endif /* DIR_H */
diff --git a/usr/src/contrib/mkmf/src/dlist.c b/usr/src/contrib/mkmf/src/dlist.c
new file mode 100644 (file)
index 0000000..043955b
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: dlist.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include "Mkmf.h"
+#include "dlist.h"
+#include "hash.h"
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+static HASHBLK *printtag = NULL;       /* include files already printed */
+static int COLUMN;                     /* last column printed */
+static void putinchain();              /* output nested subinclude filenames */
+static void putinclude();              /* output include file pathname */
+static void putobjd();                 /* output object file name */
+static void rmprinttag();              /* remove "already printed" tags */
+
+/*
+ * dlappend() adds a dependency chain block to the end of a list of
+ * dependency chain blocks. Each dependency chain block consists of a pointer
+ * to a source file name block contained in a singly-linked list, and a pointer
+ * to the head of the dependent list of included files. Returns a pointer to
+ * the dependency chain block, or a null pointer if out of memory.
+ */
+DLBLK *
+dlappend(srctyp, srcblk, incblk, dlist)
+       int srctyp;                     /* source file type */
+       SLBLK *srcblk;                  /* pointer to the source file block */
+       INCBLK *incblk;                 /* included file dependency chain */
+       DLIST *dlist;                   /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       DLBLK *dblk;                    /* pointer to dependency list block */
+
+       if (dlist == NULL)
+               return(NULL);
+       if ((dblk = (DLBLK *) malloc(sizeof(DLBLK))) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       dblk->d_src = srcblk;
+       dblk->d_type = srctyp;
+       dblk->d_incl = incblk;
+       dblk->d_next = NULL;
+       if (dlist->d_tail == NULL)
+               {
+               dlist->d_head = dlist->d_tail = dblk;
+               }
+       else    {
+               dlist->d_tail = dlist->d_tail->d_next = dblk;
+               }
+       return(dblk);
+}
+
+
+
+/*
+ * dlinit() returns a pointer to the head block of a dependency list, or
+ * null pointer if out of memory.
+ */
+DLIST *
+dlinit()
+{
+       char *malloc();                 /* memory allocator */
+       DLIST *dlist;                   /* pointer to list head block */
+
+       if ((dlist = (DLIST *) malloc(sizeof(DLIST))) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       dlist->d_head = dlist->d_tail = NULL;
+       return(dlist);
+}
+
+
+
+/*
+ * dlprint() appends the object-include file dependencies to the end of
+ * a makefile. Transitive closure is checked by making suring that an
+ * object-include file dependency is not generated if the source file is
+ * included in another file.
+ */
+void
+dlprint(dlist, ofp)
+       DLIST *dlist;                   /* dependency list */
+       FILE *ofp;                      /* output stream */
+{
+       DLBLK *dblk;                    /* pointer to dependency list block */
+       HASHBLK *lookupinclude();       /* look up include name in hash table */
+       INCBLK *iblk;                   /* cur. include file hash table blk */
+
+       if (dlist->d_head != NULL)
+               fprintf(ofp, "%s\n", DEPENDMARK);
+       for (dblk=dlist->d_head; dblk != NULL; dblk=dblk->d_next)
+               {
+               if (lookupinclude(dblk->d_src->key, dblk->d_type) == NULL)
+                       {
+                       putobjd(dblk->d_src, ofp);
+                       for (iblk=dblk->d_incl; iblk != NULL; iblk=iblk->i_next)
+                               {
+                               putinchain(iblk->i_hblk, ofp);
+                               }
+                       fprintf(ofp, "\n");
+                       rmprinttag();
+                       }
+               }
+}
+
+
+
+/*
+ * putinchain() outputs a chain of nested include file names. It changes
+ * the sign of each chain block h_val field as it traverses the chain to
+ * detect looping.
+ */
+static void
+putinchain(htb, ofp)
+       HASHBLK *htb;                   /* hash table blk including chain */
+       FILE *ofp;                      /* output stream */
+{
+       INCBLK *iblk;                   /* cur. include file hash table blk */
+
+       putinclude(htb, ofp);
+       htb->h_val = -htb->h_val;
+       for (iblk=htb->h_sub; iblk != NULL; iblk=iblk->i_next)
+               {
+               if (iblk->i_hblk->h_val < 0)
+                       {
+                       if (iblk->i_loop == NO)
+                               {
+                               warn2("recursive include nesting of \"%s\" in \"%s\"",
+                                     iblk->i_hblk->h_def, htb->h_def);
+                               iblk->i_loop = YES;
+                               }
+                       continue;
+                       }
+               putinchain(iblk->i_hblk, ofp);
+               }
+       htb->h_val = -htb->h_val;
+}
+
+
+
+#define MAXLINE                80
+#define        TABSIZE         8
+
+/*
+ * putinclude() writes an include file pathname to stream ofp if
+ * if it has not already been written on the current dependency line.
+ * and adds the hash block containing the file pathname to the
+ * "already printed" printtag list. The last block on the list
+ * points back onto itself rather than at NULL so that the non-NULL
+ * tag will indicate that the filename has already been seen.
+ */
+static void
+putinclude(htb, ofp)
+       HASHBLK *htb;                   /* include file hash block */
+       FILE *ofp;                      /* output stream */
+{
+       if (htb->h_tag == NULL)
+               {
+               COLUMN += htb->h_val + 1;
+               if (COLUMN >= (MAXLINE - 2))
+                       {
+                       fprintf(ofp, " \\\n\t%s", htb->h_def);
+                       COLUMN = htb->h_val + TABSIZE;
+                       }
+               else    {
+                       fprintf(ofp, " %s", htb->h_def);
+                       }
+               /* add to "already printed" filenames */
+               htb->h_tag = (printtag == NULL) ? htb :printtag;
+               printtag = htb;
+               }
+}
+
+
+
+/*
+ * putobjd() writes an object file dependency name.
+ */
+static void
+putobjd(srcblk, ofp)
+       SLBLK *srcblk;                  /* source file name list block */
+       FILE *ofp;                      /* output stream */
+{
+       extern char OBJSFX[];           /* object file name suffix */
+       int putobj();                   /* output object file name */
+
+       COLUMN = putobj(srcblk->key, ofp) + 1;
+       fprintf(ofp, ":");
+}
+
+
+
+/*
+ * rmprinttag() removes the chain of tags indicating that an include
+ * file dependency has already been printed for the current source file.
+ */
+static void
+rmprinttag()
+{
+       register HASHBLK *curhtb;       /* current hash table block */
+       register HASHBLK *nxthtb;       /* next hash table block */
+
+       for (curhtb = printtag; curhtb != NULL; curhtb = nxthtb)
+               {
+               nxthtb = curhtb->h_tag;
+               curhtb->h_tag = NULL;
+               }
+       printtag = NULL;
+}
diff --git a/usr/src/contrib/mkmf/src/dlist.h b/usr/src/contrib/mkmf/src/dlist.h
new file mode 100644 (file)
index 0000000..9b24a8a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: dlist.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Dependency list definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Dependency list block
+ */
+typedef struct _dlblk
+       {
+       int d_type;                     /* source file type */
+       struct slblk *d_src;            /* points to a source list block */
+       struct _iblk *d_incl;           /* pointer to include block chain */
+       struct _dlblk *d_next;          /* ptr to next list block */
+       } DLBLK;
+/*
+ * Dependency list head block
+ */
+typedef struct _dlisthb
+       {
+       DLBLK *d_head;                  /* pointer to first list block */
+       DLBLK *d_tail;                  /* pointer to last list block */
+       } DLIST;
+/*
+ * Functions defined for dependency list operations
+ */
+extern DLBLK *dlappend();              /* append to list */
+extern DLIST *dlinit();                        /* initialize list */
+extern void dlprint();                 /* print list */
diff --git a/usr/src/contrib/mkmf/src/editmf.c b/usr/src/contrib/mkmf/src/editmf.c
new file mode 100644 (file)
index 0000000..f57237a
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 1983, 1985, 1991, 1993 Peter J. Nicklin.
+ * Copyright (c) 1991, 1993 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: editmf.c,v 4.6 93/05/25 21:49:09 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include <signal.h>
+#include <stdio.h>
+#include "Mkmf.h"
+#include "config.h"
+#include "dlist.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+static char Mftemp[] = "mkmfXXXXXX";           /* temporary makefile */
+
+/*
+ * editmf() replaces macro definitions within a makefile.
+ */
+void
+editmf(mfname, mfpath)
+       char *mfname;                   /* makefile name */
+       char *mfpath;                   /* makefile template pathname */
+{
+       extern char IOBUF[];            /* I/O buffer line */
+       extern int DEPEND;              /* dependency analysis? */
+       extern SLIST *EXTLIST;          /* external header file name list */
+       extern SLIST *HEADLIST;         /* header file name list */
+       extern SLIST *LIBLIST;          /* library pathname list */
+       extern SLIST *SRCLIST;          /* source file name list */
+       extern SLIST *SYSLIST;          /* system header file name list */
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       char *findmacro();              /* is the line a macro definition? */
+       char *getlin();                 /* get a line from input stream */
+       char *mktemp();                 /* make file name */
+       char mnam[MACRONAMSIZE];        /* macro name buffer */
+       DLIST *dlp;                     /* dependency list */
+       DLIST *mkdepend();              /* generate object-include file deps */
+       FILE *ifp;                      /* input stream */
+       FILE *mustfopen();              /* must open file or die */
+       FILE *ofp;                      /* output stream */
+       HASHBLK *htb;                   /* hash table block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       void cleanup();                 /* remove temporary makefile and exit */
+       void dlprint();                 /* print dependency list */
+       void purgcontinue();            /* get rid of continuation lines */
+       void putmacro();                /* put macro defs from table */
+       void putlin();                  /* put a makefile line */
+       void putobjmacro();             /* put object file name macro def */
+       void putslmacro();              /* put macro defs from linked list */
+
+       ifp = mustfopen(mfpath, "r");
+       mktemp("Mftemp");
+
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               {
+               signal(SIGINT, cleanup);
+               signal(SIGHUP, cleanup);
+               signal(SIGQUIT, cleanup);
+               }
+
+       ofp = mustfopen(Mftemp, "w");
+       if (DEPEND)
+               {
+               dlp = mkdepend();
+               }
+
+       while (getlin(ifp) != NULL)
+               {
+               if (DEPEND && EQUAL(IOBUF, DEPENDMARK))
+                       break;
+               if (findmacro(mnam, IOBUF) != NULL)
+                       {
+                       if (EQUAL(mnam, MHEADERS))
+                               {
+                               putslmacro(HEADLIST, ofp);
+                               purgcontinue(ifp);
+                               }
+                       else if (EQUAL(mnam, MOBJECTS))
+                               {
+                               putobjmacro(ofp);
+                               purgcontinue(ifp);
+                               }
+                       else if (EQUAL(mnam, MSOURCES))
+                               {
+                               putslmacro(SRCLIST, ofp);
+                               purgcontinue(ifp);
+                               }
+                       else if (EQUAL(mnam, MSYSHDRS))
+                               {
+                               putslmacro(SYSLIST, ofp);
+                               purgcontinue(ifp);
+                               }
+                       else if (EQUAL(mnam, MEXTERNALS))
+                               {
+                               if (DEPEND)
+                                       {
+                                       putslmacro(EXTLIST, ofp);
+                                       purgcontinue(ifp);
+                                       }
+                               else    {
+                                       putlin(ofp);
+                                       }
+                               }
+                       else if (EQUAL(mnam, MLIBLIST) && LIBLIST != NULL)
+                               {
+                               putslmacro(LIBLIST, ofp);
+                               purgcontinue(ifp);
+                               }
+                       else if ((htb = htlookup(mnam, MDEFTABLE)) != NULL)
+                               {
+                               if (htb->h_val == VREADWRITE)
+                                       {
+                                       putmacro(htb->h_def, ofp);
+                                       purgcontinue(ifp);
+                                       }
+                               else    {
+                                       putlin(ofp);
+                                       }
+                               }
+                       else    {
+                               putlin(ofp);
+                               }
+                       }
+               else    {
+                       putlin(ofp);
+                       }
+               }
+       fclose(ifp);
+       if (DEPEND)
+               {
+               dlprint(dlp, ofp);
+               }
+       fclose(ofp);
+
+       signal(SIGINT, SIG_IGN);
+       signal(SIGHUP, SIG_IGN);
+       signal(SIGQUIT, SIG_IGN);
+
+       RENAME(Mftemp, mfname);
+}
+
+
+
+/*
+ * cleanup() removes the temporary makefile and dependency file, and
+ * calls exit(1).
+ */
+void
+cleanup(sig)
+       int sig;                        /* value of signal causing cleanup */
+{
+       signal(SIGINT, cleanup);
+       signal(SIGHUP, cleanup);
+       signal(SIGQUIT, cleanup);
+
+       unlink(Mftemp);
+       exit(1);
+}
diff --git a/usr/src/contrib/mkmf/src/getarg.h b/usr/src/contrib/mkmf/src/getarg.h
new file mode 100644 (file)
index 0000000..e247318
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: getarg.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Get command line argument
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Argument syntax: `-xargument' or `-x argument'
+ */
+#define GETARG(p) ((p[1] != '\0') ? ++p : (--argc, *++argv))
+
+/*
+ * Argument syntax: `-xargument'
+ *
+ * #define GETARG(p) (++p)
+ */
diff --git a/usr/src/contrib/mkmf/src/getcwp.c b/usr/src/contrib/mkmf/src/getcwp.c
new file mode 100644 (file)
index 0000000..ce25bce
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: getcwp.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getcwp() returns the pathname of the current working project. If the
+ * PROJECT environment variable is undefined or a null string, null is
+ * returned.
+ */
+#include "null.h"
+
+char *
+getcwp()
+{
+       extern char *_PROJECT;          /* project root directory pathname */
+       void getproject();              /* get PROJECT environment variable */
+
+       if (_PROJECT == NULL)
+               getproject();
+       return(_PROJECT);
+}
diff --git a/usr/src/contrib/mkmf/src/getproject.c b/usr/src/contrib/mkmf/src/getproject.c
new file mode 100644 (file)
index 0000000..10c90e3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: getproject.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * getproject() saves the contents of the PROJECT environment variable.
+ * If the PROJECT variable is undefined or a null string, null is returned.
+ */
+#include "null.h"
+
+char *_PROJECT = NULL;                 /* project root directory pathname */
+
+void
+getproject()
+{
+       register char *pv;              /* ptr to start of PROJECT variable */
+       char *getenv();                 /* get environment variable */
+       char *strsav();                 /* save a string somewhere */
+
+       if ((pv = getenv("PROJECT")) != NULL && *pv != '\0')
+               _PROJECT = strsav(pv);
+}
diff --git a/usr/src/contrib/mkmf/src/hash.c b/usr/src/contrib/mkmf/src/hash.c
new file mode 100644 (file)
index 0000000..4d7382b
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: hash.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include "null.h"
+#include "hash.h"
+#include "macro.h"
+#include "true.h"
+
+/*
+ * hthash() returns a hash value for string, s.
+ */
+hthash(s, hash)
+       register char *s;               /* string */
+       HASH *hash;                     /* hash table */
+{
+       register int hashval;           /* hash value for string */
+
+       for (hashval = 0; *s != '\0'; s++)
+               hashval += *s;
+       return(hashval % hash->hashsiz);
+}
+
+
+
+/*
+ * htinit() returns a pointer to a new hash table, or a null pointer if
+ * out of memory.
+ */
+HASH *
+htinit(hashsiz)
+       unsigned int hashsiz;           /* hash table size */
+{
+       char *malloc();                 /* allocate memory */
+       char *calloc();                 /* allocate and zero memory */
+       HASH *ht;                       /* pointer to hash table struct */
+       HASHBLK **pt;                   /* pointer to hash pointer table */
+
+       if ((ht = (HASH *) malloc(sizeof(HASH))) == NULL ||
+           (pt = (HASHBLK **) calloc(hashsiz, sizeof(HASHBLK *))) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       ht->hashtab = pt;
+       ht->headblk = -1;
+       ht->thisblk = NULL;
+       ht->hashsiz = hashsiz;
+       ht->nk = 0;
+       return(ht);
+}
+
+
+
+/*
+ * htinstall() installs a new entry in a hash table if it doesn't already
+ * exist. If it does, the old definition and value is superseded. Returns
+ * a pointer to the entry, or null if out of memory.
+ */
+HASHBLK *
+htinstall(key, def, val, hash)
+       char *key;                      /* key for hash table entry */
+       char *def;                      /* definition string */
+       int val;                        /* integer value */
+       HASH *hash;                     /* hash table */
+{
+       char *malloc();                 /* memory allocator */
+       char *strsav();                 /* save string somewhere */
+       HASHBLK *htb;                   /* hash table entry block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int hashval;                    /* hash value for key */
+       int hthash();                   /* calculate hash value */
+
+       if ((htb = htlookup(key, hash)) == NULL)
+               {                       /* not found */
+               if ((htb = (HASHBLK *) malloc(sizeof(HASHBLK))) == NULL)
+                       return(NULL);
+               if ((htb->h_key = strsav(key)) == NULL)
+                       return(NULL);
+               hashval = hthash(key, hash);
+               htb->h_next = (hash->hashtab)[hashval];
+               hash->thisblk = (hash->hashtab)[hashval] = htb;
+               htb->h_sub = NULL;
+               htb->h_tag = NULL;
+               }
+       else    {                       /* found: free previous definition */
+               if (htb->h_def != NULL)
+                       free(htb->h_def);
+               }
+       if (def == NULL)
+               htb->h_def = NULL;
+       else if ((htb->h_def = strsav(def)) == NULL)
+               return(NULL);
+       htb->h_val = val;
+       hash->nk++;
+       return(htb);
+}
+
+
+
+/*
+ * htlookup() returns a pointer to a hash table entry if found, otherwise null.
+ */
+HASHBLK *
+htlookup(key, hash)
+       char *key;                      /* key for hash table entry */
+       HASH *hash;                     /* hash table */
+{
+       HASHBLK *htb;                   /* hash table entry block */
+       int hthash();                   /* calculate hash value */
+
+       for (htb = (hash->hashtab)[hthash(key, hash)]; htb != NULL; htb = htb->h_next)
+               if (EQUAL(htb->h_key, key))
+                       return(hash->thisblk = htb);    /* found */
+       return(hash->thisblk = NULL);                   /* not found */
+}
+
+
+
+/*
+ * htrm() removes a hash table entry. If key is null, the entire hash
+ * table is removed.
+ */
+void
+htrm(key, hash)
+       char *key;                      /* key for hash table entry */
+       HASH *hash;                     /* hash table */
+{
+       HASHBLK *htbrm();               /* remove hash table block */
+       HASHBLK *htc;                   /* first hash table block in chain */
+       int hashval;                    /* hash value for key */
+       int hthash();                   /* compute hash value */
+       int i;                          /* hash table index */
+
+       if (key == NULL)
+               {
+               for (i = 0; i < hash->hashsiz; i++)
+                       if ((htc = (hash->hashtab)[i]) != NULL)
+                               (void) htbrm(key, htc);
+               free((char *) hash);
+               }
+       else    {
+               hashval = hthash(key, hash);
+               if ((htc = (hash->hashtab)[hashval]) != NULL)
+                       (hash->hashtab)[hashval] = htbrm(key, htc);
+               hash->nk--;
+               }
+}
+
+
+
+/*
+ * htbrm() removes a hash table block identified by key. If key is null, the
+ * entire chain is removed. Returns a pointer to the first block in the chain.
+ */
+HASHBLK *
+htbrm(key, htc)
+       char *key;                      /* key string */
+       HASHBLK *htc;                   /* hash table block chain */
+{
+       HASHBLK *curblk;                /* current list block */
+       HASHBLK *nxtblk;                /* next list block */
+       HASHBLK *prvblk;                /* previous list block */
+
+       if (key == NULL)
+               while (htc != NULL)
+                       {
+                       nxtblk = htc->h_next;
+                       free(htc->h_key);
+                       if (htc->h_def != NULL)
+                               free(htc->h_def);
+                       free((char *) htc);
+                       htc = nxtblk;
+                       }
+       else    {
+               /* first block is a special case */
+               if (EQUAL(htc->h_key, key))
+                       {
+                       nxtblk = htc->h_next;
+                       free(htc->h_key);
+                       if (htc->h_def != NULL)
+                               free(htc->h_def);
+                       free((char *) htc);
+                       htc = nxtblk;
+                       }
+               else    {
+                       /* remainder of list */
+                       prvblk = htc;
+                       curblk = htc->h_next;
+                       while (curblk != NULL)
+                               if (EQUAL(curblk->h_key, key))
+                                       {
+                                       prvblk->h_next = curblk->h_next;
+                                       free(curblk->h_key);
+                                       if (htc->h_def != NULL)
+                                               free(curblk->h_def);
+                                       free((char *) curblk);
+                                       break;
+                                       }
+                               else    {
+                                       prvblk = curblk;
+                                       curblk = curblk->h_next;
+                                       }
+                       }
+               }
+       return(htc);
+}
+
+
+
+/*
+ * htnext() positions the current hash table pointer at the next hash
+ * table block. Returns FALSE if no more blocks, otherwise TRUE.
+ */
+int
+htnext(hash)
+       HASH *hash;                     /* hash table */
+{
+       register int i;                 /* hash table index */
+
+       if (hash->thisblk == NULL ||
+          ((hash->thisblk = hash->thisblk->h_next) == NULL))
+               {
+               for (i = hash->headblk+1; i < hash->hashsiz; i++)
+                       {
+                       if ((hash->hashtab)[i] != NULL)
+                               {
+                                 hash->thisblk = (hash->hashtab)[i];
+                                 break;
+                               }
+                       }
+               hash->headblk = i;
+               }
+       return((hash->thisblk != NULL) ? TRUE : FALSE);
+}
+
+
+
+/*
+ * htrewind() resets the current hash table block pointer to the beginning
+ * of the hash table (actually one element before the beginning, so that
+ * htnext() can increment the current hash table block pointer to the
+ * first element.
+ */
+void
+htrewind(hash)
+       HASH *hash;                     /* hash table */
+{
+       hash->headblk = -1;
+       hash->thisblk = NULL;
+}
diff --git a/usr/src/contrib/mkmf/src/hash.h b/usr/src/contrib/mkmf/src/hash.h
new file mode 100644 (file)
index 0000000..587d920
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: hash.h,v 4.3 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Hash table definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Singly-linked list block containing a pointer to a hash table
+ * block for an include file
+ */
+typedef struct _iblk
+       {
+       int i_loop;
+       struct _hblk *i_hblk;
+       struct _iblk *i_next;
+       } INCBLK;
+/*
+ * Hash table block
+ */
+typedef struct _hblk
+       {
+       char *h_key;                    /* points to key */
+       char *h_def;                    /* points to definition string */
+       int h_val;                      /* integer value */
+       struct _iblk *h_sub;            /* ptr to include subchain */
+       struct _hblk *h_tag;            /* ptr to auxiliary tag chain */
+       struct _hblk *h_next;           /* ptr to next block */
+       } HASHBLK;
+/*
+ * Hash pointer table struct
+ */
+typedef struct _hash
+       {
+       HASHBLK **hashtab;              /* hash pointer table */
+       HASHBLK *thisblk;               /* current hash table block */
+       int headblk;                    /* index of head of block chain */
+       int hashsiz;                    /* hash table size */
+       int nk;                         /* number of keys in table */
+       } HASH;
+/*
+ * Functions defined for hash tables
+ */
+#define htnum(ht) ((ht)->nk)           /* return number of keys in table */
+#define htkey(ht) ((ht)->thisblk->h_key)/* return key from current block */
+#define htdef(ht) ((ht)->thisblk->h_def)/* return definition from current block */
+#define htval(ht) ((ht)->thisblk->h_val)/* return value from current block */
+extern HASHBLK *htbrm();               /* remove hash table block */
+extern int hthash();                   /* compute hash value */
+extern int htnext();                   /* set hash table ptr to next block */
+extern HASH *htinit();                 /* initialize hash table */
+extern HASHBLK *htinstall();           /* install hash table entry */
+extern HASHBLK *htlookup();            /* find hash table entry */
+extern void htrewind();                        /* rewind hash table to first block */
+extern void htrm();                    /* remove hash table entry */
diff --git a/usr/src/contrib/mkmf/src/inckey.h b/usr/src/contrib/mkmf/src/inckey.h
new file mode 100644 (file)
index 0000000..fcfe2c2
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: inckey.h,v 4.3 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Include file styles
+ *
+ * Author: Peter J. Nicklin
+ */
+"C",   INCLUDE_C,              /* C */
+"C++", INCLUDE_CXX,            /* C++ */
+"F",   INCLUDE_FORTRAN,        /* Fortran */
+"P",   INCLUDE_PASCAL,         /* Pascal */
+NULL,  INCLUDE_NONE            /* mandatory last line */
diff --git a/usr/src/contrib/mkmf/src/iolin.c b/usr/src/contrib/mkmf/src/iolin.c
new file mode 100644 (file)
index 0000000..590366d
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: iolin.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include "yesno.h"
+
+char IOBUF[BUFSIZ];                    /* I/O line buffer */
+short CONTINUE;                                /* does the line continue? */
+
+/*
+ * getlin() stores a line from input stream in IOBUF. The string is terminated
+ * by a newline character which is replaced by a null character. getlin()
+ * returns IOBUF, or null pointer upon end of file.
+ */
+char *
+getlin(stream)
+       register FILE *stream;          /* input stream */
+{
+       register int c;                 /* current character */
+       register char *iop;             /* IOBUF pointer */
+
+       iop = IOBUF;
+       while ((c = getc(stream)) != '\n' && c != EOF)
+               *iop++ = c;
+       if (c == EOF && iop == IOBUF)
+               return(NULL);
+       if (iop != IOBUF && iop[-1] == '\\')
+               {
+               iop[-1] = '\0';
+               CONTINUE = YES;
+               }
+       else    {
+               iop[0] = '\0';
+               CONTINUE = NO;
+               }
+       return(IOBUF);
+}
+
+
+
+/*
+ * purgcontinue() eats up continuation lines from an input stream.
+ */
+void
+purgcontinue(stream)
+       register FILE *stream;          /* input stream */
+{
+       register int c;                 /* current character */
+       register int lastc;             /* previous character */
+
+       if (CONTINUE == YES)
+               {
+               for (;;)
+                       {
+                       while ((c = getc(stream)) != '\n' && c != EOF)
+                               lastc = c;
+                       if (c == EOF || (c == '\n' && lastc != '\\'))
+                               break;
+                       }
+               CONTINUE = NO;
+               }
+}
+
+
+
+/*
+ * putlin() writes IOBUF to stream and appends a newline character. If
+ * IOBUF holds a CONTINUE line, a `\' precedes the newline.
+ */
+void
+putlin(stream)
+       register FILE *stream;          /* output stream */
+{
+       register int c;                 /* current character */
+       register char *iop;             /* IOBUF pointer */
+
+       iop = IOBUF;
+       while (c = *iop++)
+               putc(c, stream);
+       if (CONTINUE == YES)
+               putc('\\', stream);
+       putc('\n', stream);
+}
diff --git a/usr/src/contrib/mkmf/src/macro.c b/usr/src/contrib/mkmf/src/macro.c
new file mode 100644 (file)
index 0000000..116b595
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 1983, 1985, 1991, 1993 Peter J. Nicklin.
+ * Copyright (c) 1991, 1993 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: macro.c,v 4.8 93/05/25 21:49:09 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include <stdio.h>
+#include "Mkmf.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+#include "stringx.h"
+#include "yesno.h"
+
+extern char IOBUF[];                   /* I/O buffer line */
+extern HASH *MDEFTABLE;                        /* macro definition table */
+
+/*
+ * findmacro() searchs a line for a macro definition. A macro definition
+ * takes the form "name op= value" where "name" is any sequence of characters
+ * excluding the '=' character or whitespace. "op" may be one of the '+', '?',
+ * ':', or '!' characters which have special meanings for Berkeley make(1).
+ * findmacro() returns the name, or NULL if not found.
+ */
+char *
+findmacro(macroname, bp)
+       char *macroname;                /* macro name receiving buffer */
+       register char *bp;              /* buffer pointer */
+{
+       register char *mp;              /* macro name pointer */
+
+       while (WHITESPACE(*bp))
+               bp++;
+
+       for (mp = macroname; *bp && *bp != '='; bp++, mp++)
+               {
+               if (WHITESPACE(*bp))
+                       {
+                       break;
+                       }
+               else if ((*bp == '+' ||
+                         *bp == '?' ||
+                         *bp == ':' ||
+                         *bp == '!') && bp[1] == '=')
+                       {
+                       break;
+                       }
+               *mp = *bp;
+               }
+
+       *mp = '\0';
+
+       while (WHITESPACE(*bp))
+               bp++;
+
+       if (*bp == '+' || *bp == '?' || *bp == ':' || *bp == '!')
+               bp++;
+
+       return (*bp == '=' && mp > macroname) ? macroname : NULL;
+}
+       
+
+
+/*
+ * getmacro() loads the body of a macro definition into mdefbuf and returns
+ * a pointer to mdefbuf. If the macro definition continues on more than
+ * one line further lines are fetched from the input stream.
+ */
+char *
+getmacro(mdefbuf, stream)
+       char *mdefbuf;                  /* receiving macro definition buffer */
+       FILE *stream;                   /* input stream */
+{
+       extern short CONTINUE;          /* does the line continue? */
+       char *getlin();                 /* get a line from input stream */
+       register char *bp;              /* buffer pointer */
+       register char *mp;              /* macro definition buffer pointer */
+
+       bp = IOBUF;
+       mp = mdefbuf;
+       while (*bp++ != '=')
+               continue;
+       if (WHITESPACE(*bp))
+               bp++;
+       while (*bp != '\0')
+               *mp++ = *bp++;
+       while (CONTINUE == YES)
+               {
+               *mp++ = ' ';
+               if (getlin(stream) == NULL)
+                       break;
+               bp = IOBUF;
+               while (*bp != '\0')
+                       *mp++ = *bp++;
+               }
+       *mp = '\0';
+       return(mdefbuf);
+}
+
+
+
+/*
+ * putmacro() prints a macro definition from the macro definition table.
+ */
+void
+putmacro(macrovalue, stream)
+       char *macrovalue;               /* value of macro definition */
+       register FILE *stream;          /* output stream */
+{
+       register char *iop;             /* IOBUF pointer */
+       register int c;                 /* current character */
+
+       iop = IOBUF;
+       while ((c = *iop++) != '=')
+               putc(c, stream);
+       fprintf(stream, "= %s\n", macrovalue);
+}
+
+
+
+/*
+ * putobjmacro() derives and prints object file names from the SRCLIST list.
+ */
+void
+putobjmacro(stream)
+       register FILE *stream;          /* output stream */
+{
+       extern SLIST *SRCLIST;          /* source file name list */
+       register char *iop;             /* IOBUF pointer */
+       register int c;                 /* current character */
+       char *suffix;                   /* suffix pointer */
+       HASHBLK *lookupinclude();       /* look up include name in hash table */
+       int cnt = 0;                    /* number of object filenames printed */
+       int lookuptypeofinclude();      /* look up the brand of include */
+       int putobj();                   /* print object file name */
+       int type;                       /* file type */
+       SLBLK *lbp;                     /* list block pointer */
+
+       iop = IOBUF;
+       while ((c = *iop++) != '=')
+               putc(c, stream);
+       putc('=', stream);
+       for (lbp = SRCLIST->head; lbp != NULL; lbp = lbp->next)
+               {
+               suffix = strrchr(lbp->key, '.');
+               type = lookuptypeofinclude(++suffix);
+               if (lookupinclude(lbp->key, type) == NULL)
+                       {
+                       cnt += 1;
+                       if (cnt == 1)
+                               {
+                               putc(' ', stream);
+                               putobj(lbp->key, stream);
+                               }
+                       else    {
+                               fprintf(stream, " \\\n\t\t");
+                               putobj(lbp->key, stream);
+                               }
+                       }
+               }
+       putc('\n', stream);
+}
+
+
+
+/*
+ * putslmacro() copies a macro definition from a list.
+ */
+void
+putslmacro(slist, stream)
+       SLIST *slist;                   /* singly-linked macro def list */
+       register FILE *stream;          /* output stream */
+{
+       register char *iop;             /* IOBUF pointer */
+       register int c;                 /* current character */
+       SLBLK *lbp;                     /* list block pointer */
+
+       iop = IOBUF;
+       while ((c = *iop++) != '=')
+               putc(c, stream);
+       putc('=', stream);
+       if (SLNUM(slist) > 0)
+               {
+               lbp = slist->head;
+               fprintf(stream, " %s", lbp->key);
+               }
+       if (SLNUM(slist) > 1)
+               for (lbp = lbp->next; lbp != NULL; lbp = lbp->next)
+                       fprintf(stream, " \\\n\t\t%s", lbp->key);
+       putc('\n', stream);
+}
+
+
+
+/*
+ * storemacro() stores a macro definition in the macro definition table.
+ * Returns integer YES if a macro definition (macro=definition), otherwise
+ * NO. exit(1) is called if out of memory.
+ */
+storemacro(macdef)
+       char *macdef;                   /* macro definition string */
+{
+       register int i;                 /* macro value index */
+       register int j;                 /* macro name index */
+       HASHBLK *htinstall();           /* install hash table entry */
+
+       for (i = 0; macdef[i] != '='; i++)
+               if (macdef[i] == '\0')
+                       return(NO);
+       
+       /* removing trailing blanks and tabs from end of macro name */
+       for (j = i; j > 0; j--)
+               if (!WHITESPACE(macdef[j-1]))
+                       break;
+       macdef[j] = '\0';
+
+       /* remove leading blanks and tabs from macro value */
+       for (i++; WHITESPACE(macdef[i]); i++)
+               continue;
+       if (htinstall(macdef, macdef+i, VREADWRITE, MDEFTABLE) == NULL)
+               exit(1);
+       return(YES);
+}
+
+
+
+/*
+ * storenvmacro() stores all of the environment variables as
+ * though they were macros. Returns YES if successful, otherwise
+ * NO.
+ */
+storenvmacro()
+{
+       extern char **environ;          /* user environment */
+       register char **ep;             /* environment pointer */
+       register char *value;           /* macro value pointer */
+       register int i;                 /* macro name index */
+       char macroname[MACRONAMSIZE];   /* macro name buffer */
+
+       if (environ)
+               for (ep = environ; *ep != NULL; ep++)
+                       {
+                       value = *ep;
+                       for (i = 0; *value && *value != '='; i++, value++)
+                               macroname[i] = *value;
+                       if (*value == '=')
+                               {
+                               macroname[i] = '\0';
+                               value++;
+                               }
+
+                       if (htlookup(macroname, MDEFTABLE) != NULL)
+                               continue;
+
+                       if (htinstall(macroname, value,
+                                     VREADONLY, MDEFTABLE) == NULL)
+                               return(NO);
+                       }
+       return(YES);
+}
+
+
+
+/*
+ * storedynmacro() creates placeholders for certain macro definitions
+ * that ought to be generated unless specified on the command line.
+ * This prevents environment variables with the same names from being
+ * loaded into the macro definition table unnecessarily.
+ */
+storedynmacro()
+{
+       if (htlookup(MHEADERS, MDEFTABLE) == NULL)
+               if (htinstall(MHEADERS, "", VDYNAMIC, MDEFTABLE) == NULL)
+                       return(NO);
+
+       if (htlookup(MOBJECTS, MDEFTABLE) == NULL)
+               if (htinstall(MOBJECTS, "", VDYNAMIC, MDEFTABLE) == NULL)
+                       return(NO);
+
+       if (htlookup(MSOURCES, MDEFTABLE) == NULL)
+               if (htinstall(MSOURCES, "", VDYNAMIC, MDEFTABLE) == NULL)
+                       return(NO);
+
+       if (htlookup(MEXTERNALS, MDEFTABLE) == NULL)
+               if (htinstall(MEXTERNALS, "", VDYNAMIC, MDEFTABLE) == NULL)
+                       return(NO);
+       return(YES);
+}
diff --git a/usr/src/contrib/mkmf/src/macro.h b/usr/src/contrib/mkmf/src/macro.h
new file mode 100644 (file)
index 0000000..259e0e5
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: macro.h,v 4.4 91/11/25 19:45:47 nicklin Exp $
+ *
+ * General macro function definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+#include "stringx.h"
+
+#undef CHDIR
+#define CHDIR(d) \
+       (chdir(d) == 0)                 /* change directory */
+
+#undef DOTDIR
+#define DOTDIR(dp) \
+       (dp->d_name[0] == '.' && dp->d_name[1] == '\0')
+                                       /* current directory? */
+#undef DOTDOTDIR
+#define DOTDOTDIR(dp) \
+       (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == '\0')
+                                       /* parent directory? */
+#undef EQUAL
+#define EQUAL(s1,s2) \
+       (strcmp(s1,s2) == 0)            /* string comparison */
+
+#undef MIN
+#define MIN(a,b) \
+       (((a) < (b)) ? (a) : (b))       /* minimum of two values */
+
+#undef MAX
+#define MAX(a,b) \
+       (((a) > (b)) ? (a) : (b))       /* maximum of two values */
+
+#ifndef S_ISDIR
+#define S_ISDIR(m) \
+       ((m & S_IFMT) == S_IFDIR)       /* test for directory */
+#endif
+
+#undef WHITESPACE
+#define WHITESPACE(c) \
+       (c == ' ' || c == '\t')         /* unseen space in a file */
diff --git a/usr/src/contrib/mkmf/src/misc.c b/usr/src/contrib/mkmf/src/misc.c
new file mode 100644 (file)
index 0000000..92ecf33
--- /dev/null
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 1983, 1985, 1991, 1993 Peter J. Nicklin.
+ * Copyright (c) 1991, 1993 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: misc.c,v 4.10 93/05/25 21:49:09 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include "Mkmf.h"
+#include "config.h"
+#include "dir.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "path.h"
+#include "target.h"
+#include "stringx.h"
+#include "suffix.h"
+#include "yesno.h"
+
+/*
+ * answer() installs a line from stdin in the macro definition table.
+ * exit(1) is called if EOF, error, or out of memory.
+ */
+void
+answer(mdefkey, mdefval)
+       char *mdefkey;                  /* macro definition key */
+       int mdefval;                    /* macro definition value */
+{
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       char answerbuf[ANSWERBUFSIZE];  /* answer from stdin */
+       char *gets();                   /* get a line from stdin */
+       HASHBLK *htinstall();           /* install hash table entry */
+
+       if (gets(answerbuf) == NULL)
+               exit(1);
+       if (*answerbuf != '\0')
+               if (htinstall(mdefkey, answerbuf, mdefval, MDEFTABLE) == NULL)
+                       exit(1);
+}
+
+
+
+/*
+ * fastcopy() copies file to stream fp. Returns integer YES if successful,
+ * otherwise NO.
+ */
+fastcopy(filename, ofp)
+       char *filename;                 /* file to be copied */
+       register FILE *ofp;             /* output stream */
+{
+       register int ifd;               /* input file descriptor */
+       register int n;                 /* byte count */
+       char buf[BUFSIZ];               /* I/O buffer */
+
+       if ((ifd = OPEN(filename, 0, 0644)) == -1)
+               {
+               pperror("");
+               return(NO);
+               }
+       while ((n = read(ifd, buf, BUFSIZ)) > 0)
+               write(fileno(ofp), buf, n);
+       close(ifd);
+       return(YES);
+}
+
+
+
+/*
+ * findmf() locates the makefile to be edited. The type of makefile
+ * is returned in target. The pathname to the makefile is returned
+ * in mfpath. Returns YES if makefile or makefile template can be
+ * opened, otherwise NO.
+ */
+findmf(mfname, mfpath, target)
+       char *mfname;                   /* name of target makefile */
+       char *mfpath;                   /* path to target makefile */
+       TARGET *target;                 /* type of makefile target */
+{
+       extern int CFLAG;               /* makefile creation message */
+       int readmf();                   /* read makefile */
+       int targettype;                 /* type of makefile requested */
+       void findmftemplate();          /* find makefile template */
+
+       targettype = target->type;
+       if (FILEXIST(mfname))
+               {
+               if (!FILEWRITE(mfname))
+                       {
+                       pperror(mfname);
+                       target->type = VERROR;
+                       return(NO);
+                       }
+               if (readmf(mfname, target) == VERROR)
+                       return(NO);
+               if (targettype != VUNKNOWN && targettype != target->type)
+                       {
+                       if (targettype == VPROGRAM)
+                               {
+                               warns("%s not a program makefile", mfname);
+                               }
+                       else if (targettype == VLIBRARY)
+                               {
+                               warns("%s not a library makefile", mfname);
+                               }
+                       else    {
+                               warns("%s: unknown makefile type", mfname);
+                               }
+                       return(NO);
+                       }
+               strcpy(mfpath, mfname);
+               }
+       else    {
+               target->type = (targettype == VLIBRARY) ? VLIBRARY : VPROGRAM;
+               findmftemplate(mfpath, target);
+               if (readmf(mfpath, target) == VERROR)
+                       return(NO);
+               if (CFLAG == YES)
+                       warn2("creating %s from %s", mfname, mfpath);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * findmftemplate() returns the pathname of a makefile template in mfpath.
+ */
+void
+findmftemplate(mfpath, target)
+       char *mfpath;                   /* path to target makefile */
+       TARGET *target;                 /* type of makefile target */
+{
+       extern char *MAKEFILE;          /* makefile template name */
+       extern int FFLAG;               /* makefile template pathname flag */
+       extern int LIBOBJ;              /* load object file into library? */
+       char *cwp;                      /* current project pathname pointer */
+       char *getcwp();                 /* get current project pathname */
+       char *mktname();                /* make template name */
+       char *pathcat();                /* pathname concatenation */
+       char tname[MAXNAMLEN+1];        /* template name */
+
+       if (FFLAG == YES)
+               {
+               strcpy(mfpath, MAKEFILE);
+               return;
+               }
+       strcpy(tname, MAKEFILE);
+       if (strrchr(tname, '.') == NULL)
+               switch (target->type)
+                       {
+                       case VPROGRAM:
+                               mktname(tname, SPROGRAM);
+                               break;
+                       case VLIBRARY:
+                               if (LIBOBJ == 1)
+                                       {
+                                       mktname(tname, SLIBRARY2);
+                                       }
+                               else    {
+                                       mktname(tname, SLIBRARY);
+                                       }
+                               break;
+                       }
+
+       cwp = getcwp();
+       if (cwp == NULL ||
+           !FILEXIST(pathcat(mfpath, pathcat(mfpath, cwp, MKMFLIB), tname)))
+               pathcat(mfpath, pathcat(mfpath, INSTALLDIR, MKMFLIB), tname);
+}
+
+
+
+/*
+ * gettoken() copies the next token from token buffer to token. Returns a
+ * pointer to the first character after the token, or null upon reaching
+ * the end of the token buffer.
+ */
+char *
+gettoken(token, tp)
+       register char *token;           /* receiving token */
+       register char *tp;              /* token buffer pointer */
+{
+       while (isspace(*tp) && *tp != '\0')
+               tp++;
+       if (*tp == '\0')
+               {
+               *token = '\0';
+               return(NULL);
+               }
+       while (!isspace(*tp) && *tp != '\0')
+               *token++ = *tp++;
+       *token = '\0';
+       return(tp);
+}
+
+
+
+/*
+ * getoption() copies the next matching option from token buffer to token.
+ * Returns a pointer to the first character after the token, or null upon
+ * reaching the end of the token buffer.
+ */
+char *
+getoption(token, tp, option)
+       register char *token;           /* receiving token */
+       register char *tp;              /* token buffer pointer */
+       register char *option;          /* option leader string */
+{
+       int optlen = strlen(option);    /* option length */
+
+       if ((tp = gettoken(token, tp)) == NULL)
+               return(NULL);
+
+       /* skip non-matching options */
+       while (strncmp(token, option, optlen) != 0)
+               {
+               if ((tp = gettoken(token, tp)) == NULL)
+                       {
+                       return(NULL);
+                       }
+               }
+
+       if (EQUAL(token, option))
+               tp = gettoken(token, tp);               /* -X option */
+       else
+               (void) gettoken(token, token+optlen);   /* -Xoption */
+
+       return(tp);
+}
+
+
+
+/*
+ * getpath() copies the next pathname from path buffer to path. Returns a
+ * pointer to the first character after the path, or null upon reaching
+ * the end of the path buffer.
+ */
+char *
+getpath(path, pp)
+       register char *path;            /* receiving path */
+       register char *pp;              /* path buffer pointer */
+{
+       while ((isspace(*pp) || *pp == ':') && *pp != '\0')
+               pp++;
+       if (*pp == '\0')
+               {
+               *path = '\0';
+               return(NULL);
+               }
+       while (!(isspace(*pp) || *pp == ':') && *pp != '\0')
+               *path++ = *pp++;
+       *path = '\0';
+       return(pp);
+}
+
+
+
+/*
+ * libobj() returns NO if the definition of the OBJS macro contains regular
+ * object file names, and YES if it contains $(LIBRARY)(objfile) file names
+ * (indicating that each object file should be inserted into a library
+ * immediately after compilation). Only the first line of the macro is
+ * scanned for $(LIBRARY).
+ */
+int
+libobj(bp)
+       register char *bp;              /* buffer pointer */
+{
+       register char *sbp;             /* save buffer pointer */
+       register char *mp;              /* macro name pointer */
+
+       while (*bp++ != '=')
+               continue;
+       if (WHITESPACE(*bp))
+               bp++;
+       for (mp = DLIBRARY, sbp = bp; *mp == *bp && *mp != '\0'; mp++, bp++)
+               continue;
+       if (*mp == '\0')
+               return(YES);
+       for (mp = dLIBRARY, bp = sbp; *mp == *bp && *mp != '\0'; mp++, bp++)
+               continue;
+       if (*mp == '\0')
+               return(YES);
+       return(NO);
+}
+
+
+
+/*
+ * mktname() concatenates a suffix to a makefile template name. Returns
+ * name if successful, otherwise NULL.
+ */
+char *
+mktname(base, suffix)
+       char *base;                     /* template basename */
+       char *suffix;                   /* template suffix */
+{
+       if (strlen(base) + strlen(suffix) > MAXNAMLEN)
+               {
+               warn("makefile template name too long");
+               return(NULL);
+               }
+       else    {
+               return(strcat(base, suffix));
+               }
+}
+
+
+
+/*
+ * nocore() places an "out of memory" error message on the standard error
+ * output stream stderr.
+ */
+nocore()
+{
+       warn("out of memory");
+}
+
+
+
+/*
+ * putobj() converts a source file name to an object file name and then
+ * writes the file name to stream. Returns the length of the file name.
+ */
+putobj(s, stream)
+       register char *s;               /* source file name */
+       register FILE *stream;          /* output stream */
+{
+       register int baselen = 0;       /* length of object file basename */
+       register char *dot;             /* pointer to suffix */
+       char *pathsep;                  /* pathname separator */
+       static int psfxlen = 0;         /* length of object prefix & suffix */
+       extern int LIBOBJ;              /* load object file into library? */
+       extern char OBJSFX[];           /* object file name suffix */
+
+       if (psfxlen == 0)
+               {
+               psfxlen = strlen(OBJSFX);
+               if (LIBOBJ) psfxlen += strlen(DLIBRARY) + 2;
+               }
+       if ((pathsep = strrchr(s, _PSC)) != NULL)
+               s = pathsep + 1;
+       dot = strrchr(s, '.');
+       if (LIBOBJ)
+               {
+               fprintf(stream, "%s(", DLIBRARY);
+               while (s != dot)
+                       {
+                       putc(*s++, stream);
+                       baselen++;
+                       }
+               fprintf(stream, "%s)", OBJSFX);
+               }
+       else    {
+               while (s != dot)
+                       {
+                       putc(*s++, stream);
+                       baselen++;
+                       }
+               fprintf(stream, "%s", OBJSFX);
+               }
+       return(psfxlen+baselen);
+}
+
+
+
+/*
+ * readmf() reads a makefile and loads CFLAGS, FFLAGS, and SUFFIX definitions
+ * into the macro definition table if they do not already exist. Returns
+ * integer VLIBRARY, VPROGRAM, or VUNKNOWN according to the type of makefile,
+ * or VERROR if cannot open makefile.
+ */
+readmf(mfname, target)
+       char *mfname;                   /* name of makefile */
+       TARGET *target;                 /* type of makefile target */
+{
+       register char *bp;              /* buffer pointer */
+       extern char IOBUF[];            /* I/O buffer line */
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       extern int LIBOBJ;              /* load object file into library? */
+       char *findmacro();              /* is the line a macro definition? */
+       char *findrule();               /* is the line a rule definition? */
+       char *getlin();                 /* get a line from input stream */
+       char *getmacro();               /* get macro def from input stream */
+       char macrodef[MACRODEFSIZE];    /* macro definition buffer */
+       char macroname[MACRONAMSIZE];   /* macro name buffer */
+       char rulename[2*SUFFIXSIZE+3];  /* transformation rule name */
+       FILE *fopen();                  /* open file */
+       FILE *fp;                       /* file pointer */
+       HASHBLK *htinstall();           /* install hash table entry */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int libobj();                   /* is object file loaded into library?*/
+       int storerule();                /* store transformation rule */
+       void purgcontinue();            /* get rid of continuation lines */
+
+       target->type = target->dest = VUNKNOWN;
+       if ((fp = fopen(mfname, "r")) == NULL)
+               {
+               pperror(mfname);
+               target->type = VERROR;
+               return(target->type);
+               }
+       while (getlin(fp) != NULL)
+               {
+               if (EQUAL(IOBUF, DEPENDMARK))
+                       break;
+               for (bp = IOBUF; *bp == ' '; bp++)
+                       continue;
+               if (findmacro(macroname, bp) != NULL)
+                       {
+                       if (EQUAL(macroname, MPROGRAM))
+                               {
+                               target->type = VPROGRAM;
+                               }
+                       else if (EQUAL(macroname, MLIBRARY))
+                               {
+                               target->type = VLIBRARY;
+                               }
+                       else if (EQUAL(macroname, MDESTDIR))
+                               {
+                               target->dest = VDESTDIR;
+                               }
+
+                       if (EQUAL(macroname, MOBJECTS))
+                               {
+                               if (libobj(bp) == YES)
+                                       LIBOBJ = 1;
+                               purgcontinue;
+                               }
+
+                       /* does macro definition already exist? */
+                       if (htlookup(macroname, MDEFTABLE) != NULL)
+                               continue;
+
+                       if (htinstall(macroname, getmacro(macrodef, fp),
+                                     VREADONLY, MDEFTABLE) == NULL)
+                               {
+                               fclose(fp);
+                               return(NO);
+                               }
+                       }
+               else if (*bp == '.' && findrule(rulename, bp) != NULL)
+                       {
+                       if (storerule(rulename) == NO)
+                               {
+                               fclose(fp);
+                               return(NO);
+                               }
+                       }
+               }
+       fclose(fp);
+       return(target->type);
+}
diff --git a/usr/src/contrib/mkmf/src/mksrclist.c b/usr/src/contrib/mkmf/src/mksrclist.c
new file mode 100644 (file)
index 0000000..9ef563c
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: mksrclist.c,v 4.8 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Mkmf.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "path.h"
+#include "slist.h"
+#include "stringx.h"
+#include "yesno.h"
+
+extern SLIST *SRCLIST;                 /* source file name list */
+extern SLIST *HEADLIST;                        /* header file name list */
+extern HASH *MDEFTABLE;                        /* macro definition table */
+
+static int addsrctable();              /* add file to src hash table / list */
+static int addvsrctable();             /* add virtual file to hash table */
+static int  hashtolist();              /* convert hash table file list */
+static HASH *SRCTABLE = NULL;          /* source file hash table */
+
+static struct stat CURDIRSTAT;         /* current directory status */
+
+/*
+ * mksrclist() composes a list of source and header files names
+ * from the current directory and directories listed in VPATH.
+ * Return YES if successful, otherwise NO.
+ */
+mksrclist(needsrc, needhdr)
+       int needsrc;                    /* need source file names */
+       int needhdr;                    /* need header file names */
+{
+       char *getpath();                /* get next path */
+       char *vp;                       /* virtual path buffer pointer */
+       char vpath[PATHSIZE];           /* virtual directory path buffer */
+       int addsrclist();               /* add file to header list */
+       int read_dir();                 /* read dir for source and headers */
+       struct stat statbuf;            /* virtual path stat buffer */
+
+       /*
+        * save inode info for current directory so that we can make sure
+        * that directories in VPATH do not include the current directory.
+        */
+       if (stat(CURDIR, &CURDIRSTAT) < 0)
+               {
+               pperror(CURDIR);
+               return(NO);
+               }
+
+       /*
+        * if VPATH exists, merge the source file names from the
+        * directories in VPATH with the source files in the current
+        * directory, otherwise build source list directly.
+        */
+       if (htlookup(MVPATH, MDEFTABLE) != NULL)
+               {
+               vp = htdef(MDEFTABLE);          
+
+               if ((SRCTABLE = htinit(SOURCETABLESIZE)) == NULL)
+                       return(NO);
+       
+               if (read_dir(CURDIR, addsrctable, needsrc, needhdr) == NO)
+                       return(NO);
+
+               while ((vp = getpath(vpath, vp)) != NULL)
+                       {
+                       if (stat(vpath, &statbuf) < 0)
+                               {
+                               pperror(vpath);
+                               continue;
+                               }
+
+                       if (!S_ISDIR(statbuf.st_mode))
+                               {
+                               warns("(warning) %s in VPATH not a directory", vpath);
+                               continue;
+                               }
+
+                       if (CURDIRSTAT.st_dev == statbuf.st_dev &&
+                           CURDIRSTAT.st_ino == statbuf.st_ino)
+                               {
+                               warns("(warning) current directory %s included in VPATH", vpath);
+                               continue;
+                               }
+
+                       if (read_dir(vpath, addvsrctable, needsrc, needhdr) == NO)
+                               return(NO);
+                       }
+
+               /*
+                * convert hash table source file entries to
+                * singly-linked source list
+                */
+               if (hashtolist(SRCTABLE, SRCLIST) == NO)
+                       {
+                       htrm(NULL, SRCTABLE);
+                       return(NO);
+                       }
+               htrm(NULL, SRCTABLE);
+               }
+       else    {
+               if (read_dir(CURDIR, addsrclist, needsrc, needhdr) == NO)
+                       return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * addsrclist() adds a file to a source/header file list. Returns YES if
+ * successful, otherwise NO.
+ */
+addsrclist(dirname, filename, lswitch)
+       char *dirname;                  /* directory name */
+       char *filename;                 /* file name to add to source list */
+       int lswitch;                    /* source/header list switch */
+{
+       if (lswitch == 's')
+               return((slappend(filename, SRCLIST) != NULL) ? YES : NO);
+       else
+               return((slappend(filename, HEADLIST) != NULL) ? YES : NO);
+}
+
+
+
+/*
+ * addsrctable() adds a file to a source file hash table or a header file
+ * singly-linked list. Returns YES if successful, otherwise NO.
+ */
+static int
+addsrctable(dirname, filename, tswitch)
+       char *dirname;                  /* directory name */
+       char *filename;                 /* file name to add to source table */
+       int tswitch;                    /* source/header switch */
+{
+       if (tswitch == 's')
+               {
+               if (htlookup(filename, SRCTABLE) != NULL)
+                       {
+                       warn2("(warning) duplicate file %s/%s ignored",
+                             dirname, filename);
+                       }
+               else    {
+                       if (htinstall(filename, dirname, 0, SRCTABLE) == NULL)
+                               return(NO);
+                       }
+               }         
+       else    {
+               if (slappend(filename, HEADLIST) == NULL)
+                       return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * addvsrctable() adds a file to a source file hash table. Returns
+ * YES if successful, otherwise NO.
+ */
+static int
+addvsrctable(dirname, filename, tswitch)
+       char *dirname;                  /* directory name */
+       char *filename;                 /* file name to add to source table */
+       int tswitch;                    /* source/header table switch */
+{
+       HASH *table;                    /* pointer to source/header file table */
+
+       if (tswitch == 's')
+               {
+               if (htlookup(filename, SRCTABLE) != NULL)
+                       {
+                       warn2("(warning) duplicate file %s/%s ignored",
+                             dirname, filename);
+                       }
+               else    {
+                       if (htinstall(filename, dirname, 0, SRCTABLE) == NULL)
+                               return(NO);
+                       }
+               }
+       return(YES);
+}
+
+
+
+/*
+ * hashtolist() converts the file entries stored in a hash table to a
+ * singly-linked list of pathnames. Returns YES if successful, otherwise
+ * NO.
+ */
+static int
+hashtolist(table, list)
+       HASH *table;                    /* hash table */
+        SLIST *list;                   /* pointer to list head block */
+{
+       char path[PATHSIZE];            /* path to foreign source file */
+
+       htrewind(table);
+       while (htnext(table))
+               {
+               if (htdef(table) == NULL || EQUAL(CURDIR, htdef(table)))
+                       {               /* current directory */
+                       if (slappend(htkey(table), list) == NULL)
+                               return(NO);
+                       }
+               else    {               /* VPATH directory */
+                       pathcat(path, htdef(table), htkey(table));
+                       if (slappend(path, list) == NULL)
+                               return(NO);
+                       }
+               }
+       return(YES);
+}
diff --git a/usr/src/contrib/mkmf/src/mksymlink.c b/usr/src/contrib/mkmf/src/mksymlink.c
new file mode 100644 (file)
index 0000000..1baaa97
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: mksymlink.c,v 4.10 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Mkmf.h"
+#include "config.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "path.h"
+#include "slist.h"
+#include "yesno.h"
+
+#ifdef _HasSymLinks
+
+#define NOT_SYMLINK    1               /* not a symbolic link */
+#define UNV_SYMLINK    2               /* unverified symbolic link */
+#define VER_SYMLINK    3               /* verified symbolic link */
+
+extern int errno;                      /* error indicator for system calls */
+extern SLIST *SRCLIST;                 /* source file name list */
+extern SLIST *HEADLIST;                        /* header file name list */
+extern HASH *MDEFTABLE;                        /* macro definition table */
+
+static int addsrctable();              /* add file to source hash table */
+static int addvsrctable();             /* add virtual file to hash table */
+static int  hashtolist();              /* convert hash table file list */
+static HASH *SRCTABLE = NULL;          /* source file hash table */
+static HASH *HDRTABLE = NULL;          /* header file hash table */
+
+static struct stat CURDIRSTAT;         /* current directory status */
+
+/*
+ * mksymlink() creates symbolic links from foreign directories into
+ * the current directory. Return YES if successful, otherwise NO.
+ *
+ * Given the following state of the current directory and a virtual path:
+ *
+ * ./a.c -----> dangling reference
+ * ./b.c        ordinary file
+ * ./c.c ----->        a/c.c
+ *             a/d.c
+ * ./d.c ----->        b/d.c
+ * ./e.c ----->        b/e.c
+ * ./f.c ----->        c/f.c
+ *
+ * VPATH = a b
+ *
+ * mksymlink() needs to delete a.c, shift the link for d.c from directory b
+ * to directory a, and issue a warning that f.c is linked to a file in an
+ * external directory.
+ */
+mksymlink(needsrc, needhdr)
+       int needsrc;                    /* need source file names */
+       int needhdr;                    /* need header file names */
+{
+       char *getpath();                /* get next path */
+       char *vp;                       /* virtual path buffer pointer */
+       char vpath[PATHSIZE];           /* virtual directory path buffer */
+       int read_dir();                 /* read dir for source and headers */
+       struct stat statbuf;            /* virtual path stat buffer */
+
+       if ((HDRTABLE = htinit(SOURCETABLESIZE)) == NULL)
+               return(NO);
+       if ((SRCTABLE = htinit(SOURCETABLESIZE)) == NULL)
+               return(NO);
+
+       if (stat(CURDIR, &CURDIRSTAT) < 0)
+               {
+               pperror(CURDIR);
+               return(NO);
+               }
+
+       if (read_dir(CURDIR, addsrctable, needsrc, needhdr) == NO)
+               return(NO);
+
+       /*
+        * merge source/header files in other directories into hash table
+        * source list
+        */
+       if (htlookup(MVPATH, MDEFTABLE) != NULL)
+               {
+               vp = htdef(MDEFTABLE);          
+               while ((vp = getpath(vpath, vp)) != NULL)
+                       {
+                       if (stat(vpath, &statbuf) < 0)
+                               {
+                               pperror(vpath);
+                               continue;
+                               }
+
+                       if (!S_ISDIR(statbuf.st_mode))
+                               {
+                               warns("(warning) %s in VPATH not a directory", vpath);
+                               continue;
+                               }
+
+                       if (CURDIRSTAT.st_dev == statbuf.st_dev &&
+                           CURDIRSTAT.st_ino == statbuf.st_ino)
+                               {
+                               warns("(warning) current directory %s included in VPATH", vpath);
+                               continue;
+                               }
+
+                       if (read_dir(vpath, addvsrctable, needsrc, needhdr) == NO)
+                               return(NO);
+                       }
+               }
+
+       /*
+        * convert hash table source file entries to singly-linked source list
+        */
+       if (hashtolist(SRCTABLE, SRCLIST) == NO)
+               {
+               htrm(NULL, SRCTABLE);
+               return(NO);
+               }
+       htrm(NULL, SRCTABLE);
+
+       /*
+        * convert hash table header file entries to singly-linked header list
+        */
+       if (hashtolist(HDRTABLE, HEADLIST) == NO)
+               {
+               htrm(NULL, HDRTABLE);
+               return(NO);
+               }
+       htrm(NULL, HDRTABLE);
+
+       return(YES);
+}
+
+
+
+/*
+ * addsrctable() adds a file to a source/header file hash table. Returns
+ * YES if successful, otherwise NO.
+ */
+static int
+addsrctable(dirname, filename, tswitch)
+       char *dirname;                  /* directory name */
+       char *filename;                 /* file name to add to source table */
+       int tswitch;                    /* source/header table switch */
+{
+       char symbuf[PATHSIZE];          /* symbolic link pathname buffer */
+
+if (readlink(filename, symbuf, PATHSIZE) < 0)
+               {
+#ifdef _HasEnxioReadlinkReturn         /* ugly hack around apollo bug */
+               if (errno == EINVAL || errno == ENXIO)
+#else
+                if (errno == EINVAL)
+#endif
+                       {
+                       if (htinstall(filename, NULL, NOT_SYMLINK,
+                          (tswitch == 's') ? SRCTABLE : HDRTABLE) == NULL)
+                               return(NO);
+                       }
+               else    {
+                       pperror(filename);
+                       return(NO);
+                       }
+               }
+       else    {
+               if (htinstall(filename, pathhead(symbuf), UNV_SYMLINK,
+                  (tswitch == 's') ? SRCTABLE : HDRTABLE) == NULL)
+                       return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * addvsrctable() merges source/header files from directories in the virtual
+ * path into a source or header file hash table. If a file in the current
+ * directory is linked to a file in a yet unseen directory, then the link
+ * is broken and reestabished to a file in the current virtual directory.
+ * Returns YES if successful, otherwise NO.
+ */
+static int
+addvsrctable(dirname, filename, tswitch)
+       char *dirname;                  /* directory name */
+       char *filename;                 /* file name to add to source table */
+       int tswitch;                    /* source/header table switch */
+{
+       char path[PATHSIZE];            /* path to foreign source file */
+       HASH *table;                    /* pointer to source/header file table */
+
+       table = (tswitch == 's') ? SRCTABLE : HDRTABLE;
+       if (htlookup(filename, table) != NULL)
+               {
+               if (htval(table) == UNV_SYMLINK)
+                       {
+                       if (!EQUAL(dirname, htdef(table)))
+                               {       /* link file from dirname */
+                               if(unlink(filename) < 0)
+                                       {
+                                       warns("(error) failed to remove symbolic link %s", filename);
+                                       return(NO);
+                                       }
+                               else if (symlink(pathcat(path, dirname, filename), filename) < 0)
+                                       {
+                                       pperror(filename);
+                                       return(NO);
+                                       }
+                               else    {
+                                       char oldpath[PATHSIZE]; /* extra pathname buffer */
+                                       pathcat(oldpath, htdef(table), filename);
+                                       warn2("(warning) symbolic link %s replaced by %s", oldpath, path);
+                                       }
+                               }
+                       htval(table) = VER_SYMLINK;
+                       }
+               else    {
+                       warn2("(warning) duplicate file %s/%s ignored", htdef(table), filename);
+                       }
+               }
+       else    {
+               if (htinstall(filename, NULL, VER_SYMLINK, table) == NULL)
+                       return(NO);
+               pathcat(path, dirname, filename);
+               if (symlink(path, filename) < 0)
+                       {
+                       pperror(filename);
+                       return(NO);
+                       }
+               }
+       return(YES);
+}
+
+
+
+/*
+ * hashtolist() converts the file entries stored in a hash table to a
+ * singly-linked list. Also removes dangling symbolic links, and complains
+ * about rogue links that are not in VPATH. Returns YES if successful,
+ * otherwise NO.
+ */
+static int
+hashtolist(table, list)
+       HASH *table;                    /* hash table */
+        SLIST *list;                   /* pointer to list head block */
+{
+        extern int MKSYMLINK;           /* clobber rogue links if > 1 */
+
+       htrewind(table);
+       while (htnext(table))
+               {
+               if (htval(table) == UNV_SYMLINK)
+                       {
+                       if (MKSYMLINK > 1 || !FILEXIST(htkey(table)))
+                               {
+                               if(unlink(htkey(table)) < 0)
+                                       {
+                                       warns("Failed to remove symbolic link %s", htkey(table));
+                                       }
+                               }
+                       else    {
+                               warns("%s linked to directory not in VPATH", htkey(table));
+                               if (slappend(htkey(table), list) == NULL)
+                                       return(NO);
+                               }
+                       }
+               else    {
+                       if (slappend(htkey(table), list) == NULL)
+                               return(NO);
+                       }
+               }
+       return(YES);
+}
+
+#else
+
+/*
+ * mksymlink() dummy routine always returns NO.
+ */
+mksymlink(needsrc, needhdr)
+       int needsrc;                    /* need source file names */
+       int needhdr;                    /* need header file names */
+{
+       warn("symbolic links not available");
+       return(NO);
+}
+
+#endif /* _HasSymLinks */
diff --git a/usr/src/contrib/mkmf/src/mustfopen.c b/usr/src/contrib/mkmf/src/mustfopen.c
new file mode 100644 (file)
index 0000000..58f64f7
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: mustfopen.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * mustfopen() opens a file in the manner of fopen(3). However, if the file
+ * cannot be accessed, exit(1) is called.
+ */
+#include <stdio.h>
+
+extern char *PGN;              /* program name */
+
+FILE *
+mustfopen(filename,mode)
+       char *filename;
+       char *mode;
+{
+       FILE *stream;                   /* file stream */
+
+       if ((stream = fopen(filename,mode)) == NULL)
+               {
+               if (*PGN != '\0')
+                       fprintf(stderr, "%s: ", PGN);
+               fprintf(stderr, "can't open %s\n",filename);
+               exit(1);
+               }
+       return(stream);
+}
diff --git a/usr/src/contrib/mkmf/src/null.h b/usr/src/contrib/mkmf/src/null.h
new file mode 100644 (file)
index 0000000..d30664a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: null.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * NULL constant definition
+ *
+ * Author: Peter J. Nicklin
+ */
+
+#define CNULL          (char *) 0
+#ifndef NULL
+#define NULL           0
+#endif
diff --git a/usr/src/contrib/mkmf/src/optpath.c b/usr/src/contrib/mkmf/src/optpath.c
new file mode 100644 (file)
index 0000000..fc3e2d3
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: optpath.c,v 4.4 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * optpath() condenses a pathname by eliminating adjacent separator
+ * characters, and current and parent directory names. If optpath()
+ * encounters a parent directory, it backtracks to eliminate the
+ * previous directory. If the beginning of the pathname is reached
+ * during backtracking, then if the pathname is absolute, the parent
+ * directory is purged, otherwise it is shifted to the beginning of
+ * pathname. Special care is taken not to clobber a shifted parent
+ * by using a guard pointer. Returns pathname.
+ *
+ * Note 1) For Apollo Domain/OS, adjacent separator characters are
+ * allowed as the first two characters of the path name. This correctly
+ * passes through paths containing nodenames. (eg. //nodename/myusr/include)
+ */
+#include "path.h"
+
+#define absolute_path  (*pathname == _RDIRC)
+
+char *
+optpath(pathname)
+       register char *pathname;        /* pathname to be optimized */
+{
+       register char *bp;              /* back pathname pointer */
+       register char *fp;              /* forward pathname pointer */
+       register char *up;              /* pathname update guard pointer */
+
+       bp = fp = up = pathname;
+
+       /* elimination of initial "./" causes no harmful side-effects */
+       if (fp[0] == _CDIRC && fp[1] == _PSC) fp += 2;
+#ifdef _HasNetRoot
+       else if (fp[0] == _PSC)
+               *bp++ = *fp++;  /* allow initial "//": see note 1 */
+#endif
+       while (*fp != '\0')
+               if (fp[0] == _PSC)
+                       if (fp[1] == _PSC || fp[1] == '\0')
+                               fp += 1;        /* "//" or trailing `/' */
+                       else if (fp[1]==_CDIRC && (fp[2]==_PSC || fp[2]=='\0'))
+                               fp += 2;        /* `.' */
+                       else    {
+                               *bp++ = *fp++;
+                               }
+               else    {
+                       *bp++ = *fp++;
+                       }
+       if (bp == pathname && *pathname != '\0')
+               *bp++ = (absolute_path) ? _RDIRC : _CDIRC;
+       *bp = '\0';
+       return(pathname);
+}
diff --git a/usr/src/contrib/mkmf/src/path.h b/usr/src/contrib/mkmf/src/path.h
new file mode 100644 (file)
index 0000000..24e62e3
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: path.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Pathname definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+#ifndef PATH_H
+#define PATH_H
+
+/*
+ * Buffer sizes
+ */
+#define ALIASSIZE      30              /* project directory alias size */
+#define TYPESIZE       30              /* project directory type label size */
+#define DIRDESCSIZE    128             /* project directory description size */
+#define P_BUFSIZE      1024            /* pathname buffer size */
+#define        PATHSIZE        1024            /* maximum pathname length */
+#define PPATHSIZE      256             /* maximum project pathname length */
+#define TYPBUFSIZE     256             /* directory type labels buffer */
+
+/* 
+ * Nomenclature (WARNING: Check definition usage BEFORE changing)
+ */
+#define _CDIRC         '.'             /* current directory character */
+#define _HDIRC         '~'             /* home directory character */
+#define _PDIRC         '^'             /* project root directory character */
+#define _PDTSC         '/'             /* project dir type labels sep char */
+#define _PPSC          '^'             /* project path separator character */
+#define _PSC           '/'             /* pathname separator character */
+#define _RDIRC         '/'             /* root directory character */
+#define CURDIR         "."             /* current directory */
+#define PARENTDIR      ".."            /* parent directory */
+#define PATHSEP                "/"             /* pathname separator */
+#define PPATHSEP       "^"             /* project pathname separator */
+#define ROOTDIR                "/"             /* root directory */
+#define ROOTPROJECT    "^"             /* root project */
+#define USERPROJECT    "~"             /* user's root project */
+
+/*
+ * Pathname types
+ */
+#define P_IFMT         0xf0000         /* project pathname mask */
+#define        P_IFNEW         0x00000         /* new directory or file */
+#define P_IFREG                0x10000         /* regular directory or file */
+#define        P_IFHOME        0x20000         /* root project root directory */
+#define P_IFPDIR       0x30000         /* project directory */
+#define        P_IFPROOT       0x40000         /* project root directory */
+
+/*
+ * Pathname struct
+ */
+typedef struct _path
+       {
+       unsigned long p_mode;           /* type of pathname */
+       char *p_alias;                  /* pathname alias */
+       char *p_path;                   /* pathname */
+       char *p_type;                   /* project directory type labels */
+       char *p_desc;                   /* project directory description */
+       char p_buf[P_BUFSIZE];          /* pathname buffer */
+       char p_project[PATHSIZE];       /* pathname's project */
+       } PATH;
+
+#endif /* PATH_H */
diff --git a/usr/src/contrib/mkmf/src/pathcat.c b/usr/src/contrib/mkmf/src/pathcat.c
new file mode 100644 (file)
index 0000000..c181ccc
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: pathcat.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pathcat() concatenates path components p1 and p2 into character buffer
+ * p1_p2. Returns p1_p2.
+ */
+#include <stdio.h>
+#include "path.h"
+
+extern char *PGN;                      /* program name */
+
+char *
+pathcat(p1_p2, p1, p2)
+       register char *p1;
+       register char *p2;
+       register char *p1_p2;
+{
+       register int plen;              /* maximum pathname length */
+       char *sp1_p2;                   /* start of p1_p2 */
+
+       sp1_p2 = p1_p2;
+       for (plen = PATHSIZE; plen > 0; plen--, p1_p2++, p1++)
+               if ((*p1_p2 = *p1) == '\0')
+                       break;
+       if (*p2 != '\0' && plen > 0)
+               {
+               if (p1_p2 != sp1_p2 && p1_p2[-1] != _PSC)
+                       {
+                       *p1_p2++ = _PSC;
+                       plen--;
+                       }
+               for (; plen > 0; plen--, p1_p2++, p2++)
+                       if ((*p1_p2 = *p2) == '\0')
+                               break;
+               }
+       if (plen == 0)
+               {
+               *--p1_p2 = '\0';
+               if (*PGN != '\0')
+                       fprintf(stderr, "%s: ", PGN);
+               fprintf(stderr, "pathname too long\n");
+               }
+       return(sp1_p2);
+}
diff --git a/usr/src/contrib/mkmf/src/pathhead.c b/usr/src/contrib/mkmf/src/pathhead.c
new file mode 100644 (file)
index 0000000..e871e55
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: pathhead.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pathhead() removes tail of pathname and returns pathname. The tail is
+ * defined as that part of the pathname after the last separator.
+ */
+#include "null.h"
+#include "path.h"
+
+char *
+pathhead(pathname)
+       register char *pathname;
+{
+       register char *ls;              /* last separator character */
+       register char *p;               /* pathname pointer */
+
+       ls = NULL;
+       for (p = pathname; *p != '\0'; p++)
+               if (*p == _PSC)
+                       ls = p;
+       if (ls != NULL) *ls = '\0';
+       return(pathname);
+}
diff --git a/usr/src/contrib/mkmf/src/pperror.c b/usr/src/contrib/mkmf/src/pperror.c
new file mode 100644 (file)
index 0000000..f5b4b83
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: pperror.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * pperror() writes a system error message to standard error output,
+ * preceded by the name of the program and message.
+ */
+#include <stdio.h>
+
+pperror(message)
+       char *message;                  /* error message */
+{
+       extern char *PGN;               /* program name */
+
+       if (message == NULL || *message == '\0')
+               {
+               perror(PGN);
+               }
+       else    {
+               fprintf(stderr, "%s: ", PGN);
+               perror(message);
+               }
+}
diff --git a/usr/src/contrib/mkmf/src/rule.c b/usr/src/contrib/mkmf/src/rule.c
new file mode 100644 (file)
index 0000000..191a633
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: rule.c,v 4.5 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include "Mkmf.h"
+#include "null.h"
+#include "rule.h"
+#include "slist.h"
+#include "stringx.h"
+#include "suffix.h"
+#include "yesno.h"
+
+static RULEBLK *Ruletab[RULETABSIZE];  /* rules table */
+static SLIST *Rulelist = NULL;         /* transformation rule list */
+
+/*
+ * applyrule() applies successive transformation rules to filename, and
+ * checks to see if the file exists. Returns YES if filename exists,
+ * otherwise NO.
+ */
+applyrule(target, source)
+       char *target;                   /* name of (transformed) file */
+       char *source;                   /* name of source file */
+{
+       register char *r;               /* rule pointer */
+       register char *s;               /* source buffer pointer */
+       char *sourcesuffix;             /* source file suffix */
+       char *rulesuffix;               /* target suffix in each rule */
+       char *targetsuffix;             /* transformed file suffix string */
+       int ruleindex;                  /* index into rule table */
+       RULEBLK *rblk;                  /* rule list block */
+
+       if ((targetsuffix = strrchr(target, '.')) == NULL)
+               return(NO);
+       ruleindex = targetsuffix[1];
+       if (Ruletab[ruleindex] != NULL)
+               {
+               strcpy(source, target);
+               sourcesuffix = strrchr(source, '.');
+               for (rblk=Ruletab[ruleindex]; rblk != NULL; rblk=rblk->r_next)
+                       {
+                       rulesuffix = strrchr(rblk->r_rule, '.');
+                       if (strcmp(rulesuffix, targetsuffix) == 0)
+                               {
+                               r = rblk->r_rule;
+                               s = sourcesuffix;
+                               while (*++s = *++r)
+                                       if (*s == '.')
+                                               {
+                                               *s = '\0';
+                                               break;
+                                               }
+                               if (FILEXIST(source))
+                                       return(YES);
+                               }
+                       }
+               }
+       return(NO);
+}
+
+
+
+/*
+ * buildruletable() converts a list of transformation rules into a hash table
+ * for fast lookup. Returns YES if successful, otherwise NO.
+ */
+buildruletable()
+{
+       extern char *DEFRULE[];         /* default preprocessor rules */
+       int i;                          /* default rule list counter */
+       int instalrule();               /* install rule in hash table */
+       SLBLK *rblk;                    /* singly-linked rulename block */
+
+       /* process default rules */
+       for (i = 0; DEFRULE[i] != NULL; i++)
+               {
+               if (instalrule(DEFRULE[i]) == NO)
+                       {
+                       nocore();
+                       return(NO);
+                       }
+               }
+
+       /* process rules found in makefile */
+       if (Rulelist != NULL)
+               {
+               for (rblk = Rulelist->head; rblk != NULL; rblk = rblk->next)
+                       {
+                       if (instalrule(rblk->key) == NO)
+                               {
+                               nocore();
+                               return(NO);
+                               }
+                       }
+               }
+       return(YES);
+}
+
+
+
+/*
+ * findrule() searchs a line for a transformation rule. Returns the
+ * name of the transformation rule, or NULL if not found.
+ */
+char *
+findrule(rulename, bp)
+       char *rulename;                 /* transformation rule buffer */
+       register char *bp;              /* I/O buffer pointer */
+{ 
+       register char *rp;              /* rule name pointer */
+       int dotcount = 0;               /* number of '.'s in rule */
+
+       for (rp = rulename; *bp != ':' && *bp != ' ' && *bp != '\t'; rp++, bp++)
+               {
+               if ((*rp = *bp) == '.')
+                       dotcount++;
+               }
+       *rp = '\0';
+
+       /* eat up white space between rule and ':' */
+       if (*bp != ':')
+               {
+               while (*bp == ' ' || *bp == '\t')
+                       bp++;
+               if (*bp != ':')
+                       return(NULL);
+               }
+
+       return((dotcount == 2) ? rulename : NULL);
+}
+
+
+
+/*
+ * instalrule() installs a source transformation rule in the rule lookup
+ * table. The rule table consists of a set of singly-linked lists, indexed
+ * by the first character of the suffix of the target file. The index of
+ * the target file is used by applyrule() to find out the name of the file
+ * from which it was derived. Returns YES if successful, otherwise NO.
+ */
+instalrule(rule)
+       char *rule;                     /* rule to be installed in Rule table */
+{
+       char *malloc();                 /* memory allocator */
+       char *strsav();                 /* save a string somewhere */
+       char *target;                   /* target suffix */
+       int lookupsfx();                /* get suffix type */
+       int ruleindex;                  /* index into rule table */
+       RULEBLK *rblk;                  /* rule list block */
+
+       target = strrchr(rule, '.') + 1;
+       if (lookupsfx(target) == SFXSRC)
+               {
+               ruleindex = target[0];
+               if ((rblk = (RULEBLK *) malloc(sizeof(RULEBLK))) == NULL)
+                       return(NO);
+               if ((rblk->r_rule = strsav(rule)) == NULL)
+                       return(NO);
+               rblk->r_next = Ruletab[ruleindex];
+               Ruletab[ruleindex] = rblk;
+               }
+       return(YES);
+}
+
+
+
+/*
+ * lookuprule() returns YES if rule exists, otherwise NO.
+ */
+lookuprule(rule)
+       char *rule;                     /* .x.y rule to find */
+{
+       char *targetsuffix;             /* transformed file suffix string */
+       int ruleindex;                  /* index into rule table */
+       RULEBLK *rblk;                  /* rule list block */
+
+       if ((targetsuffix = strrchr(rule, '.')) == NULL)
+               return(NO);
+       ruleindex = targetsuffix[1];
+       if (Ruletab[ruleindex] != NULL)
+               {
+               for (rblk=Ruletab[ruleindex]; rblk != NULL; rblk=rblk->r_next)
+                       {
+                       if (strcmp(rule, rblk->r_rule) == 0)
+                               return(YES);
+                       }
+               }
+       return(NO);
+}
+
+
+
+/*
+ * makerule() creates a rule from the suffixes of two file names.
+ */
+void
+makerule(rule, source, target)
+       char *rule;                     /* buffer to hold rule */
+       char *source;                   /* source file name */
+       char *target;                   /* target file name */
+{
+       strcpy(rule, strrchr(source, '.'));
+       strcat(rule, strrchr(target, '.'));
+}
+
+
+
+/*
+ * storerule() appends a transformation rule to the end of a singly-linked
+ * list. Returns integer NO if out of memory, otherwise YES.
+ */
+storerule(rulename)
+       char *rulename;                 /* transformation rule name */
+{
+       char *slappend();               /* append rule to list */
+       SLIST *slinit();                /* initialize transformation list */
+
+       if (Rulelist == NULL)
+               Rulelist = slinit();
+       if (slappend(rulename, Rulelist) == NULL)
+               return(NO);
+       return(YES);
+}
diff --git a/usr/src/contrib/mkmf/src/rule.h b/usr/src/contrib/mkmf/src/rule.h
new file mode 100644 (file)
index 0000000..aee1242
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: rule.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Rule definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Rule table block struct
+ */
+typedef struct _ruleblk
+       {
+       char *r_rule;                   /* pointer to rule string */
+       struct _ruleblk *r_next;        /* ptr to next rule list block */
+       } RULEBLK;
diff --git a/usr/src/contrib/mkmf/src/slappend.c b/usr/src/contrib/mkmf/src/slappend.c
new file mode 100644 (file)
index 0000000..b2202fa
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slappend.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slappend() saves a null-terminated key string somewhere and inserts a
+ * pointer to the key at the tail of list slist. Returns a pointer to
+ * the somewhere, or a null pointer if out of memory.
+ */
+#include <stdio.h>
+#include "macro.h"
+#include "null.h"
+#include "slist.h"
+#include "stringx.h"
+
+char *
+slappend(key, slist)
+       char *key;                      /* key string */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       SLBLK *slbptr;                  /* pointer to list block */
+       unsigned int klen;              /* key length */
+
+       if (slist == NULL)
+               return(NULL);
+       klen = strlen(key);
+       slist->maxkey = MAX(slist->maxkey, klen);
+       if ((slbptr = (SLBLK *) malloc(sizeof(SLBLK))) == NULL ||
+           (slbptr->key = malloc(klen+1)) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       strcpy(slbptr->key, key);
+       slbptr->next = NULL;
+       if (slist->tail == NULL)
+               slist->head = slist->tail = slbptr;
+       else
+               slist->tail = slist->tail->next = slbptr;
+       slist->nk++;
+       return(slbptr->key);
+}
diff --git a/usr/src/contrib/mkmf/src/slinit.c b/usr/src/contrib/mkmf/src/slinit.c
new file mode 100644 (file)
index 0000000..fe30f6d
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slinit.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slinit() returns a pointer to the head block of a new list, or null
+ * pointer if out of memory.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+SLIST *
+slinit()
+{
+       char *malloc();                 /* memory allocator */
+       SLIST *slist;                   /* pointer to list head block */
+
+       if ((slist = (SLIST *) malloc(sizeof(SLIST))) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       slist->nk = 0;
+       slist->maxkey = 0;
+       slist->head = slist->curblk = slist->tail = NULL;
+       return(slist);
+}
diff --git a/usr/src/contrib/mkmf/src/slist.h b/usr/src/contrib/mkmf/src/slist.h
new file mode 100644 (file)
index 0000000..52c6eaf
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slist.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Singly-linked list definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Singly-linked list macros
+ */
+#define SLNUM(slist)   (slist)->nk
+/*
+ * Singly-linked list block
+ */
+typedef struct slblk
+       {
+       char *key;                      /* points to a key */
+       struct slblk *next;             /* ptr to next list block */
+       } SLBLK;
+/*
+ * Singly-linked list head block
+ */
+typedef struct slisthb
+       {
+       int nk;                         /* number of keys in list */
+       int maxkey;                     /* length of longest key */
+       SLBLK *head;                    /* pointer to first list block */
+       SLBLK *curblk;                  /* pointer to current block */
+       SLBLK *tail;                    /* pointer to last list block */
+       } SLIST;
+/*
+ * Functions defined for singly-linked list operations
+ */
+extern char *slappend();               /* append key */
+extern SLIST *slinit();                        /* initialize list */
+extern void slrm();                    /* remove list item */
+extern int slsort();                   /* sort list */
+extern SLBLK **slvect();               /* make linked list vector */
+extern void slvtol();                  /* convert vector to linked list */
diff --git a/usr/src/contrib/mkmf/src/slrm.c b/usr/src/contrib/mkmf/src/slrm.c
new file mode 100644 (file)
index 0000000..8e7b6f9
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slrm.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slrm() removes a singly linked list.
+ */
+#include "null.h"
+#include "slist.h"
+
+void
+slrm(slist)
+       SLIST *slist;                   /* pointer to list head block */
+{
+       SLBLK *nxtblk;                  /* next list block */
+       while (slist->head != NULL)
+               {
+               nxtblk = slist->head->next;
+               free(slist->head->key);
+               free((char *) slist->head);
+               slist->head = nxtblk;
+               }
+       free((char *) slist);
+}
diff --git a/usr/src/contrib/mkmf/src/slsort.c b/usr/src/contrib/mkmf/src/slsort.c
new file mode 100644 (file)
index 0000000..a21bca2
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slsort.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * slsort() sorts list slist according to comparison function compar().
+ * compar() is to be called with two arguments and must return an integer
+ * greater than, equal to, or less than 0, depending on the lexicographic
+ * relationship between the two arguments. Returns integer YES if
+ * successful, otherwise NO if out of memory.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+#include "yesno.h"
+
+static int comparb();                  /* compare 2 list blocks */
+static int (*sscmp)();                 /* string compare function */
+
+slsort(compar, slist)
+       int (*compar)();                /* compare two strings */
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char **kp;                      /* pointer to key pointer array */
+       char *malloc();                 /* memory allocator */
+       char **skp;                     /* ptr to start of key ptr array */
+       SLBLK *curblk;                  /* current list block */
+
+       if (slist->nk <= 0)
+               return(YES);
+       else if ((skp = (char **) malloc((unsigned)slist->nk*sizeof(char *))) == NULL)
+               {
+               nocore();
+               return(NO);
+               }
+       for (kp = skp, curblk = slist->head; curblk != NULL; kp++, curblk = curblk->next)
+               *kp = curblk->key;
+
+       sscmp = compar;
+       qsort((char *) skp, slist->nk, sizeof(char *), comparb);
+
+       for (kp = skp, curblk = slist->head; curblk != NULL; kp++, curblk = curblk->next)
+               curblk->key = *kp;
+       
+       free((char *) skp);
+       return(YES);
+}
+
+
+
+/*
+ * comparb() compares key strings in 2 list blocks. Returns whatever
+ * sscmp() returns. sscmp() is a string compare function.
+ */
+static int
+comparb(s1, s2)
+       char **s1;                      /* string pointer */
+       char **s2;                      /* string pointer */
+{
+       return((*sscmp)(*s1, *s2));
+}
diff --git a/usr/src/contrib/mkmf/src/slvect.c b/usr/src/contrib/mkmf/src/slvect.c
new file mode 100644 (file)
index 0000000..0c92779
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slvect.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * slvect() converts a singly-linked list into a vector. Each item in
+ * the vector points to a list item. Returns a pointer to the vector,
+ * otherwise NULL if no items in list or out of memory.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+SLBLK **
+slvect(slist)
+       SLIST *slist;                   /* pointer to list head block */
+{
+       char *malloc();                 /* memory allocator */
+       SLBLK **vp;                     /* pointer to block pointer array */
+       SLBLK **svp;                    /* ptr to start of block ptr array */
+       SLBLK *cblk;                    /* current list block */
+
+       if (SLNUM(slist) <= 0)
+               return(NULL);
+       else if ((svp = (SLBLK **) malloc((unsigned)SLNUM(slist)*sizeof(SLBLK *))) == NULL)
+               {
+               nocore();
+               return(NULL);
+               }
+       for (vp=svp, cblk=slist->head; cblk != NULL; vp++, cblk=cblk->next)
+               {
+               *vp = cblk;
+               }
+       return(svp);
+}
diff --git a/usr/src/contrib/mkmf/src/slvtol.c b/usr/src/contrib/mkmf/src/slvtol.c
new file mode 100644 (file)
index 0000000..aa75e18
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: slvtol.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * slvtol() converts a vector back into a singly-linked list and deletes the
+ * vector. Each non-NULL item in the vector is added to the end of the list.
+ * The vector is assumed to be the same length as the original list.
+ */
+#include <stdio.h>
+#include "null.h"
+#include "slist.h"
+
+void
+slvtol(slist, slv)
+       SLIST *slist;                   /* pointer to list head block */
+       SLBLK **slv;                    /* ptr to singly-linked list vector */
+{
+       SLBLK *cblk;                    /* current list block */
+
+       int cbi;                        /* current block index */
+       int nk = 0;                     /* number of items in new list */
+       register SLBLK *cbp;            /* current block pointer */
+       
+       slist->head = slist->tail = NULL;
+
+       for (cbi=0; cbi < SLNUM(slist); cbi++)
+               {
+               cbp = slv[cbi];
+               if (cbp != NULL)
+                       {
+                       cbp->next = NULL;
+                       if (slist->tail == NULL)
+                               {
+                               slist->head = slist->tail = cbp;
+                               }
+                       else    {
+                               slist->tail = slist->tail->next = cbp;
+                               }
+                       nk++;
+                       }
+               }
+       slist->nk = nk;
+       free((char *) slv);
+}
diff --git a/usr/src/contrib/mkmf/src/stringx.h b/usr/src/contrib/mkmf/src/stringx.h
new file mode 100644 (file)
index 0000000..3559606
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: stringx.h,v 4.6 91/11/25 19:45:47 nicklin Exp $
+ *
+ * String definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+#ifndef STRINGX_H
+#define STRINGX_H
+
+#include "config.h"
+
+#ifdef _HasIncludeStrings
+#  include <strings.h>
+#else
+#  include <string.h>
+#endif
+
+#ifndef _HasStrDcl
+  int  strcmp();
+  int  strncmp();
+  char *strcat();
+  char *strcpy();
+  char *strchr();
+  char *strrchr();
+#endif /* _HasStrDcl */
+
+#ifndef _HasStrchr
+#  ifndef strchr
+#    define strchr     index
+#  endif
+#  ifndef strrchr
+#    define strrchr    rindex
+#  endif
+#endif
+
+#endif /* STRINGX_H */
diff --git a/usr/src/contrib/mkmf/src/strpcpy.c b/usr/src/contrib/mkmf/src/strpcpy.c
new file mode 100644 (file)
index 0000000..5f71a92
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: strpcpy.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * strpcpy() copies string s2 to s1 and returns a pointer to the
+ * next character after s1.
+ */
+char *
+strpcpy(s1, s2)
+       register char *s1;
+       register char *s2;
+{
+       while (*s1++ = *s2++)
+               continue;
+       return(--s1);
+}
diff --git a/usr/src/contrib/mkmf/src/strsav.c b/usr/src/contrib/mkmf/src/strsav.c
new file mode 100644 (file)
index 0000000..2c064f7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: strsav.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * strsav() saves a string somewhere and returns a pointer to the somewhere.
+ * Returns NULL on error.
+ */
+#include "null.h"
+#include "stringx.h"
+
+char *
+strsav(s)
+       char *s;
+{
+       char *sptr;                     /* somewhere string pointer */
+       char *malloc();                 /* memory allocator */
+
+       if ((sptr = malloc((unsigned)(strlen(s)+1))) == NULL)
+               return(NULL);
+       return(strcpy(sptr, s));
+}
diff --git a/usr/src/contrib/mkmf/src/suffix.c b/usr/src/contrib/mkmf/src/suffix.c
new file mode 100644 (file)
index 0000000..76f0d34
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: suffix.c,v 4.5 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include "Mkmf.h"
+#include "hash.h"
+#include "macro.h"
+#include "null.h"
+#include "stringx.h"
+#include "suffix.h"
+#include "yesno.h"
+
+static int SFX1[SFXTABSIZE];           /* single character suffixes */
+static int INC1[SFXTABSIZE];           /* include file types for 1 char sfx */
+static char *SPEC1[SFXTABSIZE];                /* include file specs for 1 char sfx */
+static SFXBLK *SFX2[SFXTABSIZE];       /* 2+ character suffixes */
+
+/*
+ * buildsfxtable() converts a suffix list into a hash table for fast lookup.
+ * Returns YES if successful, otherwise NO.
+ */
+buildsfxtable()
+{
+       extern HASH *MDEFTABLE;         /* macro definition table */
+       extern SUFFIX DEFSFX[];         /* default suffix list */
+       HASHBLK *htb;                   /* hash table block */
+       HASHBLK *htlookup();            /* find hash table entry */
+       int i;                          /* suffix list counter */
+       int installsfx();               /* install suffix in hash table */
+       int sfxbuftotable();            /* feed suffixes to installsfx() */
+
+       /* default suffix list */
+       for (i = 0; DEFSFX[i].suffix != NULL; i++)
+               if (installsfx(DEFSFX[i].suffix, DEFSFX[i].sfxtyp,
+                   DEFSFX[i].incspec) == NO)
+                       return(NO);
+       
+       /* supplementary suffix definitions */
+       if ((htb = htlookup(MSUFFIX, MDEFTABLE)) != NULL)
+               {
+               if (sfxbuftotable(htb->h_def) == NO)
+                       return(NO);
+               }
+       return(YES);
+}
+
+
+
+/*
+ * installsfx() installs a suffix in one of two suffix tables: SFX1 for
+ * one character suffixes, and SFX2 for two or more character suffixes.
+ * For a suffix that already exists, only its type and corresponding
+ * included file type is updated. Returns integer YES if successful,
+ * otherwise NO.
+ */
+installsfx(suffix, sfxtyp, incspec)
+       char *suffix;                   /* suffix string */
+       int sfxtyp;                     /* suffix type */
+       char *incspec;                  /* user spec for include file */
+{
+       char *malloc();                 /* memory allocator */
+       char *strsav();                 /* save a string somewhere */
+       int sfxindex;                   /* index into suffix tables */
+       int mapsuffixkey();             /* convert suffix spec to index key */ 
+       SFXBLK *sfxblk;                 /* suffix list block */
+
+       if (*suffix == '.')
+               suffix++;
+       sfxindex = suffix[0];
+       if (suffix[0] == '\0' || suffix[1] == '\0')
+               {
+               SFX1[sfxindex] = sfxtyp;        /* 0 or 1 character suffix */
+               INC1[sfxindex] = mapsuffixtokey(incspec);
+               }
+       else    {                               /* 2+ character suffix */
+               if ((sfxblk = (SFXBLK *) malloc(sizeof(SFXBLK))) == NULL)
+                       return(NO);
+               if ((sfxblk->sfx.suffix = strsav(suffix)) == NULL)
+                       return(NO);
+               sfxblk->sfx.sfxtyp = sfxtyp;
+               sfxblk->sfx.inctyp = mapsuffixtokey(incspec);
+               sfxblk->next = SFX2[sfxindex];
+               SFX2[sfxindex] = sfxblk;
+               }
+       return(YES);
+}
+
+
+
+/*
+ * mapsuffixtokey() translates a user-specified include file type string
+ * into an internal integer definition. Returns the integer definition.
+ */
+mapsuffixtokey(spec)
+       char *spec;                     /* user spec for include file */
+{
+       extern MAPINCLUDE INCKEY[];     /* default suffix list */
+
+       int i;                          /* INCKEY index */
+
+       if (spec == NULL)
+               return(INCLUDE_NONE);
+
+       for (i = 0; INCKEY[i].incspec != NULL; i++)
+               if (EQUAL(INCKEY[i].incspec, spec))
+                       break;
+       return(INCKEY[i].inctyp);
+}
+
+
+
+/*
+ * lookuptypeofinclude() returns the include file type for suffix, or 0 if
+ * unknown suffix.
+ */
+lookuptypeofinclude(suffix)
+       char *suffix;                   /* suffix string */
+{
+       SFXBLK *sfxblk;                 /* suffix block pointer */
+
+       if (suffix[0] == '\0' || suffix[1] == '\0')
+               return(INC1[*suffix]);          /* 0 or 1 char suffix */
+                                               /* 2+ character suffix */
+       for (sfxblk = SFX2[*suffix]; sfxblk != NULL; sfxblk = sfxblk->next)
+               if (EQUAL(suffix, sfxblk->sfx.suffix))
+                       return(sfxblk->sfx.inctyp);
+       return(0);
+}
+
+
+
+/*
+ * lookupsfx() returns the suffix type, or 0 if unknown suffix.
+ */
+lookupsfx(suffix)
+       char *suffix;                   /* suffix string */
+{
+       SFXBLK *sfxblk;                 /* suffix block pointer */
+
+       if (suffix[0] == '\0' || suffix[1] == '\0')
+               return(SFX1[*suffix]);          /* 0 or 1 char suffix */
+                                               /* 2+ character suffix */
+       for (sfxblk = SFX2[*suffix]; sfxblk != NULL; sfxblk = sfxblk->next)
+               if (EQUAL(suffix, sfxblk->sfx.suffix))
+                       return(sfxblk->sfx.sfxtyp);
+       return(0);
+}
+
+
+
+/*
+ * sfxbuftotable() parses a buffer containing suffixes and presents them
+ * to installsfx() for installation into the appropriate hash table.
+ * The suffix type may be altered by attaching a modifier :suffixtype.
+ *     :h      --> header file type
+ *     :o      --> object file type
+ *     :s      --> source file type (default)
+ *     :x      --> executable file type
+ *     :       --> unknown file type
+ * The include file type may be altered by attaching an additional
+ * modifier includetype.
+ *     C       --> C source code
+ *     C++     --> C++ source code
+ *     F       --> Fortran, Ratfor, Efl source code
+ *     P       --> Pascal source code
+ * If the suffix is object file type, the OBJSFX default object suffix
+ * is modified accordingly. Returns YES if successful, otherwise NO.
+ */
+sfxbuftotable(sfxbuf)
+       char *sfxbuf;                   /* buffer containing suffixes */
+{
+       extern char OBJSFX[];           /* object file name suffix */
+       char *gettoken();               /* get next token */
+       char *sfxtyp;                   /* suffix type */
+       char suffix[SUFFIXSIZE+2];      /* suffix + modifier */
+       int installsfx();               /* install suffix in hash table */
+
+       while ((sfxbuf = gettoken(suffix, sfxbuf)) != NULL)
+               if ((sfxtyp = strrchr(suffix, ':')) == NULL)
+                       {
+                       if (installsfx(suffix, SFXSRC, NULL) == NO)
+                               return(NO);
+                       }
+               else    {
+                       *sfxtyp = '\0';
+                       if (sfxtyp[1] == '\0')
+                               {
+                               if (installsfx(suffix, sfxtyp[1], NULL) == NO)
+                                       return(NO);
+                               }
+                       else
+                               {
+                               if (installsfx(suffix, sfxtyp[1], sfxtyp+2) == NO)
+                                       return(NO);
+                               }
+                       if (sfxtyp[1] == SFXOBJ)
+                               strcpy(OBJSFX, suffix);
+                       }
+       return(YES);
+}
diff --git a/usr/src/contrib/mkmf/src/suffix.h b/usr/src/contrib/mkmf/src/suffix.h
new file mode 100644 (file)
index 0000000..9cff7d7
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: suffix.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Suffix/include definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+#ifndef SUFFIX_H
+#define SUFFIX_H
+
+/*
+ * Suffix types 
+ */
+#define SFXHEAD                        'h'     /* header file name suffix */
+#define SFXOBJ                 'o'     /* object file name suffix */
+#define SFXOUT                 'x'     /* executable file name suffix */
+#define SFXSRC                 's'     /* source file name suffix */
+#define SFXNULL                        0       /* null suffix */
+
+/*
+ * Suffix/include table structs
+ */
+typedef struct _mapinclude
+       {
+       char *incspec;                  /* user spec for include files */
+       int inctyp;                     /* type of included file */
+       } MAPINCLUDE;
+
+typedef struct _suffix
+       {
+       char *suffix;                   /* points to a suffix */
+       int sfxtyp;                     /* type of file name suffix */
+       int inctyp;                     /* type of included file */
+       char *incspec;                  /* default included file user spec */
+       } SUFFIX;
+
+typedef struct _sfxblk
+       {
+       SUFFIX sfx;                     /* suffix struct */
+       struct _sfxblk *next;           /* ptr to next suffix list block */
+       } SFXBLK;
+
+#endif /* SUFFIX_H */
diff --git a/usr/src/contrib/mkmf/src/target.h b/usr/src/contrib/mkmf/src/target.h
new file mode 100644 (file)
index 0000000..fd6bc7d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: target.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Target definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * Target struct
+ */
+typedef struct _target
+       {
+       int type;                       /* prog, lib, or other target type */
+       int dest;                       /* target destination flag */
+       } TARGET;
diff --git a/usr/src/contrib/mkmf/src/true.h b/usr/src/contrib/mkmf/src/true.h
new file mode 100644 (file)
index 0000000..203790e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: true.h,v 4.3 91/11/25 19:45:47 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
diff --git a/usr/src/contrib/mkmf/src/usage.c b/usr/src/contrib/mkmf/src/usage.c
new file mode 100644 (file)
index 0000000..cd523e0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: usage.c,v 4.2 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+
+/*
+ * usage() places a usage error message on the standard error
+ * output stream stderr.
+ */
+#include <stdio.h>
+#include "null.h"
+
+extern char *PGN;                      /* program name */
+
+usage(m)
+       char *m;                        /* usage error message */
+{
+       fprintf(stderr, "usage: ");
+       if (PGN != NULL && *PGN != '\0')
+               fprintf(stderr, "%s ", PGN);
+       fprintf(stderr, "%s\n", m);
+}
diff --git a/usr/src/contrib/mkmf/src/warn.c b/usr/src/contrib/mkmf/src/warn.c
new file mode 100644 (file)
index 0000000..e8ae753
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: warn.c,v 4.3 91/11/25 19:44:59 nicklin Exp $
+ *
+ * Author: Peter J. Nicklin
+ */
+#include <stdio.h>
+#include "null.h"
+
+extern char *PGN;                      /* program name */
+
+/*
+ * warn() places an error message on the standard error output stream
+ * stderr.
+ */
+warn(m)
+       char *m;                        /* warning message */
+{
+       if (PGN != NULL && *PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       fprintf(stderr, "%s\n", m);
+}
+
+
+
+/*
+ * warns() places an error message and a string argument on the
+ * standard error output stream stderr.
+ */
+warns(m, s)
+       char *m;                        /* warning message */
+       char *s;                        /* string argument */
+{
+       if (PGN != NULL && *PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       fprintf(stderr, m, s);
+       fprintf(stderr, "\n");
+}
+
+
+
+/*
+ * warn2() places an error message and 2 string arguments on the
+ * standard error output stream stderr.
+ */
+warn2(m, s1, s2)
+       char *m;                        /* warning message */
+       char *s1;                       /* string argument */
+       char *s2;                       /* string argument */
+{
+       if (PGN != NULL && *PGN != '\0')
+               fprintf(stderr, "%s: ", PGN);
+       fprintf(stderr, m, s1, s2);
+       fprintf(stderr, "\n");
+}
diff --git a/usr/src/contrib/mkmf/src/yesno.h b/usr/src/contrib/mkmf/src/yesno.h
new file mode 100644 (file)
index 0000000..fdc606c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1983, 1985, 1991 Peter J. Nicklin.
+ * Copyright (c) 1991 Version Technology.
+ * All Rights Reserved.
+ *
+ * $License: VT.1.1 $
+ * Redistribution and use in source and binary forms,  with or without
+ * modification,  are permitted provided that the following conditions
+ * are met:  (1) Redistributions of source code must retain the  above
+ * copyright  notice,  this  list  of  conditions  and  the  following
+ * disclaimer.  (2) Redistributions in binary form must reproduce  the
+ * above  copyright notice,  this list of conditions and the following
+ * disclaimer in the  documentation  and/or other  materials  provided
+ * with  the  distribution.  (3) All advertising materials  mentioning
+ * features or  use  of  this  software  must  display  the  following
+ * acknowledgement:  ``This  product  includes  software  developed by
+ * Version Technology.''  Neither the name of Version  Technology  nor
+ * the  name  of  Peter J. Nicklin  may  be used to endorse or promote
+ * products derived from this software without specific prior  written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY VERSION TECHNOLOGY ``AS IS''  AND  ANY
+ * EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT LIMITED TO, THE
+ * IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL  VERSION  TECHNOLOGY  BE
+ * LIABLE  FOR ANY DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR  CONSEQUENTIAL DAMAGES   (INCLUDING,   BUT   NOT   LIMITED   TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR  TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE,  EVEN  IF  ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Report problems and direct questions to nicklin@netcom.com
+ *
+ * $Header: yesno.h,v 4.2 91/11/25 19:45:47 nicklin Exp $
+ *
+ * YES/NO constant definitions
+ *
+ * Author: Peter J. Nicklin
+ */
+
+#define YES 1
+#define NO  0