summaryrefslogtreecommitdiff
path: root/contrib/gcc/gcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/gcc.c')
-rw-r--r--contrib/gcc/gcc.c79
1 files changed, 73 insertions, 6 deletions
diff --git a/contrib/gcc/gcc.c b/contrib/gcc/gcc.c
index 7845fc3f013f..b4e3ef71a36e 100644
--- a/contrib/gcc/gcc.c
+++ b/contrib/gcc/gcc.c
@@ -22,6 +22,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
This paragraph is here to try to keep Sun CC from dying.
The number of chars here seems crucial!!!! */
+/* $FreeBSD$ */
+
/* This program is the user interface to the C compiler and possibly to
other compilers. It is used because compilation is a complicated procedure
which involves running several programs and passing temporary files between
@@ -688,11 +690,10 @@ static const char *cpp_unique_options =
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
%{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__}\
+ %{fshort-wchar:-U__WCHAR_TYPE__ -D__WCHAR_TYPE__=short\\ unsigned\\ int}\
%{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0}\
%{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap}\
- %{g3:-dD} %{H} %C\
- %{fshort-wchar:-U__WCHAR_TYPE__ -D__WCHAR_TYPE__=short\\ unsigned\\ int}\
- %{D*&U*&A*} %{i*} %Z %i\
+ %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i\
%{E|M|MM:%W{o*}}";
/* This contains cpp options which are common with cc1_options and are passed
@@ -1327,9 +1328,11 @@ static const char *gcc_exec_prefix;
#ifndef TOOLDIR_BASE_PREFIX
#define TOOLDIR_BASE_PREFIX "/usr/local/"
#endif
+#ifndef FREEBSD_NATIVE
#ifndef STANDARD_BINDIR_PREFIX
#define STANDARD_BINDIR_PREFIX "/usr/local/bin"
#endif
+#endif /* not FREEBSD_NATIVE */
static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
static const char *const standard_exec_prefix_1 = "/usr/lib/gcc/";
@@ -1344,7 +1347,9 @@ static const char *const standard_startfile_prefix_2 = "/usr/lib/";
static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
static const char *tooldir_prefix;
+#ifndef FREEBSD_NATIVE
static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
+#endif /* not FREEBSD_NATIVE */
/* Subdirectory to use for locating libraries. Set by
set_multilib_dir based on the compilation options. */
@@ -3218,6 +3223,7 @@ process_command (argc, argv)
/* 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]. */
+#ifndef FREEBSD_NATIVE
#ifndef VMS
/* FIXME: make_relative_prefix doesn't yet work for VMS. */
if (!gcc_exec_prefix)
@@ -3228,6 +3234,7 @@ process_command (argc, argv)
putenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL));
}
#endif
+#endif /* not FREEBSD_NATIVE */
if (gcc_exec_prefix)
{
@@ -3354,6 +3361,44 @@ process_command (argc, argv)
}
}
+ /* Options specified as if they appeared on the command line. */
+ temp = getenv ("GCC_OPTIONS");
+ if ((temp) && (strlen (temp) > 0))
+ {
+ int len;
+ int optc = 1;
+ int new_argc;
+ const char **new_argv;
+ char *envopts;
+
+ while (isspace (*temp))
+ temp++;
+ len = strlen (temp);
+ envopts = (char *) xmalloc (len + 1);
+ strcpy (envopts, temp);
+
+ for (i = 0; i < (len - 1); i++)
+ if ((isspace (envopts[i])) && ! (isspace (envopts[i+1])))
+ optc++;
+
+ new_argv = (const char **) alloca ((optc + argc) * sizeof(char *));
+
+ for (i = 0, new_argc = 1; new_argc <= optc; new_argc++)
+ {
+ while (isspace (envopts[i]))
+ i++;
+ new_argv[new_argc] = envopts + i;
+ while (!isspace (envopts[i]) && (envopts[i] != '\0'))
+ i++;
+ envopts[i++] = '\0';
+ }
+ for (i = 1; i < argc; i++)
+ new_argv[new_argc++] = argv[i];
+
+ argv = new_argv;
+ argc = new_argc;
+ }
+
/* Convert new-style -- options to old-style. */
translate_options (&argc, &argv);
@@ -3804,19 +3849,27 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
(such as cpp) rather than those of the host system. */
/* Use 2 as fourth arg meaning try just the machine as a suffix,
as well as trying the machine and the version. */
+#ifdef FREEBSD_NATIVE
+ add_prefix (&exec_prefixes, PREFIX"/bin/", "BINUTILS",
+ 0, 0, warn_std_ptr, 0);
+#endif /* FREEBSD_NATIVE */
#ifndef OS2
add_prefix (&exec_prefixes, standard_exec_prefix, "GCC",
PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
+#ifndef FREEBSD_NATIVE
add_prefix (&exec_prefixes, standard_exec_prefix_1, "BINUTILS",
PREFIX_PRIORITY_LAST, 2, warn_std_ptr, 0);
+#endif /* not FREEBSD_NATIVE */
#endif
+#ifndef FREEBSD_NATIVE
add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
add_prefix (&startfile_prefixes, standard_exec_prefix_1, "BINUTILS",
PREFIX_PRIORITY_LAST, 1, warn_std_ptr, 0);
+#endif /* not FREEBSD_NATIVE */
tooldir_prefix = concat (tooldir_base_prefix, spec_machine,
dir_separator_str, NULL);
@@ -3851,12 +3904,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
dir_separator_str, tooldir_prefix, NULL);
}
+#ifndef FREEBSD_NATIVE
add_prefix (&exec_prefixes,
concat (tooldir_prefix, "bin", dir_separator_str, NULL),
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 0);
add_prefix (&startfile_prefixes,
concat (tooldir_prefix, "lib", dir_separator_str, NULL),
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+#endif /* FREEBSD_NATIVE */
/* More prefixes are enabled in main, after we read the specs file
and determine whether this is cross-compilation or not. */
@@ -5716,6 +5771,7 @@ is_directory (path1, path2, linker)
*cp++ = '.';
*cp = '\0';
+#ifndef FREEBSD_NATIVE
/* Exclude directories that the linker is known to search. */
if (linker
&& ((cp - path == 6
@@ -5726,6 +5782,7 @@ is_directory (path1, path2, linker)
dir_separator_str, "lib",
dir_separator_str, ".", NULL)) == 0)))
return 0;
+#endif /* FREEBSD_NATIVE */
return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode));
}
@@ -5910,9 +5967,13 @@ main (argc, argv)
/* Read specs from a file if there is one. */
+#ifdef FREEBSD_NATIVE
+ just_machine_suffix = "";
+#else /* FREEBSD_NATIVE */
machine_suffix = concat (spec_machine, dir_separator_str,
spec_version, dir_separator_str, NULL);
just_machine_suffix = concat (spec_machine, dir_separator_str, NULL);
+#endif /* FREEBSD_NATIVE */
specs_file = find_a_file (&startfile_prefixes, "specs", R_OK, 0);
/* Read the specs file unless it is a default one. */
@@ -5923,11 +5984,11 @@ main (argc, argv)
/* We need to check standard_exec_prefix/just_machine_suffix/specs
for any override of as, ld and libraries. */
- specs_file = (char *) alloca (strlen (standard_exec_prefix)
+ specs_file = (char *) alloca (strlen (FBSD_DATA_PREFIX)
+ strlen (just_machine_suffix)
+ sizeof ("specs"));
- strcpy (specs_file, standard_exec_prefix);
+ strcpy (specs_file, FBSD_DATA_PREFIX);
strcat (specs_file, just_machine_suffix);
strcat (specs_file, "specs");
if (access (specs_file, R_OK) == 0)
@@ -5973,10 +6034,12 @@ main (argc, argv)
NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
+#ifndef FREEBSD_NATIVE
add_prefix (&startfile_prefixes, standard_startfile_prefix_1,
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
add_prefix (&startfile_prefixes, standard_startfile_prefix_2,
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+#endif /* not FREEBSD_NATIVE */
#if 0 /* Can cause surprises, and one can use -B./ instead. */
add_prefix (&startfile_prefixes, "./", NULL,
PREFIX_PRIORITY_LAST, 1, NULL, 0);
@@ -5990,6 +6053,10 @@ main (argc, argv)
concat (gcc_exec_prefix, machine_suffix,
standard_startfile_prefix, NULL),
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+#ifdef CROSS_STARTFILE_PREFIX
+ add_prefix (&startfile_prefixes, CROSS_STARTFILE_PREFIX, "BINUTILS",
+ PREFIX_PRIORITY_LAST, 0, NULL, 1);
+#endif
}
/* Process any user specified specs in the order given on the command
@@ -6135,7 +6202,7 @@ main (argc, argv)
}
if (n_infiles == added_libraries)
- fatal ("no input files");
+ fatal ("No input files specified");
/* Make a place to record the compiler output file names
that correspond to the input files. */