Re: [PATCH] amhello: help compilers not supporting -c and -o together

2012-01-05 Thread Peter Rosin
Stefano Lattarini skrev 2012-01-05 10:04:
> On 01/05/2012 01:46 AM, Peter Rosin wrote:
>> Hi!
>>
>> Ok for maint, or should the example be as simple as it can possible get
>> even if portability is sacrificed?
>>
> Are you sure portability is being sacrificed in our example?  I thought that
> the use of `-c' and `-o' together was only required when target-specific flags
> where used (as with e.g. "foo_CPPFLAGS = -DFOO=1").  Am I missing something?

No.  I simply forgot about that.  But while -o (w/o -c) does work for
cl *in this case*, -o has been deprecated for eons (IIRC it was deprecated
at least in MSVC 6, some 10-15 years ago, but perhaps it was deprecated even
before that?) and doesn't work as one would hope (you can't move the output
to some other directory, or something like that).

Anyway, this doesn't look too good (but it works):

$ cl -o hello.exe main.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9035 : option 'o' has been deprecated and will be 
removed in a future release
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
/out:hello.exe
main.obj


While this looks so much better:

$ lib/compile cl -o hello.exe main.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:hello.exe
main.obj


But lets cross the bridge when MS actually removes that option.


> You might also want to look at the test `amhello-binpkg.test'; if it doesn't
> fail when using a compiler that cannot grasp `-c -o' together, then our 
> example
> should have no portability problem.

Right.

Wasted effort, sigh...

Cheers,
Peter



Re: [PATCH] amhello: help compilers not supporting -c and -o together

2012-01-05 Thread Stefano Lattarini
On 01/05/2012 01:46 AM, Peter Rosin wrote:
> Hi!
> 
> Ok for maint, or should the example be as simple as it can possible get
> even if portability is sacrificed?
>
Are you sure portability is being sacrificed in our example?  I thought that
the use of `-c' and `-o' together was only required when target-specific flags
where used (as with e.g. "foo_CPPFLAGS = -DFOO=1").  Am I missing something?

You might also want to look at the test `amhello-binpkg.test'; if it doesn't
fail when using a compiler that cannot grasp `-c -o' together, then our example
should have no portability problem.

Thanks,
  Stefano



[PATCH] amhello: help compilers not supporting -c and -o together

2012-01-04 Thread Peter Rosin
Hi!

Ok for maint, or should the example be as simple as it can possible get
even if portability is sacrificed?

Cheers,
Peter

>From 782f44dd4d3d42beb9d43ee0dd7cf46accc44731 Mon Sep 17 00:00:00 2001
From: Peter Rosin 
Date: Thu, 5 Jan 2012 01:43:11 +0100
Subject: [PATCH] amhello: help compilers not supporting -c and -o together

doc/amhello/configure.ac: Add AM_PROG_CC_C_O.
doc/automake.texi (Hello World): Likewise.  Also update the expected
output from autoreconf and configure.  Describe what AM_PROG_CC_C_O
does in brief terms.
doc/Makefile.am (amhello_configury): Add compile.
---
 doc/Makefile.am  |1 +
 doc/amhello/configure.ac |1 +
 doc/automake.texi|   18 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f4f76c6..0839d5f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -55,6 +55,7 @@ amhello_configury = \
   aclocal.m4 \
   autom4te.cache \
   Makefile.in \
+  compile \
   config.h.in \
   configure \
   depcomp \
diff --git a/doc/amhello/configure.ac b/doc/amhello/configure.ac
index cd378cb..5fef25f 100644
--- a/doc/amhello/configure.ac
+++ b/doc/amhello/configure.ac
@@ -5,6 +5,7 @@
 AC_INIT([amhello], [1.0], [bug-autom...@gnu.org])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([
  Makefile
diff --git a/doc/automake.texi b/doc/automake.texi
index 0c4dc01..3a08ee2 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -1470,6 +1470,7 @@ create the @command{configure} script.
 AC_INIT([amhello], [1.0], [@value{PACKAGE_BUGREPORT}])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([
  Makefile
@@ -1487,14 +1488,15 @@ command as follows:
 
 @example
 ~/amhello % @kbd{autoreconf --install}
-configure.ac: installing `./install-sh'
-configure.ac: installing `./missing'
+configure.ac:4: installing `./compile'
+configure.ac:2: installing `./install-sh'
+configure.ac:2: installing `./missing'
 src/Makefile.am: installing `./depcomp'
 @end example
 
 At this point the build system is complete.
 
-In addition to the three scripts mentioned in its output, you can see
+In addition to the four scripts mentioned in its output, you can see
 that @command{autoreconf} created four other files: @file{configure},
 @file{config.h.in}, @file{Makefile.in}, and @file{src/Makefile.in}.
 The latter three files are templates that will be adapted to the
@@ -1509,16 +1511,17 @@ checking for gawk... no
 checking for mawk... mawk
 checking whether make sets $(MAKE)... yes
 checking for gcc... gcc
-checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
-checking whether we are cross compiling... no
+checking for C compiler default output file name... a.out
 checking for suffix of executables...
+checking whether we are cross compiling... no
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 checking for style of include used by make... GNU
 checking dependency style of gcc... gcc3
+checking whether gcc and cc understand -c and -o together... yes
 configure: creating ./config.status
 config.status: creating Makefile
 config.status: creating src/Makefile
@@ -1577,6 +1580,7 @@ Let us begin with the contents of @file{configure.ac}.
 AC_INIT([amhello], [1.0], [@value{PACKAGE_BUGREPORT}])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([
  Makefile
@@ -1635,6 +1639,10 @@ creates @file{src/Makefile} from @file{src/Makefile.in}, 
it will define
 a @file{Makefile.in} that uses @code{CC} but @file{configure.ac} does
 not define it, it will suggest you add a call to @code{AC_PROG_CC}.
 
+The @code{AM_PROG_CC_C_O} line triggers the help from the @command{compile}
+script when the C compiler does not support the @option{-c} and
+@option{-o} options together.
+
 The @code{AC_CONFIG_HEADERS([config.h])} invocation causes the
 @command{configure} script to create a @file{config.h} file gathering
 @samp{#define}s defined by other macros in @file{configure.ac}.  In our
-- 
1.7.5.1