This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Include sysdep.h before stdio.h in ldlex.c
- From: Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>
- To: binutils at sourceware dot org, Franz Fehringer <fehrin at t-online dot de>, Tristan Gingold <gingold at adacore dot com>, rdsandiford at googlemail dot com
- Date: Tue, 9 Feb 2010 07:40:19 +0100
- Subject: Re: Include sysdep.h before stdio.h in ldlex.c
- References: <878wb3v7nd.fsf@firetop.home>
Hello Richard,
* Richard Sandiford wrote on Mon, Feb 08, 2010 at 08:39:50PM CET:
> ld/
> * Makefile.am (ldlex.o): Depend on ldlex-wrapper.c too, and compile
> that instead of ldlex.c.
> * Makefile.in: Regenerate.
> * ldlex.l (sysdep.h): Don't include here.
> * ldlex-wrapper.c: New file.
>
> Index: ld/Makefile.am
> ===================================================================
> --- ld/Makefile.am 2010-01-12 20:30:19.000000000 +0000
> +++ ld/Makefile.am 2010-02-08 19:21:35.000000000 +0000
> @@ -480,16 +480,16 @@ endif
> $(COMPILE) -c `test -f ldgram.c || echo $(srcdir)/`ldgram.c $(NO_WERROR)
> endif
>
> -ldlex.o: ldlex.c
> +ldlex.o: ldlex-wrapper.c ldlex.c
> if am__fastdepCC
> - $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f ldlex.c || echo $(srcdir)/`ldlex.c $(NO_WERROR)
> + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/ldlex-wrapper.c $(NO_WERROR)
> mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
> else
> if AMDEP
> - source='ldlex.c' object='$@' libtool=no @AMDEPBACKSLASH@
> + source='ldlex-wrapper.c' object='$@' libtool=no @AMDEPBACKSLASH@
> DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
> endif
> - $(COMPILE) -c `test -f ldlex.c || echo $(srcdir)/`ldlex.c $(NO_WERROR)
> + $(COMPILE) -c ldlex-wrapper.c $(NO_WERROR)
This will create ldlex-wrapper.o, not ldlex.o, for compilers other than
GCC. I'm not sure whether this code still needs to be portable to
compilers that don't understand '-c -o', but if it does, then possible
ways out are either: add AM_PROG_CC_C_O to configure.in, or rename the
input file so that the object matches the source file with s/\.c$/.o/.
If not (i.e., it is fine to assume that '-c -o' works), then adding -o
$@ right after -c should work. (The ordering helps depcomp.)
> endif
Cheers,
Ralf