[ dropping bug-m4 and automake, adding automake-patches list; this is
  http://thread.gmane.org/gmane.comp.gnu.m4.bugs/2012/focus=7639 ]

> > According to Nelson H. F. Beebe on 9/26/2006 8:51 AM:
> > > Machinetype:            Sun W40z (4 CPUs, 2400 MHz AMD64 Opteron, 8GB 
> > > RAM); FreeBSD 6.1-RELEASE #0
> > > Configure environment:  CC=/usr/bin/c89 CFLAGS=-I/usr/local/include 
> > > CXX=/usr/bin/g++
> > > 
> > > if /usr/bin/c89 -DHAVE_CONFIG_H -I. -I. -I..  -I../lib -I../lib   
> > > -I/usr/local/include -MT m4.o -MD -MP -MF ".deps/m4.Tpo" -c -o m4.o m4.c; 
> > > \
> > >   then mv -f ".deps/m4.Tpo" ".deps/m4.Po"; else rm -f ".deps/m4.Tpo"; 
> > > exit 1; fi
> > > c89: illegal option -- M
> > > usage: c89 [-cEgOs] [-D name[=value]] ... [-I directory] ... [-L 
> > > directory] ...
> > >            [-o outfile] [-U name] ... operand ...
> > > 
> > >        where operand is one or more of file.c, file.o, file.a
> > >        or -llibrary
> > > make[2]: *** [m4.o] Error 1

There are two possible ways to go: try to move the -M<X> flags to the
end at the compile stage (to fool the c89 wrapper and still use fastdep
mode), or do the test with the flags added earlier on the command line.

Notes:
- For aesthetics, it is desirable to have the source file name appear at
  the end of the command lines at compile time
  (see the comment in automake/lib/am/depend2.am for a rationale).
- Putting the flags early will cause the `gcc' depmode to be used.
  This mode is still good enough, and, as all other modes != gcc3, does
  not exhibit the inconsistency wrt. depflag position.
- The gcc3 depmode, when issued with help of the `depcomp' script, will
  be slowed down somewhat now.  This isn't really an issue for makefiles
  generated by Automake, as they bypass the script at compile time with
  the %FASTDEP% switch.  It may, however, affect some people out there
  that have decided to operate the dependency tracking algorithm out of
  Automake (and use only the former but not the latter).  Oh well, I
  don't think we need to care too much here.
- Thus, it is IMHO rather safe to just add the flags right before we
  find a `-c' argument in `depcomp': the only time we actually use that
  is while determining `depmode' at configure time, and then we have
  good control over the command line anyway.
- AFAICS, there should be no issues with Libtool here.

Attached are two alternative patches, both of which should fix the
issue.  OK to install the second, and drop the first?

By the way, there is at least one Autoconf issue here, too, and I think
this is what Eric hinted at: $GCC gets set to yes due to __GNUC__ being
defined, which causes _AC_PROG_CC_G to add `-O2' to the command line.
But `c89', unlike `c99', only understands `-O', not `-O <NUM>'.  Oh
well,
  ./configure CFLAGS='-g -O'

serves as an easy workaround, I guess...

Cheers,
Ralf
        * lib/am/depend2.am (%FASTDEP%): Put dependency extraction flags
        at the end of the command line, for FreeBSD's c89.
        Bug report against M4 by Nelson H. F. Beebe.

Index: lib/am/depend2.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/depend2.am,v
retrieving revision 1.61
diff -u -r1.61 depend2.am
--- lib/am/depend2.am   31 Aug 2006 04:49:24 -0000      1.61
+++ lib/am/depend2.am   27 Sep 2006 16:49:07 -0000
@@ -57,7 +57,9 @@
 ## would be a good compromise.  Actually we use two line rather than one,
 ## because this way %SOURCE% is always located at the end of the first
 ## line and is therefore easier to spot.  (We need an extra line when
-## depbase is used.)
+## depbase is used.)  Unfortunately, FreeBSD's c89 errors out if the
+## -M<X> flags (of gcc3 depmode) appear before the source file name,
+## so we can't use that in this case.
 
 if %?NONLIBTOOL%
 ?GENERIC?%EXT%.o:
@@ -65,10 +67,10 @@
 if %FASTDEP%
 ## In fast-dep mode, we can always use -o.
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC?     %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% 
`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
-?GENERIC??!SUBDIROBJ?  %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o 
%OBJ% %SOURCE%
+?!GENERIC?     %COMPILE% %-c% -o %OBJ% `test -f '%SOURCE%' || echo 
'$(srcdir)/'`%SOURCE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo
+?GENERIC??!SUBDIROBJ?  %COMPILE% %-c% -o %OBJ% %SOURCE% -MT %OBJ% -MD -MP -MF 
%DEPBASE%.Tpo
 ?GENERIC??SUBDIROBJ?   depbase=`echo %OBJ% | sed 
's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
-?GENERIC??SUBDIROBJ?   %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o 
%OBJ% %SOURCE% &&\
+?GENERIC??SUBDIROBJ?   %COMPILE% %-c% -o %OBJ% %SOURCE% -MT %OBJ% -MD -MP -MF 
%DEPBASE%.Tpo &&\
        mv -f %DEPBASE%.Tpo %DEPBASE%.Po
 else !%FASTDEP%
 if %AMDEP%
@@ -90,10 +92,10 @@
 if %FASTDEP%
 ## In fast-dep mode, we can always use -o.
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC?     %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o 
%OBJOBJ% `if test -f '%SOURCE%'; then $(CYGPATH_W) '%SOURCE%'; else 
$(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi`
-?GENERIC??!SUBDIROBJ?  %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% 
-o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'`
+?!GENERIC?     %COMPILE% %-c% -o %OBJOBJ% `if test -f '%SOURCE%'; then 
$(CYGPATH_W) '%SOURCE%'; else $(CYGPATH_W) '$(srcdir)/%SOURCE%'; fi` -MT 
%OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo
+?GENERIC??!SUBDIROBJ?  %COMPILE% %-c% -o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` 
-MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo
 ?GENERIC??SUBDIROBJ?   depbase=`echo %OBJ% | sed 
's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
-?GENERIC??SUBDIROBJ?   %COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% 
-o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` &&\
+?GENERIC??SUBDIROBJ?   %COMPILE% %-c% -o %OBJOBJ% `$(CYGPATH_W) '%SOURCE%'` 
-MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo &&\
        mv -f %DEPBASE%.Tpo %DEPBASE%.Po
 else !%FASTDEP%
 if %AMDEP%
@@ -117,10 +119,10 @@
 if %FASTDEP%
 ## In fast-dep mode, we can always use -o.
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC?     %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o 
%LTOBJ% `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
-?GENERIC??!SUBDIROBJ?  %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% 
-o %LTOBJ% %SOURCE%
+?!GENERIC?     %LTCOMPILE% %-c% -o %LTOBJ% `test -f '%SOURCE%' || echo 
'$(srcdir)/'`%SOURCE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo
+?GENERIC??!SUBDIROBJ?  %LTCOMPILE% %-c% -o %LTOBJ% %SOURCE% -MT %LTOBJ% -MD 
-MP -MF %DEPBASE%.Tpo
 ?GENERIC??SUBDIROBJ?   depbase=`echo %OBJ% | sed 
's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
-?GENERIC??SUBDIROBJ?   %LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% 
-o %LTOBJ% %SOURCE% &&\
+?GENERIC??SUBDIROBJ?   %LTCOMPILE% %-c% -o %LTOBJ% %SOURCE% -MT %LTOBJ% -MD 
-MP -MF %DEPBASE%.Tpo &&\
        mv -f %DEPBASE%.Tpo %DEPBASE%.Plo
 else !%FASTDEP%
 if %AMDEP%
        * lib/depcomp (gcc3): Put dependency extraction flags before the
        `-c' flag, so they appear at the same position as in %FASTDEP%
        mode in depend2.am.  Fixes build failure for FreeBSD's c89,
        which ignores unknown options only after the first non-option.
        Bug report against M4 by Nelson H. F. Beebe.

Index: lib/depcomp
===================================================================
RCS file: /cvs/automake/automake/lib/depcomp,v
retrieving revision 1.58
diff -u -r1.58 depcomp
--- lib/depcomp 9 Jul 2006 16:09:43 -0000       1.58
+++ lib/depcomp 27 Sep 2006 16:49:19 -0000
@@ -90,9 +90,21 @@
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
 ## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
 ## it if -MD -MP comes after the -MF stuff.  Hmm.
-  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am:
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
   stat=$?
   if test $stat -eq 0; then :
   else

Reply via email to