aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>1999-05-25 12:10:27 +0000
committerDJ Delorie <dj@redhat.com>1999-05-25 12:10:27 +0000
commit751d21b5b946a4a451552fbac692b14abea3d816 (patch)
tree887e572d520d2e46474c184e520db5d07c0c261b /binutils
parentfa0e42e45712133c4c2d95261c3c0ac8d87b6765 (diff)
downloadfsf-binutils-gdb-751d21b5b946a4a451552fbac692b14abea3d816.zip
fsf-binutils-gdb-751d21b5b946a4a451552fbac692b14abea3d816.tar.gz
fsf-binutils-gdb-751d21b5b946a4a451552fbac692b14abea3d816.tar.bz2
* windres.c: add verbose option
(main): process verbose option * resrc.c (look_for_default): new. Look for the default preprocessor in a given location. (read_rc_file): for foo/bar-windres, look for foo/bar-gcc, foo/gcc (in case of foo/windres), and then gcc (the old default).
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog9
-rw-r--r--binutils/binutils.texi5
-rw-r--r--binutils/resrc.c121
-rw-r--r--binutils/windres.c15
-rw-r--r--binutils/windres.h2
5 files changed, 141 insertions, 11 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8b39b60..1b1121c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,12 @@
+1999-05-17 DJ Delorie <dj@cygnus.com>
+
+ * windres.c: add verbose option
+ (main): process verbose option
+ * resrc.c (look_for_default): new. Look for the default
+ preprocessor in a given location.
+ (read_rc_file): for foo/bar-windres, look for foo/bar-gcc,
+ foo/gcc (in case of foo/windres), and then gcc (the old default).
+
1999-05-16 Nick Clifton <nickc@cygnus.com>
* dlltool.c (deduce_name): New function: Deduce name of program to
diff --git a/binutils/binutils.texi b/binutils/binutils.texi
index 5f7c646..b431a95 100644
--- a/binutils/binutils.texi
+++ b/binutils/binutils.texi
@@ -2048,10 +2048,15 @@ Specify an include directory to use when reading an @code{rc} file.
option. @code{windres} will also search this directory when looking for
files named in the @code{rc} file.
+@item -D @var{target}
@item --define @var{sym[=val]}
Specify a @code{-D} option to pass to the preprocessor when reading an
@code{rc} file.
+@item -v
+Enable verbose mode. This tells you what the preprocessor is if you
+didn't specify one.
+
@item --language @var{val}
Specify the default language to use when reading an @code{rc} file.
@var{val} should be a hexadecimal language code. The low eight bits are
diff --git a/binutils/resrc.c b/binutils/resrc.c
index 9ba3c11..41c9cca 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -120,6 +120,52 @@ static void get_data
PARAMS ((FILE *, unsigned char *, unsigned long, const char *));
static void define_fontdirs PARAMS ((void));
+/* look for the preprocessor program */
+
+FILE *
+look_for_default (cmd, prefix, end_prefix, preprocargs, filename)
+ char *cmd;
+ char *prefix;
+ int end_prefix;
+ char *preprocargs;
+ char *filename;
+{
+ char *path = getenv ("PATH");
+ char *space;
+ int found;
+ struct stat s;
+
+ strcpy (cmd, prefix);
+
+ sprintf (cmd+end_prefix, "%s", DEFAULT_PREPROCESSOR);
+ space = strchr (cmd+end_prefix, ' ');
+ if (space)
+ *space = 0;
+
+ if (strchr (cmd, '/'))
+ {
+ found = stat (cmd, &s);
+
+ if (found < 0)
+ {
+ if (verbose)
+ fprintf (stderr, "Tried `%s'\n", cmd);
+ return 0;
+ }
+ }
+
+ strcpy (cmd, prefix);
+
+ sprintf (cmd+end_prefix, "%s %s %s",
+ DEFAULT_PREPROCESSOR, preprocargs, filename);
+
+ if (verbose)
+ fprintf (stderr, "Using `%s'\n", cmd);
+
+ cpp_pipe = popen (cmd, FOPEN_RT);
+ return cpp_pipe;
+}
+
/* Read an rc file. */
struct res_directory *
@@ -131,21 +177,78 @@ read_rc_file (filename, preprocessor, preprocargs, language)
{
char *cmd;
- if (preprocessor == NULL)
- preprocessor = DEFAULT_PREPROCESSOR;
-
if (preprocargs == NULL)
preprocargs = "";
if (filename == NULL)
filename = "-";
- cmd = xmalloc (strlen (preprocessor)
- + strlen (preprocargs)
- + strlen (filename)
- + 10);
- sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename);
+ if (preprocessor)
+ {
+ cmd = xmalloc (strlen (preprocessor)
+ + strlen (preprocargs)
+ + strlen (filename)
+ + 10);
+ sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename);
- cpp_pipe = popen (cmd, FOPEN_RT);
+ cpp_pipe = popen (cmd, FOPEN_RT);
+ }
+ else
+ {
+ char *dash, *slash, *cp;
+
+ preprocessor = DEFAULT_PREPROCESSOR;
+
+ cmd = xmalloc (strlen (program_name)
+ + strlen (preprocessor)
+ + strlen (preprocargs)
+ + strlen (filename)
+ + 10);
+
+
+ dash = slash = 0;
+ for (cp=program_name; *cp; cp++)
+ {
+ if (*cp == '-')
+ dash = cp;
+ if (
+#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__)
+ *cp == ':' || *cp == '\\' ||
+#endif
+ *cp == '/')
+ {
+ slash = cp;
+ dash = 0;
+ }
+ }
+
+ cpp_pipe = 0;
+
+ if (dash)
+ {
+ /* First, try looking for a prefixed gcc in the windres
+ directory, with the same prefix as windres */
+
+ cpp_pipe = look_for_default (cmd, program_name, dash-program_name+1,
+ preprocargs, filename);
+ }
+
+ if (slash && !cpp_pipe)
+ {
+ /* Next, try looking for a gcc in the same directory as
+ that windres */
+
+ cpp_pipe = look_for_default (cmd, program_name, slash-program_name+1,
+ preprocargs, filename);
+ }
+
+ if (!cpp_pipe)
+ {
+ /* Sigh, try the default */
+
+ cpp_pipe = look_for_default (cmd, "", 0, preprocargs, filename);
+ }
+
+ }
if (cpp_pipe == NULL)
fatal (_("can't popen `%s': %s"), cmd, strerror (errno));
free (cmd);
diff --git a/binutils/windres.c b/binutils/windres.c
index 885cd51..990db90 100644
--- a/binutils/windres.c
+++ b/binutils/windres.c
@@ -46,6 +46,10 @@
#include <ctype.h>
#include <time.h>
+/* used by resrc.c at least */
+
+int verbose = 0;
+
/* An enumeration of format types. */
enum res_format
@@ -122,6 +126,7 @@ static const struct option long_options[] =
{"output-format", required_argument, 0, 'O'},
{"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
{"target", required_argument, 0, 'F'},
+ {"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, OPTION_VERSION},
{"yydebug", no_argument, 0, OPTION_YYDEBUG},
{0, no_argument, 0, 0}
@@ -705,7 +710,9 @@ Options:\n\
-F TARGET, --target TARGET Specify COFF target\n\
--preprocessor PROGRAM Program to use to preprocess rc file\n\
--include-dir DIR Include directory when preprocessing rc file\n\
- --define SYM[=VAL] Define SYM when preprocessing rc file\n\
+ -DSYM[=VAL], --define SYM[=VAL]\n\
+ Define SYM when preprocessing rc file\n\
+ -v Verbose - tells you what it's doing\n\n
--language VAL Set language when reading rc file\n"));
#ifdef YYDEBUG
fprintf (stream, _("\
@@ -794,7 +801,7 @@ main (argc, argv)
preprocargs = NULL;
language = -1;
- while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:", long_options,
+ while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:v", long_options,
(int *) 0)) != EOF)
{
switch (c)
@@ -843,6 +850,10 @@ main (argc, argv)
}
break;
+ case 'v':
+ verbose ++;
+ break;
+
case OPTION_INCLUDE_DIR:
if (preprocargs == NULL)
{
diff --git a/binutils/windres.h b/binutils/windres.h
index a3c789a..db43dd5 100644
--- a/binutils/windres.h
+++ b/binutils/windres.h
@@ -742,6 +742,8 @@ struct bindata
unsigned char *data;
};
+extern int verbose;
+
/* Function declarations. */
extern struct res_directory *read_rc_file