]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 50300] Use CFLAGS value of "-O1" in POSIX mode.
authorPaul Smith <psmith@gnu.org>
Sun, 16 Apr 2017 19:40:57 +0000 (15:40 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Jun 2017 22:37:20 +0000 (18:37 -0400)
* read.c (record_files): Use "-O1" not "-O" for CFLAGS and FFLAGS.
* tests/scripts/targets/POSIX: Test for the new value.

read.c
tests/scripts/targets/POSIX

diff --git a/read.c b/read.c
index 047807ae74679c994c74c004550f2dd5abe79df6..5d84a13adeb7e2cba496ffbe3e305b0abc8a0923 100644 (file)
--- a/read.c
+++ b/read.c
@@ -2055,22 +2055,24 @@ record_files (struct nameseq *filenames, const char *pattern,
 
       /* Check for special targets.  Do it here instead of, say, snap_deps()
          so that we can immediately use the value.  */
-      if (streq (name, ".POSIX"))
+      if (!posix_pedantic && streq (name, ".POSIX"))
         {
           posix_pedantic = 1;
           define_variable_cname (".SHELLFLAGS", "-ec", o_default, 0);
-          /* These default values are based on IEEE Std 1003.1-2008.  */
+          /* These default values are based on IEEE Std 1003.1-2008.
+             It requires '-O 1' for [CF]FLAGS, but GCC doesn't allow space
+             between -O and the number so omit it here.  */
           define_variable_cname ("ARFLAGS", "-rv", o_default, 0);
           define_variable_cname ("CC", "c99", o_default, 0);
-          define_variable_cname ("CFLAGS", "-O", o_default, 0);
+          define_variable_cname ("CFLAGS", "-O1", o_default, 0);
           define_variable_cname ("FC", "fort77", o_default, 0);
-          define_variable_cname ("FFLAGS", "-O 1", o_default, 0);
+          define_variable_cname ("FFLAGS", "-O1", o_default, 0);
           define_variable_cname ("SCCSGETFLAGS", "-s", o_default, 0);
         }
-      else if (streq (name, ".SECONDEXPANSION"))
+      else if (!second_expansion && streq (name, ".SECONDEXPANSION"))
         second_expansion = 1;
 #if !defined (__MSDOS__) && !defined (__EMX__)
-      else if (streq (name, ".ONESHELL"))
+      else if (!one_shell && streq (name, ".ONESHELL"))
         one_shell = 1;
 #endif
 
index f9da8c35de744042f21a2515327b720c020a4c66..c44cc500111e76896a4343084fa70fbb2aa38a2d 100644 (file)
@@ -34,8 +34,8 @@ my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
              YACC => 'yacc', YFLAGS => '',
              LEX => 'lex', LFLAGS => '',
              LDFLAGS => '',
-             CC => 'c99', CFLAGS => '-O',
-             FC => 'fort77', FFLAGS => '-O 1',
+             CC => 'c99', CFLAGS => '-O1',
+             FC => 'fort77', FFLAGS => '-O1',
              SCCSFLAGS => '', SCCSGETFLAGS => '-s');
 my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
 my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);