This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: dependency tracking in ld
- From: Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>
- To: binutils at sourceware dot org
- Date: Sat, 15 Aug 2009 14:43:28 +0200
- Subject: Re: dependency tracking in ld
- References: <20090815124234.GA20656@gmx.de>
The removal of the cygnus Automake option requires a few changes in the
code. I hope I got all relevant ones right. The dependency tracking
should be tracking all files that have been tracked before, too.
However, there are still all the e*.o files which do not have dep
tracking yet. If you want this, then please say so, because it's a
matter of adding something like this line:
EXTRA_ld_new_SOURCES += $(ALL_EMULATIONS:.o=.c) $(ALL_64_EMULATIONS:.o=.c)
Another point to note is that the manual rules for ldgram.o and others
are fairly ugly and reflect the code automake would produce. There are
two ways away from it (should you want that):
1) If you require GNU make for ld/, then you can do something like this
instead:
ldgram.o: AM_CFLAGS+=$(NO_WERROR)
and let the inference rule .c.o do its work.
2) The automake-provided way for per-target flags is to have an
intermediate ("convenience") library, as in
ld_new_LDADD = libldgram.a
noinst_LIBRARIES = libldgram.a
libldgram_a_SOURCES = ldgram.c
libldgram_a_CFLAGS = $(NO_WERROR)
which of course is a bit less efficient, as it calls ar and ranlib,
but also it will rename the object to something like
libldgram_a_ldgram.o, so that it cannot interfere with a hypothetical
other object with that name compiled with other flags.
The rules I provided below are portable to non-GNU make, but use a bit
of automake internals.
Some of the special compilation rules could be eliminated
if the flags could just be passed to all rules. However,
I do not understand the code well enough to be able to tell
whether that is possible.
ld/ChangeLog:
2009-08-15 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.am (AUTOMAKE_OPTIONS): Remove cygnus. Add
no-texinfo.tex, no-dist, foreign.
(TEXINFO_TEX): New variable.
(install-data-local): Removed, not needed any more.
(all): Dependencies upon info and ld.1 not needed any more.
(MKDEP, DEP, DEP1, dep.sed, dep, dep-in, dep-am): Removed.
(mkdep generated section): Removed.
(ldgram.o, ldlex.o, deffilep.o, ldmain.o, ldfile.o): Rewrite to
use automake dependency tracking mechanism.
(EXTRA_ld_new_SOURCES): Add pep-dll.c pe-dll.c, so their
dependencies are tracked too.
(BUILT_SOURCES): New, list $(GENERATED_HFILES) to ensure they
are built early.
* configure.in: Use AM_MAINTAINER_MODE.
* aclocal.m4, configure, Makefile.in: Regenerate.
diff --git a/ld/Makefile.am b/ld/Makefile.am
index fc4a47e..a6abe8e 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -1,7 +1,8 @@
## Process this file with automake to generate Makefile.in
-AUTOMAKE_OPTIONS = cygnus dejagnu
+AUTOMAKE_OPTIONS = dejagnu no-texinfo.tex no-dist foreign
ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
+TEXINFO_TEX = $(top_srcdir)/../texinfo/texinfo.tex
SUBDIRS = po
@@ -36,7 +37,6 @@ LIB_PATH = @LIB_PATH@
BASEDIR = $(srcdir)/..
BFDDIR = $(BASEDIR)/bfd
INCDIR = $(BASEDIR)/include
-MKDEP = gcc -MM
# What version of the manual to build
DOCVER = gen
@@ -449,6 +449,10 @@ HFILES = ld.h ldctor.h ldemul.h ldexp.h ldfile.h \
GENERATED_CFILES = ldgram.c ldlex.c deffilep.c
GENERATED_HFILES = ldgram.h ldemul-list.h deffilep.h
+# Require an early dependency on the generated headers, as the dependency
+# tracking will not cause them to be built beforehand.
+BUILT_SOURCES = $(GENERATED_HFILES)
+
OFILES = ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o \
ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o \
ldfile.o ldcref.o ${EMULATION_OFILES} ${EMUL_EXTRA_OFILES}
@@ -457,12 +461,41 @@ STAGESTUFF = *.o ldscripts/* e*.c
# Disable -Werror, if it has been enabled, since old versions of bison/
# yacc will produce working code which contain compile time warnings.
-ldgram.o:
- $(COMPILE) -c $< $(NO_WERROR)
-ldlex.o:
- $(COMPILE) -c $< $(NO_WERROR)
-deffilep.o:
- $(COMPILE) -c $< $(NO_WERROR)
+ldgram.o: ldgram.c
+if am__fastdepCC
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ ldgram.c $(NO_WERROR)
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+else
+if AMDEP
+ source='ldgram.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+endif
+ $(COMPILE) -c ldgram.c $(NO_WERROR)
+endif
+
+ldlex.o: ldlex.c
+if am__fastdepCC
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ ldlex.c $(NO_WERROR)
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+else
+if AMDEP
+ source='ldlex.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+endif
+ $(COMPILE) -c ldlex.c $(NO_WERROR)
+endif
+
+deffilep.o: deffilep.c
+if am__fastdepCC
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ deffilep.c $(NO_WERROR)
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+else
+if AMDEP
+ source='deffilep.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+endif
+ $(COMPILE) -c deffilep.c $(NO_WERROR)
+endif
# At the moment this is just a list of those emulation template files
# that contain internationalised strings.
@@ -475,15 +508,39 @@ po/POTFILES.in: @MAINT@ Makefile
&& mv tmp $(srcdir)/po/POTFILES.in
ldmain.o: ldmain.c config.status
+if am__fastdepCC
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ \
+ -DDEFAULT_EMULATION='"$(EMUL)"' \
+ -DBINDIR='"$(bindir)"' -DTOOLBINDIR='"$(tooldir)/bin"' \
+ -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ $(srcdir)/ldmain.c
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+else
+if AMDEP
+ source='deffilep.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+endif
$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
-DBINDIR='"$(bindir)"' -DTOOLBINDIR='"$(tooldir)/bin"' \
-DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
$(srcdir)/ldmain.c
+endif
ldfile.o: ldfile.c config.status
- $(COMPILE) -c -DSCRIPTDIR='"$(scriptdir)"' \
- -DBINDIR='"$(bindir)"' -DTOOLBINDIR='"$(tooldir)/bin"' \
+if am__fastdepCC
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ \
+ -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' -DTOOLBINDIR='"$(tooldir)/bin"' \
+ $(srcdir)/ldfile.c
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+else
+if AMDEP
+ source='deffilep.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+endif
+ $(COMPILE) -c -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
+ -DTOOLBINDIR='"$(tooldir)/bin"' \
$(srcdir)/ldfile.c
+endif
eelf32_spu.o: eelf32_spu.c
$(COMPILE) -c -DEMBEDSPU="\"`echo embedspu | sed '$(transform)'`\"" \
@@ -1761,6 +1818,8 @@ ez8002.c: $(srcdir)/emulparams/z8002.sh \
# We need this for automake to use YLWRAP.
EXTRA_ld_new_SOURCES = deffilep.y
+# Allow dependency tracking to work for these files, too.
+EXTRA_ld_new_SOURCES += pep-dll.c pe-dll.c
ld_new_SOURCES = ldgram.y ldlex.l lexsup.c ldlang.c mri.c ldctor.c ldmain.c \
ldwrite.c ldexp.c ldemul.c ldver.c ldmisc.c ldfile.c ldcref.c
@@ -1903,16 +1962,11 @@ install-data-local:
$(INSTALL_DATA) $$f $(DESTDIR)$(scriptdir)/$$f ; \
done
-# We want install to imply install-info as per GNU standards, despite the
-# cygnus option.
-install-data-local: install-info
-
# Stuff that should be included in a distribution. The diststuff
# target is run by the taz target in ../Makefile.in.
EXTRA_DIST = ldgram.c ldgram.h ldlex.c emultempl/spu_ovl.o_c \
emultempl/spu_icache.o_c deffilep.c deffilep.h $(man_MANS)
diststuff: info $(EXTRA_DIST)
-all: info ld.1
# Both info (ld.info) and ld.1 depend on configdoc.texi.
# But info isn't a direct target. Make info-recursive to depend on
@@ -1931,393 +1985,3 @@ MAINTAINERCLEANFILES += ld.info
if GENINSRC_NEVER
DISTCLEANFILES += ld.info
endif
-
-# Targets to rebuild dependencies in this Makefile.
-# Have to get rid of DEP1 here so that "$?" later includes all of $(CFILES).
-DEP: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h
- rm -f DEP1
- $(MAKE) MKDEP="$(MKDEP)" DEP1
- echo '# IF YOU PUT ANYTHING HERE IT WILL GO AWAY' >> DEP1
- if grep ' /' DEP1 > /dev/null 2> /dev/null; then \
- echo 'make DEP failed!'; exit 1; \
- else \
- mv -f DEP1 $@; \
- fi
-
-DEP1: $(CFILES) $(GENERATED_CFILES)
- echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > DEP2
- echo '# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.' >> DEP2
- for f in $?; do \
- $(MKDEP) $(INCLUDES) $(CFLAGS) $$f > DEPA; \
- sed -n -e '1s/: .*/: \\/p' -e q < DEPA >> DEP2; \
- sed -e '1s/.*: //' -f dep.sed < DEPA | \
- LC_ALL=C sort | LC_ALL=C uniq | \
- sed -e 's/^[AB]/ /' -e '$$s/ \\$$//' >> DEP2; \
- done
- rm -f DEPA
- mv -f DEP2 $@
-
-dep.sed: dep-in.sed config.status
- sed <$(srcdir)/dep-in.sed >dep.sed \
- -e 's!@INCDIR@!$(INCDIR)!' \
- -e 's!@BFDDIR@!$(BFDDIR)!' \
- -e 's!@SRCDIR@!$(srcdir)!' \
- -e 's!@TOPDIR@!'`echo $(srcdir) | sed -e s,/ld$$,,`'!'
-
-dep: DEP
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile
- cat DEP >> tmp-Makefile
- $(srcdir)/../move-if-change tmp-Makefile Makefile
-
-dep-in: DEP
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in
- cat DEP >> tmp-Makefile.in
- $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in
-
-dep-am: DEP
- sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.am > tmp-Makefile.am
- cat DEP >> tmp-Makefile.am
- $(srcdir)/../move-if-change tmp-Makefile.am $(srcdir)/Makefile.am
-
-.PHONY: dep dep-in dep-am
-
-# What appears below is generated by a hacked mkdep using gcc -MM.
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-ldctor.o: \
- ldctor.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldctor.h \
- ldexp.h \
- ldgram.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldemul.o: \
- ldemul.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldemul-list.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldexp.o: \
- ldexp.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldfile.o: \
- ldfile.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/filenames.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldlang.o: \
- ldlang.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/demangle.h \
- $(INCDIR)/fnmatch.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/hashtab.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/obstack.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldctor.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldmain.o: \
- ldmain.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/filenames.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/progress.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldctor.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- ldwrite.h \
- sysdep.h
-ldmisc.o: \
- ldmisc.c \
- $(BFDDIR)/elf-bfd.h \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/demangle.h \
- $(INCDIR)/elf/common.h \
- $(INCDIR)/elf/external.h \
- $(INCDIR)/elf/internal.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-ldver.o: \
- ldver.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- ../bfd/bfdver.h \
- config.h \
- ld.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldlang.h \
- ldmain.h \
- ldver.h \
- sysdep.h
-ldwrite.o: \
- ldwrite.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldgram.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- ldwrite.h \
- sysdep.h
-lexsup.o: \
- lexsup.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/demangle.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- ../bfd/bfdver.h \
- config.h \
- ld.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- ldver.h \
- sysdep.h
-mri.o: \
- mri.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldgram.h \
- ldlang.h \
- ldmisc.h \
- mri.h \
- sysdep.h
-ldcref.o: \
- ldcref.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/demangle.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/objalloc.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-pe-dll.o: \
- pe-dll.c \
- $(BFDDIR)/libcoff.h \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/coff/internal.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- deffile.h \
- ld.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- ldwrite.h \
- pe-dll.h \
- sysdep.h
-pep-dll.o: \
- pep-dll.c \
- $(BFDDIR)/libcoff.h \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/coff/internal.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- deffile.h \
- ld.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldmain.h \
- ldmisc.h \
- ldwrite.h \
- pe-dll.c \
- pep-dll.h \
- sysdep.h
-ldgram.o: \
- ldgram.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldctor.h \
- ldemul.h \
- ldexp.h \
- ldfile.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- ldver.h \
- mri.h \
- sysdep.h
-ldlex.o: \
- ldlex.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/bfdlink.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- ld.h \
- ldexp.h \
- ldfile.h \
- ldgram.h \
- ldlang.h \
- ldlex.h \
- ldmain.h \
- ldmisc.h \
- sysdep.h
-deffilep.o: \
- deffilep.c \
- $(INCDIR)/ansidecl.h \
- $(INCDIR)/fopen-same.h \
- $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h \
- $(INCDIR)/symcat.h \
- ../bfd/bfd.h \
- config.h \
- deffile.h \
- ld.h \
- ldmisc.h \
- sysdep.h
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/ld/configure.in b/ld/configure.in
index eddfeb1..c4655f5 100644
--- a/ld/configure.in
+++ b/ld/configure.in
@@ -11,6 +11,7 @@ changequote(,)dnl
BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ ]*\([^ ]*\)[ ]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
changequote([,])dnl
AM_INIT_AUTOMAKE(ld, ${BFD_VERSION})
+AM_MAINTAINER_MODE
AC_ARG_WITH(lib-path, [ --with-lib-path=dir1:dir2... set default LIB_PATH],LIB_PATH=$withval)
AC_ARG_ENABLE(targets,