Index: resrc.c =================================================================== RCS file: /cvs/src/src/binutils/resrc.c,v retrieving revision 1.20 diff -u -r1.20 resrc.c --- resrc.c 23 May 2002 04:11:57 -0000 1.20 +++ resrc.c 20 Dec 2002 22:10:12 -0000 @@ -646,6 +646,7 @@ e = open_file_search (filename, FOPEN_RB, "bitmap file", &real_filename); + if (!e) return; if (stat (real_filename, &s) < 0) fatal (_("stat failed on bitmap file `%s': %s"), real_filename, strerror (errno)); @@ -691,6 +692,7 @@ e = open_file_search (filename, FOPEN_RB, "cursor file", &real_filename); + if (!e) return; /* A cursor file is basically an icon file. The start of the file is a three word structure. The first word is ignored. The second word is the type of data. The third word is the number of @@ -900,6 +902,7 @@ e = open_file_search (filename, FOPEN_RB, "font file", &real_filename); + if (!e) return; if (stat (real_filename, &s) < 0) fatal (_("stat failed on bitmap file `%s': %s"), real_filename, strerror (errno)); @@ -1006,6 +1009,7 @@ e = open_file_search (filename, FOPEN_RB, "icon file", &real_filename); + if (!e) return; /* The start of an icon file is a three word structure. The first word is ignored. The second word is the type of data. The third word is the number of entries. */ @@ -1173,6 +1177,8 @@ e = open_file_search (filename, FOPEN_RB, "messagetable file", &real_filename); + if (!e) return; + if (stat (real_filename, &s) < 0) fatal (_("stat failed on bitmap file `%s': %s"), real_filename, strerror (errno)); @@ -1327,6 +1333,7 @@ e = open_file_search (filename, FOPEN_RB, "font file", &real_filename); + if (!e) return; if (stat (real_filename, &s) < 0) fatal (_("stat failed on bitmap file `%s': %s"), real_filename, strerror (errno)); Index: windres.c =================================================================== RCS file: /cvs/src/src/binutils/windres.c,v retrieving revision 1.13 diff -u -r1.13 windres.c --- windres.c 5 May 2002 23:25:27 -0000 1.13 +++ windres.c 20 Dec 2002 22:10:13 -0000 @@ -61,7 +61,9 @@ /* Binary RES file. */ RES_FORMAT_RES, /* COFF file. */ - RES_FORMAT_COFF + RES_FORMAT_COFF, + /* Dependencies list for make rules - we can only sanely use this for output*/ + RES_FORMAT_DEPSONLY }; /* A structure used to map between format types and strings. */ @@ -79,6 +81,7 @@ { "rc", RES_FORMAT_RC }, { "res", RES_FORMAT_RES }, { "coff", RES_FORMAT_COFF }, + { "dep", RES_FORMAT_DEPSONLY }, { NULL, RES_FORMAT_UNKNOWN } }; @@ -91,6 +94,7 @@ { "exe", RES_FORMAT_COFF }, { "obj", RES_FORMAT_COFF }, { "o", RES_FORMAT_COFF }, + { "d", RES_FORMAT_DEPSONLY }, { NULL, RES_FORMAT_UNKNOWN } }; @@ -147,6 +151,9 @@ static struct res_directory *sort_resources PARAMS ((struct res_directory *)); static void reswr_init PARAMS ((void)); static const char * quot PARAMS ((const char *)); +static void write_deps_file PARAMS ((const char *)); +static void read_deps_file PARAMS((void)); +static void add_fname PARAMS((const char*)); /* When we are building a resource tree, we allocate everything onto an obstack, so that we can free it all at once if we want. */ @@ -196,9 +203,39 @@ { return (PTR) obstack_alloc (&reswr_obstack, bytes); } + + +/* This structure is used for storing referenced filenames */ +struct dependant +{ + /* next name */ + struct dependant *next; + /* file name */ + char *name; +}; + +/* Keep the head of the dependecies list to hand */ +static struct dependant *dep_list = NULL; + +/* Extend dependencies list */ +void +add_fname(s) + const char* s; +{ +struct dependant *item; + + item = xmalloc(sizeof (struct dependant)); + item->name = xstrdup(s); + item->next = dep_list; + dep_list=item; + +} + /* Open a file using the include directory search list. */ +int missingfiles=0; + FILE * open_file_search (filename, mode, errmsg, real_filename) const char *filename; @@ -213,6 +250,7 @@ if (e != NULL) { *real_filename = xstrdup (filename); + add_fname(filename); return e; } @@ -228,6 +266,8 @@ if (e != NULL) { *real_filename = n; + + add_fname(n); return e; } @@ -236,9 +276,10 @@ } } - fatal (_("can't open %s `%s': %s"), errmsg, filename, strerror (errno)); + fprintf (stderr, _("can't open %s `%s': %s\n"), errmsg, filename, strerror (errno)); - /* Return a value to avoid a compiler warning. */ + add_fname(filename); + missingfiles =1; return NULL; } @@ -723,7 +764,7 @@ -h --help Print this help message\n\ -V --version Print version information\n")); fprintf (stream, _("\ -FORMAT is one of rc, res, or coff, and is deduced from the file name\n\ +FORMAT is one of rc, res, dep or coff, and is deduced from the file name\n\ extension if not specified. A single file name is an input file.\n\ No input-file is stdin, default rc. No output-file is stdout, default rc.\n")); @@ -982,12 +1023,18 @@ case RES_FORMAT_COFF: resources = read_coff_rsrc (input_filename, target); break; - } + case RES_FORMAT_DEPSONLY: + read_deps_file (); + break; + } if (resources == NULL) fatal (_("no resources")); - /* Sort the resources. This is required for COFF, convenient for + if (missingfiles && (output_format != RES_FORMAT_DEPSONLY)) + fatal("resources incomplete"); + + /* Sort the resources. This is required for COFF, convenient for rc, and unimportant for res. */ resources = sort_resources (resources); @@ -1009,9 +1056,43 @@ case RES_FORMAT_COFF: write_coff_file (output_filename, target, resources); break; + case RES_FORMAT_DEPSONLY: + write_deps_file (output_filename); + break; } xexit (0); return 0; } +void +read_deps_file () +{ + fatal ("It is not possible to read deps files usefully"); +} + + +void +write_deps_file (filename) + const char *filename; +{ + FILE *e; + struct dependant *list; + + if (filename == NULL) + e = stdout; + else + { + e = fopen (filename, FOPEN_WT); + if (e == NULL) + fatal ("can't open `%s' for output: %s", filename, strerror (errno)); + } + + list=dep_list; + while(list) { + fprintf(e," %s",list->name); + list=list->next; + } + fprintf(e,"\n"); + fclose (e); +}