In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ba0f5503397ddc65667224047f121adc8b44784c?hp=c5cc3237190cc21fd5e0be13a3bf06942e5303a3>

- Log -----------------------------------------------------------------
commit ba0f5503397ddc65667224047f121adc8b44784c
Author: David Mitchell <[email protected]>
Date:   Wed Dec 4 15:53:51 2013 +0000

    do cflags on stdout, not stderr
    
    The current UNIX build system does a strange thing to generate the
    appropriate command-line to compile a particular src file. It calls
    the cflags shell script, which
    1) echoes to stdout the command line needed to compile the specified
       file (excluding the name of the src file itself), e.g.
            cc -c -Dfoo -Wbar ...
    2) echoes the same thing to stderr, prefixied with '          CCCMD ='
    
    Make then does
    
        `sh cflags foo.o`  foo.c
    
    the cflags output to stdout is captured by the backticks, and is used
    by make as the command line to run (with the foo.c appended). This run is
    silent. The output to stderr isn't captured, and gets displayed. So the
    user sees:
    
        $ make
        `sh cflags foo.o` foo.c
                  CCCMD = cc -c -Dfoo -Wbar ...
        ...
    
    This is annoying for 2 reasons:
    1) you don't get a simple command-line displayed which you could do a
    simple cut and paste with (e.g. when you want to recompile a specific
    source file, but alter the flags).
    2) The make generates output on stderr, even when then there aren't any
    errors. So "make 2>errs" can't be used to quickly spot warnings and
    errors.
    
    This commit fixes this by making cflags just output the cc command and
    flags to stdout, then get Makefile to call it twice, once to echo
    the command-line (on stdout), and once to execute it with backticks.
    So the make output is now:
    
        $ make
        cc -c -Dfoo -Wbar ... foo.c
        ...
    
    There is some stuff in Makefile.SH related to cross-compiling, which this
    commit make have broken. Specifically the CCCMD and CCCMDSRC macros
    have been changed in the normal case to remove backticks (and add them to
    the make rules instead), but not for the cross compilation route.
    The CC* defs in the cross-compilation case have a trailing -I$(CROSS_LIB)
    outside of the backticks, which compilates matters.
    
    However, in the subdir Cross/, there appears to be separate (and
    divergent) copies of Makefile.SH and cflags, so maybe the files
    I edited are no longer used for cross-compilation????
    
    (followup: according to
       <[email protected]>
    the cross-compiling stuff I mentioned above has bit-rotted, and I don't
    need to worry about it)

M       Makefile.SH
M       cflags.SH

commit 44213caae04b4cd4f4a3abf272bd783994216b59
Author: David Mitchell <[email protected]>
Date:   Tue Dec 3 17:12:17 2013 +0000

    cflags/cflags.SH: use '#' comments
    
    These scripts had a mixture of old-style ':' comments and new-style
    '#' comments. Since they have both, the old ones can't be needed for
    portability reasons, so standardise on the modern form.
    
    The old-style were just too confusing, especially as my syntax highlighter
    didn't know about them.

M       cflags.SH

commit cb9238a74bae69edc848d03a50c29d86772d1d22
Author: David Mitchell <[email protected]>
Date:   Tue Dec 3 16:17:56 2013 +0000

    cflags.SH - add commentary
    
    Add comments to the top of cflags.SH to explain what it does.
    Also make it output comments at the top of the generated cflags
    script explaining that its auto-generated.

M       cflags.SH
-----------------------------------------------------------------------

Summary of changes:
 Makefile.SH | 16 +++++++++------
 cflags.SH   | 66 ++++++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 51 insertions(+), 31 deletions(-)

diff --git a/Makefile.SH b/Makefile.SH
index 2f7668d..98b9ae2 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -409,9 +409,9 @@ case $CROSS_NAME in
 ## In the following dollars and backticks do not need the extra backslash.
 $spitshell >>$Makefile <<'!NO!SUBS!'
 
-CCCMD    = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@`
+CCCMD    = sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $@
 
-CCCMDSRC = `sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<`
+CCCMDSRC = sh $(shellflags) cflags "optimize='$(OPTIMIZE)'" $<
 
 CONFIGPM_FROM_CONFIG_SH = lib/Config.pm lib/Config_heavy.pl
 CONFIGPM = $(CONFIGPM_FROM_CONFIG_SH) lib/Config_git.pl
@@ -566,13 +566,16 @@ splintflags = \
 splintfiles = $(c1)
 
 .c$(OBJ_EXT): 
-       $(CCCMD) $(PLDLFLAGS) $*.c
+       @echo `$(CCCMD)` $(PLDLFLAGS) $*.c
+       @`$(CCCMD)` $(PLDLFLAGS) $*.c
 
 .c.i: 
-       $(CCCMDSRC) -E $*.c > $*.i
+       @echo `$(CCCMDSRC)` -E $*.c \> $*.i
+       @`$(CCCMDSRC)` -E $*.c > $*.i
 
 .c.s:
-       $(CCCMDSRC) -S $*.c
+       @echo `$(CCCMDSRC)` -S $*.c
+       @`$(CCCMDSRC)` -S $*.c
 
 all: $(FIRSTMAKEFILE) $(MINIPERL_EXE) $(generated_pods) $(private) 
$(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
        @echo " ";
@@ -666,7 +669,8 @@ ${file}mini.c: $file.c
     $spitshell >>$Makefile <<!GROK!THIS!
 
 ${file}mini\$(OBJ_EXT): ${file}mini.c
-       \$(CCCMD) \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB 
${file}mini.c
+       echo @\`\$(CCCMD)\` \$(PLDLFLAGS) $DPERL_IS_MINIPERL 
$DPERL_EXTERNAL_GLOB ${file}mini.c
+       @\`\$(CCCMD)\` \$(PLDLFLAGS) $DPERL_IS_MINIPERL $DPERL_EXTERNAL_GLOB 
${file}mini.c
 !GROK!THIS!
 done
 
diff --git a/cflags.SH b/cflags.SH
index a80eb5d..54ce74c 100755
--- a/cflags.SH
+++ b/cflags.SH
@@ -1,5 +1,17 @@
 #!/bin/sh
 
+# Generate the cflags script, which is used to determine what cflags
+# to pass to the compiler.
+# We create a temporary test c program and repeatedly compile it with
+# various candidate flags, and from the compiler output, determine what
+# flags are supported.
+# From this we initialise the following variables in the cflags script:
+#
+#   $warn
+#   $stdflags
+#   $extra
+#   $_exe
+
 case $PERL_CONFIG_SH in
 '')
        if test -f config.sh; then TOP=.;
@@ -13,8 +25,8 @@ case $PERL_CONFIG_SH in
        . $TOP/config.sh
        ;;
 esac
-: This forces SH files to create target in same directory as SH file.
-: This is so that make depend always knows where to find SH derivatives.
+# This forces SH files to create target in same directory as SH file.
+# This is so that make depend always knows where to find SH derivatives.
 case "$0" in
 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
 esac
@@ -202,14 +214,19 @@ esac
 extra=''
 
 echo "Extracting cflags (with variable substitutions)"
-: This section of the file will have variable substitutions done on it.
-: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
-: Protect any dollar signs and backticks that you do not want interpreted
-: by putting a backslash in front.  You may delete these comments.
+# This section of the file will have variable substitutions done on it.
+# Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
+# Protect any dollar signs and backticks that you do not want interpreted
+# by putting a backslash in front.  You may delete these comments.
 rm -f cflags
 $spitshell >cflags <<!GROK!THIS!
 $startsh
 
+# !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
+
+# This file is generated by cflags.SH
+
+
 # Extra warnings, used e.g. for gcc.
 warn="$warn"
 # Extra standardness.
@@ -221,7 +238,7 @@ _exe="$_exe"
 
 !GROK!THIS!
 
-: In the following dollars and backticks do not need the extra backslash.
+# In the following dollars and backticks do not need the extra backslash.
 $spitshell >>cflags <<'!NO!SUBS!'
 case $PERL_CONFIG_SH in
 '')
@@ -237,8 +254,13 @@ case $PERL_CONFIG_SH in
        ;;
 esac
 
-: syntax: cflags [optimize=XXX] [file[.suffix]]
-: displays the compiler command line for file
+# syntax: cflags [optimize=XXX] [file[.suffix]] ...
+#   displays the proposed compiler command line for each 'file'
+#
+#   with no file, dispalys it for all *.c files.
+#   The optimise=XXX arg (if present) is evalled, setting the default
+#   value of the $optimise variable, which is output on the command line
+#   (but which may be overridden for specific files below)
 
 case "X$1" in
 Xoptimize=*|X"optimize=*")
@@ -247,11 +269,6 @@ Xoptimize=*|X"optimize=*")
        ;;
 esac
 
-also=': '
-case $# in
-1) also='echo 1>&2 "     CCCMD = "'
-esac
-
 case $# in
 0) set *.c; echo "The current C flags are:" ;;
 esac
@@ -265,31 +282,31 @@ for file do
     *) echo $n "    $file.c    $c" ;;
     esac
 
-    : allow variables like toke_cflags to be evaluated
+    # allow variables like toke_cflags to be evaluated
 
     if echo $file | grep -v / >/dev/null
     then
       eval 'eval ${'"${file}_cflags"'-""}'
     fi
 
-    : or customize here
+    # or customize here
 
     case "$file" in
     *) ;;
 
-    *) : Customization examples follow: ;;
+    # Customization examples follow:
     av) ccflags=`echo $ccflags | sed -e s/-pipe//` ;;
     deb) ccflags="$ccflags -fno-jump-tables" ;;
     hv) warn=`echo $warn | sed -e s/-Wextra//` ;;
     toke) optimize=-O0 ;;
     esac
 
-    : The examples are intentionally unreachable as the '*)' case always
-    : matches. To use them, move before the '*)' and edit as appropriate.
-    : It is not a good idea to set ccflags to an absolute value here, as it
-    : often contains general -D defines which are needed for correct
-    : compilation. It is better to edit ccflags as shown, using interpolation
-    : to add flags, or sed to remove flags.
+    # The examples are intentionally unreachable as the '*)' case always
+    # matches. To use them, move before the '*)' and edit as appropriate.
+    # It is not a good idea to set ccflags to an absolute value here, as it
+    # often contains general -D defines which are needed for correct
+    # compilation. It is better to edit ccflags as shown, using interpolation
+    # to add flags, or sed to remove flags.
 
 
     case "$cc" in
@@ -339,9 +356,8 @@ for file do
     esac
 
 
-    : Can we perhaps use $ansi2knr here
+    # Can we perhaps use $ansi2knr here
     echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
-    eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn 
$extra"'
 
     . $TOP/config.sh
 

--
Perl5 Master Repository

Reply via email to