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

  1. Newsgroups: comp.sources.misc
  2. From: dvadura@plg.waterloo.edu (Dennis Vadura)
  3. Subject:  v27i111:  dmake - dmake Version 3.8, Part10/41
  4. Message-ID: <1992Jan28.031501.7361@sparky.imd.sterling.com>
  5. X-Md4-Signature: 259e2101312464f2ed97ace9a0409c45
  6. Date: Tue, 28 Jan 1992 03:15:01 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: dvadura@plg.waterloo.edu (Dennis Vadura)
  10. Posting-number: Volume 27, Issue 111
  11. Archive-name: dmake/part10
  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.10 (part 10 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file dmake/infer.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" != 10; 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/infer.c' &&
  34. X                     CELLPTR,int,int,char *,char *, int));
  35. static ICELLPTR   _derive_prerequisites ANSI((ICELLPTR, ICELLPTR *));
  36. static char *      _dump_inf_chain ANSI((ICELLPTR, int, int));
  37. X
  38. static int _prep = -1;    /* Integer value of Prep variable */
  39. X
  40. X
  41. PUBLIC void
  42. Infer_recipe( cp, setdirroot )/*
  43. ================================
  44. X   Perform a breadth-first search of the inference graph and return if
  45. X   possible an inferred set of prerequisites for making the current target.
  46. */
  47. CELLPTR cp;
  48. CELLPTR setdirroot;
  49. {
  50. X   ICELLPTR nomatch, match;
  51. X
  52. X   DB_ENTER("Infer_recipe");
  53. X
  54. X   if( cp->ce_attr & A_NOINFER ) {DB_VOID_RETURN;}
  55. X   if( _prep == -1 ) _prep = atoi(Prep);  /* _dfa_subset needs _prep */
  56. X
  57. X   match = NIL(ICELL);
  58. X   nomatch = _add_iset( NIL(ICELL), NIL(ICELL), NIL(CELL), NIL(DFALINK),
  59. X            setdirroot, _prep+_count_dots(cp->CE_NAME), 0,
  60. X            _strdup(cp->CE_NAME), NIL(char),
  61. X            cp->ce_time != (time_t)0L);
  62. X
  63. X   /* Make sure we try whole heartedly to infer at least one suffix */
  64. X   if( nomatch->ic_dmax == 0 ) ++nomatch->ic_dmax;
  65. X
  66. X   DB_EXECUTE( "inf", _dump_iset("nomatch",nomatch); );
  67. X
  68. X   while( nomatch != NIL(ICELL) ) {
  69. X      ICELLPTR new_nomatch = NIL(ICELL);
  70. X      ICELLPTR ic, pmatch, mmatch;
  71. X      CELLPTR  prereq;
  72. X      int      first;
  73. X
  74. X      for( ic=nomatch; ic != NIL(ICELL); ic=ic->ic_next ) {
  75. X     int ipush = FALSE;
  76. X
  77. X     if( ic->ic_dir ) ipush = Push_dir(ic->ic_dir, ic->ic_name, FALSE);
  78. X     match = _union_iset(match, _derive_prerequisites(ic, &new_nomatch));
  79. X     if( ipush ) Pop_dir(FALSE);
  80. X      }
  81. X
  82. X      DB_EXECUTE( "inf", _dump_iset("match",match); );
  83. X      DB_EXECUTE( "inf", _dump_iset("nomatch",new_nomatch); );
  84. X
  85. X      /* We have now deduced the two sets MATCH and NOMATCH.  MATCH holds the
  86. X       * set of edges that we encountered that matched.  If this set is empty
  87. X       * then we can apply transitive closure (if enabled) to the elements of
  88. X       * NOMATCH to see if we can find some other method to make the target.
  89. X       *
  90. X       * If MATCH is non-empty, we have found a method for making the target.
  91. X       * It is the shortest method for doing so (ie. uses fewest number of
  92. X       * steps).  If MATCH contains more than one element then we have a
  93. X       * possible ambiguity.
  94. X       */
  95. X      if( match == NIL(ICELL) ) {
  96. X     nomatch = new_nomatch;
  97. X     if( Transitive ) continue;
  98. X     goto all_done;
  99. X      }
  100. X
  101. X      /* Ok, we have a set of possible matches in MATCH, we should check the
  102. X       * set for ambiguity.  If more than one inference path exists of the
  103. X       * same depth, then we may issue an ambigous inference error message.
  104. X       *
  105. X       * The message is suppressed if MATCH contains two elements and one of
  106. X       * them is the empty-prerequisite-rule.  In this case we ignore the
  107. X       * ambiguity and take the rule that infers the prerequisite.
  108. X       *
  109. X       * Also if there are any chains that rely on a non-existant prerequisite
  110. X       * that may get made because it has a recipe then we prefer any that
  111. X       * rely on existing final prerequisites over those that we have to make.
  112. X       *
  113. X       * NOTE:  May turn this around at some point.
  114. X       */
  115. X
  116. X      /* Split out those that have to be made from those that end in
  117. X       * prerequisites that already exist. */
  118. X      pmatch = mmatch = NIL(ICELL);
  119. X      for(; match; match = ic ) {
  120. X     ic = match->ic_next;
  121. X     match->ic_next = NIL(ICELL);
  122. X
  123. X     if( match->ic_exists )
  124. X        pmatch = _union_iset(pmatch, match);
  125. X     else
  126. X        mmatch = _union_iset(mmatch, match);
  127. X      }
  128. X
  129. X      if( pmatch )
  130. X     match = pmatch;
  131. X      else
  132. X     match = mmatch;
  133. X
  134. X      /* Make sure it is unique */
  135. X      if( match->ic_next != NIL(ICELL) ) {
  136. X     int dump = (match->ic_next->ic_next != NIL(ICELL));
  137. X
  138. X     /* Check for definite ambiguity */
  139. X     if( !dump )
  140. X        if( (match->ic_meta->ce_prq && match->ic_next->ic_meta->ce_prq) ||
  141. X            (!match->ic_meta->ce_prq && !match->ic_next->ic_meta->ce_prq)  )
  142. X           dump = TRUE;
  143. X        else if(!match->ic_meta->ce_prq && match->ic_next->ic_meta->ce_prq )
  144. X           match = match->ic_next;
  145. X
  146. X     if( dump ) {
  147. X        int count = 1;
  148. X
  149. X        Continue = TRUE;
  150. X        Error( "Ambiguous inference chains for target '%s'", cp->CE_NAME );
  151. X        for( ic=match; ic; ic=ic->ic_next )
  152. X           (void) _dump_inf_chain(ic, TRUE, count++);
  153. X        Fatal( "resolve ambiguity before proceeding.");
  154. X        /*NOTREACHED*/
  155. X     }
  156. X      }
  157. X
  158. X      /* MATCH now points at the derived recipe.  We must now take cp, and
  159. X       * construct the correct graph so that the make may proceed. */
  160. X
  161. X      if( Verbose & V_INFER ) {
  162. X     char *tmp = _dump_inf_chain(match, TRUE, FALSE);
  163. X     printf("%s:  Inferring prerequistes and recipes using:\n%s:  ... %s\n",
  164. X         Pname, Pname, tmp );
  165. X     FREE(tmp);
  166. X      }
  167. X
  168. X      pmatch = NIL(ICELL);
  169. X      prereq = NIL(CELL);
  170. X      first  = TRUE;
  171. X
  172. X      while( match ) {
  173. X         CELLPTR infcell=NIL(CELL);
  174. X
  175. X     /* Compute the inferred prerequisite first. */
  176. X     if( match->ic_name ) {
  177. X        if( match->ic_meta )
  178. X           infcell = Def_cell( match->ic_name );
  179. X        else
  180. X           infcell = cp;
  181. X
  182. X        infcell->ce_flag |= F_TARGET;
  183. X
  184. X        if( infcell != cp ) {
  185. X           infcell->ce_flag |= F_INFER;
  186. X           if( !first ) infcell->ce_flag |= F_REMOVE;
  187. X        }
  188. X
  189. X        if( !match->ic_flag )
  190. X           infcell->ce_attr |= A_NOINFER;
  191. X
  192. X        first = FALSE;
  193. X     }
  194. X
  195. X     /* Add global prerequisites from previous rule if there are any and
  196. X      * the recipe. */
  197. X     if( pmatch ) {
  198. X        CELLPTR imeta = pmatch->ic_meta;
  199. X        LINKPTR lp;
  200. X
  201. X        infcell->ce_per   = pmatch->ic_dfa->dl_per;
  202. X        infcell->ce_attr |= (imeta->ce_attr & A_TRANSFER);
  203. X
  204. X        if( !(infcell->ce_flag & F_RULES) ) {
  205. X           infcell->ce_flag |= (imeta->ce_flag&(F_SINGLE|F_GROUP))|F_RULES;
  206. X           infcell->ce_recipe = imeta->ce_recipe;
  207. X        }
  208. X
  209. X        pmatch->ic_dfa->dl_per = NIL(char);
  210. X
  211. X        /* If infcell already had a directory set then modify it based on
  212. X         * whether it was the original cell or some intermediary. */
  213. X        if( imeta->ce_dir )
  214. X           if( infcell->ce_dir && infcell == cp ) {
  215. X          /* cp->ce_dir was set and we have pushed the directory prior
  216. X           * to calling this routine.  We should therefore pop it and
  217. X           * push the new concatenated directory required by the
  218. X           * inference. */
  219. X          infcell->ce_dir=_strdup(Build_path(infcell->ce_dir,
  220. X                             imeta->ce_dir));
  221. X           }
  222. X           else
  223. X          infcell->ce_dir = imeta->ce_dir;
  224. X
  225. X        for( lp=imeta->ce_indprq; lp != NIL(LINK); lp=lp->cl_next ) {
  226. X           char    *name = lp->cl_prq->CE_NAME;
  227. X           CELLPTR tcp;
  228. X
  229. X           name = _build_name( cp->CE_NAME, name, infcell->ce_per );
  230. X           tcp  = Def_cell( name );
  231. X           tcp->ce_flag |= F_REMOVE;
  232. X           Add_prerequisite( infcell, tcp, FALSE, FALSE );
  233. X
  234. X           if( Verbose & V_INFER )
  235. X          printf( "%s:  Inferred indirect prerequisite [%s]\n",
  236. X              Pname, name );
  237. X           FREE(name);
  238. X        }
  239. X     }
  240. X
  241. X     /* Add the previous cell as the prerequisite */
  242. X     if( prereq )
  243. X        (Add_prerequisite(infcell,prereq,FALSE,FALSE))->cl_flag |= F_TARGET;
  244. X
  245. X     pmatch = match;
  246. X     prereq = infcell;
  247. X     match  = match->ic_parent;
  248. X      }
  249. X
  250. X      DB_PRINT("inf", ("Terminated due to a match"));
  251. X      break;
  252. X   }
  253. X
  254. all_done:
  255. X   _free_icells();
  256. X
  257. X   DB_VOID_RETURN;
  258. }
  259. X
  260. X
  261. static ICELLPTR
  262. _derive_prerequisites( ic, nnmp )/*
  263. ===================================
  264. X   Take a cell and derive a set of prerequisites from the cell.  Categorize
  265. X   them into those that MATCH (ie. those that we found in the file system),
  266. X   and those that do not match NOMATCH that we may possibly have a look at
  267. X   later.  When we process the next level of the breadth-first search.
  268. X   
  269. X   Once MATCH is non-empty we will stop inserting elements into NOMATCH
  270. X   since we know that either MATCH is successful and unique or it will
  271. X   issue an ambiguity error.  We will never go on to look at elements
  272. X   in NOMATCH after wards. */
  273. ICELLPTR ic;
  274. ICELLPTR *nnmp;
  275. {
  276. X   ICELLPTR   match = NIL(ICELL);
  277. X   DFALINKPTR pdfa;
  278. X   DFALINKPTR dfas;
  279. X
  280. X   DB_ENTER("_derive_prerequisites");
  281. X
  282. X   /* If none of the inference nodes match then forget about the inference.
  283. X    * The user did not tell us how to make such a target.  We also stop the
  284. X    * Inference if the new set of DFA's is a proper subset of a previous
  285. X    * subset and it's PREP counts exceed the value of Prep.
  286. X    */
  287. X   dfas = _dfa_subset( Match_dfa(ic->ic_name), &ic->ic_dfastack );
  288. X
  289. X   DB_EXECUTE("inf", _dump_dfa_stack(dfas, &ic->ic_dfastack); );
  290. X
  291. X   /* Ok, we have nothing here to work with so return an empty cell. */
  292. X   if( dfas == NIL(DFALINK) ) {
  293. X      DB_PRINT( "mem", ("%s:<- mem %ld",ic->ic_name, (long)coreleft()));
  294. X      DB_PRINT( "inf", ("<<< Exit, no dfas, cp = %04x", NIL(CELL)) );
  295. X      DB_RETURN( NIL(ICELL) );
  296. X   }
  297. X
  298. X   /* Save the dfas, we are going to use on the stack for this cell. */
  299. X   ic->ic_dfastack.df_set = dfas;
  300. X
  301. X   /* Run through the %-meta cells, build the prerequisite cells.  For each
  302. X    * %-meta go through it's list of edges and try to use each in turn to
  303. X    * decuce a likely prerequisite.  We perform a breadth-first search
  304. X    * matching the first path that results in a unique method for making the
  305. X    * target. */
  306. X   for( pdfa = dfas; pdfa != NIL(DFALINK); pdfa = pdfa->dl_next ) {
  307. X      LINK tl;
  308. X      LINKPTR edge;
  309. X      CELLPTR pmeta;
  310. X
  311. X      pmeta = pdfa->dl_meta;
  312. X      DB_PRINT( "inf", ("Using dfa:  [%s]", pmeta->CE_NAME) );
  313. X
  314. X      /* If the %-meta is a singleton meta then deal with it differently from
  315. X       * the case when it is a bunch of %-meta's found on the original entries
  316. X       * prerequisite list. */
  317. X      if( pmeta->ce_flag & F_MULTI )
  318. X     edge = pmeta->ce_prq;
  319. X      else {
  320. X     tl.cl_prq = pmeta;
  321. X     tl.cl_next = NIL(LINK);
  322. X     edge = &tl;
  323. X      }
  324. X
  325. X      /* Now run through the list of prerequisite edge's for the %-meta. */
  326. X      for( ; edge != NIL(LINK); edge = edge->cl_next ) {
  327. X     HASHPTR  thp;        /* temporary hash table pointer        */
  328. X     HASH     iprqh;    /* hash cell for new prerequisite    */
  329. X     CELL     iprq;        /* inferred prerequisite to look for    */
  330. X     CELLPTR  idirroot;    /* Inferred prerequisite root        */
  331. X     CELLPTR  nidirroot;    /* Inferred prerequisite root        */
  332. X     STRINGPTR ircp;    /* Inferred prerequisites recipe    */
  333. X     char     *idir;    /* directory to CD to.            */
  334. X     int      ipush = 0;    /* flag for push on inferred prereq     */
  335. X     char     *name = NIL(char);         /* prerequisite name    */
  336. X     CELLPTR  meta = edge->cl_prq;
  337. X     int      dmax_fix;
  338. X     int      trans;
  339. X     int      noinf;
  340. X     int      exists;
  341. X     
  342. X     if( meta->ce_prq ) name = meta->ce_prq->cl_prq->CE_NAME;
  343. X
  344. X     DB_PRINT( "inf", ("Trying edge from [%s] to [%s] for [%s]",
  345. X           meta->CE_NAME, name?name:"(nil)", ic->ic_name) );
  346. X
  347. X     /* Set the temp CELL used for building prerequisite candidates to
  348. X      * all zero so that we don't have to keep initializing all the
  349. X      * fields. */
  350. X     {
  351. X        register char *s = (char *) &iprq;
  352. X        register int   n = sizeof(CELL);
  353. X        while( n ) { *s++ = '\0'; n--; }
  354. X     }
  355. X
  356. X     nidirroot = idirroot = ic->ic_setdirroot;
  357. X     iprq.ce_name = &iprqh;
  358. X
  359. X     if( name ) {
  360. X        /* Build the prerequisite name from the %-meta prerequisite given
  361. X         * for the %-meta rule. */
  362. X        iprqh.ht_name = _build_name( ic->ic_name, name, pdfa->dl_per );
  363. X        if((dmax_fix = (_count_dots(name)-_count_dots(meta->CE_NAME))) < 0)
  364. X           dmax_fix = 0;
  365. X
  366. X        if( !strcmp(ic->ic_name, iprqh.ht_name) ||
  367. X        (_count_dots(iprqh.ht_name) > ic->ic_dmax + dmax_fix) ) {
  368. X           FREE( iprqh.ht_name );
  369. X           continue;
  370. X        }
  371. X
  372. X        DB_PRINT( "inf", ("Checking prerequisite [%s]", iprqh.ht_name) );
  373. X
  374. X        /* See if the prerequisite CELL has been previously defined.  If
  375. X         * it has, then make a copy of it into iprq, and use it to try
  376. X         * the inference.  We make the copy so that we don't modify the
  377. X         * stat of the inferred cell if the inference fails.
  378. X         */
  379. X        thp = Get_name( iprqh.ht_name, Defs, FALSE );
  380. X        if(thp != NIL(HASH)) {
  381. X           iprq = *thp->CP_OWNR;
  382. X           ircp = iprq.ce_recipe;
  383. X        }
  384. X        else
  385. X           ircp = NIL(STRING);
  386. X     }
  387. X     else
  388. X        iprqh.ht_name = NIL(char);
  389. X
  390. X
  391. X     /* If the %-meta has a .SETDIR set then we change to the new
  392. X      * directory prior to performing the stat of the new prerequisite.
  393. X      * If the change of directory fails then the rule is droped from
  394. X      * further consideration.
  395. X      */
  396. X     if( iprq.ce_dir ) {
  397. X        if( ipush = Push_dir(iprq.ce_dir, iprqh.ht_name, TRUE) ) {
  398. X           nidirroot = thp->CP_OWNR;
  399. X           idir      = Pwd;
  400. X        }
  401. X        else {
  402. X           if( iprqh.ht_name ) FREE( iprqh.ht_name );
  403. X           continue;
  404. X        }
  405. X     }
  406. X     else
  407. X        idir = NIL(char);
  408. X
  409. X
  410. X     /* Stat the inferred prerequisite.
  411. X      */
  412. X     if( name ) {
  413. X        if( Verbose & V_INFER )
  414. X           printf( "%s:  Trying prerequisite [%s] for [%s]\n", Pname,
  415. X               iprqh.ht_name, ic->ic_name );
  416. X
  417. X        if( !(iprq.ce_flag & F_STAT) ) Stat_target(&iprq, FALSE);
  418. X     }
  419. X
  420. X
  421. X     /* If the STAT succeeded or if the prerequisite has a recipe for
  422. X      * making it then it's a match and a candidate for getting infered.
  423. X      * Otherwise it is not a match, and we cannot yet tell if it is
  424. X      * going to be a successful path to follow, so we save it for
  425. X      * later consideration.
  426. X      */
  427. X     noinf = ((Glob_attr)&A_NOINFER);
  428. X     if( meta->ce_prq )
  429. X        noinf |= ((meta->ce_prq->cl_prq->ce_attr)&A_NOINFER);
  430. X     trans = Transitive || !noinf;
  431. X     exists = (iprq.ce_time != (time_t)0L);
  432. X
  433. X     if( exists || (ircp != NIL(STRING)) || !name ) {
  434. X        match = _add_iset( match, ic, meta, pdfa, idirroot, ic->ic_dmax,
  435. X                   trans, iprq.ce_name->ht_name, idir, exists );
  436. X        DB_PRINT("inf",("Added to MATCH %s",iprq.ce_name->ht_name));
  437. X     }
  438. X     else if( !noinf && match == NIL(ICELL) ) {
  439. X        *nnmp = _add_iset( *nnmp, ic, meta, pdfa, nidirroot, ic->ic_dmax,
  440. X                   trans, iprq.ce_name->ht_name, idir, exists );
  441. X        DB_PRINT("inf",("Added to NOMATCH %s",iprq.ce_name->ht_name));
  442. X     }
  443. X
  444. X     /* If we pushed a directory for the inferred prerequisite then
  445. X      * pop it.
  446. X      */
  447. X     if( ipush ) Pop_dir(FALSE);
  448. X     if( iprqh.ht_name ) FREE(iprqh.ht_name);
  449. X      }
  450. X   }
  451. X
  452. X   DB_RETURN(match);
  453. }
  454. X
  455. X
  456. static char *
  457. _build_name( tg, meta, per )
  458. char *tg;
  459. char *meta;
  460. char *per;
  461. {
  462. X   char    *name;
  463. X
  464. X   name = Apply_edit( meta, "%", per, FALSE, FALSE );
  465. X   if( strchr(name, '$') ) {
  466. X      HASHPTR m_at;
  467. X      char *tmp;
  468. X
  469. X      m_at = Def_macro( "@", tg, M_MULTI );
  470. X      tmp = Expand( name );
  471. X
  472. X      if( m_at->ht_value != NIL(char) ) {
  473. X     FREE( m_at->ht_value );
  474. X     m_at->ht_value = NIL(char);
  475. X      }
  476. X
  477. X      if( name != meta ) FREE( name );
  478. X      name = tmp;
  479. X   }
  480. X   else if( name == meta )
  481. X      name = _strdup( name );
  482. X
  483. X   return(name);
  484. }
  485. X
  486. X
  487. static DFALINKPTR
  488. _dfa_subset( pdfa, stack )/*
  489. ============================
  490. X   This is the valid DFA subset computation.  Whenever a CELL has a Match_dfa
  491. X   subset computed this algorithm is run to see if any of the previously
  492. X   computed sets on the DFA stack are proper subsets of the new set.  If they
  493. X   are, then any elements of the matching subset whose Prep counts exceed
  494. X   the allowed maximum given by Prep are removed from the computed DFA set,
  495. X   and hence from consideration, thereby cutting off the cycle in the
  496. X   inference graph. */
  497. DFALINKPTR       pdfa;
  498. register DFASETPTR stack;
  499. {
  500. X   register DFALINKPTR element;
  501. X   DFALINKPTR          nelement;
  502. X
  503. X   DB_ENTER( "_dfa_subset" );
  504. X
  505. X   for(; pdfa != NIL(DFALINK) && stack != NIL(DFASET); stack = stack->df_next) {
  506. X      int subset = TRUE;
  507. X
  508. X      for( element=stack->df_set; subset && element != NIL(DFALINK);
  509. X           element=element->dl_next ) {
  510. X         register DFALINKPTR subel;
  511. X
  512. X     for( subel = pdfa;
  513. X          subel != NIL(DFALINK) && (subel->dl_meta != element->dl_meta);
  514. X          subel = subel->dl_next );
  515. X
  516. X     if( subset = (subel != NIL(DFALINK)) ) element->dl_member = subel;
  517. X      }
  518. X
  519. X      if( subset )
  520. X     for( element=stack->df_set; element != NIL(DFALINK);
  521. X          element=element->dl_next ) {
  522. X        DFALINKPTR mem = element->dl_member;
  523. X        int        npr = element->dl_prep + 1;
  524. X
  525. X        if( npr > _prep )
  526. X           mem->dl_delete++;
  527. X        else
  528. X           mem->dl_prep = npr;
  529. X     }
  530. X   }
  531. X
  532. X   for( element = pdfa; element != NIL(DFALINK); element = nelement ) {
  533. X      nelement = element->dl_next;
  534. X
  535. X      if( element->dl_delete ) {
  536. X     /* A member of the subset has a PREP count equal to PREP, so
  537. X      * it should not be considered further in the inference, hence
  538. X      * we remove it from the doubly linked set list */
  539. X     if( element == pdfa )
  540. X        pdfa = element->dl_next;
  541. X     else
  542. X        element->dl_prev->dl_next = element->dl_next;
  543. X
  544. X     if( element->dl_next != NIL(DFALINK) )
  545. X        element->dl_next->dl_prev = element->dl_prev;
  546. X
  547. X     DB_PRINT("inf", ("deleting dfa [%s]", element->dl_meta->CE_NAME));
  548. X     FREE( element->dl_per );
  549. X     FREE( element );
  550. X      }
  551. X   }
  552. X
  553. X   DB_RETURN( pdfa );
  554. }
  555. X
  556. X
  557. X
  558. static void
  559. _free_dfas( chain )/*
  560. =====================
  561. X   Free the list of DFA's constructed by Match_dfa, and linked together by
  562. X   LINK cells.  FREE the % value as well, as long as it isn't NIL. */
  563. DFALINKPTR chain;
  564. {
  565. X   register DFALINKPTR tl;
  566. X
  567. X   DB_ENTER( "_free_dfas" );
  568. X
  569. X   for( tl=chain; tl != NIL(DFALINK); chain = tl ) {
  570. X      tl = tl->dl_next;
  571. X
  572. X      DB_PRINT( "inf", ("Freeing DFA [%s], %% = [%s]", chain->dl_meta->CE_NAME,
  573. X                chain->dl_per) );
  574. X
  575. X      if( chain->dl_per != NIL(char) ) FREE( chain->dl_per );
  576. X      FREE( chain );
  577. X   }
  578. X
  579. X   DB_VOID_RETURN;
  580. }
  581. X
  582. X
  583. static int
  584. _count_dots( name )/*
  585. =====================*/
  586. char *name;
  587. {
  588. X   register char *p;
  589. X   register int  i = 0;
  590. X
  591. X   for( p = name; *p; p++ ) if(*p == '.') i++;
  592. X
  593. X   return( i );
  594. }
  595. X
  596. X
  597. static ICELLPTR _icells = NIL(ICELL);
  598. #ifdef DBUG
  599. static int _icell_cost = 0;
  600. #endif
  601. X
  602. static ICELLPTR
  603. _add_iset( iset, parent, meta, dfa, setdirroot, dmax, noinf, name, dir, exists)
  604. ICELLPTR   iset;
  605. ICELLPTR   parent;
  606. CELLPTR    meta;
  607. DFALINKPTR dfa;
  608. CELLPTR    setdirroot;
  609. int       dmax;
  610. int       noinf;
  611. char      *name;
  612. char      *dir;
  613. int       exists;
  614. {
  615. X   ICELLPTR icell;
  616. X
  617. X   DB_ENTER("_add_iset");
  618. X   TALLOC(icell, 1, ICELL);
  619. X
  620. X   DB_EXECUTE("inf", _icell_cost+=(sizeof(ICELL)+strlen(dir?dir:"")+strlen(name?name:"")+2););
  621. X
  622. X   icell->ic_meta = meta;
  623. X   icell->ic_dfa  = dfa;
  624. X   icell->ic_setdirroot = setdirroot;
  625. X
  626. X   if( parent ) icell->ic_dfastack.df_next = &parent->ic_dfastack;
  627. X
  628. X   icell->ic_dmax = dmax;
  629. X   icell->ic_dir = _strdup(dir);
  630. X   icell->ic_name = _strdup(name);
  631. X   icell->ic_parent = parent;
  632. X   icell->ic_next = iset;
  633. X   icell->ic_flag = noinf;
  634. X   icell->ic_exists = exists;
  635. X
  636. X   icell->ic_link = _icells;
  637. X   _icells = icell;
  638. X
  639. X   DB_RETURN(icell);
  640. }
  641. X
  642. X
  643. static void
  644. _free_icells()
  645. {
  646. X   register ICELLPTR ic;
  647. X
  648. X   DB_ENTER("_free_icells");
  649. X
  650. X   for( ; _icells; _icells = ic ) {
  651. X      ic = _icells->ic_link;
  652. X
  653. X      _free_dfas(_icells->ic_dfastack.df_set);
  654. X      if( _icells->ic_dir ) FREE(_icells->ic_dir);
  655. X      if( _icells->ic_name) FREE(_icells->ic_name);
  656. X      FREE(_icells);
  657. X   }
  658. X
  659. X   DB_PRINT("inf",("Used %d memory for icells",_icell_cost));
  660. X   DB_EXECUTE("inf", _icell_cost=0; );
  661. X
  662. X   DB_VOID_RETURN;
  663. }
  664. X
  665. X
  666. static ICELLPTR
  667. _union_iset( iset, uset )
  668. ICELLPTR iset;
  669. ICELLPTR uset;
  670. {
  671. X   register ICELLPTR ic;
  672. X
  673. X   if( iset == NIL(ICELL) ) return(uset);
  674. X
  675. X   for( ic=iset; ic->ic_next != NIL(ICELL); ic=ic->ic_next );
  676. X   ic->ic_next = uset;
  677. X
  678. X   return(iset);
  679. }
  680. X
  681. X
  682. static char *
  683. _dump_inf_chain( ip, flag, print )/*
  684. ====================================*/
  685. ICELLPTR ip;
  686. int      flag;
  687. int     print;
  688. {
  689. X   char *tmp;
  690. X
  691. X   if( ip == NIL(ICELL) ) return(NIL(char));
  692. X
  693. X   tmp = _dump_inf_chain(ip->ic_parent, FALSE, FALSE);
  694. X
  695. X   if( ip->ic_meta ) {
  696. X      tmp = _strjoin(tmp, "(", -1, TRUE);
  697. X      tmp = _strjoin(tmp, ip->ic_meta->CE_NAME, -1, TRUE);
  698. X
  699. X      if( ip->ic_dir && !*ip->ic_dir ) {
  700. X     tmp = _strjoin(tmp, "[", -1, TRUE);
  701. X     if( strncmp(Makedir,ip->ic_dir, strlen(Makedir)) )
  702. X        tmp = _strjoin(tmp, ip->ic_dir, -1, TRUE);
  703. X     else
  704. X        tmp = _strjoin(tmp, ip->ic_dir+strlen(Makedir)+1, -1, TRUE);
  705. X     tmp = _strjoin(tmp, "]", -1, TRUE);
  706. X      }
  707. X      tmp = _strjoin(tmp, (ip->ic_name)?") -->":")", -1, TRUE);
  708. X   }
  709. X   
  710. X   if( ip->ic_name ) tmp = _strapp( tmp, ip->ic_name );
  711. X
  712. X   if( flag && ip->ic_meta->ce_prq) {
  713. X      tmp = _strjoin(tmp, "(", -1, TRUE);
  714. X      tmp = _strjoin(tmp, ip->ic_meta->ce_prq->cl_prq->CE_NAME, -1, TRUE);
  715. X      tmp = _strjoin(tmp, ")", -1, TRUE);
  716. X   }
  717. X
  718. X   if( print ) {
  719. X      fprintf( stderr, "%s:  %2d. %s\n", Pname, print, tmp );
  720. X      FREE(tmp);
  721. X      tmp = NIL(char);
  722. X   }
  723. X
  724. X   return(tmp);
  725. }
  726. X
  727. X
  728. #ifdef DBUG
  729. _dump_dfa_stack(dfas, dfa_stack)
  730. DFALINKPTR dfas;
  731. DFASETPTR  dfa_stack;
  732. {
  733. X   register DFALINKPTR pdfa;
  734. X   char      *tmp = NIL(char);
  735. X   DFASETPTR ds;
  736. X
  737. X   for( pdfa = dfas; pdfa != NIL(DFALINK); pdfa = pdfa->dl_next )
  738. X      tmp = _strapp( tmp, pdfa->dl_meta->CE_NAME );
  739. X
  740. X   tmp = _strapp( tmp, ":: {" );
  741. X   for( ds = dfa_stack; ds != NIL(DFASET); ds = ds->df_next ) {
  742. X      tmp = _strapp( tmp, "[" );
  743. X      for( pdfa = ds->df_set; pdfa != NIL(DFALINK); pdfa = pdfa->dl_next )
  744. X     tmp = _strapp( tmp, pdfa->dl_meta->CE_NAME );
  745. X      tmp = _strapp( tmp, "]" );
  746. X   }
  747. X   tmp = _strapp( tmp, "}" );
  748. X
  749. X   printf( "DFA set and stack contents:\n%s\n", tmp );
  750. X   FREE(tmp);
  751. }
  752. X
  753. X
  754. _dump_iset( name, iset )
  755. char     *name;
  756. ICELLPTR iset;
  757. {
  758. X   int cell = 0;
  759. X
  760. X   printf( "**** ISET for %s\n", name );
  761. X   for( ; iset != NIL(ICELL); iset = iset->ic_next ){
  762. X      printf( "cell %d\n", cell++ );
  763. X      if( iset->ic_meta )
  764. X     printf( "edge: %s --> %s\n", iset->ic_meta->CE_NAME,
  765. X         iset->ic_meta->ce_prq ?
  766. X         iset->ic_meta->ce_prq->cl_prq->CE_NAME :
  767. X         "(nil)" );
  768. X      else
  769. X     printf( "edge: (nil)\n" );
  770. X
  771. X      if( iset->ic_dfa )
  772. X     printf( "dfa: %s\n", iset->ic_dfa->dl_meta->CE_NAME );
  773. X      else
  774. X     printf( "dfa: (nil)\n" );
  775. X
  776. X      printf( "sdr: %04x\n", iset->ic_setdirroot );
  777. X      _dump_dfa_stack(iset->ic_dfastack.df_set, &iset->ic_dfastack);
  778. X
  779. X      printf( "dmax: %d\n", iset->ic_dmax );
  780. X      printf( "name: %s\n", iset->ic_name );
  781. X      printf( "dir:  %s\n", iset->ic_dir?iset->ic_dir:"(nil)" );
  782. X
  783. X      printf( "parent: " );
  784. X      if( iset->ic_parent )
  785. X    if( iset->ic_parent->ic_meta )
  786. X       printf( "%s --> %s\n",
  787. X               iset->ic_parent->ic_meta->CE_NAME,
  788. X           iset->ic_parent->ic_meta->ce_prq ?
  789. X           iset->ic_parent->ic_meta->ce_prq->cl_prq->CE_NAME :
  790. X           "(nil)" );
  791. X    else
  792. X       printf( "(nil)\n" );
  793. X      else
  794. X     printf( "(nil)\n" );
  795. X   }
  796. X   printf( "==================================\n" );
  797. }
  798. #endif
  799. SHAR_EOF
  800. chmod 0640 dmake/infer.c ||
  801. echo 'restore of dmake/infer.c failed'
  802. Wc_c="`wc -c < 'dmake/infer.c'`"
  803. test 24141 -eq "$Wc_c" ||
  804.     echo 'dmake/infer.c: original size 24141, current size' "$Wc_c"
  805. rm -f _shar_wnt_.tmp
  806. fi
  807. # ============= dmake/itypes.h ==============
  808. if test -f 'dmake/itypes.h' -a X"$1" != X"-c"; then
  809.     echo 'x - skipping dmake/itypes.h (File already exists)'
  810.     rm -f _shar_wnt_.tmp
  811. else
  812. > _shar_wnt_.tmp
  813. sed 's/^X//' << 'SHAR_EOF' > 'dmake/itypes.h' &&
  814. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/itypes.h,v 1.1 1992/01/24 03:29:40 dvadura Exp $
  815. -- SYNOPSIS -- type declarations for common types
  816. -- 
  817. -- DESCRIPTION
  818. --     portable type declarations.
  819. --
  820. -- AUTHOR
  821. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  822. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  823. --
  824. -- COPYRIGHT
  825. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  826. -- 
  827. --      This program is free software; you can redistribute it and/or
  828. --      modify it under the terms of the GNU General Public License
  829. --      (version 1), as published by the Free Software Foundation, and
  830. --      found in the file 'LICENSE' included with this distribution.
  831. -- 
  832. --      This program is distributed in the hope that it will be useful,
  833. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  834. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  835. --      GNU General Public License for more details.
  836. -- 
  837. --      You should have received a copy of the GNU General Public License
  838. --      along with this program;  if not, write to the Free Software
  839. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  840. --
  841. -- LOG
  842. --     $Log: itypes.h,v $
  843. X * Revision 1.1  1992/01/24  03:29:40  dvadura
  844. X * dmake Version 3.8, Initial revision
  845. X *
  846. */
  847. X
  848. X
  849. #ifndef ITYPES_h
  850. #define    ITYPES_h
  851. X
  852. #if defined(M_I86) || defined(MC68000)
  853. typedef char  int8;               /* typedefs for right size ints */
  854. typedef int   int16;
  855. typedef long  int32;
  856. typedef unsigned char  uint8;
  857. typedef unsigned int   uint16;
  858. typedef unsigned long  uint32;
  859. #else
  860. typedef char  int8;               /* typedefs for right size ints */
  861. typedef short int16;
  862. typedef long  int32;
  863. typedef unsigned char  uint8;
  864. typedef unsigned short uint16;
  865. typedef unsigned long  uint32;
  866. #endif
  867. X
  868. #endif
  869. X
  870. SHAR_EOF
  871. chmod 0640 dmake/itypes.h ||
  872. echo 'restore of dmake/itypes.h failed'
  873. Wc_c="`wc -c < 'dmake/itypes.h'`"
  874. test 1822 -eq "$Wc_c" ||
  875.     echo 'dmake/itypes.h: original size 1822, current size' "$Wc_c"
  876. rm -f _shar_wnt_.tmp
  877. fi
  878. # ============= dmake/mac/arlib.c ==============
  879. if test ! -d 'dmake/mac'; then
  880.     mkdir 'dmake/mac'
  881. fi
  882. if test -f 'dmake/mac/arlib.c' -a X"$1" != X"-c"; then
  883.     echo 'x - skipping dmake/mac/arlib.c (File already exists)'
  884.     rm -f _shar_wnt_.tmp
  885. else
  886. > _shar_wnt_.tmp
  887. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/arlib.c' &&
  888. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/mac/arlib.c,v 1.1 1992/01/24 03:29:41 dvadura Exp $
  889. -- SYNOPSIS -- Library access code.
  890. -- 
  891. -- DESCRIPTION
  892. --  This implementation uses the library timestamp inplace of the
  893. --  library member timestamp.
  894. --
  895. -- AUTHOR
  896. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  897. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  898. --
  899. -- COPYRIGHT
  900. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  901. -- 
  902. --      This program is free software; you can redistribute it and/or
  903. --      modify it under the terms of the GNU General Public License
  904. --      (version 1), as published by the Free Software Foundation, and
  905. --      found in the file 'LICENSE' included with this distribution.
  906. -- 
  907. --      This program is distributed in the hope that it will be useful,
  908. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  909. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  910. --      GNU General Public License for more details.
  911. -- 
  912. --      You should have received a copy of the GNU General Public License
  913. --      along with this program;  if not, write to the Free Software
  914. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  915. --
  916. -- LOG
  917. --     $Log: arlib.c,v $
  918. X * Revision 1.1  1992/01/24  03:29:41  dvadura
  919. X * dmake Version 3.8, Initial revision
  920. X *
  921. */
  922. X
  923. #include "extern.h"
  924. X
  925. PUBLIC time_t
  926. seek_arch(char * /* name */, char *lib) {
  927. X   static   int warned = FALSE;
  928. X
  929. X   if (!warned && !(Glob_attr&A_SILENT))
  930. X    warned = TRUE,
  931. X    Warning("Can't extract library member timestamp;\n\
  932. X    using library timestamp instead.");
  933. X   return (Do_stat(lib, NULL, NULL));
  934. }
  935. X
  936. PUBLIC int
  937. touch_arch(char * /* name */, char *lib) {
  938. X   static   int warned = FALSE;
  939. X
  940. X   if (!warned && !(Glob_attr&A_SILENT))
  941. X    warned = TRUE,
  942. X    Warning("Can't update library member timestamp;\n\
  943. X    touching library instead.");
  944. X   return (Do_touch(lib, NULL, NULL));
  945. }
  946. SHAR_EOF
  947. chmod 0640 dmake/mac/arlib.c ||
  948. echo 'restore of dmake/mac/arlib.c failed'
  949. Wc_c="`wc -c < 'dmake/mac/arlib.c'`"
  950. test 1950 -eq "$Wc_c" ||
  951.     echo 'dmake/mac/arlib.c: original size 1950, current size' "$Wc_c"
  952. rm -f _shar_wnt_.tmp
  953. fi
  954. # ============= dmake/mac/bogus.c ==============
  955. if test -f 'dmake/mac/bogus.c' -a X"$1" != X"-c"; then
  956.     echo 'x - skipping dmake/mac/bogus.c (File already exists)'
  957.     rm -f _shar_wnt_.tmp
  958. else
  959. > _shar_wnt_.tmp
  960. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/bogus.c' &&
  961. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/mac/bogus.c,v 1.1 1992/01/24 03:29:42 dvadura Exp $
  962. -- SYNOPSIS -- Write the shell of subroutines we can't or don't
  963. --             need to implement
  964. --
  965. -- DESCRIPTION
  966. --  dmake uses a couple of functions which I am either unable to figure out
  967. --  how to implement or which are not needed.  The shells of these routines
  968. --  are in this file.
  969. --
  970. -- AUTHOR
  971. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  972. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  973. --
  974. --
  975. -- COPYRIGHT
  976. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  977. -- 
  978. --      This program is free software; you can redistribute it and/or
  979. --      modify it under the terms of the GNU General Public License
  980. --      (version 1), as published by the Free Software Foundation, and
  981. --      found in the file 'LICENSE' included with this distribution.
  982. -- 
  983. --      This program is distributed in the hope that it will be useful,
  984. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  985. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  986. --      GNU General Public License for more details.
  987. -- 
  988. --      You should have received a copy of the GNU General Public License
  989. --      along with this program;  if not, write to the Free Software
  990. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  991. --
  992. -- LOG
  993. --     $Log: bogus.c,v $
  994. X * Revision 1.1  1992/01/24  03:29:42  dvadura
  995. X * dmake Version 3.8, Initial revision
  996. X *
  997. */
  998. X
  999. #include "extern.h"
  1000. X
  1001. X
  1002. X
  1003. /*
  1004. X * tzset() is a Microsoft "extension" to ANSI C.  It sets global
  1005. X * variables telling if we are in dayling savings time, the time
  1006. X * zone, and difference between the current time and GMT.
  1007. X * None of these globals are used by dmake, so this routine is
  1008. X * not needed
  1009. X */
  1010. PUBLIC void tzset () {}
  1011. X
  1012. X
  1013. X
  1014. /*
  1015. X * Add an environmental variable that child processes can use.
  1016. X * Since MPW currently doesn't allow child processes, this isn't
  1017. X * needed.
  1018. X */
  1019. PUBLIC int putenv (char * /* pEnvString */) {return (0);}
  1020. X
  1021. X
  1022. X
  1023. /*
  1024. X * Execute a child process.  This may be able to be done with
  1025. X * the MPW system() call someday, but cannot be done currently.
  1026. X */
  1027. PUBLIC int runargv (CELLPTR /* target */, int /* ignore */, int /* group */,
  1028. X                    int /* last */, int /* shell */, char * /* pCmd */) {
  1029. X    static int warned = FALSE;
  1030. X
  1031. X    if (!warned && !(Glob_attr & A_SILENT)) {
  1032. X        warned = TRUE;
  1033. X        Fatal ("Can't execute any targets:  use '-n' option.");
  1034. X    } /* if */
  1035. X
  1036. X    return (0);
  1037. } /* int runargv () */
  1038. X
  1039. X
  1040. X
  1041. /*
  1042. X * Wait for the child process to complete.  Only needed to be implemented
  1043. X * if we could executing multiple processes at once.
  1044. X */
  1045. PUBLIC int Wait_for_child(int /* abort_flg */, int /* pid */) {return (1);}
  1046. X
  1047. X
  1048. X
  1049. /*
  1050. X * Do any cleanup for any processes when we quit.
  1051. X */
  1052. PUBLIC void Clean_up_processes() {}
  1053. SHAR_EOF
  1054. chmod 0640 dmake/mac/bogus.c ||
  1055. echo 'restore of dmake/mac/bogus.c failed'
  1056. Wc_c="`wc -c < 'dmake/mac/bogus.c'`"
  1057. test 2850 -eq "$Wc_c" ||
  1058.     echo 'dmake/mac/bogus.c: original size 2850, current size' "$Wc_c"
  1059. rm -f _shar_wnt_.tmp
  1060. fi
  1061. # ============= dmake/mac/config.h ==============
  1062. if test -f 'dmake/mac/config.h' -a X"$1" != X"-c"; then
  1063.     echo 'x - skipping dmake/mac/config.h (File already exists)'
  1064.     rm -f _shar_wnt_.tmp
  1065. else
  1066. > _shar_wnt_.tmp
  1067. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/config.h' &&
  1068. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/mac/config.h,v 1.1 1992/01/24 03:29:43 dvadura Exp $
  1069. -- SYNOPSIS -- Configurarion include file for the Macintosh.
  1070. -- 
  1071. -- DESCRIPTION
  1072. --  There is one of these for each specific machine configuration.
  1073. --  It can be used to further tweek the machine specific sources
  1074. --  so that they compile.
  1075. --
  1076. -- AUTHOR
  1077. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1078. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1079. --
  1080. -- COPYRIGHT
  1081. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1082. -- 
  1083. --      This program is free software; you can redistribute it and/or
  1084. --      modify it under the terms of the GNU General Public License
  1085. --      (version 1), as published by the Free Software Foundation, and
  1086. --      found in the file 'LICENSE' included with this distribution.
  1087. -- 
  1088. --      This program is distributed in the hope that it will be useful,
  1089. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1090. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1091. --      GNU General Public License for more details.
  1092. -- 
  1093. --      You should have received a copy of the GNU General Public License
  1094. --      along with this program;  if not, write to the Free Software
  1095. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1096. --
  1097. -- LOG
  1098. --     $Log: config.h,v $
  1099. X * Revision 1.1  1992/01/24  03:29:43  dvadura
  1100. X * dmake Version 3.8, Initial revision
  1101. X *
  1102. */
  1103. X
  1104. /* Definitions left out of StdArg.h */
  1105. #define va_alist     ...
  1106. #define va_dcl
  1107. X
  1108. #define CONST const
  1109. X
  1110. #define FALSE 0
  1111. #define TRUE 1
  1112. X
  1113. /* signal extensions */
  1114. #define SIGQUIT SIGTERM
  1115. X
  1116. X
  1117. /* Mac doesn't have a stat function or structure so we have to add one in. */
  1118. typedef long off_t;
  1119. struct stat {
  1120. X    unsigned short st_mode;
  1121. X    off_t st_size;
  1122. X    time_t st_mtime;
  1123. X    time_t st_ctime;
  1124. X    /* struct stat has lots of other fields, but we don't need them for dmake */
  1125. }; /* struct stat */
  1126. #define S_IFDIR  0040000    /* directory */
  1127. #define S_IFREG  0100000    /* regular */
  1128. #define S_IFMT   (S_IFDIR | S_IFREG)    /* Format */
  1129. #define S_IREAD  0000400    /* read owner permission */
  1130. #define S_IWRITE 0000200    /* write owner permission */
  1131. #define S_IEXEC  0000100    /* execute owner permission */
  1132. X
  1133. X
  1134. /* Global for environmental variables */
  1135. extern char **environ;
  1136. X
  1137. X
  1138. /* We really want main to be in the mac directory
  1139. X   so that we get the envp argument */
  1140. #define main(argc, argv)    dmakemain(argc, argv)
  1141. X
  1142. /* Directory/file info. and directory moving */
  1143. int stat (char *pPath, struct stat *pStat);
  1144. char *getcwd (char *pPath, size_t pathSize);
  1145. int chdir (char *pPath);
  1146. int utime (char *pPath, time_t *pTimes);
  1147. X
  1148. /* Routines to handle conversion from Unix file names to Mac file names */
  1149. char *Unix2MacFName(char *pUnixName);
  1150. FILE *MacFOpen (char *pName, char *pMode);
  1151. #define fopen(pFName, pMode)    MacFOpen(pFName, pMode)
  1152. X
  1153. /* a small problem with pointer to voids on some unix machines needs this */
  1154. #define PVOID void *
  1155. SHAR_EOF
  1156. chmod 0640 dmake/mac/config.h ||
  1157. echo 'restore of dmake/mac/config.h failed'
  1158. Wc_c="`wc -c < 'dmake/mac/config.h'`"
  1159. test 2976 -eq "$Wc_c" ||
  1160.     echo 'dmake/mac/config.h: original size 2976, current size' "$Wc_c"
  1161. rm -f _shar_wnt_.tmp
  1162. fi
  1163. # ============= dmake/mac/config.mk ==============
  1164. if test -f 'dmake/mac/config.mk' -a X"$1" != X"-c"; then
  1165.     echo 'x - skipping dmake/mac/config.mk (File already exists)'
  1166.     rm -f _shar_wnt_.tmp
  1167. else
  1168. > _shar_wnt_.tmp
  1169. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/config.mk' &&
  1170. # This is an OS Mac specific configuration file
  1171. #   It assumes that OBJDIR, TARGET and DEBUG are previously defined.
  1172. #   It defines  CFLAGS, LDARGS, CPPFLAGS, STARTUPFILE, LDOBJS
  1173. #   It augments SRC, OBJDIR, TARGET, CFLAGS, LDLIBS
  1174. #
  1175. X
  1176. STARTUPFILE = :$(OS):startup.mk
  1177. X
  1178. CPPFLAGS    = $(CFLAGS)
  1179. LDOBJS      = $(CSTARTUP) :$(OBJDIR):{$(<:f)}
  1180. LDARGS      = $(LDFLAGS) -o $@ $(LDOBJS) $(LDLIBS)
  1181. X
  1182. # Debug flags
  1183. DB_CFLAGS   = -sym on 
  1184. DB_LDFLAGS  = -sym on
  1185. DB_LDLIBS   =
  1186. X
  1187. # NO Debug flags
  1188. NDB_CFLAGS  = -sym off
  1189. NDB_LDFLAGS = -sym off
  1190. NDB_LDLIBS  =
  1191. X
  1192. # Local configuration modifications for CFLAGS.
  1193. CFLAGS     += -I :$(OS) -d _MPW -s $(<:b)
  1194. LDFLAGS    += -w -c 'MPS ' -t MPST
  1195. X
  1196. # Since we writing out what files we want to execute, we can't use .SETDIR
  1197. # to specify the files to compile in the Mac directory.
  1198. # Instead, we copy the files to the (top-level) current directory and compile
  1199. # them there.
  1200. %.c : ":$(OS):%.c"
  1201. X    duplicate -y $< $@
  1202. X
  1203. # Common Mac source files.
  1204. OS_SRC = arlib.c bogus.c dirbrk.c directry.c environ.c main.c rmprq.c \
  1205. X         ruletab.c tempnam.c tomacfil.c
  1206. .IF $(SHELL) != mwp
  1207. X   .SETDIR=$(OS) : $(OS_SRC)
  1208. .ENDIF
  1209. SRC += $(OS_SRC)
  1210. X
  1211. # Set source dirs so that we can find files named in this
  1212. # config file.
  1213. .SOURCE.h : $(OS)
  1214. SHAR_EOF
  1215. chmod 0640 dmake/mac/config.mk ||
  1216. echo 'restore of dmake/mac/config.mk failed'
  1217. Wc_c="`wc -c < 'dmake/mac/config.mk'`"
  1218. test 1234 -eq "$Wc_c" ||
  1219.     echo 'dmake/mac/config.mk: original size 1234, current size' "$Wc_c"
  1220. rm -f _shar_wnt_.tmp
  1221. fi
  1222. # ============= dmake/mac/dirbrk.c ==============
  1223. if test -f 'dmake/mac/dirbrk.c' -a X"$1" != X"-c"; then
  1224.     echo 'x - skipping dmake/mac/dirbrk.c (File already exists)'
  1225.     rm -f _shar_wnt_.tmp
  1226. else
  1227. > _shar_wnt_.tmp
  1228. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/dirbrk.c' &&
  1229. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/mac/dirbrk.c,v 1.1 1992/01/24 03:29:44 dvadura Exp $
  1230. -- SYNOPSIS -- define the directory separator string.
  1231. -- 
  1232. -- DESCRIPTION
  1233. --  Define this string for any character that may appear in a path name
  1234. --  and can be used as a directory separator.
  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: dirbrk.c,v $
  1259. X * Revision 1.1  1992/01/24  03:29:44  dvadura
  1260. X * dmake Version 3.8, Initial revision
  1261. X *
  1262. */
  1263. X
  1264. #include "extern.h"
  1265. X
  1266. /* mac only uses ':' */
  1267. char*   DirBrkStr = ":";
  1268. X
  1269. /*
  1270. ** Return TRUE if the name is the full specification of a path name to a file
  1271. ** starting at the root of the file system, otherwise return FALSE
  1272. */
  1273. PUBLIC int
  1274. If_root_path(name)
  1275. char *name;
  1276. {
  1277. X   name = Unix2MacFName (name);
  1278. X   return( (strchr(name, ':') != NIL(char)) &&
  1279. X           (name[0] != ':') );
  1280. }
  1281. SHAR_EOF
  1282. chmod 0640 dmake/mac/dirbrk.c ||
  1283. echo 'restore of dmake/mac/dirbrk.c failed'
  1284. Wc_c="`wc -c < 'dmake/mac/dirbrk.c'`"
  1285. test 1787 -eq "$Wc_c" ||
  1286.     echo 'dmake/mac/dirbrk.c: original size 1787, current size' "$Wc_c"
  1287. rm -f _shar_wnt_.tmp
  1288. fi
  1289. # ============= dmake/mac/directry.c ==============
  1290. if test -f 'dmake/mac/directry.c' -a X"$1" != X"-c"; then
  1291.     echo 'x - skipping dmake/mac/directry.c (File already exists)'
  1292.     rm -f _shar_wnt_.tmp
  1293. else
  1294. > _shar_wnt_.tmp
  1295. sed 's/^X//' << 'SHAR_EOF' > 'dmake/mac/directry.c' &&
  1296. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/mac/directry.c,v 1.1 1992/01/24 03:29:45 dvadura Exp $
  1297. -- SYNOPSIS -- Fake directory and file functions for the Mac
  1298. --
  1299. -- DESCRIPTION
  1300. --  This file contains implementations for some ANSI standard routines dmake
  1301. --  uses which are not otherwise available for the mac.
  1302. --
  1303. --  Assume we are using at least 128K ROMS.
  1304. --
  1305. -- AUTHOR
  1306. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1307. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1308. --
  1309. --
  1310. -- COPYRIGHT
  1311. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1312. -- 
  1313. --      This program is free software; you can redistribute it and/or
  1314. --      modify it under the terms of the GNU General Public License
  1315. --      (version 1), as published by the Free Software Foundation, and
  1316. --      found in the file 'LICENSE' included with this distribution.
  1317. SHAR_EOF
  1318. true || echo 'restore of dmake/mac/directry.c failed'
  1319. fi
  1320. echo 'End of part 10, continue with part 11'
  1321. echo 11 > _shar_seq_.tmp
  1322. exit 0
  1323. exit 0 # Just in case...
  1324.