home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / dmake / part20 < prev    next >
Encoding:
Text File  |  1990-07-26  |  39.5 KB  |  1,502 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v14i030: dmake version 3.5 part 20/21
  3. From: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 14, Issue 30
  7. Submitted-by: dvadura@watdragon.waterloo.edu (Dennis Vadura)
  8. Archive-name: dmake/part20
  9.  
  10. #!/bin/sh
  11. # this is part 20 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file common/dbug.c continued
  14. #
  15. CurArch=20
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file common/dbug.c"
  26. sed 's/^X//' << 'SHAR_EOF' >> common/dbug.c
  27. X    while (*ctlp != EOS) {
  28. X    start = ctlp;
  29. X    while (*ctlp != EOS && *ctlp != ',') {
  30. X        ctlp++;
  31. X    }
  32. X    if (*ctlp == ',') {
  33. X        *ctlp++ = EOS;
  34. X    }
  35. X    new = (struct link *) DbugMalloc (sizeof (struct link));
  36. X    new -> string = StrDup (start);
  37. X    new -> next_link = head;
  38. X    head = new;
  39. X    }
  40. X    return (head);
  41. X}
  42. X
  43. X
  44. X/*
  45. X *  FUNCTION
  46. X *
  47. X *    InList    test a given string for member of a given list
  48. X *
  49. X *  SYNOPSIS
  50. X *
  51. X *    LOCAL BOOLEAN InList (linkp, cp)
  52. X *    struct link *linkp;
  53. X *    char *cp;
  54. X *
  55. X *  DESCRIPTION
  56. X *
  57. X *    Tests the string pointed to by "cp" to determine if it is in
  58. X *    the list pointed to by "linkp".  Linkp points to the first
  59. X *    link in the list.  If linkp is NULL then the string is treated
  60. X *    as if it is in the list (I.E all strings are in the null list).
  61. X *    This may seem rather strange at first but leads to the desired
  62. X *    operation if no list is given.  The net effect is that all
  63. X *    strings will be accepted when there is no list, and when there
  64. X *    is a list, only those strings in the list will be accepted.
  65. X *
  66. X */
  67. X
  68. XLOCAL BOOLEAN InList (linkp, cp)
  69. Xstruct link *linkp;
  70. Xchar *cp;
  71. X{
  72. X    REGISTER struct link *scan;
  73. X    REGISTER BOOLEAN accept;
  74. X
  75. X    if (linkp == NULL) {
  76. X    accept = TRUE;
  77. X    } else {
  78. X    accept = FALSE;
  79. X    for (scan = linkp; scan != NULL; scan = scan -> next_link) {
  80. X        if (STREQ (scan -> string, cp)) {
  81. X        accept = TRUE;
  82. X        break;
  83. X        }
  84. X    }
  85. X    }
  86. X    return (accept);
  87. X}
  88. X
  89. X
  90. X/*
  91. X *  FUNCTION
  92. X *
  93. X *    PushState    push current state onto stack and set up new one
  94. X *
  95. X *  SYNOPSIS
  96. X *
  97. X *    LOCAL VOID PushState ()
  98. X *
  99. X *  DESCRIPTION
  100. X *
  101. X *    Pushes the current state on the state stack, and initializes
  102. X *    a new state.  The only parameter inherited from the previous
  103. X *    state is the function nesting level.  This action can be
  104. X *    inhibited if desired, via the "r" flag.
  105. X *
  106. X *    The state stack is a linked list of states, with the new
  107. X *    state added at the head.  This allows the stack to grow
  108. X *    to the limits of memory if necessary.
  109. X *
  110. X */
  111. X
  112. XLOCAL VOID PushState ()
  113. X{
  114. X    REGISTER struct state *new;
  115. X
  116. X    new = (struct state *) DbugMalloc (sizeof (struct state));
  117. X    new -> flags = 0;
  118. X    new -> delay = 0;
  119. X    new -> maxdepth = MAXDEPTH;
  120. X    if (stack != NULL) {
  121. X    new -> level = stack -> level;
  122. X    } else {
  123. X    new -> level = 0;
  124. X    }
  125. X    new -> out_file = stderr;
  126. X    new -> functions = NULL;
  127. X    new -> p_functions = NULL;
  128. X    new -> keywords = NULL;
  129. X    new -> processes = NULL;
  130. X    new -> next_state = stack;
  131. X    stack = new;
  132. X    init_done = TRUE;
  133. X}
  134. X
  135. X
  136. X/*
  137. X *  FUNCTION
  138. X *
  139. X *    DoTrace    check to see if tracing is current enabled
  140. X *
  141. X *  SYNOPSIS
  142. X *
  143. X *    LOCAL BOOLEAN DoTrace ()
  144. X *
  145. X *  DESCRIPTION
  146. X *
  147. X *    Checks to see if tracing is enabled based on whether the
  148. X *    user has specified tracing, the maximum trace depth has
  149. X *    not yet been reached, the current function is selected,
  150. X *    and the current process is selected.  Returns TRUE if
  151. X *    tracing is enabled, FALSE otherwise.
  152. X *
  153. X */
  154. X
  155. XLOCAL BOOLEAN DoTrace ()
  156. X{
  157. X    REGISTER BOOLEAN trace;
  158. X
  159. X    trace = FALSE;
  160. X    if (TRACING) {
  161. X    if (stack -> level <= stack -> maxdepth) {
  162. X        if (InList (stack -> functions, func)) {
  163. X        if (InList (stack -> processes, _db_process_)) {
  164. X            trace = TRUE;
  165. X        }
  166. X        }
  167. X    }
  168. X    }
  169. X    return (trace);
  170. X}
  171. X
  172. X
  173. X/*
  174. X *  FUNCTION
  175. X *
  176. X *    DoProfile    check to see if profiling is current enabled
  177. X *
  178. X *  SYNOPSIS
  179. X *
  180. X *    LOCAL BOOLEAN DoProfile ()
  181. X *
  182. X *  DESCRIPTION
  183. X *
  184. X *    Checks to see if profiling is enabled based on whether the
  185. X *    user has specified profiling, the maximum trace depth has
  186. X *    not yet been reached, the current function is selected,
  187. X *    and the current process is selected.  Returns TRUE if
  188. X *    profiling is enabled, FALSE otherwise.
  189. X *
  190. X */
  191. X
  192. XLOCAL BOOLEAN DoProfile ()
  193. X{
  194. X    REGISTER BOOLEAN profile;
  195. X
  196. X    profile = FALSE;
  197. X    if (PROFILING) {
  198. X    if (stack -> level <= stack -> maxdepth) {
  199. X        if (InList (stack -> p_functions, func)) {
  200. X        if (InList (stack -> processes, _db_process_)) {
  201. X            profile = TRUE;
  202. X        }
  203. X        }
  204. X    }
  205. X    }
  206. X    return (profile);
  207. X}
  208. X
  209. X
  210. X/*
  211. X *  FUNCTION
  212. X *
  213. X *    _db_keyword_    test keyword for member of keyword list
  214. X *
  215. X *  SYNOPSIS
  216. X *
  217. X *    BOOLEAN _db_keyword_ (keyword)
  218. X *    char *keyword;
  219. X *
  220. X *  DESCRIPTION
  221. X *
  222. X *    Test a keyword to determine if it is in the currently active
  223. X *    keyword list.  As with the function list, a keyword is accepted
  224. X *    if the list is null, otherwise it must match one of the list
  225. X *    members.  When debugging is not on, no keywords are accepted.
  226. X *    After the maximum trace level is exceeded, no keywords are
  227. X *    accepted (this behavior subject to change).  Additionally,
  228. X *    the current function and process must be accepted based on
  229. X *    their respective lists.
  230. X *
  231. X *    Returns TRUE if keyword accepted, FALSE otherwise.
  232. X *
  233. X */
  234. X
  235. XBOOLEAN _db_keyword_ (keyword)
  236. Xchar *keyword;
  237. X{
  238. X    REGISTER BOOLEAN accept;
  239. X
  240. X    if (!init_done) {
  241. X    _db_push_ ("");
  242. X    }
  243. X    accept = FALSE;
  244. X    if (DEBUGGING) {
  245. X    if (stack -> level <= stack -> maxdepth) {
  246. X        if (InList (stack -> functions, func)) {
  247. X        if (InList (stack -> keywords, keyword)) {
  248. X            if (InList (stack -> processes, _db_process_)) {
  249. X            accept = TRUE;
  250. X            }
  251. X        }
  252. X        }
  253. X    }
  254. X    }
  255. X    return (accept);
  256. X}
  257. X
  258. X
  259. X/*
  260. X *  FUNCTION
  261. X *
  262. X *    Indent    indent a line to the given indentation level
  263. X *
  264. X *  SYNOPSIS
  265. X *
  266. X *    LOCAL VOID Indent (indent)
  267. X *    int indent;
  268. X *
  269. X *  DESCRIPTION
  270. X *
  271. X *    Indent a line to the given level.  Note that this is
  272. X *    a simple minded but portable implementation.
  273. X *    There are better ways.
  274. X *
  275. X *    Also, the indent must be scaled by the compile time option
  276. X *    of character positions per nesting level.
  277. X *
  278. X */
  279. X
  280. XLOCAL VOID Indent (indent)
  281. Xint indent;
  282. X{
  283. X    REGISTER int count;
  284. X    AUTO char buffer[PRINTBUF];
  285. X
  286. X    indent *= INDENT;
  287. X    for (count = 0; (count < (indent - INDENT)) && (count < (PRINTBUF - 1)); count++) {
  288. X    if ((count % INDENT) == 0) {
  289. X        buffer[count] = '|';
  290. X    } else {
  291. X        buffer[count] = ' ';
  292. X    }
  293. X    }
  294. X    buffer[count] = EOS;
  295. X    (VOID) fprintf (_db_fp_, buffer);
  296. X    (VOID) fflush (_db_fp_);
  297. X}
  298. X
  299. X
  300. X/*
  301. X *  FUNCTION
  302. X *
  303. X *    FreeList    free all memory associated with a linked list
  304. X *
  305. X *  SYNOPSIS
  306. X *
  307. X *    LOCAL VOID FreeList (linkp)
  308. X *    struct link *linkp;
  309. X *
  310. X *  DESCRIPTION
  311. X *
  312. X *    Given pointer to the head of a linked list, frees all
  313. X *    memory held by the list and the members of the list.
  314. X *
  315. X */
  316. X
  317. XLOCAL VOID FreeList (linkp)
  318. Xstruct link *linkp;
  319. X{
  320. X    REGISTER struct link *old;
  321. X
  322. X    while (linkp != NULL) {
  323. X    old = linkp;
  324. X    linkp = linkp -> next_link;
  325. X    if (old -> string != NULL) {
  326. X        free (old -> string);
  327. X    }
  328. X    free ((char *) old);
  329. X    }
  330. X}
  331. X
  332. X
  333. X/*
  334. X *  FUNCTION
  335. X *
  336. X *    StrDup   make a duplicate of a string in new memory
  337. X *
  338. X *  SYNOPSIS
  339. X *
  340. X *    LOCAL char *StrDup (string)
  341. X *    char *string;
  342. X *
  343. X *  DESCRIPTION
  344. X *
  345. X *    Given pointer to a string, allocates sufficient memory to make
  346. X *    a duplicate copy, and copies the string to the newly allocated
  347. X *    memory.  Failure to allocated sufficient memory is immediately
  348. X *    fatal.
  349. X *
  350. X */
  351. X
  352. X
  353. XLOCAL char *StrDup (string)
  354. Xchar *string;
  355. X{
  356. X    REGISTER char *new;
  357. X
  358. X    new = DbugMalloc (strlen (string) + 1);
  359. X    (VOID) strcpy (new, string);
  360. X    return (new);
  361. X}
  362. X
  363. X
  364. X/*
  365. X *  FUNCTION
  366. X *
  367. X *    DoPrefix    print debugger line prefix prior to indentation
  368. X *
  369. X *  SYNOPSIS
  370. X *
  371. X *    LOCAL VOID DoPrefix (_line_)
  372. X *    int _line_;
  373. X *
  374. X *  DESCRIPTION
  375. X *
  376. X *    Print prefix common to all debugger output lines, prior to
  377. X *    doing indentation if necessary.  Print such information as
  378. X *    current process name, current source file name and line number,
  379. X *    and current function nesting depth.
  380. X *
  381. X */
  382. X  
  383. XLOCAL VOID DoPrefix (_line_)
  384. Xint _line_;
  385. X{
  386. X    lineno++;
  387. X    if (stack -> flags & NUMBER_ON) {
  388. X    (VOID) fprintf (_db_fp_, "%5d: ", lineno);
  389. X    }
  390. X    if (stack -> flags & PROCESS_ON) {
  391. X    (VOID) fprintf (_db_fp_, "%s: ", _db_process_);
  392. X    }
  393. X    if (stack -> flags & FILE_ON) {
  394. X    (VOID) fprintf (_db_fp_, "%14s: ", file);
  395. X    }
  396. X    if (stack -> flags & LINE_ON) {
  397. X    (VOID) fprintf (_db_fp_, "%5d: ", _line_);
  398. X    }
  399. X    if (stack -> flags & DEPTH_ON) {
  400. X    (VOID) fprintf (_db_fp_, "%4d: ", stack -> level);
  401. X    }
  402. X    (VOID) fflush (_db_fp_);
  403. X}
  404. X
  405. X
  406. X/*
  407. X *  FUNCTION
  408. X *
  409. X *    OpenFile    open new output stream for debugger output
  410. X *
  411. X *  SYNOPSIS
  412. X *
  413. X *    LOCAL VOID OpenFile (name)
  414. X *    char *name;
  415. X *
  416. X *  DESCRIPTION
  417. X *
  418. X *    Given name of a new file (or "-" for stdout) opens the file
  419. X *    and sets the output stream to the new file.
  420. X *
  421. X */
  422. X
  423. XLOCAL VOID OpenFile (name)
  424. Xchar *name;
  425. X{
  426. X    REGISTER FILE *fp;
  427. X    REGISTER BOOLEAN newfile;
  428. X
  429. X    if (name != NULL) {
  430. X    if (strcmp (name, "-") == 0) {
  431. X        _db_fp_ = stdout;
  432. X        stack -> out_file = _db_fp_;
  433. X    } else {
  434. X        if (!Writable (name)) {
  435. X        (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name);
  436. X        perror ("");
  437. X        (VOID) fflush (_db_fp_);
  438. X        (VOID) XDelay (stack -> delay);
  439. X        } else {
  440. X        if (EXISTS (name)) {
  441. X            newfile = FALSE;
  442. X        } else {
  443. X            newfile = TRUE;
  444. X        }
  445. X        fp = fopen (name, "a");
  446. X        if (fp == NULL) {
  447. X             (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name);
  448. X            perror ("");
  449. X            (VOID) fflush (_db_fp_);
  450. X            (VOID) XDelay (stack -> delay);
  451. X        } else {
  452. X            _db_fp_ = fp;
  453. X            stack -> out_file = fp;
  454. X            if (newfile) {
  455. X            ChangeOwner (name);
  456. X            }
  457. X        }
  458. X        }
  459. X    }
  460. X    }
  461. X}
  462. X
  463. X
  464. X/*
  465. X *  FUNCTION
  466. X *
  467. X *    OpenProfile    open new output stream for profiler output
  468. X *
  469. X *  SYNOPSIS
  470. X *
  471. X *    LOCAL VOID OpenProfile (name)
  472. X *    char *name;
  473. X *
  474. X *  DESCRIPTION
  475. X *
  476. X *    Given name of a new file, opens the file
  477. X *    and sets the profiler output stream to the new file.
  478. X *
  479. X *    It is currently unclear whether the prefered behavior is
  480. X *    to truncate any existing file, or simply append to it.
  481. X *    The latter behavior would be desirable for collecting
  482. X *    accumulated runtime history over a number of separate
  483. X *    runs.  It might take some changes to the analyzer program
  484. X *    though, and the notes that Binayak sent with the profiling
  485. X *    diffs indicated that append was the normal mode, but this
  486. X *    does not appear to agree with the actual code. I haven't
  487. X *    investigated at this time [fnf; 24-Jul-87].
  488. X */
  489. X
  490. XLOCAL VOID OpenProfile (name)
  491. Xchar *name;
  492. X{
  493. X    REGISTER FILE *fp;
  494. X    REGISTER BOOLEAN newfile;
  495. X
  496. X    if (name != NULL) {
  497. X    if (!Writable (name)) {
  498. X        (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name);
  499. X        perror ("");
  500. X        (VOID) fflush (_db_fp_);
  501. X        (VOID) XDelay (stack -> delay);
  502. X    } else {
  503. X        if (EXISTS (name)) {
  504. X        newfile = FALSE;
  505. X        } else {
  506. X        newfile = TRUE;
  507. X        }
  508. X        fp = fopen (name, "w");
  509. X        if (fp == NULL) {
  510. X        (VOID) fprintf (_db_fp_, ERR_OPEN, _db_process_, name);
  511. X        perror ("");
  512. X        (VOID) fflush (_db_fp_);
  513. X        (VOID) XDelay (stack -> delay);
  514. X        } else {
  515. X        _db_pfp_ = fp;
  516. X        stack -> prof_file = fp;
  517. X        if (newfile) {
  518. X            ChangeOwner (name);
  519. X        }
  520. X        }
  521. X    }
  522. X    }
  523. X}
  524. X
  525. X
  526. X/*
  527. X *  FUNCTION
  528. X *
  529. X *    CloseFile    close the debug output stream
  530. X *
  531. X *  SYNOPSIS
  532. X *
  533. X *    LOCAL VOID CloseFile (fp)
  534. X *    FILE *fp;
  535. X *
  536. X *  DESCRIPTION
  537. X *
  538. X *    Closes the debug output stream unless it is standard output
  539. X *    or standard error.
  540. X *
  541. X */
  542. X
  543. XLOCAL VOID CloseFile (fp)
  544. XFILE *fp;
  545. X{
  546. X    if (fp != stderr && fp != stdout) {
  547. X    if (fclose (fp) == EOF) {
  548. X        (VOID) fprintf (stderr, ERR_CLOSE, _db_process_);
  549. X        perror ("");
  550. X        (VOID) fflush (stderr);
  551. X        (VOID) XDelay (stack -> delay);
  552. X    }
  553. X    }
  554. X}
  555. X
  556. X
  557. X/*
  558. X *  FUNCTION
  559. X *
  560. X *    DbugExit    print error message and exit
  561. X *
  562. X *  SYNOPSIS
  563. X *
  564. X *    LOCAL VOID DbugExit (why)
  565. X *    char *why;
  566. X *
  567. X *  DESCRIPTION
  568. X *
  569. X *    Prints error message using current process name, the reason for
  570. X *    aborting (typically out of memory), and exits with status 1.
  571. X *    This should probably be changed to use a status code
  572. X *    defined in the user's debugger include file.
  573. X *
  574. X */
  575. XLOCAL VOID DbugExit (why)
  576. Xchar *why;
  577. X{
  578. X    (VOID) fprintf (stderr, ERR_ABORT, _db_process_, why);
  579. X    (VOID) fflush (stderr);
  580. X    (VOID) XDelay (stack -> delay);
  581. X    exit (1);
  582. X}
  583. X
  584. X
  585. X/*
  586. X *  FUNCTION
  587. X *
  588. X *    DbugMalloc    allocate memory for debugger runtime support
  589. X *
  590. X *  SYNOPSIS
  591. X *
  592. X *    LOCAL char *DbugMalloc (size)
  593. X *    int size;
  594. X *
  595. X *  DESCRIPTION
  596. X *
  597. X *    Allocate more memory for debugger runtime support functions.
  598. X *    Failure to to allocate the requested number of bytes is
  599. X *    immediately fatal to the current process.  This may be
  600. X *    rather unfriendly behavior.  It might be better to simply
  601. X *    print a warning message, freeze the current debugger state,
  602. X *    and continue execution.
  603. X *
  604. X */
  605. XLOCAL char *DbugMalloc (size)
  606. Xint size;
  607. X{
  608. X    register char *new;
  609. X
  610. X    new = malloc ( size );
  611. X    if (new == NULL) {
  612. X    DbugExit ("out of memory");
  613. X    }
  614. X    return (new);
  615. X}
  616. X
  617. X
  618. X/*
  619. X *    This function may be eliminated when strtok is available
  620. X *    in the runtime environment (missing from BSD4.1).
  621. X */
  622. X
  623. XLOCAL char *strtok (s1, s2)
  624. Xchar *s1, *s2;
  625. X{
  626. X    static char *end = NULL;
  627. X    REGISTER char *rtnval;
  628. X
  629. X    rtnval = NULL;
  630. X    if (s2 != NULL) {
  631. X    if (s1 != NULL) {
  632. X        end = s1;
  633. X        rtnval = strtok ((char *) NULL, s2);
  634. X    } else if (end != NULL) {
  635. X        if (*end != EOS) {
  636. X        rtnval = end;
  637. X        while (*end != *s2 && *end != EOS) {end++;}
  638. X        if (*end != EOS) {
  639. X            *end++ = EOS;
  640. X        }
  641. X        }
  642. X    }
  643. X    }
  644. X    return (rtnval);
  645. X}
  646. X
  647. X
  648. X/*
  649. X *  FUNCTION
  650. X *
  651. X *    BaseName    strip leading pathname components from name
  652. X *
  653. X *  SYNOPSIS
  654. X *
  655. X *    LOCAL char *BaseName (pathname)
  656. X *    char *pathname;
  657. X *
  658. X *  DESCRIPTION
  659. X *
  660. X *    Given pointer to a complete pathname, locates the base file
  661. X *    name at the end of the pathname and returns a pointer to
  662. X *    it.
  663. X *
  664. X */
  665. X
  666. XLOCAL char *BaseName (pathname)
  667. Xchar *pathname;
  668. X{
  669. X    register char *base;
  670. X
  671. X    base = strrchr (pathname, '/');
  672. X    if (base++ == NULL) {
  673. X    base = pathname;
  674. X    }
  675. X    return (base);
  676. X}
  677. X
  678. X
  679. X/*
  680. X *  FUNCTION
  681. X *
  682. X *    Writable    test to see if a pathname is writable/creatable
  683. X *
  684. X *  SYNOPSIS
  685. X *
  686. X *    LOCAL BOOLEAN Writable (pathname)
  687. X *    char *pathname;
  688. X *
  689. X *  DESCRIPTION
  690. X *
  691. X *    Because the debugger might be linked in with a program that
  692. X *    runs with the set-uid-bit (suid) set, we have to be careful
  693. X *    about opening a user named file for debug output.  This consists
  694. X *    of checking the file for write access with the real user id,
  695. X *    or checking the directory where the file will be created.
  696. X *
  697. X *    Returns TRUE if the user would normally be allowed write or
  698. X *    create access to the named file.  Returns FALSE otherwise.
  699. X *
  700. X */
  701. X
  702. XLOCAL BOOLEAN Writable (pathname)
  703. Xchar *pathname;
  704. X{
  705. X    REGISTER BOOLEAN granted;
  706. X#ifdef unix
  707. X    REGISTER char *lastslash;
  708. X#endif
  709. X
  710. X#ifndef unix
  711. X    granted = TRUE;
  712. X#else
  713. X    granted = FALSE;
  714. X    if (EXISTS (pathname)) {
  715. X    if (WRITABLE (pathname)) {
  716. X        granted = TRUE;
  717. X    }
  718. X    } else {
  719. X    lastslash = strrchr (pathname, '/');
  720. X    if (lastslash != NULL) {
  721. X        *lastslash = EOS;
  722. X    } else {
  723. X        pathname = ".";
  724. X    }
  725. X    if (WRITABLE (pathname)) {
  726. X        granted = TRUE;
  727. X    }
  728. X    if (lastslash != NULL) {
  729. X        *lastslash = '/';
  730. X    }
  731. X    }
  732. X#endif
  733. X    return (granted);
  734. X}
  735. X
  736. X
  737. X/*
  738. X *    This function may be eliminated when strrchr is available
  739. X *    in the runtime environment (missing from BSD4.1).
  740. X *    Alternately, you can use rindex() on BSD systems.
  741. X */
  742. X
  743. XLOCAL char *strrchr (s, c)
  744. Xchar *s;
  745. Xchar c;
  746. X{
  747. X    REGISTER char *scan;
  748. X
  749. X    for (scan = s; *scan != EOS; scan++) {;}
  750. X    while (scan > s && *--scan != c) {;}
  751. X    if (*scan != c) {
  752. X    scan = NULL;
  753. X    }
  754. X    return (scan);
  755. X}
  756. X
  757. X
  758. X/*
  759. X *  FUNCTION
  760. X *
  761. X *    ChangeOwner    change owner to real user for suid programs
  762. X *
  763. X *  SYNOPSIS
  764. X *
  765. X *    LOCAL VOID ChangeOwner (pathname)
  766. X *
  767. X *  DESCRIPTION
  768. X *
  769. X *    For unix systems, change the owner of the newly created debug
  770. X *    file to the real owner.  This is strictly for the benefit of
  771. X *    programs that are running with the set-user-id bit set.
  772. X *
  773. X *    Note that at this point, the fact that pathname represents
  774. X *    a newly created file has already been established.  If the
  775. X *    program that the debugger is linked to is not running with
  776. X *    the suid bit set, then this operation is redundant (but
  777. X *    harmless).
  778. X *
  779. X */
  780. X
  781. XLOCAL VOID ChangeOwner (pathname)
  782. Xchar *pathname;
  783. X{
  784. X#ifdef unix
  785. X    if (chown (pathname, getuid (), getgid ()) == -1) {
  786. X    (VOID) fprintf (stderr, ERR_CHOWN, _db_process_, pathname);
  787. X    perror ("");
  788. X    (VOID) fflush (stderr);
  789. X    (VOID) XDelay (stack -> delay);
  790. X    }
  791. X#endif
  792. X}
  793. X
  794. X
  795. X/*
  796. X *  FUNCTION
  797. X *
  798. X *    _db_setjmp_    save debugger environment
  799. X *
  800. X *  SYNOPSIS
  801. X *
  802. X *    VOID _db_setjmp_ ()
  803. X *
  804. X *  DESCRIPTION
  805. X *
  806. X *    Invoked as part of the user's DBUG_SETJMP macro to save
  807. X *    the debugger environment in parallel with saving the user's
  808. X *    environment.
  809. X *
  810. X */
  811. X
  812. XVOID _db_setjmp_ ()
  813. X{
  814. X   jmplevel = stack -> level;
  815. X   jmpfunc = func;
  816. X   jmpfile = file;
  817. X}
  818. X
  819. X
  820. X/*
  821. X *  FUNCTION
  822. X *
  823. X *    _db_longjmp_    restore previously saved debugger environment
  824. X *
  825. X *  SYNOPSIS
  826. X *
  827. X *    VOID _db_longjmp_ ()
  828. X *
  829. X *  DESCRIPTION
  830. X *
  831. X *    Invoked as part of the user's DBUG_LONGJMP macro to restore
  832. X *    the debugger environment in parallel with restoring the user's
  833. X *    previously saved environment.
  834. X *
  835. X */
  836. X
  837. XVOID _db_longjmp_ ()
  838. X{
  839. X    stack -> level = jmplevel;
  840. X    if (jmpfunc) {
  841. X    func = jmpfunc;
  842. X    }
  843. X    if (jmpfile) {
  844. X    file = jmpfile;
  845. X    }
  846. X}
  847. X
  848. X
  849. X/*
  850. X *  FUNCTION
  851. X *
  852. X *    DelayArg   convert D flag argument to appropriate value
  853. X *
  854. X *  SYNOPSIS
  855. X *
  856. X *    LOCAL int DelayArg (value)
  857. X *    int value;
  858. X *
  859. X *  DESCRIPTION
  860. X *
  861. X *    Converts delay argument, given in tenths of a second, to the
  862. X *    appropriate numerical argument used by the system to delay
  863. X *    that that many tenths of a second.  For example, on the
  864. X *    AMIGA, there is a system call "Delay()" which takes an
  865. X *    argument in ticks (50 per second).  On unix, the sleep
  866. X *    command takes seconds.  Thus a value of "10", for one
  867. X *    second of delay, gets converted to 50 on the amiga, and 1
  868. X *    on unix.  Other systems will need to use a timing loop.
  869. X *
  870. X */
  871. X
  872. XLOCAL int DelayArg (value)
  873. Xint value;
  874. X{
  875. X    int delayarg = 0;
  876. X    
  877. X#ifdef unix
  878. X    delayarg = value / 10;        /* Delay is in seconds for sleep () */
  879. X#endif
  880. X#ifdef AMIGA
  881. X    delayarg = (HZ * value) / 10;    /* Delay in ticks for XDelay () */
  882. X#endif
  883. X    return (delayarg);
  884. X}
  885. X
  886. X
  887. X/*
  888. X *    A dummy delay stub for systems that do not support delays.
  889. X *    With a little work, this can be turned into a timing loop.
  890. X */
  891. X
  892. X#ifndef unix
  893. X#ifndef AMIGA
  894. XXDelay ()
  895. X{
  896. X}
  897. X#endif
  898. X#endif
  899. X
  900. X
  901. X/*
  902. X *  FUNCTION
  903. X *
  904. X *    perror    perror simulation for systems that don't have it
  905. X *
  906. X *  SYNOPSIS
  907. X *
  908. X *    LOCAL VOID perror (s)
  909. X *    char *s;
  910. X *
  911. X *  DESCRIPTION
  912. X *
  913. X *    Perror produces a message on the standard error stream which
  914. X *    provides more information about the library or system error
  915. X *    just encountered.  The argument string s is printed, followed
  916. X *    by a ':', a blank, and then a message and a newline.
  917. X *
  918. X *    An undocumented feature of the unix perror is that if the string
  919. X *    's' is a null string (NOT a NULL pointer!), then the ':' and
  920. X *    blank are not printed.
  921. X *
  922. X *    This version just complains about an "unknown system error".
  923. X *
  924. X */
  925. X
  926. X#if !unix && !(AMIGA && LATTICE)
  927. XLOCAL VOID perror (s)
  928. X#ifdef __STDC__
  929. Xconst char *s;
  930. X#else
  931. Xchar *s;
  932. X#endif
  933. X{
  934. X    if (s && *s != EOS) {
  935. X    (VOID) fprintf (stderr, "%s: ", s);
  936. X    }
  937. X    (VOID) fprintf (stderr, "<unknown system error>\n");
  938. X}
  939. X#endif    /* !unix && !(AMIGA && LATTICE) */
  940. X
  941. X/*
  942. X * Here we need the definitions of the clock routine.  Add your
  943. X * own for whatever system that you have.
  944. X */
  945. X
  946. X#if unix
  947. X
  948. X# include <sys/param.h>
  949. X# if BSD4_3 || sun
  950. X
  951. X/*
  952. X * Definition of the Clock() routine for 4.3 BSD.
  953. X */
  954. X
  955. X#include <sys/time.h>
  956. X#include <sys/resource.h>
  957. X
  958. X/*
  959. X * Returns the user time in milliseconds used by this process so
  960. X * far.
  961. X */
  962. X
  963. XLOCAL unsigned long Clock ()
  964. X{
  965. X    struct rusage ru;
  966. X
  967. X    (VOID) getrusage (RUSAGE_SELF, &ru);
  968. X    return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000));
  969. X}
  970. X
  971. X#else
  972. X
  973. XLOCAL unsigned long Clock ()
  974. X{
  975. X    return (0);
  976. X}
  977. X
  978. X# endif
  979. X
  980. X#else
  981. X
  982. X#if AMIGA
  983. X
  984. Xstruct DateStamp {        /* Yes, this is a hack, but doing it right */
  985. X    long ds_Days;        /* is incredibly ugly without splitting this */
  986. X    long ds_Minute;        /* off into a separate file */
  987. X    long ds_Tick;
  988. X};
  989. X
  990. Xstatic int first_clock = TRUE;
  991. Xstatic struct DateStamp begin;
  992. Xstatic struct DateStamp elapsed;
  993. X
  994. XLOCAL unsigned long Clock ()
  995. X{
  996. X    register struct DateStamp *now;
  997. X    register unsigned long millisec = 0;
  998. X    extern VOID *AllocMem ();
  999. X
  1000. X    now = (struct DateStamp *) AllocMem ((long) sizeof (struct DateStamp), 0L);
  1001. X    if (now != NULL) {
  1002. X    if (first_clock == TRUE) {
  1003. X        first_clock = FALSE;
  1004. X        (VOID) DateStamp (now);
  1005. X        begin = *now;
  1006. X    }
  1007. X    (VOID) DateStamp (now);
  1008. X    millisec = 24 * 3600 * (1000 / HZ) * (now -> ds_Days - begin.ds_Days);
  1009. X    millisec += 60 * (1000 / HZ) * (now -> ds_Minute - begin.ds_Minute);
  1010. X    millisec += (1000 / HZ) * (now -> ds_Tick - begin.ds_Tick);
  1011. X    (VOID) FreeMem (now, (long) sizeof (struct DateStamp));
  1012. X    }
  1013. X    return (millisec);
  1014. X}
  1015. X
  1016. X#else
  1017. X
  1018. XLOCAL unsigned long Clock ()
  1019. X{
  1020. X    return (0);
  1021. X}
  1022. X
  1023. X#endif    /* AMIGA */
  1024. X
  1025. X#endif    /* unix */
  1026. X
  1027. X#ifdef AMIGA
  1028. XXDelay(x)
  1029. Xint x;
  1030. X{
  1031. X    if (x) Delay(x);    /* fix Delay bug in AmigaDOS */
  1032. X}
  1033. X#endif
  1034. X
  1035. SHAR_EOF
  1036. echo "File common/dbug.c is complete"
  1037. chmod 0440 common/dbug.c || echo "restore of common/dbug.c fails"
  1038. echo "x - extracting common/db.h (Text)"
  1039. sed 's/^X//' << 'SHAR_EOF' > common/db.h &&
  1040. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/common/RCS/db.h,v 1.1 90/07/19 13:30:43 dvadura Exp $
  1041. X-- SYNOPSIS -- front end to DBUG macros.
  1042. X-- 
  1043. X-- DESCRIPTION
  1044. X--    This is a front end to Fred Fish's DBUG macros.  The intent was
  1045. X--    to provide an interface so that if you don't have the DBUG code
  1046. X--    you can still compile dmake, by undefining DBUG, if you do have
  1047. X--    the code then you can use Fred Fish's DBUG package.  Originally
  1048. X--    the DBUG stuff was copyrighted, it is now in the public domain
  1049. X--    so the need for this is not as apparent.
  1050. X-- 
  1051. X-- AUTHOR
  1052. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1053. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1054. X--
  1055. X-- COPYRIGHT
  1056. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1057. X-- 
  1058. X--      This program is free software; you can redistribute it and/or
  1059. X--      modify it under the terms of the GNU General Public License
  1060. X--      (version 1), as published by the Free Software Foundation, and
  1061. X--      found in the file 'LICENSE' included with this distribution.
  1062. X-- 
  1063. X--      This program is distributed in the hope that it will be useful,
  1064. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1065. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1066. X--      GNU General Public License for more details.
  1067. X-- 
  1068. X--      You should have received a copy of the GNU General Public License
  1069. X--      along with this program;  if not, write to the Free Software
  1070. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1071. X--
  1072. X-- LOG
  1073. X--     $Log:    db.h,v $
  1074. X * Revision 1.1  90/07/19  13:30:43  dvadura
  1075. X * Initial Revision of Version 3.5
  1076. X * 
  1077. X*/
  1078. X
  1079. X#ifndef    DB_h
  1080. X#define    DB_h
  1081. X
  1082. X#ifdef DBUG
  1083. X
  1084. X#  include <stdio.h>
  1085. X#  include <dbug.h>
  1086. X
  1087. X#  define DB_ENTER(a1)                DBUG_ENTER(a1)
  1088. X#  define DB_RETURN(a1)               DBUG_RETURN(a1)
  1089. X#  define DB_VOID_RETURN              DBUG_VOID_RETURN
  1090. X#  define DB_EXECUTE(keyword, a1)     DBUG_EXECUTE(keyword,a1)
  1091. X#  define DB_PRINT(keyword,arglist)   DBUG_PRINT(keyword,arglist)
  1092. X#  define DB_PUSH(a1)                 DBUG_PUSH(a1)
  1093. X#  define DB_POP()                    DBUG_POP()
  1094. X#  define DB_PROCESS(a1)              DBUG_PROCESS(a1)
  1095. X#  define DB_FILE (stderr)            DBUG_FILE(stderr)
  1096. X#  define DB_SETJMP                   DBUG_SETJMP
  1097. X#  define DB_LONGJMP                  DBUG_LONGJMP
  1098. X
  1099. X#else
  1100. X
  1101. X#  define DB_ENTER(a1)
  1102. X#  define DB_RETURN(a1)               return (a1)
  1103. X#  define DB_VOID_RETURN              return
  1104. X#  define DB_EXECUTE(keyword, a1)
  1105. X#  define DB_PRINT(keyword,arglist)
  1106. X#  define DB_PUSH(a1)
  1107. X#  define DB_POP()
  1108. X#  define DB_PROCESS(a1)
  1109. X#  define DB_FILE(stderr)
  1110. X#  define DB_SETJMP                   setjmp
  1111. X#  define DB_LONGJMP                  longjmp
  1112. X
  1113. X#endif
  1114. X#endif
  1115. X
  1116. SHAR_EOF
  1117. chmod 0440 common/db.h || echo "restore of common/db.h fails"
  1118. echo "x - extracting common/alloc.h (Text)"
  1119. sed 's/^X//' << 'SHAR_EOF' > common/alloc.h &&
  1120. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/common/RCS/alloc.h,v 1.1 90/07/19 13:30:39 dvadura Exp $
  1121. X-- SYNOPSIS -- macros for allocating memory.
  1122. X-- 
  1123. X-- DESCRIPTION
  1124. X--    A somewhat nicer interface to malloc and calloc.
  1125. X--    Here we standardise the calling convention with a common macro
  1126. X--    interface.
  1127. X-- 
  1128. X-- AUTHOR
  1129. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1130. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1131. X--
  1132. X-- COPYRIGHT
  1133. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1134. X-- 
  1135. X--      This program is free software; you can redistribute it and/or
  1136. X--      modify it under the terms of the GNU General Public License
  1137. X--      (version 1), as published by the Free Software Foundation, and
  1138. X--      found in the file 'LICENSE' included with this distribution.
  1139. X-- 
  1140. X--      This program is distributed in the hope that it will be useful,
  1141. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1142. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1143. X--      GNU General Public License for more details.
  1144. X-- 
  1145. X--      You should have received a copy of the GNU General Public License
  1146. X--      along with this program;  if not, write to the Free Software
  1147. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1148. X--
  1149. X-- LOG
  1150. X--     $Log:    alloc.h,v $
  1151. X * Revision 1.1  90/07/19  13:30:39  dvadura
  1152. X * Initial Revision of Version 3.5
  1153. X * 
  1154. X*/
  1155. X
  1156. X#ifndef ALLOC_h
  1157. X#define ALLOC_h
  1158. X
  1159. X/* DO NOT CHANGE these!  These are the definitions that the make source
  1160. X * uses for allocating memory.  They must be defined for make to compile
  1161. X * properly.
  1162. X */
  1163. X
  1164. X#ifndef _TYPES_
  1165. Xtypedef long size_t;
  1166. X#endif
  1167. X
  1168. X#define    usizeof(t)    (size_t)sizeof(t)
  1169. X
  1170. X#ifdef    DBUG
  1171. X#define FREE(p)         My_free((char*)(p), __FILE__, __LINE__)
  1172. X#define MALLOC(n, t)    (t*) My_malloc((n)*usizeof(t),  __FILE__, __LINE__)
  1173. X#define CALLOC(n, t)    (t*) My_calloc((n), usizeof(t), __FILE__, __LINE__)
  1174. X#else
  1175. X#define FREE(p)         free((char*)(p))
  1176. X#define MALLOC(n, t)    (t*) malloc((unsigned int)(n)*usizeof(t))
  1177. X#define CALLOC(n, t)    (t*) calloc((unsigned int)(n), usizeof(t))
  1178. X#endif
  1179. X
  1180. X#define TALLOC(p, n, t)    if ((p = CALLOC(n, t)) == (t*)0) {No_ram();}
  1181. X
  1182. X#endif
  1183. X
  1184. SHAR_EOF
  1185. chmod 0440 common/alloc.h || echo "restore of common/alloc.h fails"
  1186. echo "x - extracting basename.c (Text)"
  1187. sed 's/^X//' << 'SHAR_EOF' > basename.c &&
  1188. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/basename.c,v 1.1 90/07/19 13:53:01 dvadura Exp $
  1189. X-- SYNOPSIS -- return pointer to last pathname component
  1190. X-- 
  1191. X-- DESCRIPTION
  1192. X--    take a file name like /fred/foo/hoe/mary.k, and return the 'mary.k'
  1193. X--    portion
  1194. X-- 
  1195. X-- AUTHOR
  1196. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1197. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1198. X--
  1199. X-- COPYRIGHT
  1200. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1201. X-- 
  1202. X--      This program is free software; you can redistribute it and/or
  1203. X--      modify it under the terms of the GNU General Public License
  1204. X--      (version 1), as published by the Free Software Foundation, and
  1205. X--      found in the file 'LICENSE' included with this distribution.
  1206. X-- 
  1207. X--      This program is distributed in the hope that it will be useful,
  1208. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1209. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1210. X--      GNU General Public License for more details.
  1211. X-- 
  1212. X--      You should have received a copy of the GNU General Public License
  1213. X--      along with this program;  if not, write to the Free Software
  1214. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1215. X--
  1216. X-- LOG
  1217. X--     $Log:    basename.c,v $
  1218. X * Revision 1.1  90/07/19  13:53:01  dvadura
  1219. X * Initial Revision of Version 3.5
  1220. X * 
  1221. X*/
  1222. X
  1223. X#include <string.h>
  1224. X#include "extern.h"
  1225. X
  1226. Xchar*
  1227. Xbasename( path )
  1228. Xchar *path;
  1229. X{
  1230. X   char *p;
  1231. X   char *q;
  1232. X
  1233. X   if( *(q = path) ) {
  1234. X      for(; *(p=_strpbrk(q, DirBrkStr)) != '\0'; q = p+1 );
  1235. X      if( !*q ) {
  1236. X     for( p=q-1; p != path; --p )
  1237. X        if( strchr( DirBrkStr, *p ) == NIL(char) ) return( p+1 );
  1238. X     return( strchr(DirBrkStr, *p)?path:(p+1) );
  1239. X      }
  1240. X      path = q;
  1241. X   }
  1242. X   return( path );
  1243. X}
  1244. SHAR_EOF
  1245. chmod 0440 basename.c || echo "restore of basename.c fails"
  1246. echo "x - extracting _updctl (Text)"
  1247. sed 's/^X//' << 'SHAR_EOF' > _updctl &&
  1248. SHAR_EOF
  1249. chmod 0640 _updctl || echo "restore of _updctl fails"
  1250. echo "x - extracting _todo (Text)"
  1251. sed 's/^X//' << 'SHAR_EOF' > _todo &&
  1252. X- Finish and test the unix dmaked remote daemon, and allow remote makes to
  1253. X  span NFS'ed file systems.
  1254. X
  1255. X- See if I can find spawnvp.c source someplace so I can hack the environment
  1256. X  to better support the MKS argument passing convention in the DOS version.
  1257. SHAR_EOF
  1258. chmod 0640 _todo || echo "restore of _todo fails"
  1259. echo "x - extracting _readme (Text)"
  1260. sed 's/^X//' << 'SHAR_EOF' > _readme &&
  1261. XThis is the first distribution of dmake version 3.5.  dmake is a
  1262. Xmake like tool that has been written by me and has been used by individuals at
  1263. Xthe University of Waterloo for about a year and a half now.  I feel it has
  1264. Xmatured enough to be made available on a wider scale.
  1265. X
  1266. Xdmake is available for anonymous ftp from watmsg.uwaterloo.ca address is
  1267. X129.97.129.9.  It is in the pub/src directory, set your mode to binary,
  1268. Xand copy either:
  1269. X
  1270. X    dmake-3.5.tar.Z        - compressed tar format
  1271. X    dmake-3.5.zoo        - zoo archive
  1272. X
  1273. Xdmake is different from other versions of make in that it supports significant
  1274. Xenhancements (See the man page).  A short summary of the more important
  1275. Xones follows:
  1276. X
  1277. X    . support for portable makefiles
  1278. X    . runs on many platforms (DOS, generic unix [sysv and bsd4.3],
  1279. X      apollo, and others)
  1280. X    . significantly enhanced macro facilities
  1281. X    . transitive closure on inference graph
  1282. X    . sofisticated inference algorithm
  1283. X    . support for traversing the file sytem both during making of targets
  1284. X      and during inference
  1285. X    . %-meta rules for specifying rules to be used for inferring
  1286. X      prerequisites
  1287. X    . highly configurable
  1288. X    . support for libraries
  1289. X    . parallel making of targets on architectures that support it
  1290. X    . attributed targets
  1291. X    . text diversions
  1292. X
  1293. XAll code found in this distribution is original and writen by me except where
  1294. Xnoted in the source and the following:
  1295. X
  1296. X- dbug package from Fred Fish  (dmake DEBUG=1, to make a debugging version
  1297. X  of dmake)
  1298. X
  1299. X- malloc.c package, came from the net originally, author name wasn't
  1300. X  on it when I found it, I can't even remember where I got it.
  1301. X
  1302. X-dennis
  1303. SHAR_EOF
  1304. chmod 0640 _readme || echo "restore of _readme fails"
  1305. echo "x - extracting _readme.dos (Text)"
  1306. sed 's/^X//' << 'SHAR_EOF' > _readme.dos &&
  1307. XSome notes on the MSDOS implementation of dmake.
  1308. X
  1309. Xdmake does not care if you are running command.com or some other command
  1310. Xinterpretter, you must however specify the proper values of the environment
  1311. Xvariables SHELL, SHELLFLAGS, GROUPSHELL, and GROUPFLAGS in order for things
  1312. Xto work correctly.  Read the man page first.
  1313. X
  1314. XGroup recipes under DOS require you to set the GROUPSUFFIX macro.
  1315. X
  1316. XAs shipped the startup.mk files for the DOS version try to figure out what
  1317. Xcommand interpretter you are using and set things up appropriately.
  1318. XTwo command interpretters are supported in the shipped startup.mk file,
  1319. Xcommand.com, and the MKS Korn shell.
  1320. X
  1321. Xdmake does not contain any builtin commands.  It gets all commands it executes
  1322. Xfrom an external environment.  It is therefore most useful if it is used in
  1323. Xconjunction with an environment such as is provided by the the MKS Tool kit,
  1324. Xor equivalent.
  1325. X
  1326. XIf running under the MKS toolkit, dmake does not currently support their
  1327. Xextended length argument passing conventions.  I need a working version of
  1328. Xspawnvp source in order to modify it so that it puts the right magic cookies
  1329. Xin the right places so that an invoked MKS command knows to look into the
  1330. Xenvironment for its command line arguments rather than in the DOS command
  1331. Xtail.
  1332. SHAR_EOF
  1333. chmod 0640 _readme.dos || echo "restore of _readme.dos fails"
  1334. echo "x - extracting _install (Text)"
  1335. sed 's/^X//' << 'SHAR_EOF' > _install &&
  1336. XINSTALLATION INSTRUCTIONS
  1337. X
  1338. XThis file contains the instructions required to install and create the
  1339. Xappropriate version of dmake.
  1340. X
  1341. X
  1342. XMAKING THE PROPER VERSION
  1343. X
  1344. XIn order to use dmake you must first make the correct version.  As shipped
  1345. Xthere exist several versions that you can make:
  1346. X
  1347. X    bsd43uw       - Generic BSD 4.3 at U of Waterloo
  1348. X    bsd43       - Generic BSD 4.3 (eg, true BSD, apollo, sun OS4, SGI etc)
  1349. X    sysvr3       - Generic SysV R3 UNIX (NCR tower, ....etc)
  1350. X    tccdos       - DOS with tcc 2.0
  1351. X    dynix      - Sequent symmetry dynix
  1352. X    mscdos       - DOS with MSC 4.0 or >  not tested
  1353. X    386ix      - 386/ix (SysV R3), not tested
  1354. X
  1355. XThe source code is organized as follows:
  1356. X
  1357. X            dmake         [source for all common functions]
  1358. X              |
  1359. X              |
  1360. X             -----------
  1361. X             |           |
  1362. X            unix     msdos    [source for OS specific functions]
  1363. X             |         |
  1364. X  ----------------------     -------------
  1365. X  |         |          |     |           |
  1366. X386ix     bsd43    sysvr3  tccdos     mscdos    [source for OSRELEASE specific
  1367. X        |                     functions]
  1368. X    --------
  1369. X    |      |
  1370. X       uw    dynix
  1371. X
  1372. X
  1373. XEach of the directories (eg. bsd43, mscdos, tccdos, and sysvr3) contain source
  1374. Xthat is specific to that release of the OS (and possibly C-library)
  1375. XTo make the apropriate versions of dmake, simply type the command
  1376. X
  1377. X    'make system'
  1378. X
  1379. Xwhere system is one of the supplied possibilities.  For a complete list
  1380. Xof the versions you can make, see the comments in the file 'makefile'.
  1381. X
  1382. XThe bootstrapping of dmake is accomplished by running a shell script with the
  1383. Xappropriate compile commands hard coded.
  1384. X
  1385. X(NOTE:  If you are using MSDOS then, you will actually be using the make.bat
  1386. X    scriptfile to make the correct version of dmake for MSDOS.  If you
  1387. X    are running a SHELL other than command.com, you may have to perform
  1388. X    some extra work to invoke the batch file.)
  1389. X
  1390. XThe making of dmake, echoes the commands being executed, and should proceed
  1391. Xrelatively error free.  Ignore any warnings that concerned unused arguments
  1392. Xto functions, these are normal in some configurations (esp the MSDOS)
  1393. Xconfiguration.
  1394. X
  1395. X
  1396. XSTARTUP FILE
  1397. X
  1398. Xdmake requires the loading of a startup file when it is first invoked.  The
  1399. Xpath for the startup file is set in the file 'startup.h' found in the unix
  1400. Xand msdos directories.  You may override the value of the path variable
  1401. Xcompiled-in by creating a file at the root source directory called startup.h
  1402. Xand inserting into that file a definition that is like the definition found
  1403. Xin the supplied startup.h files.
  1404. X
  1405. X
  1406. XINSTALLATION
  1407. X
  1408. XTo install dmake you must copy the executable to where your system
  1409. Xlocates executables, and you must place a copy of startup.mk (found in the
  1410. Xdirectory corresponding to the version you just made) into a location
  1411. Xcorresponding to the value of the MAKESTARTUP macro or environment variable.
  1412. XYou are free to customize the contents of startup.mk.
  1413. X
  1414. XTo make dmake again, (using itself), you will have to set three environment
  1415. Xvariables.  See the file makefile.mk for their names and their legal values.
  1416. XOnce set you can invoke dmake to make itself.
  1417. X
  1418. X
  1419. XDOCUMENTATION
  1420. X
  1421. XAll documentation for dmake appears under the man directory.
  1422. XThe file dmake.tf included in this distribution contains the troff
  1423. Xsource for the man page.  You must typeset it using the -man macros.
  1424. XIf you cannot typeset it, the file dmake.p is a version that has been
  1425. Xtypeset for a normal dumb terminal.  The file dmake.p contains control
  1426. Xcharacters.  The file dmake.nc is a version of the man page that has
  1427. Xall of the control characters stripped.
  1428. X
  1429. X
  1430. XCREATING A NEW VERSION
  1431. X
  1432. XTo create yet another version of dmake you should follow the following steps.
  1433. X
  1434. XThe sysvr3 version as sent is the base version, all dmake versions must provide
  1435. Xthe equivalent of the functions defined in the sysvr3 directory, and MUST
  1436. Xprovide the same semantics (MSDOS archive lib searches are an exception since
  1437. Xwe cannot search libraries for timestamps in MSDOS, Actually the MKS version
  1438. Xof dmake does this, I don't have the time to add this code though).
  1439. X   eg. vms for VMS, or amiga for AMIGA.
  1440. X
  1441. X2. copy the files from unix and sysvr3 directories to the new dir.
  1442. X
  1443. X3. modify dmake.sh to contain the appropriate C compiler flags and link command
  1444. X   and to include any specific C files that you have had to add for this
  1445. X   version of dmake, and run the result through the shell.
  1446. X   (Also make the changes to config.mk once you have a working copy of
  1447. X   dmake)
  1448. X
  1449. X4. Not all OS/OSRELEASE combinations are compatible so in order to make
  1450. X   dmake on each, the particular directory may contain C-source for functions
  1451. X   present in the SVID SysV R3 distribution which are used by dmake but are
  1452. X   not supplied by the C-library in current use.  For example the bsd43
  1453. X   directory contains source for tempnam.c since it is not provided with
  1454. X   the BSD C-library.  Before writing a new version of the source file
  1455. X   check the other directories to see if one already exists.
  1456. X
  1457. X5. Under some systems the standard include files may be missing or incorrect.
  1458. X   eg. under BSD stdarg.h and string.h.  If this is the case
  1459. X   you should create the proper .h file in the proper directory.
  1460. X   This works as expected as the compile line includes the flag -Idir
  1461. X   where dir is the configuration dir, (bsd43 for example) and any
  1462. X   standard include files will be searched for in dir before the compiler
  1463. X   looks in the normal places.
  1464. X
  1465. X6. This should be all you require to create a new version of dmake.
  1466. X   If you have any questions send e-mail to dvadura@watdragon.uwaterloo.ca
  1467. SHAR_EOF
  1468. chmod 0640 _install || echo "restore of _install fails"
  1469. echo "x - extracting LICENSE (Text)"
  1470. sed 's/^X//' << 'SHAR_EOF' > LICENSE &&
  1471. X            GNU GENERAL PUBLIC LICENSE
  1472. X             Version 1, February 1989
  1473. X
  1474. X Copyright (C) 1989 Free Software Foundation, Inc.
  1475. X                    675 Mass Ave, Cambridge, MA 02139, USA
  1476. X Everyone is permitted to copy and distribute verbatim copies
  1477. X of this license document, but changing it is not allowed.
  1478. X
  1479. X                Preamble
  1480. X
  1481. X  The license agreements of most software companies try to keep users
  1482. Xat the mercy of those companies.  By contrast, our General Public
  1483. XLicense is intended to guarantee your freedom to share and change free
  1484. Xsoftware--to make sure the software is free for all its users.  The
  1485. XGeneral Public License applies to the Free Software Foundation's
  1486. Xsoftware and to any other program whose authors commit to using it.
  1487. XYou can use it for your programs, too.
  1488. X
  1489. X  When we speak of free software, we are referring to freedom, not
  1490. Xprice.  Specifically, the General Public License is designed to make
  1491. Xsure that you have the freedom to give away or sell copies of free
  1492. Xsoftware, that you receive source code or can get it if you want it,
  1493. SHAR_EOF
  1494. echo "End of part 20"
  1495. echo "File LICENSE is continued in part 21"
  1496. echo "21" > s2_seq_.tmp
  1497. exit 0
  1498.  
  1499.