From bacchus.pa.dec.com!decwrl!uunet!allbery Fri Jul 27 18:54:36 PDT 1990 Article 1755 of comp.sources.misc: Path: bacchus.pa.dec.com!decwrl!uunet!allbery From: dvadura@watdragon.waterloo.edu (Dennis Vadura) Newsgroups: comp.sources.misc Subject: v14i030: dmake version 3.5 part 20/21 Message-ID: <98874@uunet.UU.NET> Date: 26 Jul 90 23:48:46 GMT Sender: allbery@uunet.UU.NET Lines: 1496 Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) Posting-number: Volume 14, Issue 30 Submitted-by: dvadura@watdragon.waterloo.edu (Dennis Vadura) Archive-name: dmake/part20 #!/bin/sh # this is part 20 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file common/dbug.c continued # CurArch=20 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 echo "x - Continuing file common/dbug.c" sed 's/^X//' << 'SHAR_EOF' >> common/dbug.c X while (*ctlp != EOS) { X start = ctlp; X while (*ctlp != EOS && *ctlp != ',') { X ctlp++; X } X if (*ctlp == ',') { X *ctlp++ = EOS; X } X new = (struct link *) DbugMalloc (sizeof (struct link)); X new -> string = StrDup (start); X new -> next_link = head; X head = new; X } X return (head); X} X X X/* X * FUNCTION X * X * InList test a given string for member of a given list X * X * SYNOPSIS X * X * LOCAL BOOLEAN InList (linkp, cp) X * struct link *linkp; X * char *cp; X * X * DESCRIPTION X * X * Tests the string pointed to by "cp" to determine if it is in X * the list pointed to by "linkp". Linkp points to the first X * link in the list. If linkp is NULL then the string is treated X * as if it is in the list (I.E all strings are in the null list). X * This may seem rather strange at first but leads to the desired X * operation if no list is given. The net effect is that all X * strings will be accepted when there is no list, and when there X * is a list, only those strings in the list will be accepted. X * X */ X XLOCAL BOOLEAN InList (linkp, cp) Xstruct link *linkp; Xchar *cp; X{ X REGISTER struct link *scan; X REGISTER BOOLEAN accept; X X if (linkp == NULL) { X accept = TRUE; X } else { X accept = FALSE; X for (scan = linkp; scan != NULL; scan = scan -> next_link) { X if (STREQ (scan -> string, cp)) { X accept = TRUE; X break; X } X } X } X return (accept); X} X X X/* X * FUNCTION X * X * PushState push current state onto stack and set up new one X * X * SYNOPSIS X * X * LOCAL VOID PushState () X * X * DESCRIPTION X * X * Pushes the current state on the state stack, and initializes X * a new state. The only parameter inherited from the previous X * state is the function nesting level. This action can be X * inhibited if desired, via the "r" flag. X * X * The state stack is a linked list of states, with the new X * state added at the head. This allows the stack to grow X * to the limits of memory if necessary. X * X */ X XLOCAL VOID PushState () X{ X REGISTER struct state *new; X X new = (struct state *) DbugMalloc (sizeof (struct state)); X new -> flags = 0; X new -> delay = 0; X new -> maxdepth = MAXDEPTH; X if (stack != NULL) { X new -> level = stack -> level; X } else { X new -> level = 0; X } X new -> out_file = stderr; X new -> functions = NULL; X new -> p_functions = NULL; X new -> keywords = NULL; X new -> processes = NULL; X new -> next_state = stack; X stack = new; X init_done = TRUE; X} X X X/* X * FUNCTION X * X * DoTrace check to see if tracing is current enabled X * X * SYNOPSIS X * X * LOCAL BOOLEAN DoTrace () X * X * DESCRIPTION X * X * Checks to see if tracing is enabled based on whether the X * user has specified tracing, the maximum trace depth has X * not yet been reached, the current function is selected, X * and the current process is selected. Returns TRUE if X * tracing is enabled, FALSE otherwise. X * X */ X XLOCAL BOOLEAN DoTrace () X{ X REGISTER BOOLEAN trace; X X trace = FALSE; X if (TRACING) { X if (stack -> level <= stack -> maxdepth) { X if (InList (stack -> functions, func)) { X if (InList (stack -> processes, _db_process_)) { X trace = TRUE; X } X } X } X } X return (trace); X} X X X/* X * FUNCTION X * X * DoProfile check to see if profiling is current enabled X * X * SYNOPSIS X * X * LOCAL BOOLEAN DoProfile () X * X * DESCRIPTION X * X * Checks to see if profiling is enabled based on whether the X * user has specified profiling, the maximum trace depth has X * not yet been reached, the current function is selected, X * and the current process is selected. Returns TRUE if X * profiling is enabled, FALSE otherwise. X * X */ X XLOCAL BOOLEAN DoProfile () X{ X REGISTER BOOLEAN profile; X X profile = FALSE; X if (PROFILING) { X if (stack -> level <= stack -> maxdepth) { X if (InList (stack -> p_functions, func)) { X if (InList (stack -> processes, _db_process_)) { X profile = TRUE; X } X } X } X } X return (profile); X} X X X/* X * FUNCTION X * X * _db_keyword_ test keyword for member of keyword list X * X * SYNOPSIS X * X * BOOLEAN _db_keyword_ (keyword) X * char *keyword; X * X * DESCRIPTION X * X * Test a keyword to determine if it is in the currently active X * keyword list. As with the function list, a keyword is accepted X * if the list is null, otherwise it must match one of the list X * members. When debugging is not on, no keywords are accepted. X * After the maximum trace level is exceeded, no keywords are X * accepted (this behavior subject to change). Additionally, X * the current function and process must be accepted based on X * their respective lists. X * X * Returns TRUE if keyword accepted, FALSE otherwise. X * X */ X XBOOLEAN _db_keyword_ (keyword) Xchar *keyword; X{ X REGISTER BOOLEAN accept; X X if (!init_done) { X _db_push_ (""); X } X accept = FALSE; X if (DEBUGGING) { X if (stack -> level <= stack -> maxdepth) { X if (InList (stack -> functions, func)) { X if (InList (stack -> keywords, keyword)) { X if (InList (stack -> processes, _db_process_)) { X accept = TRUE; X } X } X } X } X } X return (accept); X} X X X/* X * FUNCTION X * X * Indent indent a line to the given indentation level X * X * SYNOPSIS X * X * LOCAL VOID Indent (indent) X * int indent; X * X * DESCRIPTION X * X * Indent a line to the given level. Note that this is X * a simple minded but portable implementation. X * There are better ways. X * X * Also, the indent must be scaled by the compile time option X * of character positions per nesting level. X * X */ X XLOCAL VOID Indent (indent) Xint indent; X{ X REGISTER int count; X AUTO char buffer[PRINTBUF]; X X indent *= INDENT; X for (count = 0; (count < (indent - INDENT)) && (count < (PRINTBUF - 1)); count++) { X if ((count % INDENT) == 0) { X buffer[count] = '|'; X } else { X buffer[count] = ' '; X } X } X buffer[count] = EOS; X (VOID) fprintf (_db_fp_, buffer); X (VOID) fflush (_db_fp_); X} X X X/* X * FUNCTION X * X * FreeList free all memory associated with a linked list X * X * SYNOPSIS X * X * LOCAL VOID FreeList (linkp) X * struct link *linkp; X * X * DESCRIPTION X * X * Given pointer to the head of a linked list, frees all X * memory held by the list and the members of the list. X * X */ X XLOCAL VOID FreeList (linkp) Xstruct link *linkp; X{ X REGISTER struct link *old; X X while (linkp != NULL) { X old = linkp; X linkp = linkp -> next_link; X if (old -> string != NULL) { X free (old -> string); X } X free ((char *) old); X } X} X X X/* X * FUNCTION X * X * StrDup make a duplicate of a string in new memory X * X * SYNOPSIS X * X * LOCAL char *StrDup (string) X * char *string; X * X * DESCRIPTION X * X * Given pointer to a string, allocates sufficient memory to make X * a duplicate copy, and copies the string to the newly allocated X * memory. Failure to allocated sufficient memory is immediately X * fatal. X * X */ X X XLOCAL char *StrDup (string) Xchar *string; X{ X REGISTER char *new; X X new = DbugMalloc (strlen (string) + 1); X (VOID) strcpy (new, string); X return (new); X} X X X/* X * FUNCTION X * X * DoPrefix print debugger line prefix prior to indentation X * X * SYNOPSIS X * X * LOCAL VOID DoPrefix (_line_) X * int _line_; X * X * DESCRIPTION X * X * Print prefix common to all debugger output lines, prior to X * doing indentation if necessary. Print such information as X * current process name, current source file name and line number, X * and current function nesting depth. X * X */ X X XLOCAL VOID DoPrefix (_line_) Xint _line_; X{ X lineno++; X if (stack -> flags & NUMBER_ON) { X (VOID) fprintf (_db_fp_, "%5d: ", lineno); X } X if (stack -> flags & PROCESS_ON) { X (VOID) fprintf (_db_fp_, "%s: ", _db_process_); X } X if (stack -> flags & FILE_ON) { X (VOID) fprintf (_db_fp_, "%14s: ", file); X } X if (stack -> flags & LINE_ON) { X (VOID) fprintf (_db_fp_, "%5d: ", _line_); X } X if (stack -> flags & DEPTH_ON) { X (VOID) fprintf (_db_fp_, "%4d: ", stack -> level); X } X (VOID) fflush (_db_fp_); X} X X X/* X * FUNCTION X * X * OpenFile open new output stream for debugger output X * X * SYNOPSIS X * X * LOCAL VOID OpenFile (name) X * char *name; X * X * DESCRIPTION X * X * Given name of a new file (or "-" for stdout) opens the file X * and sets the output stream to the new file. X * X */ X XLOCAL VOID OpenFile (name) Xchar *name; X{ X REGISTER FILE *fp; X REGISTER BOOLEAN newfile; X X if (name != NULL) { X if (strcmp (name, "-") == 0) { X _db_fp_ = stdout; X stack -> out_file = _db_fp_; X } else { X if (!Writable (name)) { X (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); X perror (""); X (VOID) fflush (_db_fp_); X (VOID) XDelay (stack -> delay); X } else { X if (EXISTS (name)) { X newfile = FALSE; X } else { X newfile = TRUE; X } X fp = fopen (name, "a"); X if (fp == NULL) { X (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); X perror (""); X (VOID) fflush (_db_fp_); X (VOID) XDelay (stack -> delay); X } else { X _db_fp_ = fp; X stack -> out_file = fp; X if (newfile) { X ChangeOwner (name); X } X } X } X } X } X} X X X/* X * FUNCTION X * X * OpenProfile open new output stream for profiler output X * X * SYNOPSIS X * X * LOCAL VOID OpenProfile (name) X * char *name; X * X * DESCRIPTION X * X * Given name of a new file, opens the file X * and sets the profiler output stream to the new file. X * X * It is currently unclear whether the prefered behavior is X * to truncate any existing file, or simply append to it. X * The latter behavior would be desirable for collecting X * accumulated runtime history over a number of separate X * runs. It might take some changes to the analyzer program X * though, and the notes that Binayak sent with the profiling X * diffs indicated that append was the normal mode, but this X * does not appear to agree with the actual code. I haven't X * investigated at this time [fnf; 24-Jul-87]. X */ X XLOCAL VOID OpenProfile (name) Xchar *name; X{ X REGISTER FILE *fp; X REGISTER BOOLEAN newfile; X X if (name != NULL) { X if (!Writable (name)) { X (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); X perror (""); X (VOID) fflush (_db_fp_); X (VOID) XDelay (stack -> delay); X } else { X if (EXISTS (name)) { X newfile = FALSE; X } else { X newfile = TRUE; X } X fp = fopen (name, "w"); X if (fp == NULL) { X (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name); X perror (""); X (VOID) fflush (_db_fp_); X (VOID) XDelay (stack -> delay); X } else { X _db_pfp_ = fp; X stack -> prof_file = fp; X if (newfile) { X ChangeOwner (name); X } X } X } X } X} X X X/* X * FUNCTION X * X * CloseFile close the debug output stream X * X * SYNOPSIS X * X * LOCAL VOID CloseFile (fp) X * FILE *fp; X * X * DESCRIPTION X * X * Closes the debug output stream unless it is standard output X * or standard error. X * X */ X XLOCAL VOID CloseFile (fp) XFILE *fp; X{ X if (fp != stderr && fp != stdout) { X if (fclose (fp) == EOF) { X (VOID) fprintf (stderr, ERR_CLOSE, _db_process_); X perror (""); X (VOID) fflush (stderr); X (VOID) XDelay (stack -> delay); X } X } X} X X X/* X * FUNCTION X * X * DbugExit print error message and exit X * X * SYNOPSIS X * X * LOCAL VOID DbugExit (why) X * char *why; X * X * DESCRIPTION X * X * Prints error message using current process name, the reason for X * aborting (typically out of memory), and exits with status 1. X * This should probably be changed to use a status code X * defined in the user's debugger include file. X * X */ X XLOCAL VOID DbugExit (why) Xchar *why; X{ X (VOID) fprintf (stderr, ERR_ABORT, _db_process_, why); X (VOID) fflush (stderr); X (VOID) XDelay (stack -> delay); X exit (1); X} X X X/* X * FUNCTION X * X * DbugMalloc allocate memory for debugger runtime support X * X * SYNOPSIS X * X * LOCAL char *DbugMalloc (size) X * int size; X * X * DESCRIPTION X * X * Allocate more memory for debugger runtime support functions. X * Failure to to allocate the requested number of bytes is X * immediately fatal to the current process. This may be X * rather unfriendly behavior. It might be better to simply X * print a warning message, freeze the current debugger state, X * and continue execution. X * X */ X XLOCAL char *DbugMalloc (size) Xint size; X{ X register char *new; X X new = malloc ( size ); X if (new == NULL) { X DbugExit ("out of memory"); X } X return (new); X} X X X/* X * This function may be eliminated when strtok is available X * in the runtime environment (missing from BSD4.1). X */ X XLOCAL char *strtok (s1, s2) Xchar *s1, *s2; X{ X static char *end = NULL; X REGISTER char *rtnval; X X rtnval = NULL; X if (s2 != NULL) { X if (s1 != NULL) { X end = s1; X rtnval = strtok ((char *) NULL, s2); X } else if (end != NULL) { X if (*end != EOS) { X rtnval = end; X while (*end != *s2 && *end != EOS) {end++;} X if (*end != EOS) { X *end++ = EOS; X } X } X } X } X return (rtnval); X} X X X/* X * FUNCTION X * X * BaseName strip leading pathname components from name X * X * SYNOPSIS X * X * LOCAL char *BaseName (pathname) X * char *pathname; X * X * DESCRIPTION X * X * Given pointer to a complete pathname, locates the base file X * name at the end of the pathname and returns a pointer to X * it. X * X */ X XLOCAL char *BaseName (pathname) Xchar *pathname; X{ X register char *base; X X base = strrchr (pathname, '/'); X if (base++ == NULL) { X base = pathname; X } X return (base); X} X X X/* X * FUNCTION X * X * Writable test to see if a pathname is writable/creatable X * X * SYNOPSIS X * X * LOCAL BOOLEAN Writable (pathname) X * char *pathname; X * X * DESCRIPTION X * X * Because the debugger might be linked in with a program that X * runs with the set-uid-bit (suid) set, we have to be careful X * about opening a user named file for debug output. This consists X * of checking the file for write access with the real user id, X * or checking the directory where the file will be created. X * X * Returns TRUE if the user would normally be allowed write or X * create access to the named file. Returns FALSE otherwise. X * X */ X XLOCAL BOOLEAN Writable (pathname) Xchar *pathname; X{ X REGISTER BOOLEAN granted; X#ifdef unix X REGISTER char *lastslash; X#endif X X#ifndef unix X granted = TRUE; X#else X granted = FALSE; X if (EXISTS (pathname)) { X if (WRITABLE (pathname)) { X granted = TRUE; X } X } else { X lastslash = strrchr (pathname, '/'); X if (lastslash != NULL) { X *lastslash = EOS; X } else { X pathname = "."; X } X if (WRITABLE (pathname)) { X granted = TRUE; X } X if (lastslash != NULL) { X *lastslash = '/'; X } X } X#endif X return (granted); X} X X X/* X * This function may be eliminated when strrchr is available X * in the runtime environment (missing from BSD4.1). X * Alternately, you can use rindex() on BSD systems. X */ X XLOCAL char *strrchr (s, c) Xchar *s; Xchar c; X{ X REGISTER char *scan; X X for (scan = s; *scan != EOS; scan++) {;} X while (scan > s && *--scan != c) {;} X if (*scan != c) { X scan = NULL; X } X return (scan); X} X X X/* X * FUNCTION X * X * ChangeOwner change owner to real user for suid programs X * X * SYNOPSIS X * X * LOCAL VOID ChangeOwner (pathname) X * X * DESCRIPTION X * X * For unix systems, change the owner of the newly created debug X * file to the real owner. This is strictly for the benefit of X * programs that are running with the set-user-id bit set. X * X * Note that at this point, the fact that pathname represents X * a newly created file has already been established. If the X * program that the debugger is linked to is not running with X * the suid bit set, then this operation is redundant (but X * harmless). X * X */ X XLOCAL VOID ChangeOwner (pathname) Xchar *pathname; X{ X#ifdef unix X if (chown (pathname, getuid (), getgid ()) == -1) { X (VOID) fprintf (stderr, ERR_CHOWN, _db_process_, pathname); X perror (""); X (VOID) fflush (stderr); X (VOID) XDelay (stack -> delay); X } X#endif X} X X X/* X * FUNCTION X * X * _db_setjmp_ save debugger environment X * X * SYNOPSIS X * X * VOID _db_setjmp_ () X * X * DESCRIPTION X * X * Invoked as part of the user's DBUG_SETJMP macro to save X * the debugger environment in parallel with saving the user's X * environment. X * X */ X XVOID _db_setjmp_ () X{ X jmplevel = stack -> level; X jmpfunc = func; X jmpfile = file; X} X X X/* X * FUNCTION X * X * _db_longjmp_ restore previously saved debugger environment X * X * SYNOPSIS X * X * VOID _db_longjmp_ () X * X * DESCRIPTION X * X * Invoked as part of the user's DBUG_LONGJMP macro to restore X * the debugger environment in parallel with restoring the user's X * previously saved environment. X * X */ X XVOID _db_longjmp_ () X{ X stack -> level = jmplevel; X if (jmpfunc) { X func = jmpfunc; X } X if (jmpfile) { X file = jmpfile; X } X} X X X/* X * FUNCTION X * X * DelayArg convert D flag argument to appropriate value X * X * SYNOPSIS X * X * LOCAL int DelayArg (value) X * int value; X * X * DESCRIPTION X * X * Converts delay argument, given in tenths of a second, to the X * appropriate numerical argument used by the system to delay X * that that many tenths of a second. For example, on the X * AMIGA, there is a system call "Delay()" which takes an X * argument in ticks (50 per second). On unix, the sleep X * command takes seconds. Thus a value of "10", for one X * second of delay, gets converted to 50 on the amiga, and 1 X * on unix. Other systems will need to use a timing loop. X * X */ X XLOCAL int DelayArg (value) Xint value; X{ X int delayarg = 0; X X#ifdef unix X delayarg = value / 10; /* Delay is in seconds for sleep () */ X#endif X#ifdef AMIGA X delayarg = (HZ * value) / 10; /* Delay in ticks for XDelay () */ X#endif X return (delayarg); X} X X X/* X * A dummy delay stub for systems that do not support delays. X * With a little work, this can be turned into a timing loop. X */ X X#ifndef unix X#ifndef AMIGA XXDelay () X{ X} X#endif X#endif X X X/* X * FUNCTION X * X * perror perror simulation for systems that don't have it X * X * SYNOPSIS X * X * LOCAL VOID perror (s) X * char *s; X * X * DESCRIPTION X * X * Perror produces a message on the standard error stream which X * provides more information about the library or system error X * just encountered. The argument string s is printed, followed X * by a ':', a blank, and then a message and a newline. X * X * An undocumented feature of the unix perror is that if the string X * 's' is a null string (NOT a NULL pointer!), then the ':' and X * blank are not printed. X * X * This version just complains about an "unknown system error". X * X */ X X#if !unix && !(AMIGA && LATTICE) XLOCAL VOID perror (s) X#ifdef __STDC__ Xconst char *s; X#else Xchar *s; X#endif X{ X if (s && *s != EOS) { X (VOID) fprintf (stderr, "%s: ", s); X } X (VOID) fprintf (stderr, "\n"); X} X#endif /* !unix && !(AMIGA && LATTICE) */ X X/* X * Here we need the definitions of the clock routine. Add your X * own for whatever system that you have. X */ X X#if unix X X# include X# if BSD4_3 || sun X X/* X * Definition of the Clock() routine for 4.3 BSD. X */ X X#include X#include X X/* X * Returns the user time in milliseconds used by this process so X * far. X */ X XLOCAL unsigned long Clock () X{ X struct rusage ru; X X (VOID) getrusage (RUSAGE_SELF, &ru); X return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000)); X} X X#else X XLOCAL unsigned long Clock () X{ X return (0); X} X X# endif X X#else X X#if AMIGA X Xstruct DateStamp { /* Yes, this is a hack, but doing it right */ X long ds_Days; /* is incredibly ugly without splitting this */ X long ds_Minute; /* off into a separate file */ X long ds_Tick; X}; X Xstatic int first_clock = TRUE; Xstatic struct DateStamp begin; Xstatic struct DateStamp elapsed; X XLOCAL unsigned long Clock () X{ X register struct DateStamp *now; X register unsigned long millisec = 0; X extern VOID *AllocMem (); X X now = (struct DateStamp *) AllocMem ((long) sizeof (struct DateStamp), 0L); X if (now != NULL) { X if (first_clock == TRUE) { X first_clock = FALSE; X (VOID) DateStamp (now); X begin = *now; X } X (VOID) DateStamp (now); X millisec = 24 * 3600 * (1000 / HZ) * (now -> ds_Days - begin.ds_Days); X millisec += 60 * (1000 / HZ) * (now -> ds_Minute - begin.ds_Minute); X millisec += (1000 / HZ) * (now -> ds_Tick - begin.ds_Tick); X (VOID) FreeMem (now, (long) sizeof (struct DateStamp)); X } X return (millisec); X} X X#else X XLOCAL unsigned long Clock () X{ X return (0); X} X X#endif /* AMIGA */ X X#endif /* unix */ X X#ifdef AMIGA XXDelay(x) Xint x; X{ X if (x) Delay(x); /* fix Delay bug in AmigaDOS */ X} X#endif X SHAR_EOF echo "File common/dbug.c is complete" chmod 0440 common/dbug.c || echo "restore of common/dbug.c fails" echo "x - extracting common/db.h (Text)" sed 's/^X//' << 'SHAR_EOF' > common/db.h && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/common/RCS/db.h,v 1.1 90/07/19 13:30:43 dvadura Exp $ X-- SYNOPSIS -- front end to DBUG macros. X-- X-- DESCRIPTION X-- This is a front end to Fred Fish's DBUG macros. The intent was X-- to provide an interface so that if you don't have the DBUG code X-- you can still compile dmake, by undefining DBUG, if you do have X-- the code then you can use Fred Fish's DBUG package. Originally X-- the DBUG stuff was copyrighted, it is now in the public domain X-- so the need for this is not as apparent. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: db.h,v $ X * Revision 1.1 90/07/19 13:30:43 dvadura X * Initial Revision of Version 3.5 X * X*/ X X#ifndef DB_h X#define DB_h X X#ifdef DBUG X X# include X# include X X# define DB_ENTER(a1) DBUG_ENTER(a1) X# define DB_RETURN(a1) DBUG_RETURN(a1) X# define DB_VOID_RETURN DBUG_VOID_RETURN X# define DB_EXECUTE(keyword, a1) DBUG_EXECUTE(keyword,a1) X# define DB_PRINT(keyword,arglist) DBUG_PRINT(keyword,arglist) X# define DB_PUSH(a1) DBUG_PUSH(a1) X# define DB_POP() DBUG_POP() X# define DB_PROCESS(a1) DBUG_PROCESS(a1) X# define DB_FILE (stderr) DBUG_FILE(stderr) X# define DB_SETJMP DBUG_SETJMP X# define DB_LONGJMP DBUG_LONGJMP X X#else X X# define DB_ENTER(a1) X# define DB_RETURN(a1) return (a1) X# define DB_VOID_RETURN return X# define DB_EXECUTE(keyword, a1) X# define DB_PRINT(keyword,arglist) X# define DB_PUSH(a1) X# define DB_POP() X# define DB_PROCESS(a1) X# define DB_FILE(stderr) X# define DB_SETJMP setjmp X# define DB_LONGJMP longjmp X X#endif X#endif X SHAR_EOF chmod 0440 common/db.h || echo "restore of common/db.h fails" echo "x - extracting common/alloc.h (Text)" sed 's/^X//' << 'SHAR_EOF' > common/alloc.h && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/common/RCS/alloc.h,v 1.1 90/07/19 13:30:39 dvadura Exp $ X-- SYNOPSIS -- macros for allocating memory. X-- X-- DESCRIPTION X-- A somewhat nicer interface to malloc and calloc. X-- Here we standardise the calling convention with a common macro X-- interface. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: alloc.h,v $ X * Revision 1.1 90/07/19 13:30:39 dvadura X * Initial Revision of Version 3.5 X * X*/ X X#ifndef ALLOC_h X#define ALLOC_h X X/* DO NOT CHANGE these! These are the definitions that the make source X * uses for allocating memory. They must be defined for make to compile X * properly. X */ X X#ifndef _TYPES_ Xtypedef long size_t; X#endif X X#define usizeof(t) (size_t)sizeof(t) X X#ifdef DBUG X#define FREE(p) My_free((char*)(p), __FILE__, __LINE__) X#define MALLOC(n, t) (t*) My_malloc((n)*usizeof(t), __FILE__, __LINE__) X#define CALLOC(n, t) (t*) My_calloc((n), usizeof(t), __FILE__, __LINE__) X#else X#define FREE(p) free((char*)(p)) X#define MALLOC(n, t) (t*) malloc((unsigned int)(n)*usizeof(t)) X#define CALLOC(n, t) (t*) calloc((unsigned int)(n), usizeof(t)) X#endif X X#define TALLOC(p, n, t) if ((p = CALLOC(n, t)) == (t*)0) {No_ram();} X X#endif X SHAR_EOF chmod 0440 common/alloc.h || echo "restore of common/alloc.h fails" echo "x - extracting basename.c (Text)" sed 's/^X//' << 'SHAR_EOF' > basename.c && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/basename.c,v 1.1 90/07/19 13:53:01 dvadura Exp $ X-- SYNOPSIS -- return pointer to last pathname component X-- X-- DESCRIPTION X-- take a file name like /fred/foo/hoe/mary.k, and return the 'mary.k' X-- portion X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: basename.c,v $ X * Revision 1.1 90/07/19 13:53:01 dvadura X * Initial Revision of Version 3.5 X * X*/ X X#include X#include "extern.h" X Xchar* Xbasename( path ) Xchar *path; X{ X char *p; X char *q; X X if( *(q = path) ) { X for(; *(p=_strpbrk(q, DirBrkStr)) != '\0'; q = p+1 ); X if( !*q ) { X for( p=q-1; p != path; --p ) X if( strchr( DirBrkStr, *p ) == NIL(char) ) return( p+1 ); X return( strchr(DirBrkStr, *p)?path:(p+1) ); X } X path = q; X } X return( path ); X} SHAR_EOF chmod 0440 basename.c || echo "restore of basename.c fails" echo "x - extracting _updctl (Text)" sed 's/^X//' << 'SHAR_EOF' > _updctl && SHAR_EOF chmod 0640 _updctl || echo "restore of _updctl fails" echo "x - extracting _todo (Text)" sed 's/^X//' << 'SHAR_EOF' > _todo && X- Finish and test the unix dmaked remote daemon, and allow remote makes to X span NFS'ed file systems. X X- See if I can find spawnvp.c source someplace so I can hack the environment X to better support the MKS argument passing convention in the DOS version. SHAR_EOF chmod 0640 _todo || echo "restore of _todo fails" echo "x - extracting _readme (Text)" sed 's/^X//' << 'SHAR_EOF' > _readme && XThis is the first distribution of dmake version 3.5. dmake is a Xmake like tool that has been written by me and has been used by individuals at Xthe University of Waterloo for about a year and a half now. I feel it has Xmatured enough to be made available on a wider scale. X Xdmake is available for anonymous ftp from watmsg.uwaterloo.ca address is X129.97.129.9. It is in the pub/src directory, set your mode to binary, Xand copy either: X X dmake-3.5.tar.Z - compressed tar format X dmake-3.5.zoo - zoo archive X Xdmake is different from other versions of make in that it supports significant Xenhancements (See the man page). A short summary of the more important Xones follows: X X . support for portable makefiles X . runs on many platforms (DOS, generic unix [sysv and bsd4.3], X apollo, and others) X . significantly enhanced macro facilities X . transitive closure on inference graph X . sofisticated inference algorithm X . support for traversing the file sytem both during making of targets X and during inference X . %-meta rules for specifying rules to be used for inferring X prerequisites X . highly configurable X . support for libraries X . parallel making of targets on architectures that support it X . attributed targets X . text diversions X XAll code found in this distribution is original and writen by me except where Xnoted in the source and the following: X X- dbug package from Fred Fish (dmake DEBUG=1, to make a debugging version X of dmake) X X- malloc.c package, came from the net originally, author name wasn't X on it when I found it, I can't even remember where I got it. X X-dennis SHAR_EOF chmod 0640 _readme || echo "restore of _readme fails" echo "x - extracting _readme.dos (Text)" sed 's/^X//' << 'SHAR_EOF' > _readme.dos && XSome notes on the MSDOS implementation of dmake. X Xdmake does not care if you are running command.com or some other command Xinterpretter, you must however specify the proper values of the environment Xvariables SHELL, SHELLFLAGS, GROUPSHELL, and GROUPFLAGS in order for things Xto work correctly. Read the man page first. X XGroup recipes under DOS require you to set the GROUPSUFFIX macro. X XAs shipped the startup.mk files for the DOS version try to figure out what Xcommand interpretter you are using and set things up appropriately. XTwo command interpretters are supported in the shipped startup.mk file, Xcommand.com, and the MKS Korn shell. X Xdmake does not contain any builtin commands. It gets all commands it executes Xfrom an external environment. It is therefore most useful if it is used in Xconjunction with an environment such as is provided by the the MKS Tool kit, Xor equivalent. X XIf running under the MKS toolkit, dmake does not currently support their Xextended length argument passing conventions. I need a working version of Xspawnvp source in order to modify it so that it puts the right magic cookies Xin the right places so that an invoked MKS command knows to look into the Xenvironment for its command line arguments rather than in the DOS command Xtail. SHAR_EOF chmod 0640 _readme.dos || echo "restore of _readme.dos fails" echo "x - extracting _install (Text)" sed 's/^X//' << 'SHAR_EOF' > _install && XINSTALLATION INSTRUCTIONS X XThis file contains the instructions required to install and create the Xappropriate version of dmake. X X XMAKING THE PROPER VERSION X XIn order to use dmake you must first make the correct version. As shipped Xthere exist several versions that you can make: X X bsd43uw - Generic BSD 4.3 at U of Waterloo X bsd43 - Generic BSD 4.3 (eg, true BSD, apollo, sun OS4, SGI etc) X sysvr3 - Generic SysV R3 UNIX (NCR tower, ....etc) X tccdos - DOS with tcc 2.0 X dynix - Sequent symmetry dynix X mscdos - DOS with MSC 4.0 or > not tested X 386ix - 386/ix (SysV R3), not tested X XThe source code is organized as follows: X X dmake [source for all common functions] X | X | X ----------- X | | X unix msdos [source for OS specific functions] X | | X ---------------------- ------------- X | | | | | X386ix bsd43 sysvr3 tccdos mscdos [source for OSRELEASE specific X | functions] X -------- X | | X uw dynix X X XEach of the directories (eg. bsd43, mscdos, tccdos, and sysvr3) contain source Xthat is specific to that release of the OS (and possibly C-library) XTo make the apropriate versions of dmake, simply type the command X X 'make system' X Xwhere system is one of the supplied possibilities. For a complete list Xof the versions you can make, see the comments in the file 'makefile'. X XThe bootstrapping of dmake is accomplished by running a shell script with the Xappropriate compile commands hard coded. X X(NOTE: If you are using MSDOS then, you will actually be using the make.bat X scriptfile to make the correct version of dmake for MSDOS. If you X are running a SHELL other than command.com, you may have to perform X some extra work to invoke the batch file.) X XThe making of dmake, echoes the commands being executed, and should proceed Xrelatively error free. Ignore any warnings that concerned unused arguments Xto functions, these are normal in some configurations (esp the MSDOS) Xconfiguration. X X XSTARTUP FILE X Xdmake requires the loading of a startup file when it is first invoked. The Xpath for the startup file is set in the file 'startup.h' found in the unix Xand msdos directories. You may override the value of the path variable Xcompiled-in by creating a file at the root source directory called startup.h Xand inserting into that file a definition that is like the definition found Xin the supplied startup.h files. X X XINSTALLATION X XTo install dmake you must copy the executable to where your system Xlocates executables, and you must place a copy of startup.mk (found in the Xdirectory corresponding to the version you just made) into a location Xcorresponding to the value of the MAKESTARTUP macro or environment variable. XYou are free to customize the contents of startup.mk. X XTo make dmake again, (using itself), you will have to set three environment Xvariables. See the file makefile.mk for their names and their legal values. XOnce set you can invoke dmake to make itself. X X XDOCUMENTATION X XAll documentation for dmake appears under the man directory. XThe file dmake.tf included in this distribution contains the troff Xsource for the man page. You must typeset it using the -man macros. XIf you cannot typeset it, the file dmake.p is a version that has been Xtypeset for a normal dumb terminal. The file dmake.p contains control Xcharacters. The file dmake.nc is a version of the man page that has Xall of the control characters stripped. X X XCREATING A NEW VERSION X XTo create yet another version of dmake you should follow the following steps. X XThe sysvr3 version as sent is the base version, all dmake versions must provide Xthe equivalent of the functions defined in the sysvr3 directory, and MUST Xprovide the same semantics (MSDOS archive lib searches are an exception since Xwe cannot search libraries for timestamps in MSDOS, Actually the MKS version Xof dmake does this, I don't have the time to add this code though). X eg. vms for VMS, or amiga for AMIGA. X X2. copy the files from unix and sysvr3 directories to the new dir. X X3. modify dmake.sh to contain the appropriate C compiler flags and link command X and to include any specific C files that you have had to add for this X version of dmake, and run the result through the shell. X (Also make the changes to config.mk once you have a working copy of X dmake) X X4. Not all OS/OSRELEASE combinations are compatible so in order to make X dmake on each, the particular directory may contain C-source for functions X present in the SVID SysV R3 distribution which are used by dmake but are X not supplied by the C-library in current use. For example the bsd43 X directory contains source for tempnam.c since it is not provided with X the BSD C-library. Before writing a new version of the source file X check the other directories to see if one already exists. X X5. Under some systems the standard include files may be missing or incorrect. X eg. under BSD stdarg.h and string.h. If this is the case X you should create the proper .h file in the proper directory. X This works as expected as the compile line includes the flag -Idir X where dir is the configuration dir, (bsd43 for example) and any X standard include files will be searched for in dir before the compiler X looks in the normal places. X X6. This should be all you require to create a new version of dmake. X If you have any questions send e-mail to dvadura@watdragon.uwaterloo.ca SHAR_EOF chmod 0640 _install || echo "restore of _install fails" echo "x - extracting LICENSE (Text)" sed 's/^X//' << 'SHAR_EOF' > LICENSE && X GNU GENERAL PUBLIC LICENSE X Version 1, February 1989 X X Copyright (C) 1989 Free Software Foundation, Inc. X 675 Mass Ave, Cambridge, MA 02139, USA X Everyone is permitted to copy and distribute verbatim copies X of this license document, but changing it is not allowed. X X Preamble X X The license agreements of most software companies try to keep users Xat the mercy of those companies. By contrast, our General Public XLicense is intended to guarantee your freedom to share and change free Xsoftware--to make sure the software is free for all its users. The XGeneral Public License applies to the Free Software Foundation's Xsoftware and to any other program whose authors commit to using it. XYou can use it for your programs, too. X X When we speak of free software, we are referring to freedom, not Xprice. Specifically, the General Public License is designed to make Xsure that you have the freedom to give away or sell copies of free Xsoftware, that you receive source code or can get it if you want it, SHAR_EOF echo "End of part 20" echo "File LICENSE is continued in part 21" echo "21" > s2_seq_.tmp exit 0