This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Automatic makefile dependencies for generated ld/e*.c


On Wed, Apr 17, 2019 at 11:11:59AM -0700, H.J. Lu wrote:
> This breaks AMDEP with in-tree build:
> 
> [hjl@gnu-4 ld]$ /bin/sh ./genscripts.sh "." "/usr/lib64" "/usr" "/usr"
> x86_64-redhat-linux-gnu x86_64-redhat-linux-gnu x86_64-redhat-linux
> ".deps" "" "elf_x86_64 elf_i386 elf32_x86_64 elf_l1om elf_k1om
> i386pep" "/usr/local/lib /lib /usr/lib" yes yes i386pep "x86_64-pep"
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 132: .deps/ei386pep.Tc: No such file or directory
> cat: .deps/ei386pep.Tc: No such file or directory
> ./genscripts.sh: line 650: .deps/ei386pep.Pc: No such file or directory
> [hjl@gnu-4 ld]$

I don't usually build in the source tree, but when I did just now I
didn't see this.  Were you building in a tree that had already been
configured before updating the source?

Hmm, I can see that we might get this sort of failure with
--enable-dependency-tracking=no since the .deps dir won't be created
when configuring.

	* Makefile.am (GENDEPDIR): New var, used..
	(GENSCRIPTS): ..here.
	* Makefile.in: Regenerate.
	* genscripts.sh: Test for $DEPDIR set before every use.

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 0e9dc862e5..4a0bb15227 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -152,6 +152,7 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \
 BFDLIB = ../bfd/libbfd.la
 LIBIBERTY = ../libiberty/libiberty.a
 
+# These all start with e so 'make clean' can find them.
 ALL_EMULATION_SOURCES = \
 	eaix5ppc.c \
 	eaix5rs6.c \
@@ -611,9 +612,12 @@ ldemul-list.h: Makefile
 stringify.sed: ${srcdir}/emultempl/$(STRINGIFY)
 	  cp ${srcdir}/emultempl/$(STRINGIFY) stringify.sed
 
-# These all start with e so 'make clean' can find them.
-
-GENSCRIPTS = $(SHELL) $(srcdir)/genscripts.sh "${srcdir}" "${libdir}" "${prefix}" "${exec_prefix}" @host@ @target@ @target_alias@ "${DEPDIR}" "${LIB_PATH}" "@EMULATION_LIBPATH@" "@NATIVE_LIB_DIRS@" @use_sysroot@ @enable_initfini_array@
+if AMDEP
+  GENDEPDIR=$(DEPDIR)
+else
+  GENDEPDIR=
+endif
+GENSCRIPTS = $(SHELL) $(srcdir)/genscripts.sh "${srcdir}" "${libdir}" "${prefix}" "${exec_prefix}" @host@ @target@ @target_alias@ "$(GENDEPDIR)" "${LIB_PATH}" "@EMULATION_LIBPATH@" "@NATIVE_LIB_DIRS@" @use_sysroot@ @enable_initfini_array@
 GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed
 
 @TDIRS@
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index 7ee03d2b1c..cb2b081e9e 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -129,11 +129,15 @@ TOOL_LIB=$2
 
 source_sh()
 {
-  echo $1 >> ${DEPDIR}/e${EMULATION_NAME}.Tc
+  if test -n "${DEPDIR}"; then
+    echo $1 >> ${DEPDIR}/e${EMULATION_NAME}.Tc
+  fi
   . $1
 }
 
-rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
+if test -n "${DEPDIR}"; then
+  rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
+fi
 
 # Include the emulation-specific parameters:
 CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh"
@@ -639,12 +643,14 @@ fi
 > e${EMULATION_NAME}.c
 source_em ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
 
-ecdeps=
-for dep in `cat ${DEPDIR}/e${EMULATION_NAME}.Tc`; do
-  case " $ecdeps " in
-    *" $dep "*): ;;
-    *) ecdeps="$ecdeps $dep" ;;
-  esac
-done
-rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
-echo "e${EMULATION_NAME}.c:${ecdeps}" > ${DEPDIR}/e${EMULATION_NAME}.Pc
+if test -n "${DEPDIR}"; then
+  ecdeps=
+  for dep in `cat ${DEPDIR}/e${EMULATION_NAME}.Tc`; do
+    case " $ecdeps " in
+      *" $dep "*): ;;
+      *) ecdeps="$ecdeps $dep" ;;
+    esac
+  done
+  rm -f ${DEPDIR}/e${EMULATION_NAME}.Tc
+  echo "e${EMULATION_NAME}.c:${ecdeps}" > ${DEPDIR}/e${EMULATION_NAME}.Pc
+fi

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]