Source: ghdl
Followup-For: Bug #916475

Hello.

I see that you have committed most suggestions in this bug report.
Great!

Four were ignored, probably because you are busy with the build
failures.

Just in case, a rebased version is attached.

I have not tried a full rebuild, because it is also possible that you
prefer the existing code.
>From 9b98af64ac20f6e58674034bf07d8b6a589a3c33 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Wed, 14 Dec 2022 13:48:00 +0100
Subject: [PATCH 1/4] Simplify installation of the ghdl wrapper

---
 debian/ghdl-common.install                    | 7 ++++++-
 debian/installed-names/README                 | 2 ++
 debian/{ghdl.wrapper => installed-names/ghdl} | 0
 debian/rules                                  | 1 -
 4 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 debian/installed-names/README
 rename debian/{ghdl.wrapper => installed-names/ghdl} (100%)
 mode change 100644 => 100755

diff --git a/debian/ghdl-common.install b/debian/ghdl-common.install
index d76d810e..7ac15337 100644
--- a/debian/ghdl-common.install
+++ b/debian/ghdl-common.install
@@ -1,3 +1,8 @@
-usr/bin/ghdl
+# This Debian-specific script lives under debian/, but cannot be named
+# debian/ghdl because this path is used by dh_install tools.
+# dh_install cannot rename it during the installation phase, so it
+# lives in debian/installed-names.
+debian/installed-names/ghdl             usr/bin
+
 usr/lib/ghdl/src
 usr/lib/ghdl/include
diff --git a/debian/installed-names/README b/debian/installed-names/README
new file mode 100644
index 00000000..2b391142
--- /dev/null
+++ b/debian/installed-names/README
@@ -0,0 +1,2 @@
+A comment in debian/ghdl-common.install explains why this directory
+exists.
diff --git a/debian/ghdl.wrapper b/debian/installed-names/ghdl
old mode 100644
new mode 100755
similarity index 100%
rename from debian/ghdl.wrapper
rename to debian/installed-names/ghdl
diff --git a/debian/rules b/debian/rules
index 9644cf9a..b1c90406 100755
--- a/debian/rules
+++ b/debian/rules
@@ -159,7 +159,6 @@ override_dh_auto_build:
 	fi
 
 override_dh_auto_install:
-	install -pD debian/ghdl.wrapper $(CURDIR)/debian/tmp/usr/bin/ghdl
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Installing with mcode backend
-- 
2.30.2

>From 246eb3cb650ba8de44d05d6483356e960c3ae674 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Wed, 14 Dec 2022 14:02:42 +0100
Subject: [PATCH 2/4] Replace some hand-written commands with dh_install or
 link debhelper files

This should be a no-op, but reduce the overall complexity.

Shell/Make tests are replaced with package names in the debhelper
configuration file name.

Symbolic links are explicitly marked as such instead of created in the
already complex debian/rules, then installed as normal files by
debian/*.install.
---
 debian/ghdl-common.install |  6 +++++-
 debian/ghdl-gcc.install    |  1 -
 debian/ghdl-gcc.links      |  3 +++
 debian/ghdl-llvm.install   |  1 -
 debian/ghdl-llvm.links     |  3 +++
 debian/ghdl-mcode.install  |  1 -
 debian/ghdl-mcode.links    |  3 +++
 debian/rules               | 19 ++-----------------
 8 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/debian/ghdl-common.install b/debian/ghdl-common.install
index 7ac15337..5b739b1b 100644
--- a/debian/ghdl-common.install
+++ b/debian/ghdl-common.install
@@ -4,5 +4,9 @@
 # lives in debian/installed-names.
 debian/installed-names/ghdl             usr/bin
 
-usr/lib/ghdl/src
+# Depending on DEB_BUILD_PROFILES, between one and three copies are
+# installed under debian/tmp. A redundant shell wildcard should be
+# sufficient as long as the contents match.
+usr/lib/ghdl/*/vhdl/src/                usr/lib/ghdl
+
 usr/lib/ghdl/include
diff --git a/debian/ghdl-gcc.install b/debian/ghdl-gcc.install
index b721e0cd..a7c5c6f0 100644
--- a/debian/ghdl-gcc.install
+++ b/debian/ghdl-gcc.install
@@ -7,6 +7,5 @@ usr/lib/ghdl/gcc/vhdl/*.a
 usr/lib/ghdl/gcc/vhdl/grt.*
 usr/lib/ghdl/gcc/vhdl/grt-*.*
 
-usr/lib/ghdl/gcc/vhdl/src
 usr/lib/ghdl/gcc/vhdl/std
 usr/lib/ghdl/gcc/vhdl/ieee
diff --git a/debian/ghdl-gcc.links b/debian/ghdl-gcc.links
index 6ba63a7b..70f476c2 100644
--- a/debian/ghdl-gcc.links
+++ b/debian/ghdl-gcc.links
@@ -1 +1,4 @@
+# The actual files are provided by the ghdl-common package.
+usr/lib/ghdl/src                        usr/lib/ghdl/gcc/vhdl/src
+
 usr/share/man/man1/ghdl.1.gz usr/share/man/man1/ghdl-gcc.1.gz
diff --git a/debian/ghdl-llvm.install b/debian/ghdl-llvm.install
index b9abd68e..d2236f97 100644
--- a/debian/ghdl-llvm.install
+++ b/debian/ghdl-llvm.install
@@ -6,6 +6,5 @@ usr/lib/ghdl/llvm/vhdl/*.a
 usr/lib/ghdl/llvm/vhdl/grt.*
 usr/lib/ghdl/llvm/vhdl/grt-*.*
 
-usr/lib/ghdl/llvm/vhdl/src
 usr/lib/ghdl/llvm/vhdl/std
 usr/lib/ghdl/llvm/vhdl/ieee
diff --git a/debian/ghdl-llvm.links b/debian/ghdl-llvm.links
index 52b5924a..e4471ded 100644
--- a/debian/ghdl-llvm.links
+++ b/debian/ghdl-llvm.links
@@ -1 +1,4 @@
+# The actual files are provided by the ghdl-common package.
+usr/lib/ghdl/src                        usr/lib/ghdl/llvm/vhdl/src
+
 usr/share/man/man1/ghdl.1.gz usr/share/man/man1/ghdl-llvm.1.gz
diff --git a/debian/ghdl-mcode.install b/debian/ghdl-mcode.install
index 84e7ea12..176179f6 100644
--- a/debian/ghdl-mcode.install
+++ b/debian/ghdl-mcode.install
@@ -1,5 +1,4 @@
 usr/bin/ghdl-mcode
 usr/lib/ghdl/mcode/libghdlvpi.so
-usr/lib/ghdl/mcode/vhdl/src
 usr/lib/ghdl/mcode/vhdl/std
 usr/lib/ghdl/mcode/vhdl/ieee
diff --git a/debian/ghdl-mcode.links b/debian/ghdl-mcode.links
index de694b94..1ad44505 100644
--- a/debian/ghdl-mcode.links
+++ b/debian/ghdl-mcode.links
@@ -1 +1,4 @@
+# The actual files are provided by the ghdl-common package.
+usr/lib/ghdl/src                        usr/lib/ghdl/mcode/vhdl/src
+
 usr/share/man/man1/ghdl.1.gz usr/share/man/man1/ghdl-mcode.1.gz
diff --git a/debian/rules b/debian/rules
index b1c90406..dd82a431 100755
--- a/debian/rules
+++ b/debian/rules
@@ -189,24 +189,9 @@ override_dh_auto_install:
 	fi
 	@echo
 	@echo ------------------------------------------------------------
-	@echo Moving parts to required locations
+	@echo Removing sources installed by upstream but unwanted in Debian.
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_MCODE)" ]; then \
-		$(RM) -r debian/tmp/usr/lib/ghdl/src && \
-		mv debian/tmp/usr/lib/ghdl/mcode/vhdl/src debian/tmp/usr/lib/ghdl && \
-		ln -s ../../src debian/tmp/usr/lib/ghdl/mcode/vhdl/src; \
-	fi
-	if [ -n "$(WITH_LLVM)" ]; then \
-		$(RM) -r debian/tmp/usr/lib/ghdl/src && \
-		mv debian/tmp/usr/lib/ghdl/llvm/vhdl/src debian/tmp/usr/lib/ghdl && \
-		ln -s ../../src debian/tmp/usr/lib/ghdl/llvm/vhdl/src; \
-	fi
-	if [ -n "$(WITH_GCC)" ]; then \
-		$(RM) -r debian/tmp/usr/lib/ghdl/src && \
-		mv debian/tmp/usr/lib/ghdl/gcc/vhdl/src debian/tmp/usr/lib/ghdl && \
-		ln -s ../../src debian/tmp/usr/lib/ghdl/gcc/vhdl/src; \
-	fi
-	$(RM) debian/tmp/usr/lib/ghdl/src/ieee2008/LICENSE
+	$(RM) debian/tmp/usr/lib/ghdl/*/vhdl/src/ieee2008/LICENSE
 
 override_dh_dwz:
 	# dwz currently has problems with some debug sections created by the
-- 
2.30.2

>From 6d5b4bbe77577f1e9bfac6b556a0f2b169e96965 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Wed, 14 Dec 2022 13:09:10 +0100
Subject: [PATCH 3/4] debian/rules: replace some shell control constructs with
 Make equivalents

Move the list of local patches and the built-using value in separate
Make variables for readability.

Prefer Make conditionals to shell tests so that the log explicitly
show which execution path is selected.

Prefer a separate recipe line for each command, so that each exit
status is checked (without 'set -e' or '&&'). In case of failure, the
log is also more explicit about the last executed command.
---
 debian/rules | 182 +++++++++++++++++++++++++--------------------------
 1 file changed, 91 insertions(+), 91 deletions(-)

diff --git a/debian/rules b/debian/rules
index dd82a431..da020aae 100755
--- a/debian/rules
+++ b/debian/rules
@@ -73,27 +73,30 @@ override_dh_auto_clean:
 override_dh_installdocs:
 	dh_installdocs --link-doc=ghdl-common
 
+# Ignore comment lines, extensions like .diff and options like -p0.
+gcc_local_patches != sed '/^#/d; s/\..*//' debian/patches/gcc-$(DEB_GNAT_VERSION)/series
+
 override_dh_auto_configure:
 	mkdir -p $(BUILDDIR)/mcode $(BUILDDIR)/llvm $(BUILDDIR)/gcc
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Configuring with mcode backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_MCODE)" ]; then \
-		cd $(BUILDDIR)/mcode && \
-		../../configure --srcdir=../.. $(common_configure_arguments) \
-			--libdir=lib/ghdl/mcode; \
-	fi
+  ifneq (,$(WITH_MCODE))
+	cd $(BUILDDIR)/mcode && \
+	../../configure --srcdir=../.. $(common_configure_arguments) \
+		--libdir=lib/ghdl/mcode
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Configuring with llvm backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_LLVM)" ]; then \
-		cd $(BUILDDIR)/llvm && \
-		../../configure --srcdir=../.. $(common_configure_arguments) \
-			--libdir=lib/ghdl/llvm \
-			--with-llvm-config; \
-	fi
+  ifneq (,$(WITH_LLVM))
+	cd $(BUILDDIR)/llvm && \
+	../../configure --srcdir=../.. $(common_configure_arguments) \
+		--libdir=lib/ghdl/llvm \
+		--with-llvm-config
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Configuring with gcc backend
@@ -102,77 +105,76 @@ override_dh_auto_configure:
 	# We have to disable the gcc-verbose-lto-link patch since it replaces
 	# the LLINKER value with one that runs the linker under /usr/bin/time
 	# and the spaces are not escaped properly somewhere on the ghdl side.
-	set -e && \
-	if [ -n "$(WITH_GCC)" ]; then \
-		cd $(BUILDDIR)/gcc && \
-		ln -sf ${GCC_DIR}/gcc-*.tar.* && \
-		cp -a  ${GCC_DIR}/debian/ . && \
-		if [ -n "$$(grep -v '^\#' ${CURDIR}/debian/gcc-patches/gcc-${DEB_GNAT_VERSION}/series)" ]; then \
-			cp -n ${CURDIR}/debian/gcc-patches/gcc-${DEB_GNAT_VERSION}/*.diff debian/patches/  && \
-			cat ${CURDIR}/debian/gcc-patches/gcc-${DEB_GNAT_VERSION}/series >> debian/patches/series  && \
-			sed -i "s/\(^series_stamp.*\)/debian_patches += $$(grep -v '^#' ${CURDIR}/debian/gcc-patches/gcc-$(DEB_GNAT_VERSION)/series|sed 's/\..*//'|tr '\n' ' ')\n\n\1/" debian/rules.patch ; \
-		fi && \
-		echo -n > $(BUILDDIR)/gcc/debian/patches/gcc-verbose-lto-link.diff && \
-		debian/rules patch && \
-		../../configure --srcdir=../.. $(common_configure_arguments) \
-			--libdir=lib/ghdl/gcc \
-			--with-gcc=src && \
-		make copy-sources && \
-		mkdir -p gccbuild && \
-		cd gccbuild && \
-		../src/configure --prefix=/usr/lib/ghdl/gcc --enable-languages=vhdl \
-			--enable-multiarch --enable-default-pie \
-			--disable-bootstrap --disable-lto --disable-multilib \
-			--disable-libssp --disable-libgomp --disable-libquadmath \
-			--with-system-zlib --without-isl --without-included-gettext \
-			--with-gnu-as --with-gnu-ld \
-			--build=$(DEB_BUILD_GNU_TYPE) \
-			--host=$(DEB_HOST_GNU_TYPE) \
-			--target=$(DEB_TARGET_GNU_TYPE); \
-	fi
+  ifneq (,$(WITH_GCC))
+	ln -sf ${GCC_DIR}/gcc-*.tar.* -t$(BUILDDIR)/gcc
+	cp -a  ${GCC_DIR}/debian/ $(BUILDDIR)/gcc
+    ifneq (,$(gcc_local_patches))
+	cp -n ${CURDIR}/debian/gcc-patches/gcc-${DEB_GNAT_VERSION}/*.diff $(BUILDDIR)/gcc/debian/patches/
+	cat ${CURDIR}/debian/gcc-patches/gcc-${DEB_GNAT_VERSION}/series >> $(BUILDDIR)/gcc/debian/patches/series
+	sed -i "s/\(^series_stamp.*\)/debian_patches += $(gcc_local_patches)\n\n\1/" $(BUILDDIR)/gcc/debian/rules.patch
+    endif
+	echo -n > $(BUILDDIR)/gcc/debian/patches/gcc-verbose-lto-link.diff
+	make -C$(BUILDDIR)/gcc/ -fdebian/rules patch
+	cd $(BUILDDIR)/gcc && \
+	../../configure --srcdir=../.. $(common_configure_arguments) \
+		--libdir=lib/ghdl/gcc \
+		--with-gcc=src
+	make -C$(BUILDDIR)/gcc copy-sources
+	mkdir -p $(BUILDDIR)/gcc/gccbuild
+	cd $(BUILDDIR)/gcc/gccbuild && \
+	../src/configure --prefix=/usr/lib/ghdl/gcc --enable-languages=vhdl \
+		--enable-multiarch --enable-default-pie \
+		--disable-bootstrap --disable-lto --disable-multilib \
+		--disable-libssp --disable-libgomp --disable-libquadmath \
+		--with-system-zlib --without-isl --without-included-gettext \
+		--with-gnu-as --with-gnu-ld \
+		--build=$(DEB_BUILD_GNU_TYPE) \
+		--host=$(DEB_HOST_GNU_TYPE) \
+		--target=$(DEB_TARGET_GNU_TYPE)
+  endif
 
 override_dh_auto_build:
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Building with mcode backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_MCODE)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/mcode; \
-	fi
+  ifneq (,$(WITH_MCODE))
+	$(MAKE) -C $(BUILDDIR)/mcode
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Building with llvm backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_LLVM)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/llvm; \
-	fi
+  ifneq (,$(WITH_LLVM))
+	$(MAKE) -C $(BUILDDIR)/llvm
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Building with gcc backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_GCC)" ]; then \
-		$(MAKE) $(MAKEPARALLEL) -C $(BUILDDIR)/gcc/gccbuild && \
-		$(MAKE) -C $(BUILDDIR)/gcc lib/ghdl/gcc/libgrt.a all.vpi && \
-		$(MAKE) -C $(BUILDDIR)/gcc ghdllib \
-			GHDL_GCC_BIN=$(BUILDDIR)/gcc/gccbuild/gcc/ghdl \
-			GHDL1_GCC_BIN="--GHDL1=$(BUILDDIR)/gcc/gccbuild/gcc/ghdl1"; \
-	fi
+  ifneq (,$(WITH_GCC))
+	$(MAKE) $(MAKEPARALLEL) -C $(BUILDDIR)/gcc/gccbuild
+	$(MAKE) -C $(BUILDDIR)/gcc lib/ghdl/gcc/libgrt.a all.vpi
+	$(MAKE) -C $(BUILDDIR)/gcc ghdllib \
+		GHDL_GCC_BIN=$(BUILDDIR)/gcc/gccbuild/gcc/ghdl \
+		GHDL1_GCC_BIN="--GHDL1=$(BUILDDIR)/gcc/gccbuild/gcc/ghdl1"
+  endif
 
 override_dh_auto_install:
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Installing with mcode backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_MCODE)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=../../debian/tmp; \
-	fi
+  ifneq (,$(WITH_MCODE))
+	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=../../debian/tmp
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Installing with llvm backend
 	@echo ------------------------------------------------------------
-	if [ -n "$(WITH_LLVM)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=../../debian/tmp; \
-	fi
+  ifneq (,$(WITH_LLVM))
+	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=../../debian/tmp
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Installing with gcc backend
@@ -180,13 +182,13 @@ override_dh_auto_install:
 	# Place a symlink for the binary ahead of time so that the compilation
 	# of the VHDL standard libraries works during the gcc install step. The
 	# binary is properly moved afterwards.
-	if [ -n "$(WITH_GCC)" ]; then \
-		mkdir -p $(CURDIR)/debian/tmp/usr/bin && \
-		ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(CURDIR)/debian/tmp/usr/bin/ghdl-gcc && \
-		$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install \
-			DESTDIR=$(CURDIR)/debian/tmp && \
-		$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(CURDIR)/debian/tmp; \
-	fi
+  ifneq (,$(WITH_GCC))
+	mkdir -p $(CURDIR)/debian/tmp/usr/bin
+	ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(CURDIR)/debian/tmp/usr/bin/ghdl-gcc
+	$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install \
+		DESTDIR=$(CURDIR)/debian/tmp
+	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(CURDIR)/debian/tmp
+  endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Removing sources installed by upstream but unwanted in Debian.
@@ -210,34 +212,32 @@ override_dh_auto_test:
 	# work right when run from the build directory. To keep it simple
 	# simply install into a temporary location and tell the testsuite to
 	# find ghdl there.
-	if [ -n "$(WITH_MCODE)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=$(TESTRUNDIR)/mcode && \
-		debian/tests/ghdl-tests buildtest mcode; \
-	fi
-	if [ -n "$(WITH_LLVM)" ]; then \
-		$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=$(TESTRUNDIR)/llvm && \
-		debian/tests/ghdl-tests buildtest llvm; \
-	fi
+  ifneq (,$(WITH_MCODE))
+	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=$(TESTRUNDIR)/mcode
+	debian/tests/ghdl-tests buildtest mcode
+  endif
+  ifneq (,$(WITH_LLVM))
+	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=$(TESTRUNDIR)/llvm
+	debian/tests/ghdl-tests buildtest llvm
+  endif
 	# Place a symlink for the binary ahead of time so that the compilation
 	# of the VHDL standard libraries works during the gcc install step. The
 	# binary is properly moved afterwards (so that it can find its
 	# libraries as relative paths from the executable's location).
-	if [ -n "$(WITH_GCC)" ]; then \
-		mkdir -p $(TESTRUNDIR)/gcc/usr/bin && \
-		ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc && \
-		$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install DESTDIR=$(TESTRUNDIR)/gcc && \
-		$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(TESTRUNDIR)/gcc && \
-		mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/bin/ghdl-gcc \
-		   $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc && \
-		mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/lib/ghdl/libbacktrace.a \
-		   $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/vhdl/libbacktrace.a && \
-		ln -sf lib/ghdl/gcc/libexec $(TESTRUNDIR)/gcc/usr/libexec && \
-		debian/tests/ghdl-tests buildtest gcc; \
-	fi
-
+  ifneq (,$(WITH_GCC))
+	mkdir -p $(TESTRUNDIR)/gcc/usr/bin
+	ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc
+	$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install DESTDIR=$(TESTRUNDIR)/gcc
+	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(TESTRUNDIR)/gcc
+	mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/bin/ghdl-gcc \
+	   $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc
+	mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/lib/ghdl/libbacktrace.a \
+	   $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/vhdl/libbacktrace.a
+	ln -sf lib/ghdl/gcc/libexec $(TESTRUNDIR)/gcc/usr/libexec
+	debian/tests/ghdl-tests buildtest gcc
+  endif
+
+ifneq (,$(WITH_GCC))
 override_dh_gencontrol:
-	if [ -n "$(WITH_GCC)" ]; then \
-		dh_gencontrol -- -VBuilt-Using-GCC="$(shell dpkg-query -f '$${Source} (= $${Version})' -W gcc-$(DEB_GNAT_VERSION)-source)"; \
-	else \
-		dh_gencontrol; \
-	fi
+	dh_gencontrol -- -VBuilt-Using-GCC="$(shell dpkg-query -f '$${Source} (= $${Version})' -W gcc-$(DEB_GNAT_VERSION)-source)"
+endif
-- 
2.30.2

>From 5a4423d0f4c2ffc68328f5c035ee3f9646cb5640 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Wed, 14 Dec 2022 18:46:51 +0100
Subject: [PATCH 4/4] Replace a patch chunk with a Make command line override

Make assignments are allowed to be overridden on the command line, and
maintaining the command line is far easier than maintaining a patch.
---
 debian/patches/modify-install-paths |  9 ---------
 debian/rules                        | 28 ++++++++++++++++++++--------
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/debian/patches/modify-install-paths b/debian/patches/modify-install-paths
index 09d9b14a..05b0459d 100644
--- a/debian/patches/modify-install-paths
+++ b/debian/patches/modify-install-paths
@@ -25,15 +25,6 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
  MKDIR=mkdir
  LN=ln -s
  CP=cp
-@@ -59,7 +60,7 @@
- GRT_RANLIB=ranlib
- GHDL_DESC?=tarball
- 
--VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)
-+VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)/vhdl
- 
- ifeq "$(enable_checks)" "true"
-  # Debug + checks
 @@ -137,9 +138,9 @@
  
  install: install.$(backend) install.vhdllib install.vpi install.libghdl install.ghw
diff --git a/debian/rules b/debian/rules
index da020aae..c79e24ea 100755
--- a/debian/rules
+++ b/debian/rules
@@ -57,6 +57,10 @@ common_configure_arguments := \
   --enable-gplcompat \
  # EOL
 
+install_common_arguments := \
+  VHDL_LIB_DIR='$$(prefix)/$$(libdirsuffix)/vhdl' \
+  # EOL
+
 %:
 	dh ${@}
 
@@ -166,14 +170,16 @@ override_dh_auto_install:
 	@echo Installing with mcode backend
 	@echo ------------------------------------------------------------
   ifneq (,$(WITH_MCODE))
-	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=../../debian/tmp
+	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=../../debian/tmp \
+	  $(install_common_arguments)
   endif
 	@echo
 	@echo ------------------------------------------------------------
 	@echo Installing with llvm backend
 	@echo ------------------------------------------------------------
   ifneq (,$(WITH_LLVM))
-	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=../../debian/tmp
+	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=../../debian/tmp \
+	  $(install_common_arguments)
   endif
 	@echo
 	@echo ------------------------------------------------------------
@@ -186,8 +192,10 @@ override_dh_auto_install:
 	mkdir -p $(CURDIR)/debian/tmp/usr/bin
 	ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(CURDIR)/debian/tmp/usr/bin/ghdl-gcc
 	$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install \
-		DESTDIR=$(CURDIR)/debian/tmp
-	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(CURDIR)/debian/tmp
+		DESTDIR=$(CURDIR)/debian/tmp \
+		$(install_common_arguments)
+	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(CURDIR)/debian/tmp \
+		$(install_common_arguments)
   endif
 	@echo
 	@echo ------------------------------------------------------------
@@ -213,11 +221,13 @@ override_dh_auto_test:
 	# simply install into a temporary location and tell the testsuite to
 	# find ghdl there.
   ifneq (,$(WITH_MCODE))
-	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=$(TESTRUNDIR)/mcode
+	$(MAKE) -C $(BUILDDIR)/mcode install DESTDIR=$(TESTRUNDIR)/mcode \
+	  $(install_common_arguments)
 	debian/tests/ghdl-tests buildtest mcode
   endif
   ifneq (,$(WITH_LLVM))
-	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=$(TESTRUNDIR)/llvm
+	$(MAKE) -C $(BUILDDIR)/llvm install DESTDIR=$(TESTRUNDIR)/llvm \
+	  $(install_common_arguments)
 	debian/tests/ghdl-tests buildtest llvm
   endif
 	# Place a symlink for the binary ahead of time so that the compilation
@@ -227,8 +237,10 @@ override_dh_auto_test:
   ifneq (,$(WITH_GCC))
 	mkdir -p $(TESTRUNDIR)/gcc/usr/bin
 	ln -sf ../lib/ghdl/gcc/bin/ghdl-gcc $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc
-	$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install DESTDIR=$(TESTRUNDIR)/gcc
-	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(TESTRUNDIR)/gcc
+	$(MAKE) -C $(BUILDDIR)/gcc/gccbuild install DESTDIR=$(TESTRUNDIR)/gcc \
+	  $(install_common_arguments)
+	$(MAKE) -C $(BUILDDIR)/gcc install DESTDIR=$(TESTRUNDIR)/gcc \
+	  $(install_common_arguments)
 	mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/bin/ghdl-gcc \
 	   $(TESTRUNDIR)/gcc/usr/bin/ghdl-gcc
 	mv $(TESTRUNDIR)/gcc/usr/lib/ghdl/gcc/lib/ghdl/libbacktrace.a \
-- 
2.30.2

Reply via email to