diff options
author | obrien <obrien@FreeBSD.org> | 2001-05-29 09:54:45 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-05-29 09:54:45 +0000 |
commit | 9e25b214f6ffa5e1ce0477e0875814c6dc788513 (patch) | |
tree | 1994140af3d273beb3c28117801149b563fe84f5 /contrib/gcc/gcc.c | |
parent | 4228d2730e508fb2ae3cb1127aaeb27d4534874c (diff) | |
download | FreeBSD-src-9e25b214f6ffa5e1ce0477e0875814c6dc788513.zip FreeBSD-src-9e25b214f6ffa5e1ce0477e0875814c6dc788513.tar.gz |
Support the environmental var "GCC_OPTIONS". Which can hold a set of
default options for GCC. These options are interpreted first and can be
overwritten by explicit command line parameters. This provides one way of
adding [temporary] options to your world build w/o editing /etc/make.conf.
Diffstat (limited to 'contrib/gcc/gcc.c')
-rw-r--r-- | contrib/gcc/gcc.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/contrib/gcc/gcc.c b/contrib/gcc/gcc.c index fc3f5ae..a43bdf3 100644 --- a/contrib/gcc/gcc.c +++ b/contrib/gcc/gcc.c @@ -2744,6 +2744,44 @@ process_command (argc, argv) } #endif + /* 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; + 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 = (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); @@ -2853,6 +2891,14 @@ process_command (argc, argv) n_infiles++; i++; } + else if (strcmp (argv[i], "-l") == 0) + { + if (i + 1 == argc) + fatal ("argument to `-l' is missing"); + + n_infiles++; + i++; + } else if (strncmp (argv[i], "-l", 2) == 0) n_infiles++; else if (strcmp (argv[i], "-save-temps") == 0) @@ -3259,6 +3305,12 @@ process_command (argc, argv) infiles[n_infiles].language = "*"; infiles[n_infiles++].name = argv[++i]; } + else if (strcmp (argv[i], "-l") == 0) + { /* POSIX allows separation of -l and the lib arg; + canonicalize by concatenating -l with its arg */ + infiles[n_infiles].language = "*"; + infiles[n_infiles++].name = concat ("-l", argv[++i], NULL); + } else if (strncmp (argv[i], "-l", 2) == 0) { infiles[n_infiles].language = "*"; |