commit:     74be6618a29b1c8749ccc2ab840e96168f2ade34
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  4 03:02:00 2025 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Fri Apr  4 03:44:28 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74be6618

sci-electronics/spice: correctly error when compiling fails

The makefiles for this project are from 1989, back when software
developers still knew how to write real build systems. For example, real
build systems are intelligent enough to:

- mark loads of rules as "-command", which tells make to not fail if the
  command fails
- run make by concatenating makefile fragments and piping it to `make -f -`
- recursively run more makes via concatenation
- pass -k to all make invocations, so that we try to build as much as
  possible even if we can't succeed in the end
- mandatorily require running make from a shell script that sets up
  everything, somehow

There is only one slight problem with this otherwise brilliant design.
Namely, none of it is a good idea.

ANYWAY, this software does not build due to Modern C violations. It is
also entirely uninteresting to invest serious time in the build system
for this thing, or even attempt to report it, since the software exists
as a wikipedia "historically significant events" page plus random
third-party download sites and web.archive.org and a progression of
modernized and extended forks. The actual project was declared finished
and done with in 1993.

I'm told keeping the package around is important because, as the father
of an entire industry, it's important to have as a point of reference
whenever doing various kinds of work. Still, the darned thing could do a
bit better about actually compiling. Step 1 is to error out on compile
failures, rather than succeeding and then failing to run the built
executables / have the input files for "dobin" and erroring out with
inscrutable messages.

Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 .../files/spice-3.5.5-makefile-exit-on-fail.patch  | 66 ++++++++++++++++++++++
 sci-electronics/spice/spice-3.5.5-r4.ebuild        |  4 +-
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git 
a/sci-electronics/spice/files/spice-3.5.5-makefile-exit-on-fail.patch 
b/sci-electronics/spice/files/spice-3.5.5-makefile-exit-on-fail.patch
new file mode 100644
index 000000000000..f0af690c9fef
--- /dev/null
+++ b/sci-electronics/spice/files/spice-3.5.5-makefile-exit-on-fail.patch
@@ -0,0 +1,66 @@
+From 57beed0c071b159695a8695de23325bdfd5f1ec6 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwart...@gmail.com>
+Date: Thu, 3 Apr 2025 20:51:10 -0400
+Subject: [PATCH] src_compile: exit on failure
+
+This "build script" wraps around `make` in some horrifying ways. And as
+a result, if make exits with an error this is ignored.
+
+To cap it off, the entire software is based around recursive make -k so
+it takes forever to build and return errors. There is no point in doing
+this just to get a failed build; be more responsive.
+---
+ util/build                | 2 +-
+ util/skeleton/make_std.bd | 8 ++++----
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/util/build b/util/build
+index bf4bbcc..c740858 100755
+--- a/util/build
++++ b/util/build
+@@ -172,7 +172,7 @@ if test -z "${DEBUG}"; then
+       $EXEC cat ${FILES0} "${TOP0}/${DIR}/${SUBDIR}/makedefs" \
+               "${TMP_TRAILER}" "${SKEL_DIR}/make_std.bd" \
+       | make -f - bootstrap DIR="${DIR}" SUBDIR="${SUBDIR}" \
+-              VPATH="${TOP0}/${DIR}/${SUBDIR}" CWD="${CWD}"
++              VPATH="${TOP0}/${DIR}/${SUBDIR}" CWD="${CWD}" || exit
+       echo Done with build at `date`
+ else
+       $EXEC cat ${FILES0} "${TOP0}/${DIR}/${SUBDIR}/makedefs" \
+diff --git a/util/skeleton/make_std.bd b/util/skeleton/make_std.bd
+index d4ef591..50baf3a 100644
+--- a/util/skeleton/make_std.bd
++++ b/util/skeleton/make_std.bd
+@@ -16,17 +16,17 @@ BUILD_DIR =                                                
                      \
+               echo Making \"$(PURPOSE)\" in "$${NEW_NAME}";                 \
+               cat $(FILES_L) $${NEW_DIR}/makedefs                           \
+                       $(FILES_T) $${OFILE} $${DFILE}                        \
+-              | ${MAKE} -f - -k recursive                                   \
++              | ${MAKE} -f - recursive                                      \
+                       PARENT="$${NEW_PARENT}" NAME="$${NEW_NAME}"           \
+                       $${SET_COMP} $${COMP_TO_CWD} $${CWD_TO_COMP}          \
+                       VPATH="$${NEW_VPATH}" SUBDIR="$${SUBDIR}"             \
+-                      DIR="$${DIR}"
++                      DIR="$${DIR}" || exit
+ 
+ .c.o:
+       $(CC) $(CFLAGS) $(INCLUDE) -c $(SRC_DIR)/$*.c $(OUTPUT) $(ASM_HACK)
+ 
+ bootstrap: always
+-      -@if test "x$(DIR)" = "xsrc/"; then                                   \
++      @if test "x$(DIR)" = "xsrc/"; then                                    \
+               if test ! -d "$(OBJ_DIR)"; then                               \
+                       $(MKDIR) -p "$(OBJ_DIR)";                             \
+               fi;                                                           \
+@@ -41,7 +41,7 @@ bootstrap: always
+       $(BUILD_DIR);
+ 
+ recurse: $(PRE_PURPOSE) $(UPDATE_TARGET)
+-      -@SUBDIRS="$(MAKE_SUBDIRS)";                                          \
++      @SUBDIRS="$(MAKE_SUBDIRS)";                                           \
+       for xx in $${SUBDIRS}; do                                             \
+               if test -z "$(DIR)"; then                                     \
+                       DIR=$${xx}/;                                          \
+-- 
+2.49.0
+

diff --git a/sci-electronics/spice/spice-3.5.5-r4.ebuild 
b/sci-electronics/spice/spice-3.5.5-r4.ebuild
index 383863ebe1d0..1fd93a015f94 100644
--- a/sci-electronics/spice/spice-3.5.5-r4.ebuild
+++ b/sci-electronics/spice/spice-3.5.5-r4.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -33,6 +33,8 @@ PATCHES=(
        "${FILESDIR}"/${P}-gcc-4.1.patch
        # Bug https://bugs.gentoo.org/783192
        "${FILESDIR}"/${P}-arlocal.patch
+       # util/build never exits on failure, leading to confusing reports
+       "${FILESDIR}"/${P}-makefile-exit-on-fail.patch
 )
 
 src_prepare() {

Reply via email to