summaryrefslogtreecommitdiff
path: root/cflags.SH
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-12-04 15:53:51 +0000
committerDavid Mitchell <davem@iabyn.com>2013-12-25 20:30:47 +0000
commitba0f5503397ddc65667224047f121adc8b44784c (patch)
treee972e39d0ab94882661a6396b31bdd6dfdc81ae1 /cflags.SH
parent44213caae04b4cd4f4a3abf272bd783994216b59 (diff)
downloadperl-ba0f5503397ddc65667224047f121adc8b44784c.tar.gz
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 <20131204170112.GA2490@iabyn.com> the cross-compiling stuff I mentioned above has bit-rotted, and I don't need to worry about it)
Diffstat (limited to 'cflags.SH')
-rwxr-xr-xcflags.SH15
1 files changed, 7 insertions, 8 deletions
diff --git a/cflags.SH b/cflags.SH
index cd6697c6b0..54ce74c995 100755
--- a/cflags.SH
+++ b/cflags.SH
@@ -254,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=*")
@@ -264,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
@@ -358,7 +358,6 @@ for file do
# 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