Print this page
make: unifdef SUN5_0 (defined)


  42 static  char    *search_dir;
  43 static  char    command_output_tmpfile[30];
  44 static  int     is_path = 0;
  45 static  char    sfile[MAXPATHLEN];
  46 extern "C" {
  47 static  void    (*warning_ptr) (char *, ...) = (void (*) (char *, ...)) NULL;
  48 }
  49 
  50 FILE *
  51 get_report_file(void)
  52 {
  53         return(report_file);
  54 }
  55 
  56 char *
  57 get_target_being_reported_for(void)
  58 {
  59         return(target_being_reported_for);
  60 }
  61 
  62 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
  63 extern "C" {
  64 static void
  65 close_report_file(void)
  66 {
  67         (void)fputs("\n", report_file);
  68         (void)fclose(report_file);
  69 }
  70 } // extern "C"
  71 #else
  72 static void
  73 close_report_file(int, ...)
  74 {
  75         (void)fputs("\n", report_file);
  76         (void)fclose(report_file);
  77 }
  78 #endif
  79 
  80 static void
  81 clean_up(FILE *nse_depinfo_fp, FILE *merge_fp, char *nse_depinfo_file, char *merge_file, int unlinkf)
  82 {
  83         fclose(nse_depinfo_fp);
  84         fclose(merge_fp);
  85         fclose(command_output_fp);
  86         unlink(command_output_tmpfile);
  87         if (unlinkf)
  88                 unlink(merge_file);
  89         else
  90                 rename(merge_file, nse_depinfo_file);
  91 }
  92 
  93 
  94 /*
  95  *  Update the file, if necessary.  We don't want to rewrite
  96  *  the file if we don't have to because we don't want the time of the file
  97  *  to change in that case.
  98  */
  99 
 100 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 101 extern "C" {
 102 static void
 103 close_file(void)
 104 #else
 105 static void
 106 close_file(int, ...)
 107 #endif
 108 {
 109         char            line[MAXPATHLEN+2];
 110         char            buf[MAXPATHLEN+2];
 111         FILE            *nse_depinfo_fp;
 112         FILE            *merge_fp;
 113         char            nse_depinfo_file[MAXPATHLEN];
 114         char            merge_file[MAXPATHLEN];
 115         char            lock_file[MAXPATHLEN];
 116         int             err;
 117         int             len;
 118         int             changed = 0;
 119         int             file_locked;
 120 
 121         fprintf(command_output_fp, "\n");
 122         fclose(command_output_fp);
 123         if ((command_output_fp = fopen(command_output_tmpfile, "r")) == NULL) {
 124                 return;
 125         }
 126         sprintf(nse_depinfo_file, "%s/%s", search_dir, NSE_DEPINFO);
 127         sprintf(merge_file, NOCATGETS("%s/.tmp%s.%d"), search_dir, NSE_DEPINFO, getpid());


 197                         if (file_locked) {
 198                                 unlink(lock_file);
 199                         }
 200                         unlink(command_output_tmpfile);
 201                         return;
 202                 } /* entry found */
 203                 fputs(line, merge_fp);
 204         } 
 205         /* Entry never found.  Add it if there is a search path */
 206         if (is_path) {
 207                 while (fgets(line, MAXPATHLEN+2, command_output_fp) != NULL) {
 208                         fprintf(nse_depinfo_fp, "%s", line);
 209                 }
 210         }
 211         clean_up(nse_depinfo_fp, merge_fp, nse_depinfo_file, merge_file, 1);
 212         if (file_locked) {
 213                 unlink(lock_file);
 214         }
 215 }
 216 
 217 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 218 } // extern "C"
 219 #endif
 220 
 221 static void
 222 report_dep(char *iflag, char *filename)
 223 {
 224 
 225         if (command_output_fp == NULL) {
 226                 sprintf(command_output_tmpfile, 
 227                         NOCATGETS("%s/%s.%d.XXXXXX"), tmpdir, NSE_DEPINFO, getpid());
 228                 int fd = mkstemp(command_output_tmpfile);
 229                 if ((fd < 0) || (command_output_fp = fdopen(fd, "w")) == NULL) {
 230                         return;
 231                 }
 232                 if ((search_dir = getenv(NOCATGETS("NSE_DEP"))) == NULL) {
 233                         return;
 234                 }
 235 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 236                 atexit(close_file);
 237 #else
 238                 on_exit(close_file, 0);
 239 #endif
 240                 strcpy(sfile, filename);
 241                 if (iflag == NULL || *iflag == '\0') {
 242                         return;
 243                 }
 244                 fprintf(command_output_fp, "%s:", sfile);
 245         }
 246         fprintf(command_output_fp, " ");
 247         fprintf(command_output_fp, iflag);
 248         if (iflag != NULL) {
 249                 is_path = 1;
 250         }
 251 }
 252 
 253 void
 254 report_libdep(char *lib, char *flag)
 255 {
 256         char            *ptr;
 257         char            filename[MAXPATHLEN];
 258         char            *p;
 259 


 271 void
 272 report_search_path(char *iflag)
 273 {
 274         char            curdir[MAXPATHLEN];
 275         char            *sdir;
 276         char            *newiflag;
 277         char            filename[MAXPATHLEN];
 278         char            *p, *ptr;
 279 
 280         if ((sdir = getenv(NOCATGETS("NSE_DEP"))) == NULL) {
 281                 return;
 282         }
 283         if ((p= getenv(SUNPRO_DEPENDENCIES)) == NULL) {
 284                 return;
 285         }
 286         ptr = strchr(p, ' ');
 287         if( ! ptr ) {
 288                 return;
 289         }
 290         sprintf(filename, NOCATGETS("%s-CPP"), ptr+1);
 291 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 292         getcwd(curdir, sizeof(curdir));
 293 #else
 294         getwd(curdir);
 295 #endif
 296         if (strcmp(curdir, sdir) != 0 && strlen(iflag) > 2 && 
 297             iflag[2] != '/') {
 298                 /* Makefile must have had an "cd xx; cc ..." */
 299                 /* Modify the -I path to be relative to the cd */
 300                 newiflag = (char *)malloc(strlen(iflag) + strlen(curdir) + 2);
 301                 sprintf(newiflag, "-%c%s/%s", iflag[1], curdir, &iflag[2]);
 302                 report_dep(newiflag, filename);
 303         } else {
 304                 report_dep(iflag, filename);
 305         }
 306 }
 307 
 308 void
 309 report_dependency(const char *name)
 310 {
 311         register char   *filename;
 312         char            buffer[MAXPATHLEN+1];
 313         register char   *p;
 314         register char   *p2;
 315         char            nse_depinfo_file[MAXPATHLEN];


 321                 }
 322                 if (strlen(filename) == 0) {
 323                         report_file = (FILE *)-1;
 324                         return;
 325                 }
 326                 (void)strcpy(buffer, name);
 327                 name = buffer;
 328                 p = strchr(filename, ' ');
 329                 if(p) {
 330                         *p= 0;
 331                 } else {
 332                         report_file = (FILE *)-1;
 333                         return;
 334                 }
 335                 if ((report_file= fopen(filename, "a")) == NULL) {
 336                         if ((report_file= fopen(filename, "w")) == NULL) {
 337                                 report_file= (FILE *)-1;
 338                                 return;
 339                         }
 340                 }
 341 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 342                 atexit(close_report_file);
 343 #else
 344                 (void)on_exit(close_report_file, (char *)report_file);
 345 #endif
 346                 if ((p2= strchr(p+1, ' ')) != NULL)
 347                         *p2= 0;
 348                 target_being_reported_for= (char *)malloc((unsigned)(strlen(p+1)+1));
 349                 (void)strcpy(target_being_reported_for, p+1);
 350                 (void)fputs(p+1, report_file);
 351                 (void)fputs(":", report_file);
 352                 *p= ' ';
 353                 if (p2 != NULL)
 354                         *p2= ' ';
 355         }
 356         if (report_file == (FILE *)-1)
 357                 return;
 358         (void)fputs(name, report_file);
 359         (void)fputs(" ", report_file);
 360 }
 361 
 362 #ifdef MAKE_IT
 363 void
 364 make_it(filename)
 365         register char   *filename;




  42 static  char    *search_dir;
  43 static  char    command_output_tmpfile[30];
  44 static  int     is_path = 0;
  45 static  char    sfile[MAXPATHLEN];
  46 extern "C" {
  47 static  void    (*warning_ptr) (char *, ...) = (void (*) (char *, ...)) NULL;
  48 }
  49 
  50 FILE *
  51 get_report_file(void)
  52 {
  53         return(report_file);
  54 }
  55 
  56 char *
  57 get_target_being_reported_for(void)
  58 {
  59         return(target_being_reported_for);
  60 }
  61 

  62 extern "C" {
  63 static void
  64 close_report_file(void)
  65 {
  66         (void)fputs("\n", report_file);
  67         (void)fclose(report_file);
  68 }
  69 } // extern "C"








  70 
  71 static void
  72 clean_up(FILE *nse_depinfo_fp, FILE *merge_fp, char *nse_depinfo_file, char *merge_file, int unlinkf)
  73 {
  74         fclose(nse_depinfo_fp);
  75         fclose(merge_fp);
  76         fclose(command_output_fp);
  77         unlink(command_output_tmpfile);
  78         if (unlinkf)
  79                 unlink(merge_file);
  80         else
  81                 rename(merge_file, nse_depinfo_file);
  82 }
  83 
  84 
  85 /*
  86  *  Update the file, if necessary.  We don't want to rewrite
  87  *  the file if we don't have to because we don't want the time of the file
  88  *  to change in that case.
  89  */
  90 

  91 extern "C" {
  92 static void
  93 close_file(void)




  94 {
  95         char            line[MAXPATHLEN+2];
  96         char            buf[MAXPATHLEN+2];
  97         FILE            *nse_depinfo_fp;
  98         FILE            *merge_fp;
  99         char            nse_depinfo_file[MAXPATHLEN];
 100         char            merge_file[MAXPATHLEN];
 101         char            lock_file[MAXPATHLEN];
 102         int             err;
 103         int             len;
 104         int             changed = 0;
 105         int             file_locked;
 106 
 107         fprintf(command_output_fp, "\n");
 108         fclose(command_output_fp);
 109         if ((command_output_fp = fopen(command_output_tmpfile, "r")) == NULL) {
 110                 return;
 111         }
 112         sprintf(nse_depinfo_file, "%s/%s", search_dir, NSE_DEPINFO);
 113         sprintf(merge_file, NOCATGETS("%s/.tmp%s.%d"), search_dir, NSE_DEPINFO, getpid());


 183                         if (file_locked) {
 184                                 unlink(lock_file);
 185                         }
 186                         unlink(command_output_tmpfile);
 187                         return;
 188                 } /* entry found */
 189                 fputs(line, merge_fp);
 190         } 
 191         /* Entry never found.  Add it if there is a search path */
 192         if (is_path) {
 193                 while (fgets(line, MAXPATHLEN+2, command_output_fp) != NULL) {
 194                         fprintf(nse_depinfo_fp, "%s", line);
 195                 }
 196         }
 197         clean_up(nse_depinfo_fp, merge_fp, nse_depinfo_file, merge_file, 1);
 198         if (file_locked) {
 199                 unlink(lock_file);
 200         }
 201 }
 202 

 203 } // extern "C"

 204 
 205 static void
 206 report_dep(char *iflag, char *filename)
 207 {
 208 
 209         if (command_output_fp == NULL) {
 210                 sprintf(command_output_tmpfile, 
 211                         NOCATGETS("%s/%s.%d.XXXXXX"), tmpdir, NSE_DEPINFO, getpid());
 212                 int fd = mkstemp(command_output_tmpfile);
 213                 if ((fd < 0) || (command_output_fp = fdopen(fd, "w")) == NULL) {
 214                         return;
 215                 }
 216                 if ((search_dir = getenv(NOCATGETS("NSE_DEP"))) == NULL) {
 217                         return;
 218                 }

 219                 atexit(close_file);



 220                 strcpy(sfile, filename);
 221                 if (iflag == NULL || *iflag == '\0') {
 222                         return;
 223                 }
 224                 fprintf(command_output_fp, "%s:", sfile);
 225         }
 226         fprintf(command_output_fp, " ");
 227         fprintf(command_output_fp, iflag);
 228         if (iflag != NULL) {
 229                 is_path = 1;
 230         }
 231 }
 232 
 233 void
 234 report_libdep(char *lib, char *flag)
 235 {
 236         char            *ptr;
 237         char            filename[MAXPATHLEN];
 238         char            *p;
 239 


 251 void
 252 report_search_path(char *iflag)
 253 {
 254         char            curdir[MAXPATHLEN];
 255         char            *sdir;
 256         char            *newiflag;
 257         char            filename[MAXPATHLEN];
 258         char            *p, *ptr;
 259 
 260         if ((sdir = getenv(NOCATGETS("NSE_DEP"))) == NULL) {
 261                 return;
 262         }
 263         if ((p= getenv(SUNPRO_DEPENDENCIES)) == NULL) {
 264                 return;
 265         }
 266         ptr = strchr(p, ' ');
 267         if( ! ptr ) {
 268                 return;
 269         }
 270         sprintf(filename, NOCATGETS("%s-CPP"), ptr+1);

 271         getcwd(curdir, sizeof(curdir));



 272         if (strcmp(curdir, sdir) != 0 && strlen(iflag) > 2 && 
 273             iflag[2] != '/') {
 274                 /* Makefile must have had an "cd xx; cc ..." */
 275                 /* Modify the -I path to be relative to the cd */
 276                 newiflag = (char *)malloc(strlen(iflag) + strlen(curdir) + 2);
 277                 sprintf(newiflag, "-%c%s/%s", iflag[1], curdir, &iflag[2]);
 278                 report_dep(newiflag, filename);
 279         } else {
 280                 report_dep(iflag, filename);
 281         }
 282 }
 283 
 284 void
 285 report_dependency(const char *name)
 286 {
 287         register char   *filename;
 288         char            buffer[MAXPATHLEN+1];
 289         register char   *p;
 290         register char   *p2;
 291         char            nse_depinfo_file[MAXPATHLEN];


 297                 }
 298                 if (strlen(filename) == 0) {
 299                         report_file = (FILE *)-1;
 300                         return;
 301                 }
 302                 (void)strcpy(buffer, name);
 303                 name = buffer;
 304                 p = strchr(filename, ' ');
 305                 if(p) {
 306                         *p= 0;
 307                 } else {
 308                         report_file = (FILE *)-1;
 309                         return;
 310                 }
 311                 if ((report_file= fopen(filename, "a")) == NULL) {
 312                         if ((report_file= fopen(filename, "w")) == NULL) {
 313                                 report_file= (FILE *)-1;
 314                                 return;
 315                         }
 316                 }

 317                 atexit(close_report_file);



 318                 if ((p2= strchr(p+1, ' ')) != NULL)
 319                         *p2= 0;
 320                 target_being_reported_for= (char *)malloc((unsigned)(strlen(p+1)+1));
 321                 (void)strcpy(target_being_reported_for, p+1);
 322                 (void)fputs(p+1, report_file);
 323                 (void)fputs(":", report_file);
 324                 *p= ' ';
 325                 if (p2 != NULL)
 326                         *p2= ' ';
 327         }
 328         if (report_file == (FILE *)-1)
 329                 return;
 330         (void)fputs(name, report_file);
 331         (void)fputs(" ", report_file);
 332 }
 333 
 334 #ifdef MAKE_IT
 335 void
 336 make_it(filename)
 337         register char   *filename;