/* FIXME: when autoconf is fixed, remove the host check - dj */
#if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX)
#define HAVE_TARGET_EXECUTABLE_SUFFIX
-#else
-#undef TARGET_EXECUTABLE_SUFFIX
-#define TARGET_EXECUTABLE_SUFFIX ""
#endif
/* By default there is no special suffix for host executables. */
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-#ifndef GET_ENV_PATH_LIST
-#define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
-#endif
-
/* Most every one is fine with LIBRARY_PATH. For some, it conflicts. */
#ifndef LIBRARY_PATH_ENV
#define LIBRARY_PATH_ENV "LIBRARY_PATH"
/* The target version specified with -V */
-static const char *spec_version = DEFAULT_TARGET_VERSION;
+static const char *const spec_version = DEFAULT_TARGET_VERSION;
/* The target machine specified with -b. */
# define STARTFILE_PREFIX_SPEC ""
#endif
-static const char *asm_debug = ASM_DEBUG_SPEC;
+static const char *asm_debug;
static const char *cpp_spec = CPP_SPEC;
static const char *cpp_predefines = CPP_PREDEFINES;
static const char *cc1_spec = CC1_SPEC;
call cc1 (or cc1obj in objc/lang-specs.h) from the main specs so
that we default the front end language better. */
static const char *trad_capable_cpp =
-"%{traditional|ftraditional|traditional-cpp:tradcpp0}\
- %{!traditional:%{!ftraditional:%{!traditional-cpp:cc1 -E}}}";
+"cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}";
static const char *cpp_unique_options =
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{CC:%{!E:%eGNU C does not support -CC without using -E}}\
- %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %{$} %I\
+ %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*} %{P} %I\
%{MD:-MD %W{!o: %b.d}%W{o*:%.d%*}}\
%{MMD:-MMD %W{!o: %b.d}%W{o*:%.d%*}}\
%{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
%{E|M|MM:%W{o*}}";
/* This contains cpp options which are common with cc1_options and are passed
- only when preprocessing only to avoid duplication. */
+ only when preprocessing only to avoid duplication. We pass the cc1 spec
+ options to the preprocessor so that it the cc1 spec may manipulate
+ options used to set target flags. Those special target flags settings may
+ in turn cause preprocessor symbols to be defined specially. */
static const char *cpp_options =
-"%(cpp_unique_options) %{std*} %{W*&pedantic*} %{w} %{m*} %{f*}\
+"%(cpp_unique_options) %1 %{std*} %{W*&pedantic*} %{w} %{m*} %{f*}\
%{O*} %{undef}";
/* This contains cpp options which are not passed when the preprocessor
static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
%1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
+ -auxbase%{c|S:%{o*:-strip%*}%{!o*: %b}}%{!c:%{!S: %b}}\
%{g*} %{O*} %{W*&pedantic*} %{w} %{std*} %{ansi}\
%{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
%{Qn:-fno-ident} %{--help:--help}\
{"@c",
/* cc1 has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps is given. */
- "%{E|M|MM:%(trad_capable_cpp) %{ansi:-std=c89} %(cpp_options)\
- %(cpp_debug_options)}\
+ "%{E|M|MM:%(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional:\
%eGNU C no longer supports -traditional without -E}\
%{save-temps|traditional-cpp:%(trad_capable_cpp) \
- %{ansi:-std=c89} %(cpp_options) %b.i \n\
+ %(cpp_options) %b.i \n\
cc1 -fpreprocessed %b.i %(cc1_options)}\
%{!save-temps:%{!traditional-cpp:\
- cc1 %{ansi:-std=c89} %(cpp_unique_options) %(cc1_options)}}\
+ cc1 %(cpp_unique_options) %(cc1_options)}}\
%{!fsyntax-only:%(invoke_as)}}}}", 0},
{"-",
"%{!E:%e-E required when input is from standard input}\
- %(trad_capable_cpp) %{ansi:-std=c89} %(cpp_options)", 0},
+ %(trad_capable_cpp) %(cpp_options)", 0},
{".h", "@c-header", 0},
{"@c-header",
"%{!E:%ecompilation of header file requested} \
- %(trad_capable_cpp) %{ansi:-std=c89} %(cpp_options) %(cpp_debug_options)",
+ %(trad_capable_cpp) %(cpp_options) %(cpp_debug_options)",
0},
{".i", "@cpp-output", 0},
{"@cpp-output",
}
#endif
+ /* Initialize here, not in definition. The IRIX 6 O32 cc sometimes chokes
+ on ?: in file-scope variable initializations. */
+ asm_debug = ASM_DEBUG_SPEC;
+
for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
{
sl = &static_specs[i];
{
char *temp;
- GET_ENV_PATH_LIST (temp, "PATH");
+ GET_ENVIRONMENT (temp, "PATH");
if (temp)
{
char *startp, *endp, *nstore;
/* Used to track if none of the -B paths are used. */
static int warn_B;
-/* Used to track if standard path isn't used and -b or -V is specified. */
-static int warn_std;
-
/* Gives value to pass as "warn" to add_prefix for standard prefixes. */
static int *warn_std_ptr = 0;
\f
int j;
#endif
- GET_ENV_PATH_LIST (gcc_exec_prefix, "GCC_EXEC_PREFIX");
+ GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX");
n_switches = 0;
n_infiles = 0;
}
}
+ /* If there is a -V or -b option (or both), process it now, before
+ trying to interpret the rest of the command line. */
+ if (argc > 1 && argv[1][0] == '-'
+ && (argv[1][1] == 'V' || argv[1][1] == 'b'))
+ {
+ const char *new_version = DEFAULT_TARGET_VERSION;
+ const char *new_machine = DEFAULT_TARGET_MACHINE;
+ const char *progname = argv[0];
+ char **new_argv;
+ char *new_argv0;
+ int baselen;
+
+ while (argc > 1 && argv[1][0] == '-'
+ && (argv[1][1] == 'V' || argv[1][1] == 'b'))
+ {
+ char opt = argv[1][1];
+ const char *arg;
+ if (argv[1][2] != '\0')
+ {
+ arg = argv[1] + 2;
+ argc -= 1;
+ argv += 1;
+ }
+ else if (argc > 2)
+ {
+ arg = argv[2];
+ argc -= 2;
+ argv += 2;
+ }
+ else
+ fatal ("`-%c' option must have argument", opt);
+ if (opt == 'V')
+ new_version = arg;
+ else
+ new_machine = arg;
+ }
+
+ for (baselen = strlen (progname); baselen > 0; baselen--)
+ if (IS_DIR_SEPARATOR (progname[baselen-1]))
+ break;
+ new_argv0 = xmemdup (progname, baselen,
+ baselen + concat_length (new_version, new_machine,
+ "-gcc-", NULL) + 1);
+ strcpy (new_argv0 + baselen, new_machine);
+ strcat (new_argv0, "-gcc-");
+ strcat (new_argv0, new_version);
+
+ new_argv = xmemdup (argv, (argc + 1) * sizeof (argv[0]),
+ (argc + 1) * sizeof (argv[0]));
+ new_argv[0] = new_argv0;
+
+ execvp (new_argv0, new_argv);
+ fatal ("couldn't run `%s': %s", new_argv0, xstrerror (errno));
+ }
+
/* Set up the default search paths. If there is no GCC_EXEC_PREFIX,
see if we can create it from the pathname specified in argv[0]. */
/* COMPILER_PATH and LIBRARY_PATH have values
that are lists of directory names with colons. */
- GET_ENV_PATH_LIST (temp, "COMPILER_PATH");
+ GET_ENVIRONMENT (temp, "COMPILER_PATH");
if (temp)
{
const char *startp, *endp;
}
}
- GET_ENV_PATH_LIST (temp, LIBRARY_PATH_ENV);
+ GET_ENVIRONMENT (temp, LIBRARY_PATH_ENV);
if (temp && *cross_compile == '0')
{
const char *startp, *endp;
}
/* Use LPATH like LIBRARY_PATH (for the CMU build program). */
- GET_ENV_PATH_LIST (temp, "LPATH");
+ GET_ENVIRONMENT (temp, "LPATH");
if (temp && *cross_compile == '0')
{
const char *startp, *endp;
/* Scan argv twice. Here, the first time, just count how many switches
there will be in their vector, and how many input files in theirs.
- Also parse any switches that determine the configuration name, such as -b.
Here we also parse the switches that cc itself uses (e.g. -v). */
for (i = 1; i < argc; i++)
switch (c)
{
case 'b':
- n_switches++;
- if (p[1] == 0 && i + 1 == argc)
- fatal ("argument to `-b' is missing");
- if (p[1] == 0)
- spec_machine = argv[++i];
- else
- spec_machine = p + 1;
-
- warn_std_ptr = &warn_std;
+ case 'V':
+ fatal ("`-%c' must come at the start of the command line", c);
break;
case 'B':
else
{
char ch = switches[n_switches].part1[0];
- if (ch == 'b' || ch == 'B')
+ if (ch == 'B')
switches[n_switches].validated = 1;
}
n_switches++;
/* If not cross-compiling, look for startfiles in the standard places.
Similarly, don't add the standard prefixes if startfile handling
will be under control of startfile_prefix_spec. */
- if (*cross_compile == '0' || *startfile_prefix_spec == 0)
+ if (*cross_compile == '0' && *startfile_prefix_spec == 0)
{
if (*md_exec_prefix)
{