home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / dmake / part07 < prev    next >
Encoding:
Text File  |  1992-01-29  |  40.3 KB  |  1,437 lines

  1. Newsgroups: comp.sources.misc
  2. From: dvadura@plg.waterloo.edu (Dennis Vadura)
  3. Subject:  v27i108:  dmake - dmake Version 3.8, Part07/41
  4. Message-ID: <1992Jan28.031346.7149@sparky.imd.sterling.com>
  5. X-Md4-Signature: 93621952264f40327b8491aa870d552a
  6. Date: Tue, 28 Jan 1992 03:13:46 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: dvadura@plg.waterloo.edu (Dennis Vadura)
  10. Posting-number: Volume 27, Issue 108
  11. Archive-name: dmake/part07
  12. Environment: Atari-ST, Coherent, Mac, MSDOS, OS/2, UNIX
  13. Supersedes: dmake: Volume 19, Issue 22-58
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. # this is dmake.shar.07 (part 7 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file dmake/dbug/malloc/testmlc.c continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 7; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test -f _shar_wnt_.tmp; then
  33. sed 's/^X//' << 'SHAR_EOF' >> 'dmake/dbug/malloc/testmlc.c' &&
  34. #ifndef lint
  35. static char *SQ_SccsId = "@(#)mtest3.c    1.2 88/08/25";
  36. #endif
  37. #include <stdio.h>
  38. /*
  39. ** looptest.c -- intensive allocator tester 
  40. **
  41. ** Usage:  looptest
  42. **
  43. ** History:
  44. **    4-Feb-1987 rtech!daveb 
  45. */
  46. X
  47. # ifdef SYS5
  48. # define random    rand
  49. # else
  50. # include <sys/vadvise.h>
  51. # endif
  52. X
  53. # include <stdio.h>
  54. # include <signal.h>
  55. # include <setjmp.h>
  56. X
  57. # define MAXITER    1000000        /* main loop iterations */
  58. # define MAXOBJS    1000        /* objects in pool */
  59. # define BIGOBJ        90000        /* max size of a big object */
  60. # define TINYOBJ    80        /* max size of a small object */
  61. # define BIGMOD        100        /* 1 in BIGMOD is a BIGOBJ */
  62. # define STATMOD    10000        /* interation interval for status */
  63. X
  64. main( argc, argv )
  65. int argc;
  66. char **argv;
  67. {
  68. X    register int **objs;        /* array of objects */
  69. X    register int *sizes;        /* array of object sizes */
  70. X    register int n;            /* iteration counter */
  71. X    register int i;            /* object index */
  72. X    register int size;        /* object size */
  73. X    register int r;            /* random number */
  74. X
  75. X    int objmax;            /* max size this iteration */
  76. X    int cnt;            /* number of allocated objects */
  77. X    int nm = 0;            /* number of mallocs */
  78. X    int nre = 0;            /* number of reallocs */
  79. X    int nal;            /* number of allocated objects */
  80. X    int nfre;            /* number of free list objects */
  81. X    long alm;            /* memory in allocated objects */
  82. X    long frem;            /* memory in free list */
  83. X    long startsize;            /* size at loop start */
  84. X    long endsize;            /* size at loop exit */
  85. X    long maxiter = 0;        /* real max # iterations */
  86. X
  87. X    extern char end;        /* memory before heap */
  88. X    char *calloc();
  89. X    char *malloc();
  90. X    char *sbrk();
  91. X    long atol();
  92. X
  93. # ifndef SYS5
  94. X    /* your milage may vary... */
  95. X    vadvise( VA_ANOM );
  96. # endif
  97. X
  98. X    if (argc > 1)
  99. X        maxiter = atol (argv[1]);
  100. X    if (maxiter <= 0)
  101. X        maxiter = MAXITER;
  102. X
  103. X    printf("MAXITER %d MAXOBJS %d ", maxiter, MAXOBJS );
  104. X    printf("BIGOBJ %d, TINYOBJ %d, nbig/ntiny 1/%d\n",
  105. X    BIGOBJ, TINYOBJ, BIGMOD );
  106. X    fflush( stdout );
  107. X
  108. X    if( NULL == (objs = (int **)calloc( MAXOBJS, sizeof( *objs ) ) ) )
  109. X    {
  110. X        fprintf(stderr, "Can't allocate memory for objs array\n");
  111. X        exit(1);
  112. X    }
  113. X
  114. X    if( NULL == ( sizes = (int *)calloc( MAXOBJS, sizeof( *sizes ) ) ) )
  115. X    {
  116. X        fprintf(stderr, "Can't allocate memory for sizes array\n");
  117. X        exit(1);
  118. X    }
  119. X
  120. X    /* as per recent discussion on net.lang.c, calloc does not 
  121. X    ** necessarily fill in NULL pointers...
  122. X    */
  123. X    for( i = 0; i < MAXOBJS; i++ )
  124. X        objs[ i ] = NULL;
  125. X
  126. X    startsize = sbrk(0) - &end;
  127. X    printf( "Memory use at start: %d bytes\n", startsize );
  128. X    fflush(stdout);
  129. X
  130. X    printf("Starting the test...\n");
  131. X    fflush(stdout);
  132. X    for( n = 0; n < maxiter ; n++ )
  133. X    {
  134. X        if( !(n % STATMOD) )
  135. X        {
  136. X            printf("%d iterations\n", n);
  137. X            fflush(stdout);
  138. X        }
  139. X
  140. X        /* determine object of interst and it's size */
  141. X
  142. X        r = random();
  143. X        objmax = ( r % BIGMOD ) ? TINYOBJ : BIGOBJ;
  144. X        size = r % objmax;
  145. X        i = r % (MAXOBJS - 1);
  146. X
  147. X        /* either replace the object of get a new one */
  148. X
  149. X        if( objs[ i ] == NULL )
  150. X        {
  151. X            objs[ i ] = (int *)malloc( size );
  152. X            nm++;
  153. X        }
  154. X        else
  155. X        {
  156. X            /* don't keep bigger objects around */
  157. X            if( size > sizes[ i ] )
  158. X            {
  159. X                objs[ i ] = (int *)realloc( objs[ i ], size );
  160. X                nre++;
  161. X            }
  162. X            else
  163. X            {
  164. X                free( objs[ i ] );
  165. X                objs[ i ] = (int *)malloc( size );
  166. X                nm++;
  167. X            }
  168. X        }
  169. X
  170. X        sizes[ i ] = size;
  171. X        if( objs[ i ] == NULL )
  172. X        {
  173. X            printf("\nCouldn't allocate %d byte object!\n", 
  174. X                size );
  175. X            break;
  176. X        }
  177. X    } /* for() */
  178. X
  179. X    printf( "\n" );
  180. X    cnt = 0;
  181. X    for( i = 0; i < MAXOBJS; i++ )
  182. X        if( objs[ i ] )
  183. X            cnt++;
  184. X
  185. X    printf( "Did %d iterations, %d objects, %d mallocs, %d reallocs\n",
  186. X        n, cnt, nm, nre );
  187. X    printf( "Memory use at end: %d bytes\n", sbrk(0) - &end );
  188. X    fflush( stdout );
  189. X
  190. X    /* free all the objects */
  191. X    for( i = 0; i < MAXOBJS; i++ )
  192. X        if( objs[ i ] != NULL )
  193. X            free( objs[ i ] );
  194. X
  195. X    endsize = sbrk(0) - &end;
  196. X    printf( "Memory use after free: %d bytes\n", endsize );
  197. X    fflush( stdout );
  198. X
  199. X    if( startsize != endsize )
  200. X        printf("startsize %d != endsize %d\n", startsize, endsize );
  201. X
  202. X    free( objs );
  203. X    free( sizes );
  204. X
  205. X    malloc_dump(2);
  206. X    exit( 0 );
  207. }
  208. X
  209. SHAR_EOF
  210. chmod 0640 dmake/dbug/malloc/testmlc.c ||
  211. echo 'restore of dmake/dbug/malloc/testmlc.c failed'
  212. Wc_c="`wc -c < 'dmake/dbug/malloc/testmlc.c'`"
  213. test 3971 -eq "$Wc_c" ||
  214.     echo 'dmake/dbug/malloc/testmlc.c: original size 3971, current size' "$Wc_c"
  215. rm -f _shar_wnt_.tmp
  216. fi
  217. # ============= dmake/dbug/malloc/tostring.c ==============
  218. if test -f 'dmake/dbug/malloc/tostring.c' -a X"$1" != X"-c"; then
  219.     echo 'x - skipping dmake/dbug/malloc/tostring.c (File already exists)'
  220.     rm -f _shar_wnt_.tmp
  221. else
  222. > _shar_wnt_.tmp
  223. sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/tostring.c' &&
  224. /*
  225. X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).  
  226. X * You may copy, distribute, and use this software as long as this
  227. X * copyright statement is not removed.
  228. X */
  229. #include "tostring.h"
  230. X
  231. /*
  232. X * Function:    tostring()
  233. X *
  234. X * Purpose:    to convert an integer to an ascii display string
  235. X *
  236. X * Arguments:    buf    - place to put the 
  237. X *        val    - integer to convert
  238. X *        len    - length of output field (0 if just enough to hold data)
  239. X *        base    - base for number conversion (only works for base <= 16)
  240. X *        fill    - fill char when len > # digits
  241. X *
  242. X * Returns:    length of string
  243. X *
  244. X * Narrative:    IF fill character is non-blank
  245. X *            Determine base
  246. X *                If base is HEX
  247. X *                    add "0x" to begining of string
  248. X *                IF base is OCTAL
  249. X *                    add "0" to begining of string
  250. X *
  251. X *        While value is greater than zero
  252. X *            use val % base as index into xlation str to get cur char
  253. X *            divide val by base
  254. X *
  255. X *        Determine fill-in length
  256. X *
  257. X *        Fill in fill chars
  258. X *
  259. X *        Copy in number
  260. X *        
  261. X *
  262. X * Mod History:    
  263. X *   90/01/24    cpcahil        Initial revision.
  264. X */
  265. X
  266. #ifndef lint
  267. static
  268. char rcs_hdr[] = "$Id: tostring.c,v 1.1 1992/01/24 03:29:16 dvadura Exp $";
  269. #endif
  270. X
  271. #define T_LEN 10
  272. X
  273. int
  274. tostring(buf,val,len,base,fill)
  275. X    int      base;
  276. X    char    * buf;
  277. X    char      fill;
  278. X    int      len;
  279. X    int      val;
  280. X    
  281. {
  282. X    char    * bufstart = buf;
  283. X    int      i = T_LEN;
  284. X    char    * xbuf = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  285. X    char      tbuf[T_LEN];
  286. X
  287. X    /*
  288. X     * if we are filling with non-blanks, make sure the
  289. X     * proper start string is added
  290. X     */
  291. X    if( fill != ' ' )
  292. X    {
  293. X        switch(base)
  294. X        {
  295. X            case B_HEX:
  296. X                *(buf++) = '0';
  297. X                *(buf++) = 'x';
  298. X                if( len )
  299. X                {
  300. X                    len -= 2;
  301. X                }
  302. X                break;
  303. X            case B_OCTAL:
  304. X                *(buf++) = fill;
  305. X                if( len )
  306. X                {
  307. X                    len--;
  308. X                }
  309. X                break;
  310. X            default:
  311. X                break;
  312. X        }
  313. X    }
  314. X
  315. X    while( val > 0 )
  316. X    {
  317. X        tbuf[--i] = xbuf[val % base];
  318. X        val = val / base;
  319. X    }
  320. X
  321. X    if( len )
  322. X    {
  323. X        len -= (T_LEN - i);
  324. X
  325. X        if( len > 0 )
  326. X        {
  327. X            while(len-- > 0)
  328. X            {
  329. X                *(buf++) = fill;
  330. X            }
  331. X        }
  332. X        else
  333. X        {
  334. X            /* 
  335. X             * string is too long so we must truncate
  336. X             * off some characters.  We do this the easiest
  337. X             * way by just incrementing i.  This means the
  338. X             * most significant digits are lost.
  339. X             */
  340. X            while( len++ < 0 )
  341. X            {
  342. X                i++;
  343. X            }
  344. X        }
  345. X    }
  346. X
  347. X    while( i < T_LEN )
  348. X    {
  349. X        *(buf++) = tbuf[i++];
  350. X    }
  351. X
  352. X    return( (int) (buf - bufstart) );
  353. X
  354. } /* tostring(... */
  355. X
  356. /*
  357. X * $Log: tostring.c,v $
  358. X * Revision 1.1  1992/01/24  03:29:16  dvadura
  359. X * dmake Version 3.8, Initial revision
  360. X *
  361. X * Revision 1.4  90/05/11  00:13:11  cpcahil
  362. X * added copyright statment
  363. X * 
  364. X * Revision 1.3  90/02/24  21:50:33  cpcahil
  365. X * lots of lint fixes
  366. X * 
  367. X * Revision 1.2  90/02/24  17:29:42  cpcahil
  368. X * changed $Header to $Id so full path wouldnt be included as part of rcs 
  369. X * id string
  370. X * 
  371. X * Revision 1.1  90/02/22  23:17:44  cpcahil
  372. X * Initial revision
  373. X * 
  374. X */
  375. SHAR_EOF
  376. chmod 0640 dmake/dbug/malloc/tostring.c ||
  377. echo 'restore of dmake/dbug/malloc/tostring.c failed'
  378. Wc_c="`wc -c < 'dmake/dbug/malloc/tostring.c'`"
  379. test 2807 -eq "$Wc_c" ||
  380.     echo 'dmake/dbug/malloc/tostring.c: original size 2807, current size' "$Wc_c"
  381. rm -f _shar_wnt_.tmp
  382. fi
  383. # ============= dmake/dbug/malloc/tostring.h ==============
  384. if test -f 'dmake/dbug/malloc/tostring.h' -a X"$1" != X"-c"; then
  385.     echo 'x - skipping dmake/dbug/malloc/tostring.h (File already exists)'
  386.     rm -f _shar_wnt_.tmp
  387. else
  388. > _shar_wnt_.tmp
  389. sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/tostring.h' &&
  390. /*
  391. X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).  
  392. X * You may copy, distribute, and use this software as long as this
  393. X * copyright statement is not removed.
  394. X */
  395. /*
  396. X * $Id: tostring.h,v 1.1 1992/01/24 03:29:17 dvadura Exp $
  397. X */
  398. #define B_BIN     2
  399. #define B_DEC    10
  400. #define B_HEX    16
  401. #define B_OCTAL     8
  402. X
  403. /* 
  404. X * $Log: tostring.h,v $
  405. X * Revision 1.1  1992/01/24  03:29:17  dvadura
  406. X * dmake Version 3.8, Initial revision
  407. X *
  408. X * Revision 1.2  90/05/11  00:13:11  cpcahil
  409. X * added copyright statment
  410. X * 
  411. X * Revision 1.1  90/02/23  07:09:05  cpcahil
  412. X * Initial revision
  413. X * 
  414. X */
  415. SHAR_EOF
  416. chmod 0640 dmake/dbug/malloc/tostring.h ||
  417. echo 'restore of dmake/dbug/malloc/tostring.h failed'
  418. Wc_c="`wc -c < 'dmake/dbug/malloc/tostring.h'`"
  419. test 582 -eq "$Wc_c" ||
  420.     echo 'dmake/dbug/malloc/tostring.h: original size 582, current size' "$Wc_c"
  421. rm -f _shar_wnt_.tmp
  422. fi
  423. # ============= dmake/dmake.c ==============
  424. if test -f 'dmake/dmake.c' -a X"$1" != X"-c"; then
  425.     echo 'x - skipping dmake/dmake.c (File already exists)'
  426.     rm -f _shar_wnt_.tmp
  427. else
  428. > _shar_wnt_.tmp
  429. sed 's/^X//' << 'SHAR_EOF' > 'dmake/dmake.c' &&
  430. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/dmake.c,v 1.1 1992/01/24 03:26:58 dvadura Exp $
  431. -- SYNOPSIS -- The main program.
  432. -- 
  433. -- DESCRIPTION
  434. -- 
  435. --     dmake [-#dbug_string] [ options ]
  436. --             [ macro definitions ] [ target ... ]
  437. -- 
  438. --     This file contains the main command line parser for the
  439. --     make utility.  The valid flags recognized are as follows:
  440. -- 
  441. --     -f file         - use file as the makefile
  442. --    -C file        - duplicate console output to file (MSDOS only)
  443. --    -K file        - .KEEP_STATE file
  444. --     -#dbug_string   - dump out debugging info, see below
  445. --     -v{dfimt}    - verbose, print what we are doing, as we do it.
  446. -- 
  447. --      options: (can be catenated, ie -irn == -i -r -n)
  448. -- 
  449. --    -A        - enable AUGMAKE special target mapping
  450. --    -B        - enable non-use of TABS to start recipe lines
  451. --    -c        - use non-standard comment scanning
  452. --     -i              - ignore errors
  453. --     -n              - trace and print, do not execute commands
  454. --     -t              - touch, update dates without executing commands
  455. --     -T              - do not apply transitive closure on inference rules
  456. --     -r              - don't use internal rules
  457. --     -s              - do your work silently
  458. --    -S        - force Sequential make, overrides -P
  459. --     -q              - check if target is up to date.  Does not
  460. --               do anything.  Returns 0 if up to date, -1
  461. --               otherwise.
  462. --     -p              - print out a version of the makefile
  463. --    -P#        - set value of MAXPROCESS
  464. --     -E              - define environment strings as macros
  465. --     -e              - as -E but done after parsing makefile
  466. --     -u              - force unconditional update of target
  467. --     -k              - make all independent targets even if errors
  468. --     -V              - print out this make version number
  469. --     -M        - Microsoft make compatibility, (* disabled *)
  470. --     -h              - print out usage info
  471. --     -x        - export macro defs to environment
  472. -- 
  473. --     NOTE:  - #ddbug_string is only availabe for versions of dmake that
  474. --         have been compiled with -DDBUG switch on.  Not the case for
  475. --         distributed versions.  Any such versions must be linked
  476. --         together with a version of Fred Fish's debug code.
  477. --              
  478. --     NOTE:  - in order to compile the code the include file stddef.h
  479. --         must be shipped with the bundled code.
  480. -- 
  481. -- AUTHOR
  482. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  483. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  484. --
  485. -- COPYRIGHT
  486. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  487. -- 
  488. --      This program is free software; you can redistribute it and/or
  489. --      modify it under the terms of the GNU General Public License
  490. --      (version 1), as published by the Free Software Foundation, and
  491. --      found in the file 'LICENSE' included with this distribution.
  492. -- 
  493. --      This program is distributed in the hope that it will be useful,
  494. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  495. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  496. --      GNU General Public License for more details.
  497. -- 
  498. --      You should have received a copy of the GNU General Public License
  499. --      along with this program;  if not, write to the Free Software
  500. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  501. --
  502. -- LOG
  503. --     $Log: dmake.c,v $
  504. X * Revision 1.1  1992/01/24  03:26:58  dvadura
  505. X * dmake Version 3.8, Initial revision
  506. X *
  507. */
  508. X
  509. /* Set this flag to one, and the global variables in vextern.h will not
  510. X * be defined as 'extern', instead they will be defined as global vars
  511. X * when this module is compiled. */
  512. #define _DEFINE_GLOBALS_ 1
  513. X
  514. #include "extern.h"
  515. #include "patchlvl.h"
  516. #include "version.h"
  517. X
  518. #ifndef MSDOS
  519. #define USAGE \
  520. "Usage:\n%s [-ABceEhiknpqrsStTuVx] [-v{dfimt}] [-P#] [-{f|K} file] [macro[*][+][:]=value ...] [target ...]\n"
  521. #else
  522. #define USAGE \
  523. "Usage:\n%s [-ABceEhiknpqrsStTuVx] [-v{dfimt}] [-P#] [-{f|C|K} file] [macro[*][+][:]=value ...] [target ...]\n"
  524. #endif
  525. X
  526. #if __STDC__ == 1
  527. void Fatal(char *fmt, ...);
  528. void Warning(char *fmt, ...);
  529. #endif
  530. X
  531. static char *sccid = "Copyright (c) 1990,1991 by Dennis Vadura";
  532. static char _warn  = TRUE;        /* warnings on by default */
  533. X
  534. static    void    _do_VPATH();
  535. static    void    _do_ReadEnvironment();
  536. static  void    _do_f_flag ANSI((char, char *, char **));
  537. X
  538. PUBLIC int
  539. main(argc, argv)
  540. int  argc;
  541. char **argv;
  542. {
  543. #ifdef MSDOS
  544. X   char*   std_fil_name = NIL(char);
  545. #endif
  546. X
  547. X   char*   fil_name = NIL(char);
  548. X   char*   state_name = NIL(char);
  549. X   char*   cmdmacs;
  550. X   char*   targets;
  551. X   FILE*   mkfil;
  552. X   int     ex_val;
  553. X   int     m_export;
  554. X
  555. X   DB_ENTER("main");
  556. X
  557. X   /* Initialize Global variables to their default values       */
  558. X   Prolog(argc, argv);
  559. X   Create_macro_vars();
  560. X   Catch_signals(Quit);
  561. X
  562. X   Def_macro( "MAKECMD", Pname, M_PRECIOUS|M_NOEXPORT );
  563. X   Pname = basename(Pname);
  564. X
  565. X   DB_PROCESS(Pname);
  566. X   (void) setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* stdout line buffered */
  567. X
  568. X   Continue  = FALSE;
  569. X   Comment   = FALSE;
  570. X   Get_env   = FALSE;
  571. X   Force     = FALSE;
  572. X   Target    = FALSE;
  573. X   If_expand = FALSE;
  574. X   Listing   = FALSE;
  575. X   Readenv   = FALSE;
  576. X   Rules     = TRUE;
  577. X   Trace     = FALSE;
  578. X   Touch     = FALSE;
  579. X   Check     = FALSE;
  580. X   Microsoft = FALSE;
  581. X   Makemkf   = FALSE;
  582. X   m_export  = FALSE;
  583. X   cmdmacs   = NIL(char);
  584. X   targets   = NIL(char);
  585. X
  586. X   Verbose     = V_NONE;
  587. X   Transitive  = TRUE;
  588. X   Nest_level  = 0;
  589. X   Line_number = 0;
  590. X   Suppress_temp_file = FALSE;
  591. X
  592. X   while( --argc > 0 ) {
  593. X      register char *p;
  594. X      char *q;
  595. X
  596. X      if( *(p = *++argv) == '-' ) {
  597. X         if( p[1] == '\0' ) Fatal("Missing option letter");
  598. X
  599. X         /* copy options to Buffer for $(MFLAGS), strip 'f' and 'C'*/
  600. X         q = strchr(Buffer, '\0');
  601. X         while (*p != '\0') {
  602. X        char c = (*q++ = *p++);
  603. X            if( c == 'f' || c == 'C' ) q--;
  604. X     }
  605. X
  606. X     if( *(q-1) == '-' )
  607. X        q--;
  608. X     else
  609. X            *q++ = ' ';
  610. X
  611. X     *q = '\0';
  612. X
  613. X         for( p = *argv+1; *p; p++) switch (*p) {
  614. X        case 'f':
  615. X           _do_f_flag( 'f', *++argv, &fil_name ); argc--;
  616. X           break;
  617. X
  618. #if defined(MSDOS) && !defined(OS2)
  619. X        case 'C':
  620. X           _do_f_flag( 'C', *++argv, &std_fil_name ); argc--;
  621. X           Hook_std_writes( std_fil_name );
  622. X           break;
  623. #endif
  624. X
  625. X        case 'K':
  626. X           _do_f_flag( 'K', *++argv, &state_name ); argc--;
  627. X           Def_macro(".KEEP_STATE", state_name, M_EXPANDED|M_PRECIOUS);
  628. X           break;
  629. X
  630. X        case 'k': Continue   = TRUE;  break;
  631. X        case 'c': Comment    = TRUE;  break;
  632. X        case 'p': Listing    = TRUE;  break;
  633. X        case 'r': Rules      = FALSE; break;
  634. X        case 'n': Trace      = TRUE;  break;
  635. X        case 't': Touch      = TRUE;  break;
  636. X        case 'q': Check      = TRUE;  break;
  637. X        case 'u': Force      = TRUE;  break;
  638. X        case 'x': m_export   = TRUE;  break;
  639. X        case 'T': Transitive = FALSE; break;
  640. X        case 'e': Get_env    = 'e';   break;
  641. X        case 'E': Get_env    = 'E';   break;
  642. X
  643. X        case 'V': Version();  Quit(NIL(CELL));  break;
  644. X        case 'A': Def_macro("AUGMAKE", "y", M_EXPANDED); break;
  645. X        case 'B': Def_macro(".NOTABS", "y", M_EXPANDED); break;
  646. X        case 'i': Def_macro(".IGNORE", "y", M_EXPANDED); break;
  647. X        case 's': Def_macro(".SILENT", "y", M_EXPANDED); break;
  648. X        case 'S': Def_macro(".SEQUENTIAL", "y", M_EXPANDED); break;
  649. X
  650. X        case 'v':
  651. X           if( p[-1] != '-' ) Usage(TRUE);
  652. X           while( p[1] ) switch( *++p ) {
  653. X          case 'd': Verbose |= V_PRINT_DIR; break;
  654. X          case 'f': Verbose |= V_FILE_IO;   break;
  655. X          case 'i': Verbose |= V_INFER;     break;
  656. X          case 'm': Verbose |= V_MAKE;      break;
  657. X          case 't': Verbose |= V_LEAVE_TMP; break;
  658. X
  659. X          default: Usage(TRUE); break;
  660. X           }
  661. X           if( !Verbose ) Verbose = V_ALL;
  662. X           break;
  663. X
  664. X        case 'P':
  665. X           if( p[1] ) {
  666. X          Def_macro( "MAXPROCESS", p+1, M_MULTI|M_EXPANDED );
  667. X          p += strlen(p)-1;
  668. X           }
  669. X           else
  670. X          Fatal( "Missing number for -P flag" );
  671. X           break;
  672. X
  673. #ifdef DBUG
  674. X        case '#':
  675. X           DB_PUSH(p+1);
  676. X           p += strlen(p)-1;
  677. X           break;
  678. #endif
  679. X
  680. X        case 'h': Usage(FALSE); break;
  681. X        case 0:   break;    /* lone - */
  682. X        default:  Usage(TRUE);  break;
  683. X     }
  684. X      }
  685. X      else if( (q = strchr(p, '=')) != NIL(char) ) {
  686. X     cmdmacs = _stradd( cmdmacs, _strdup2(p), TRUE );
  687. X     Parse_macro( p, (q[-1]!='+')?M_PRECIOUS:M_DEFAULT );
  688. X      }
  689. X      else {
  690. X     register CELLPTR cp;
  691. X     targets = _stradd( targets, _strdup(p), TRUE );
  692. X     Add_prerequisite(Root, cp = Def_cell(p), FALSE, FALSE);
  693. X     cp->ce_flag |= F_TARGET;
  694. X     cp->ce_attr |= A_FRINGE;
  695. X     Target = TRUE;
  696. X      }
  697. X   }
  698. X
  699. X   Def_macro( "MAKEMACROS",  cmdmacs, M_PRECIOUS|M_NOEXPORT );
  700. X   Def_macro( "MAKETARGETS", targets, M_PRECIOUS|M_NOEXPORT );
  701. X   if( cmdmacs != NIL(char) ) FREE(cmdmacs);
  702. X   if( targets != NIL(char) ) FREE(targets);
  703. X
  704. X   Def_macro( "MFLAGS", Buffer, M_PRECIOUS|M_NOEXPORT );
  705. X   Def_macro( "%", "$@", M_PRECIOUS|M_NOEXPORT );
  706. X
  707. X   if( *Buffer ) Def_macro( "MAKEFLAGS", Buffer+1, M_PRECIOUS|M_NOEXPORT );
  708. X
  709. X   _warn  = FALSE;      /* disable warnings for builtin rules */
  710. X   ex_val = Target;     /* make sure we don't mark any        */
  711. X   Target = TRUE;       /* of the default rules as            */
  712. X   Make_rules();        /* potential targets                  */
  713. X   _warn = TRUE;
  714. X
  715. X   if( Rules ) {
  716. X      char *fname;
  717. X
  718. X      if( (mkfil=Search_file("MAKESTARTUP", &fname)) != NIL(FILE) ) {
  719. X         Parse(mkfil);
  720. X     Def_macro( "MAKESTARTUP", fname, M_EXPANDED|M_MULTI );
  721. X         mkfil = NIL(FILE);
  722. X      }
  723. X      else
  724. X         Fatal( "Configuration file `%s' not found", fname );
  725. X   }
  726. X
  727. X   Target = ex_val;
  728. X
  729. X   if( Get_env == 'E' ) _do_ReadEnvironment();
  730. X
  731. X   if( fil_name != NIL(char) )
  732. X      mkfil = Openfile( fil_name, FALSE, TRUE );
  733. X   else {
  734. X      /* Search .MAKEFILES dependent list looking for a makefile.
  735. X       */
  736. X      register CELLPTR cp;
  737. X      register LINKPTR lp;
  738. X
  739. X      cp = Def_cell( ".MAKEFILES" );
  740. X
  741. X      if( (lp = cp->CE_PRQ) != NIL(LINK) ) {
  742. X         int s_n, s_t, s_q;
  743. X
  744. X         s_n = Trace;
  745. X         s_t = Touch;
  746. X         s_q = Check;
  747. X
  748. X         Trace = Touch = Check = FALSE;
  749. X         Makemkf = Wait_for_completion = TRUE;
  750. X         mkfil = NIL(FILE);
  751. X
  752. X         for(;  lp != NIL(LINK) && mkfil == NIL(FILE); lp=lp->cl_next) {
  753. X        if( lp->cl_prq->ce_attr & A_FRINGE ) continue;
  754. X
  755. X            mkfil = Openfile( lp->cl_prq->CE_NAME, FALSE, FALSE );
  756. X
  757. X            if( mkfil == NIL(FILE) &&
  758. X        Make(lp->cl_prq, NIL(CELL)) != -1 )
  759. X               mkfil = Openfile( lp->cl_prq->CE_NAME, FALSE, FALSE );
  760. X         }
  761. X
  762. X         Trace = s_n;
  763. X         Touch = s_t;
  764. X         Check = s_q;
  765. X         Makemkf = Wait_for_completion = FALSE;
  766. X      }
  767. X   }
  768. X
  769. X   if( mkfil != NIL(FILE) ) {
  770. X      char *f = Filename();
  771. X      char *p;
  772. X
  773. X      if( strcmp(f, "stdin") == 0 ) f = "-";
  774. X      p = _stradd( "-f", f, FALSE );
  775. X      Def_macro( "MAKEFILE", p, M_PRECIOUS|M_NOEXPORT );
  776. X      Parse( mkfil );
  777. X   }
  778. X   else if( !Rules )
  779. X      Fatal( "No `makefile' present" );
  780. X
  781. X   if( Nest_level     ) Fatal( "Missing .END for .IF" );
  782. X   if( Get_env == 'e' ) _do_ReadEnvironment();
  783. X
  784. X   _do_VPATH();                  /* kludge it up with .SOURCE    */
  785. X
  786. X   if( Listing ) Dump();        /* print out the structures     */
  787. X   if( Trace ) Glob_attr &= ~A_SILENT;    /* make sure we see the trace   */
  788. X
  789. X   if( !Target )
  790. X      Fatal( "No target" );
  791. X   else {
  792. X      Test_circle( Root, TRUE );
  793. X      Check_circle_dfa();
  794. X   }
  795. X
  796. X   Push_dir( Start_dir, ".SETDIR", (int)(Glob_attr & A_IGNORE ));
  797. X
  798. X   if( m_export ) {
  799. X      int i;
  800. X
  801. X      for( i=0; i<HASH_TABLE_SIZE; ++i ) {
  802. X     HASHPTR hp = Macs[i];
  803. X
  804. X     while( hp ) {
  805. X        if( !(hp->ht_flag & M_NOEXPORT) && hp->ht_value != NIL(char) )
  806. X           if( Write_env_string(hp->ht_name, hp->ht_value) != 0 )
  807. X           Warning( "Could not export %s", hp->ht_name );
  808. X        hp = hp->ht_next;
  809. X     }
  810. X      }
  811. X   }
  812. X   if( Buffer != NIL(char) ) {FREE( Buffer ); Buffer = NIL(char);}
  813. X   if( Trace ) Def_macro(".SEQUENTIAL", "y", M_EXPANDED);
  814. X   if( Glob_attr & A_SEQ ) Def_macro( "MAXPROCESS", "1", M_EXPANDED|M_FORCE );
  815. X
  816. X   ex_val = Make_targets();
  817. X
  818. X   Pop_dir( (Glob_attr & A_IGNORE) != 0 );
  819. X   Clear_signals();
  820. X   Epilog(ex_val);      /* Does not return -- EVER */
  821. }
  822. X
  823. X
  824. static void
  825. _do_f_flag( flag, name, fname )
  826. char  flag;
  827. char *name;
  828. char **fname;
  829. {
  830. X   if( *fname == NIL(char) ) {
  831. X      if( name != NIL(char) ) {
  832. X     *fname = name;
  833. X      } else
  834. X     Fatal("No file name for -%c", flag);
  835. X   } else
  836. X      Fatal("Only one `-%c file' allowed", flag);
  837. }
  838. X
  839. X
  840. static void
  841. _do_ReadEnvironment()
  842. {
  843. X   t_attr saveattr = Glob_attr;
  844. X
  845. X   Glob_attr |= A_SILENT;
  846. X   ReadEnvironment();
  847. X   Glob_attr = saveattr;
  848. }
  849. X
  850. X
  851. static void
  852. _do_VPATH()
  853. {
  854. X   HASHPTR hp;
  855. X   char    *_rl[2];
  856. X   extern char **Rule_tab;
  857. X
  858. X   hp = GET_MACRO("VPATH");
  859. X   if( hp == NIL(HASH) ) return;
  860. X
  861. X   _rl[0] = ".SOURCE :^ $(VPATH:s/:/ /)";
  862. X   _rl[1] = NIL(char);
  863. X
  864. X   Rule_tab = _rl;
  865. X   Parse( NIL(FILE) );
  866. }
  867. X
  868. X
  869. /*  The file table and pointer to the next FREE slot for use by both
  870. X    Openfile and Closefile.  Each open stacks the new file onto the open
  871. X    file stack, and a corresponding close will close the passed file, and
  872. X    return the next file on the stack.  The maximum number of nested
  873. X    include files is limited by the value of MAX_INC_DEPTH */
  874. X
  875. static struct {
  876. X   FILE         *file;      /* file pointer                 */
  877. X   char         *name;      /* name of file                 */
  878. X   int          numb;       /* line number                  */
  879. } ftab[ MAX_INC_DEPTH ];
  880. X
  881. static int next_file_slot = 0;
  882. X
  883. /* Set the proper macro value to reflect the depth of the .INCLUDE directives.
  884. X */
  885. static void
  886. _set_inc_depth()
  887. {
  888. X   char buf[10];
  889. X   sprintf( buf, "%d", next_file_slot );
  890. X   Def_macro( "INCDEPTH", buf, M_MULTI|M_NOEXPORT );
  891. }
  892. X
  893. X
  894. PUBLIC FILE *
  895. Openfile(name, mode, err)/*
  896. ===========================
  897. X   This routine opens a file for input or output depending on mode.
  898. X   If the file name is `-' then it returns standard input.
  899. X   The file is pushed onto the open file stack.  */
  900. char *name;
  901. int  mode;
  902. int  err;
  903. {
  904. X   FILE *fil;
  905. X
  906. X   DB_ENTER("Openfile");
  907. X
  908. X   if( name == NIL(char) || !*name )
  909. X      if( !err )
  910. X         DB_RETURN(NIL(FILE));
  911. X      else
  912. X         Fatal( "Openfile:  NIL filename" );
  913. X   
  914. X   if( next_file_slot == MAX_INC_DEPTH )
  915. X      Fatal( "Too many open files. Max nesting level is %d.", MAX_INC_DEPTH);
  916. X
  917. X   DB_PRINT( "io", ("Opening file [%s], in slot %d", name, next_file_slot) );
  918. X
  919. X   if( strcmp("-", name) == 0 ) {
  920. X      name = "stdin";
  921. X      fil = stdin;
  922. X   }
  923. X   else
  924. X      fil = fopen( name, mode ? "w":"r" );
  925. X
  926. X   if( Verbose & V_FILE_IO )
  927. X      printf( "%s:  Openning [%s] for %s", Pname, name, mode?"write":"read" );
  928. X
  929. X   if( fil == NIL(FILE) ) {
  930. X      if( Verbose & V_FILE_IO ) printf( " (fail)\n" );
  931. X      if( err )
  932. X         Fatal( mode ? "Cannot open file %s for write" : "File %s not found",
  933. X        name );
  934. X   }
  935. X   else {
  936. X      if( Verbose & V_FILE_IO ) printf( " (success)\n" );
  937. X      ftab[next_file_slot].file   = fil;
  938. X      ftab[next_file_slot].numb   = Line_number;
  939. X      ftab[next_file_slot++].name = _strdup(name);
  940. X      Line_number = 0;
  941. X      _set_inc_depth();
  942. X   }
  943. X
  944. X   DB_RETURN(fil);
  945. }
  946. X
  947. X
  948. PUBLIC FILE *
  949. Closefile()/*
  950. =============
  951. X   This routine is used to close the last file opened.  This forces make
  952. X   to open files in a last open first close fashion.  It returns the
  953. X   file pointer to the next file on the stack, and NULL if the stack is empty.*/
  954. {
  955. X   DB_ENTER("Closefile");
  956. X
  957. X   if( !next_file_slot )
  958. X      DB_RETURN( NIL(FILE) );
  959. X
  960. X   if( ftab[--next_file_slot].file != stdin ) {
  961. X      DB_PRINT( "io", ("Closing file in slot %d", next_file_slot) );
  962. X
  963. X      if( Verbose & V_FILE_IO )
  964. X     printf( "%s:  Closing [%s]\n", Pname, ftab[next_file_slot].name );
  965. X
  966. X      fclose( ftab[next_file_slot].file );
  967. X      FREE( ftab[next_file_slot].name );
  968. X   }
  969. X
  970. X   _set_inc_depth();
  971. X
  972. X   if( next_file_slot > 0 ) {
  973. X      Line_number = ftab[next_file_slot].numb;
  974. X      DB_RETURN( ftab[next_file_slot-1].file );
  975. X   }
  976. X   else
  977. X      Line_number = 0;
  978. X
  979. X   DB_RETURN( NIL(FILE) );
  980. }
  981. X
  982. X
  983. PUBLIC FILE *
  984. Search_file( macname, rname )
  985. char *macname;
  986. char **rname;
  987. {
  988. X   HASHPTR hp;
  989. X   FILE *fil = NIL(FILE);
  990. X   char *fname;
  991. X   char *ename = NIL(char);
  992. X
  993. X   /* order of precedence is:
  994. X    *
  995. X    *   MACNAME  from command line (precious is marked)
  996. X    *         ... via MACNAME:=filename definition.
  997. X    *   MACNAME  from environment
  998. X    *   MACNAME  from builtin rules (not precious)
  999. X    */
  1000. X
  1001. X   if( (hp = GET_MACRO(macname)) != NIL(HASH) )
  1002. X      ename = fname = Expand(hp->ht_value);
  1003. X
  1004. X   if( hp->ht_flag & M_PRECIOUS ) fil = Openfile(fname, FALSE, FALSE);
  1005. X
  1006. X   if( fil == NIL(FILE) ) {
  1007. X      fname=Expand(Read_env_string(macname));
  1008. X      if( fil = Openfile(fname, FALSE, FALSE) ) FREE(ename);
  1009. X   }
  1010. X
  1011. X   if( fil == NIL(FILE) && hp != NIL(HASH) )
  1012. X      fil = Openfile(fname=ename, FALSE, FALSE);
  1013. X
  1014. X   if( rname ) *rname = fname;
  1015. X
  1016. X   return(fil);
  1017. }
  1018. X
  1019. X
  1020. PUBLIC char *
  1021. Filename()/*
  1022. ============
  1023. X   Return name of file on top of stack */
  1024. {
  1025. X   return( next_file_slot==0 ? NIL(char) : ftab[next_file_slot-1].name );
  1026. }
  1027. X
  1028. X
  1029. PUBLIC int
  1030. Nestlevel()/*
  1031. =============
  1032. X   Return the file nesting level */
  1033. {
  1034. X   return( next_file_slot );
  1035. }
  1036. X
  1037. X
  1038. /*
  1039. ** print error message from variable arg list
  1040. */
  1041. X
  1042. static int errflg = TRUE;
  1043. static int warnflg = FALSE;
  1044. X
  1045. static void
  1046. errargs(fmt, args)
  1047. char    *fmt;
  1048. va_list  args;
  1049. {
  1050. X   int warn = _warn && warnflg && !(Glob_attr & A_SILENT);
  1051. X
  1052. X   if( errflg || warn ) {
  1053. X      char *f = Filename();
  1054. X
  1055. X      fprintf( stderr, "%s:  ", Pname );
  1056. X      if( f != NIL(char) ) fprintf(stderr, "%s:  line %d:  ", f, Line_number);
  1057. X
  1058. X      if( errflg )
  1059. X         fprintf(stderr, "Error -- ");
  1060. X      else if( warn )
  1061. X         fprintf(stderr, "Warning -- ");
  1062. X
  1063. X      vfprintf( stderr, fmt, args );
  1064. X      putc( '\n', stderr );
  1065. X      if( errflg && !Continue ) Quit( NIL(CELL) );
  1066. X   }
  1067. }
  1068. X
  1069. /*
  1070. ** Print error message and abort
  1071. */
  1072. #if __STDC__ == 1
  1073. void
  1074. Fatal(char *fmt, ...)
  1075. #elif defined(_MPW)
  1076. Fatal(char *fmt, va_alist)
  1077. va_dcl
  1078. #else
  1079. int
  1080. Fatal(fmt, va_alist)
  1081. char *fmt;
  1082. va_dcl;
  1083. #endif
  1084. {
  1085. X   va_list args;
  1086. X
  1087. X   va_start(args, fmt);
  1088. X   Continue = FALSE;
  1089. X   errargs(fmt, args);
  1090. X   va_end(args);
  1091. }
  1092. X
  1093. /*
  1094. ** error message and exit (unless -k)
  1095. */
  1096. #if __STDC__ == 1
  1097. void
  1098. Error (char *fmt, ...)
  1099. #elif defined(_MPW)
  1100. Error(char *fmt, va_alist)
  1101. va_dcl
  1102. #else
  1103. int
  1104. Error(fmt, va_alist)
  1105. char*   fmt;
  1106. va_dcl;
  1107. #endif
  1108. {
  1109. X   va_list args;
  1110. X
  1111. X   va_start(args, fmt);
  1112. X   errargs(fmt, args);
  1113. X   va_end(args);
  1114. }
  1115. X
  1116. X
  1117. /*
  1118. ** non-fatal message
  1119. */
  1120. #if __STDC__ == 1
  1121. void
  1122. Warning(char *fmt, ...)
  1123. #elif defined(_MPW)
  1124. Error(char *fmt, va_alist)
  1125. va_dcl
  1126. #else
  1127. int
  1128. Warning(fmt, va_alist)
  1129. char *fmt;
  1130. va_dcl;
  1131. #endif
  1132. {
  1133. X   va_list args;
  1134. X
  1135. X   va_start(args, fmt);
  1136. X   warnflg = TRUE;
  1137. X   errflg = FALSE;
  1138. X   errargs(fmt, args);
  1139. X   errflg = TRUE;
  1140. X   warnflg = FALSE;
  1141. X   va_end(args);
  1142. }
  1143. X
  1144. X
  1145. PUBLIC void
  1146. No_ram()
  1147. {
  1148. X   Fatal( "No more memory" );
  1149. }
  1150. X
  1151. X
  1152. PUBLIC
  1153. X
  1154. Usage( eflag )
  1155. int eflag;
  1156. {
  1157. X   if( eflag ) {
  1158. X      fprintf(stderr, USAGE, Pname);
  1159. X   }
  1160. X   else {
  1161. X   printf(USAGE, Pname);
  1162. X   puts("    -P#        - set max number of child processes for parallel make");
  1163. X   puts("    -f file    - use file as the makefile");
  1164. #ifdef MSDOS
  1165. X   puts("    -C [+]file - duplicate console output to file, ('+' => append)");
  1166. #endif
  1167. X   puts("    -K file    - use file as the .KEEP_STATE file");
  1168. X   puts("    -v{dfimt}  - verbose, indicate what we are doing, (-v => -vdimt)");
  1169. X   puts("                   d => dump change of directory info only" );
  1170. X   puts("                   f => dump file open/close info only" );
  1171. X   puts("                   i => dump inference information only" );
  1172. X   puts("                   m => dump make of target information only" );
  1173. X   puts("                   t => keep temporary files when done\n" );
  1174. X
  1175. X   puts("Options: (can be catenated, ie -irn == -i -r -n)");
  1176. X   puts("    -A   - enable AUGMAKE special target mapping");
  1177. X   puts("    -B   - enable the use of spaces instead of tabs to start recipes");
  1178. X   puts("    -c   - use non standard comment scanning");
  1179. X   puts("    -E   - define environment strings as macros");
  1180. X   puts("    -e   - same as -E but done after parsing makefile");
  1181. X   puts("    -h   - print out usage info");
  1182. X   puts("    -i   - ignore errors");
  1183. X   puts("    -k   - make independent targets, even if errors");
  1184. X   puts("    -n   - trace and print, do not execute commands");
  1185. X   puts("    -p   - print out a version of the makefile");
  1186. X   puts("    -q   - check if target is up to date.  Does not do");
  1187. X   puts("           anything.  Returns 0 if up to date, 1 otherwise");
  1188. X   puts("    -r   - don't use internal rules");
  1189. X   puts("    -s   - do your work silently");
  1190. X   puts("    -S   - disable parallel (force sequential) make, overrides -P");
  1191. X   puts("    -t   - touch, update time stamps without executing commands");
  1192. X   puts("    -T   - do not apply transitive closure on inference rules");
  1193. X   puts("    -u   - force unconditional update of target");
  1194. X   puts("    -V   - print out version number");
  1195. X   puts("    -x   - export macro values to environment");
  1196. X   }
  1197. X
  1198. X   Quit(NIL(CELL));
  1199. }
  1200. X
  1201. X
  1202. PUBLIC
  1203. Version()
  1204. {
  1205. X   extern char **Rule_tab;
  1206. X   char **p;
  1207. X   
  1208. X   printf("%s - %s, ", Pname, sccid);
  1209. X   printf("Version %s, PL %d\n\n", VERSION, PATCHLEVEL);
  1210. X
  1211. X   puts("Default Configuration:");
  1212. X   for (p=Rule_tab;  *p != NIL(char);  p++)
  1213. X      printf("\t%s\n", *p);
  1214. }
  1215. SHAR_EOF
  1216. chmod 0640 dmake/dmake.c ||
  1217. echo 'restore of dmake/dmake.c failed'
  1218. Wc_c="`wc -c < 'dmake/dmake.c'`"
  1219. test 20915 -eq "$Wc_c" ||
  1220.     echo 'dmake/dmake.c: original size 20915, current size' "$Wc_c"
  1221. rm -f _shar_wnt_.tmp
  1222. fi
  1223. # ============= dmake/dmake.h ==============
  1224. if test -f 'dmake/dmake.h' -a X"$1" != X"-c"; then
  1225.     echo 'x - skipping dmake/dmake.h (File already exists)'
  1226.     rm -f _shar_wnt_.tmp
  1227. else
  1228. > _shar_wnt_.tmp
  1229. sed 's/^X//' << 'SHAR_EOF' > 'dmake/dmake.h' &&
  1230. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/dmake.h,v 1.1 1992/01/24 03:26:50 dvadura Exp $
  1231. -- SYNOPSIS -- global defines for dmake.
  1232. -- 
  1233. -- DESCRIPTION
  1234. --     All the interesting bits and flags that dmake uses are defined here.
  1235. --
  1236. -- AUTHOR
  1237. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1238. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1239. --
  1240. -- COPYRIGHT
  1241. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1242. -- 
  1243. --      This program is free software; you can redistribute it and/or
  1244. --      modify it under the terms of the GNU General Public License
  1245. --      (version 1), as published by the Free Software Foundation, and
  1246. --      found in the file 'LICENSE' included with this distribution.
  1247. -- 
  1248. --      This program is distributed in the hope that it will be useful,
  1249. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1250. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1251. --      GNU General Public License for more details.
  1252. -- 
  1253. --      You should have received a copy of the GNU General Public License
  1254. --      along with this program;  if not, write to the Free Software
  1255. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1256. --
  1257. -- LOG
  1258. --     $Log: dmake.h,v $
  1259. X * Revision 1.1  1992/01/24  03:26:50  dvadura
  1260. X * dmake Version 3.8, Initial revision
  1261. X *
  1262. */
  1263. X
  1264. #ifndef _DMAKE_INCLUDED_
  1265. #define _DMAKE_INCLUDED_
  1266. X
  1267. #define MAX_INC_DEPTH     10     /* max of ten nested include files      */
  1268. #define MAX_COND_DEPTH      20     /* max nesting level of conditionals    */
  1269. #define ERROR_EXIT_VALUE  255     /* return code of aborted make         */
  1270. #define CONTINUATION_CHAR '\\'   /* line continuation \<nl>              */
  1271. #define DEF_ESCAPE_CHAR   '\\'   /* escape char for used chars           */
  1272. #define ESCAPE_CHAR       *Escape_char
  1273. #define COMMENT_CHAR      '#'    /* start of comment chars               */
  1274. #define TGT_DEP_SEP       ':'    /* separator for targets and dependents */
  1275. #define CONDSTART      '.'     /* start of conditional token    eg .IF     */
  1276. #define DEF_MAKE_PNAME    "dmake"/* default name to use as name of make  */
  1277. X
  1278. X
  1279. /* ............... Hashing function constants ......................... */
  1280. #define HASH_TABLE_SIZE  200            /* See hash.c for description   */
  1281. X
  1282. X
  1283. /* Bit flags for cells and macro definitions. */
  1284. #define M_DEFAULT        0x0000         /* default flag value           */
  1285. #define M_MARK           0x0001         /* mark for circularity checks  */
  1286. #define M_PRECIOUS       0x0002         /* keep macro, same as A_PRE... */
  1287. #define M_MULTI          0x0004         /* multiple redefinitions ok!   */
  1288. #define M_EXPANDED       0x0008         /* macro has been assigned      */
  1289. #define M_USED         0x0010        /* macro has been expanded    */
  1290. #define M_LITERAL     0x0020        /* don't strip w/s on macro def */
  1291. #define    M_NOEXPORT     0x0040        /* don't export macro for -x    */
  1292. #define M_FORCE         0x0080        /* Force a macro redefinition    */
  1293. #define M_VAR_BIT        0x1000         /* macro bit variable           */
  1294. #define M_VAR_CHAR       0x2000         /* macro char variable          */
  1295. #define M_VAR_STRING     0x4000         /* macro string variable        */
  1296. #define M_VAR_INT     0x8000        /* macro integer variable    */
  1297. X
  1298. #define M_VAR_MASK       0xf000         /* macro variable mask          */
  1299. X
  1300. X
  1301. X
  1302. /* Global and target attribute flag definitions.
  1303. X * If you change the values of these or re-order them make appropriate changes
  1304. X * in dump.c so that the output of dmake -p matches the attribute info for a
  1305. X * target. */
  1306. X
  1307. #define A_DEFAULT        0x00000        /* default flag value           */
  1308. #define A_PRECIOUS       0x00001        /* object is precious           */
  1309. #define A_SILENT         0x00002        /* don't echo commands          */
  1310. #define A_LIBRARY        0x00004        /* target is an archive        */
  1311. #define A_EPILOG         0x00008        /* insert shell epilog code     */
  1312. #define A_PROLOG         0x00010        /* insert shell prolog code     */
  1313. #define A_IGNORE         0x00020        /* ignore errors                */
  1314. #define A_SYMBOL     0x00040    /* lib member is a symbol    */
  1315. #define A_NOINFER     0x00080    /* no trans closure from cell    */
  1316. #define A_UPDATEALL     0x00100    /* all targets of rule modified */
  1317. #define A_SEQ         0x00200    /* sequential make attribute    */
  1318. #define A_SETDIR         0x00400        /* cd to dir when making target */
  1319. #define A_SHELL         0x00800    /* run the recipe using a shell */
  1320. #define A_SWAP         0x01000    /* swap on exec.        */
  1321. #define A_MKSARGS     0x02000    /* use MKS argument swapping    */
  1322. #define A_PHONY         0x04000    /* .PHONY attribute        */
  1323. #define A_NOSTATE        0x08000    /* don't track state for me     */
  1324. #define MAX_ATTR     A_NOSTATE    /* highest valid attribute    */
  1325. #define A_LIBRARYM       0x10000        /* target is an archive member  */
  1326. #define A_FRINGE     0x20000    /* cell is on the fringe    */
  1327. #define A_COMPOSITE     0x40000    /* member of lib(targ) name    */
  1328. #define A_FFNAME     0x80000    /* if set, free ce_fname in stat*/
  1329. #define A_UPDATED    0x100000    /* Used to mark cell as updated */
  1330. #define A_ROOT          0x200000    /* True if it is a root prereq  */
  1331. X
  1332. X
  1333. /* Global and target bit flag definitions */
  1334. X
  1335. #define F_DEFAULT        0x0000         /* default flag value           */
  1336. #define F_MARK         0x0001        /* circularity check mark    */
  1337. #define F_MULTI         0x0002        /* multiple rules for target    */
  1338. #define F_SINGLE     0x0004        /* exec rules one/prerequisite  */
  1339. #define F_TARGET     0x0008        /* marks a target        */
  1340. #define F_RULES          0x0010         /* indicates target has rules   */
  1341. #define F_GROUP          0x0020         /* indicates that rules are to  */
  1342. X                        /* fed to the shell as a group  */
  1343. X
  1344. #define F_TRANS         0x0040        /* same as F_STAT not used tgthr*/
  1345. #define F_STAT         0x0040        /* target already stated    */
  1346. #define F_VISITED     0x0080        /* target scheduled for make    */
  1347. #define F_USED         0x0080        /* used in releparse.c        */
  1348. #define F_SPECIAL     0x0100        /* marks a special target    */
  1349. #define F_DFA          0x0200        /* bit for marking added DFA    */
  1350. #define F_EXPLICIT     0x0400        /* explicit target in makefile  */
  1351. #define F_PERCENT     0x0800        /* marks a target as a % rule    */
  1352. #define F_REMOVE     0x1000        /* marks an intermediate target */
  1353. #define F_MAGIC         0x2000        /* marks a magic target        */
  1354. #define F_INFER         0x4000        /* target is result of inference*/
  1355. #define F_MADE         0x8000        /* target is manufactured    */
  1356. X
  1357. X
  1358. /* Definitions for the Parser states */
  1359. #define NORMAL_SCAN    0     /* normal processing state */
  1360. #define RULE_SCAN      1     /* scan of rule text       */
  1361. X
  1362. /* definitions for macro operator types */
  1363. #define M_OP_EQ  1           /* macro operation is '='  */
  1364. #define M_OP_CL  2           /* macro operation is ':=' */
  1365. #define M_OP_PL  3           /* macro operation is '+=' */
  1366. #define M_OP_PLCL 4          /* macro operation is '+:='*/
  1367. #define M_OP_DF  5         /* macro operation is '*=' */
  1368. #define M_OP_DFCL 6         /* macro operation is '*:='*/
  1369. X
  1370. /* definitions for rule operator types */
  1371. #define R_OP_CL   1           /* rule operation is ':'   */
  1372. #define R_OP_DCL  2           /* rule operation is '::'  */
  1373. #define R_OP_BG   4           /* rule operation is ':!'  */
  1374. #define R_OP_UP   8           /* rule operation is ':^'  */
  1375. #define R_OP_MI  16           /* rule operation is ':-'  */
  1376. X
  1377. /* definitions for modifier application in Apply_modifiers in expand.c */
  1378. #define SUFFIX_FLAG    1        /* defines for macro modifier code */
  1379. #define DIRECTORY_FLAG    2
  1380. #define FILE_FLAG    4
  1381. X
  1382. /* special target definitions for use inside dmake */
  1383. #define ST_IF        1
  1384. #define ST_ELSE        2
  1385. #define ST_END        3
  1386. #define ST_REST        4    /* remaining special targets */
  1387. #define ST_INCLUDE    5
  1388. #define ST_SOURCE    7
  1389. #define ST_EXPORT    8
  1390. #define ST_IMPORT    9
  1391. #define ST_ELIF        10
  1392. #define ST_KEEP           11
  1393. X
  1394. /* Flags for controling use of -v switch */
  1395. #define V_NONE        0x00
  1396. #define V_LEAVE_TMP    0x01
  1397. #define V_PRINT_DIR    0x02
  1398. #define V_INFER            0x04
  1399. #define V_MAKE        0x08
  1400. #define V_FILE_IO       0x10
  1401. #define V_ALL        (V_LEAVE_TMP | V_PRINT_DIR | V_INFER | V_MAKE |\
  1402. X             V_FILE_IO)
  1403. X
  1404. /* Macro definitions for use inside dmake */
  1405. #define SET_TOKEN(A, B)  (A)->tk_str = (B); (A)->tk_cchar = *(B);\
  1406. X             (A)->tk_quote = 1;
  1407. #define CLEAR_TOKEN(A)   *(A)->tk_str = (A)->tk_cchar
  1408. #define GET_MACRO(A)     Get_name(A, Macs, FALSE)
  1409. #define iswhite(C)     ((C == ' ') || (C == '\t'))
  1410. X
  1411. #endif
  1412. X
  1413. SHAR_EOF
  1414. chmod 0640 dmake/dmake.h ||
  1415. echo 'restore of dmake/dmake.h failed'
  1416. Wc_c="`wc -c < 'dmake/dmake.h'`"
  1417. test 8214 -eq "$Wc_c" ||
  1418.     echo 'dmake/dmake.h: original size 8214, current size' "$Wc_c"
  1419. rm -f _shar_wnt_.tmp
  1420. fi
  1421. # ============= dmake/dmdump.c ==============
  1422. if test -f 'dmake/dmdump.c' -a X"$1" != X"-c"; then
  1423.     echo 'x - skipping dmake/dmdump.c (File already exists)'
  1424.     rm -f _shar_wnt_.tmp
  1425. else
  1426. > _shar_wnt_.tmp
  1427. sed 's/^X//' << 'SHAR_EOF' > 'dmake/dmdump.c' &&
  1428. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/dmdump.c,v 1.1 1992/01/24 03:28:51 dvadura Exp $
  1429. SHAR_EOF
  1430. true || echo 'restore of dmake/dmdump.c failed'
  1431. fi
  1432. echo 'End of part 7, continue with part 8'
  1433. echo 8 > _shar_seq_.tmp
  1434. exit 0
  1435. exit 0 # Just in case...
  1436.