home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / pisces / mkdepend / pr.c < prev   
Encoding:
C/C++ Source or Header  |  1991-09-04  |  2.9 KB  |  129 lines

  1. /*
  2.  * $XConsortium: pr.c,v 1.8 89/07/21 11:31:25 jim Exp $
  3.  */
  4. #include "def.h"
  5.  
  6. extern struct    inclist    inclist[ MAXFILES ],
  7.             *inclistp;
  8. extern char    *objfile;
  9. extern int    width;
  10. extern boolean    printed;
  11. extern boolean    verbose;
  12. extern boolean    show_where_not;
  13.  
  14. void pr();
  15.  
  16. add_include(file, file_red, include, dot)
  17.     struct inclist    *file, *file_red;
  18.     char    *include;
  19.     boolean    dot;
  20. {
  21.     register struct inclist    *newfile;
  22.     register struct filepointer    *content;
  23.  
  24.     /*
  25.      * First decide what the pathname of this include file really is.
  26.      */
  27.     newfile = inc_path(file->i_file, include, dot);
  28.     if (newfile == NULL) {
  29.         if (file != file_red)
  30.             do_log("%s (reading %s): ",
  31.                 file_red->i_file, file->i_file);
  32.         else
  33.             do_log("%s: ", file->i_file);
  34.         do_log("cannot find include file \"%s\"\n", include);
  35.         show_where_not = TRUE;
  36.         newfile = inc_path(file->i_file, include, dot);
  37.         show_where_not = FALSE;
  38.     }
  39.  
  40.     included_by(file, newfile);
  41.     if (!newfile->i_searched) {
  42.         newfile->i_searched = TRUE;
  43.         content = getfile(newfile->i_file);
  44.         find_includes(content, newfile, file_red, 0);
  45.         freefile(content);
  46.     }
  47. }
  48.  
  49. void
  50. recursive_pr_include(head, file, base)
  51.     register struct inclist    *head;
  52.     register char    *file, *base;
  53. {
  54.     register int    i;
  55.  
  56.     if (head->i_marked)
  57.         return;
  58.     head->i_marked = TRUE;
  59.     if (head->i_file != file)
  60.         pr(head, file, base);
  61.     for (i=0; i<head->i_listlen; i++)
  62.         recursive_pr_include(head->i_list[ i ], file, base);
  63. }
  64.  
  65. void
  66. pr(ip, file, base)
  67.     register struct inclist  *ip;
  68.     char    *file, *base;
  69. {
  70.     static char    *lastfile;
  71.     static int    current_len;
  72.     register int    len, i, baselen;
  73.     static  char tempname[100];
  74.     char    buf[ BUFSIZ ];
  75.  
  76.     printed = TRUE;
  77.     len = strlen(ip->i_file)+1;
  78.     baselen = strlen(base);
  79.     if (*(base+baselen-2) == '.' && (*(base+baselen-1) == 'C' ||
  80.                      *(base+baselen-1) == 'c')) {
  81.         if (current_len + len > width || file != lastfile) {
  82.         lastfile = file;
  83.         strcpy (tempname, base);
  84.         tempname[baselen-2] = '\0';
  85.         sprintf(buf, "\n%s%s : %s", tempname, objfile, ip->i_file);
  86.         len = current_len = strlen(buf);    
  87.         }
  88.         else {
  89.         buf[0] = ' ';
  90.         strcpy(buf+1, ip->i_file);
  91.         current_len += len;
  92.         }
  93.         fwrite(buf, len, 1, stdout);
  94.     }
  95.     /*
  96.      * If verbose is set, then print out what this file includes.
  97.      */
  98.     if (! verbose || ip->i_list == NULL || ip->i_notified)
  99.         return;
  100.     ip->i_notified = TRUE;
  101.     lastfile = NULL;
  102.     printf("\n# %s includes:", ip->i_file);
  103.     for (i=0; i<ip->i_listlen; i++)
  104.         printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
  105. }
  106.  
  107. rcs_pr(base, rcsdir, rcsext)
  108. char *base, *rcsdir, *rcsext;
  109. {
  110.     char buf[ BUFSIZ ];
  111.     sprintf(buf, "\n%s : %s%s%s", base, rcsdir, base, rcsext);
  112.     fwrite(buf, strlen(buf), 1, stdout);
  113.     strcpy(buf, "\n    $(GET) $@\n");
  114.     fwrite(buf, strlen(buf), 1, stdout);
  115. }
  116.  
  117. link_pr(base)
  118. char *base;
  119. {
  120.     char buf[ BUFSIZ ];
  121.     if (base[strlen(base)-1] == 'h') {
  122.     strcpy(buf, "    $(RM) $(INCDIR)$(PATHSEP)$@\n");
  123.     fwrite(buf, strlen(buf), 1, stdout);
  124.     strcpy(buf, "    $(LN) $@ $(INCDIR)$(PATHSEP)$@\n");
  125.     fwrite(buf, strlen(buf), 1, stdout);
  126.     }
  127. }
  128.  
  129.