diff --git a/.gitignore b/.gitignore
index 2e1b3ac4ff39e76b3f503c5b7c8a8bf1fe45df16..0bbd30e7e53a44721f242b69e8db1a2da74ff97e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 /.version
 /INSTALL
 /build-aux/*
+/data/*-linux-gnu*-capsule-mkstublib
 /m4/*
 /test-suite.log
 /tests/*.log
diff --git a/Makefile.am b/Makefile.am
index e314b14e23f3b49223facf23fb9b4ef15dbdfa8e..1294c16041ad86356e4426f55a6d4517df52d031 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,13 +26,26 @@ static_docs             = Building Debugging Limitations Quick-Start
 
 # installable items:
 libexec_PROGRAMS        = capsule-symbols capsule-version
-dist_libexec_SCRIPTS    = data/capsule-mkstublib data/capsule-init-project
+dist_libexec_SCRIPTS    = data/capsule-init-project
 lib_LTLIBRARIES         = libcapsule.la
 pkgconfigdir            = $(libdir)/pkgconfig
 pkgconfig_DATA          = data/capsule.pc
 nobase_include_HEADERS  = capsule/capsule.h
 dist_doc_DATA           = $(foreach doc,$(static_docs),doc/$(doc).txt)
 
+libexec_SCRIPTS         = data/$(host)-capsule-mkstublib
+
+# Write out a version of capsule-mkstublib with different defaults
+# for each architecture
+data/$(host)-capsule-mkstublib: data/capsule-mkstublib Makefile
+	$(AM_V_GEN)set -e; \
+	( \
+		sed -e 1q $<; \
+		echo '# Inserted by Makefile to make this architecture-specific'; \
+		echo ': "$${CAPSULE_SYMBOLS_TOOL:="$(libexecdir)/$(host)-capsule-symbols"}"';\
+		sed -e 1d $<; \
+	) > $@.tmp; chmod +x $@.tmp; mv $@.tmp $@
+
 install-exec-hook:
 	cd $(DESTDIR)$(libexecdir) && ln -f capsule-symbols $(host)-capsule-symbols
 	cd $(DESTDIR)$(libexecdir) && ln -f capsule-version $(host)-capsule-version
@@ -287,10 +300,13 @@ $(DOC_MAIN_SGML_FILE): sgml-build.stamp
 # These need to come after we include gtk-doc.make, which unconditionally
 # defines these variables
 CLEANFILES             += $(testmeta_DATA)
+CLEANFILES             += data/$(host)-capsule-mkstublib
 CLEANFILES             += tests/shim/libnotgl.so.c
+
 EXTRA_DIST             += $(top_srcdir)/.version
 EXTRA_DIST             += autogen.sh
 EXTRA_DIST             += build-aux/git-version-gen
+EXTRA_DIST             += data/capsule-mkstublib
 EXTRA_DIST             += doc/Strategy.txt
 EXTRA_DIST             += doc/capsule-init-project.xml
 EXTRA_DIST             += doc/capsule-mkstublib.xml
diff --git a/data/capsule.pc.in b/data/capsule.pc.in
index cf27fdccc76b4a8c94159a2ad6e3f3169384ba79..e6da6351707826ad37d84726ec91feb9fbbfeda0 100644
--- a/data/capsule.pc.in
+++ b/data/capsule.pc.in
@@ -7,7 +7,7 @@ datarootdir=@datarootdir@
 datadir=@datarootdir@
 makeinc=@datadir@/libcapsule
 CAPSULE_INIT_PROJECT_TOOL=@libexecdir@/capsule-init-project
-CAPSULE_MKSTUBLIB_TOOL=@libexecdir@/capsule-mkstublib
+CAPSULE_MKSTUBLIB_TOOL=@libexecdir@/@host@-capsule-mkstublib
 CAPSULE_SYMBOLS_TOOL=@libexecdir@/@host@-capsule-symbols
 CAPSULE_VERSION_TOOL=@libexecdir@/@host@-capsule-version
 
diff --git a/debian/libcapsule-dev-bin.install b/debian/libcapsule-dev-bin.install
index 90ce7b8cf2e7a489046b62c58b7dc64f6b9d9484..b3cdfaef3980f11f451b8dc457a79e1299c51fdb 100644
--- a/debian/libcapsule-dev-bin.install
+++ b/debian/libcapsule-dev-bin.install
@@ -1,6 +1,6 @@
+usr/lib/libcapsule/*-capsule-mkstublib
 usr/lib/libcapsule/*-capsule-symbols
 usr/lib/libcapsule/*-capsule-version
 usr/lib/libcapsule/capsule-init-project
-usr/lib/libcapsule/capsule-mkstublib
 usr/share/libcapsule/*
 usr/share/man/man1/*