gdb's configure creates config.status near the start of its run but only
generates gdb/Makefile near the end. A build interrupted with Ctrl-C in
between therefore left gdb_merge believing that gdb was configured, and
the incremental path then failed with the confusing
make[3]: *** No targets specified and no makefile found. Stop.
Write a .configured marker only after the configure script has finished
and test that instead, so such a tree is reconfigured rather than trusted.
When a tree is still incomplete, say so where the failure is visible and
point at "make distclean" instead of leaving make's message alone:
- rebuild reports the missing gdb/Makefile rather than letting the
gdb sub-make fail with "No targets specified and no makefile found"
- the "crash build failed" check adds the same advice when the marker
shows that configure did not complete
The target-mismatch instructions in configure.c now also note that
"make distclean" replaces the two manual steps.
Assisted-by: LLM
Signed-off-by: Dave Young <yangrr.2009(a)tsinghua.org.cn>
---
Makefile | 23 +++++++++++++++++++++--
configure.c | 4 +++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 3739bfa394a1..374f7b03e78a 100644
--- a/Makefile
+++ b/Makefile
@@ -383,23 +383,42 @@ help:
# opcodes already default to that -- without the full-screen TUI and
# without the libctf and libbacktrace libraries, none of which crash uses.
#
+# .configured is written only after the gdb configure script has finished.
+# gdb's config.status is created near the start of its configure run, so
+# testing for that would mistake a configure interrupted with Ctrl-C for a
+# complete one, and the incremental path below would then fail with
+# "No targets specified and no makefile found".
+#
gdb_merge: force
@if [ ! -f ${GDB}/README ]; then \
$(MAKE) gdb_unzip; fi
@echo "${LDFLAGS} -lz -ldl -rdynamic" > ${GDB}/gdb/mergelibs
@echo "../../${PROGRAM} ../../${PROGRAM}lib.a" > ${GDB}/gdb/mergeobj
@rm -f ${PROGRAM}
- @if [ ! -f ${GDB}/config.status ]; then \
+ @if [ ! -f ${GDB}/.configured ]; then \
(cd ${GDB}; ./configure ${GDB_CONF_FLAGS} --with-separate-debug-dir=/usr/lib/debug \
--with-bugurl="" --with-expat=no --with-python=no --disable-sim \
- --disable-tui --disable-libctf --disable-libbacktrace; \
+ --disable-tui --disable-libctf --disable-libbacktrace && \
+ touch .configured; \
$(MAKE) CRASH_TARGET=${TARGET}; echo ${TARGET} > crash.target) \
else $(MAKE) rebuild; fi
@if [ ! -f ${PROGRAM} ]; then \
echo; echo "${PROGRAM} build failed"; \
+ if [ ! -f ${GDB}/.configured ]; then \
+ echo; \
+ echo "The embedded gdb was not configured completely, which is what an";
\
+ echo "interrupted build leaves behind; \"make distclean\" removes
the"; \
+ echo "build products so the build can start over cleanly."; fi; \
echo; exit 1; fi
rebuild:
+ @if [ ! -f ${GDB}/gdb/Makefile ]; then \
+ echo; \
+ echo "${GDB}/gdb/Makefile does not exist, so the embedded gdb was left"; \
+ echo "unconfigured -- an interrupted build leaves it in this state."; \
+ echo "Remove the build products and start over with:"; \
+ echo; echo " make distclean"; \
+ echo; exit 1; fi
@if [ ! -f ${GDB}/${GDB}.patch ]; then \
touch ${GDB}/${GDB}.patch; fi
@if [ -f ${GDB}.patch ] && [ -s ${GDB}.patch ] && \
diff --git a/configure.c b/configure.c
index 615fdddd32c5..29129c94fca8 100644
--- a/configure.c
+++ b/configure.c
@@ -390,7 +390,9 @@ target_rebuild_instructions(struct supported_gdb_version *sp, char
*target)
fprintf(stderr, " 1. remove the %s subdirectory\n",
&sp->GDB[strlen("GDB=")]);
fprintf(stderr, " 2. perform a \"make clean\"\n");
- fprintf(stderr, " 3. retry the build\n\n");
+ fprintf(stderr, " 3. retry the build\n");
+ fprintf(stderr,
+ "\nOr do steps 1 and 2 with a single \"make distclean\".\n\n");
}
void
--
2.51.1