--- Makefile.am.orig
+++ Makefile.am
@@ -100,34 +100,36 @@ PERL_DIRECTORIES = perl perl/lib perl/lib/Wallet perl/lib/Wallet/ACL	    \
 	perl/t/policy perl/t/style perl/t/util perl/t/verifier
 
 ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = .gitignore .travis.yml LICENSE autogen client/wallet.pod	    \
-	client/wallet-rekey.pod config/allow-extract config/keytab	    \
-	config/keytab.acl config/wallet config/wallet-report.acl	    \
-	docs/design contrib/README contrib/commerzbank/wallet-history	    \
-	contrib/convert-srvtab-db contrib/used-principals		    \
-	contrib/wallet-contacts contrib/wallet-rekey-periodic		    \
-	contrib/wallet-rekey-periodic.8 contrib/wallet-summary		    \
-	contrib/wallet-summary.8 contrib/wallet-unknown-hosts		    \
-	contrib/wallet-unknown-hosts.8 docs/design-acl docs/design-api	    \
-	docs/netdb-role-api docs/notes docs/objects-and-schemes docs/setup  \
-	docs/stanford-naming examples/stanford.conf tests/HOWTO tests/TESTS \
-	tests/config/README tests/data/allow-extract tests/data/basic.conf  \
-	tests/data/cmd-fake tests/data/cmd-wrapper tests/data/fake-data	    \
-	tests/data/fake-kadmin tests/data/fake-keytab			    \
-	tests/data/fake-keytab-2 tests/data/fake-keytab-foreign		    \
-	tests/data/fake-keytab-merge tests/data/fake-keytab-old		    \
-	tests/data/fake-keytab-partial					    \
-	tests/data/fake-keytab-partial-result tests/data/fake-keytab-rekey  \
-	tests/data/fake-keytab-unknown tests/data/fake-srvtab		    \
-	tests/data/full.conf tests/data/perl.conf tests/data/wallet.conf    \
-	tests/docs/pod-spelling-t tests/docs/pod-t			    \
-	tests/perl/minimum-version-t tests/perl/module-version-t	    \
-	tests/perl/strict-t tests/server/admin-t tests/server/backend-t	    \
-	tests/server/keytab-t tests/server/report-t tests/tap/kerberos.sh   \
-	tests/tap/libtap.sh tests/tap/perl/Test/RRA.pm			    \
-	tests/tap/perl/Test/RRA/Automake.pm				    \
-	tests/tap/perl/Test/RRA/Config.pm				    \
-	tests/tap/perl/Test/RRA/ModuleVersion.pm tests/tap/remctl.sh	    \
+EXTRA_DIST = .gitignore .travis.yml LICENSE autogen client/wallet.pod	   \
+	client/wallet-rekey.pod config/allow-extract config/keytab	   \
+	config/keytab.acl config/wallet config/wallet-report.acl	   \
+	docs/design contrib/README contrib/commerzbank/wallet-history	   \
+	contrib/convert-srvtab-db contrib/used-principals		   \
+	contrib/wallet-contacts contrib/wallet-rekey-periodic		   \
+	contrib/wallet-rekey-periodic.8 contrib/wallet-summary		   \
+	contrib/wallet-summary.8 contrib/wallet-unknown-hosts		   \
+	contrib/wallet-unknown-hosts.8 docs/design-acl docs/design-api	   \
+	docs/netdb-role-api docs/notes docs/objects-and-schemes docs/setup \
+	docs/stanford-naming examples/stanford.conf			   \
+	server/keytab-backend.in server/wallet-admin.in			   \
+	server/wallet-backend.in server/wallet-report.in tests/HOWTO	   \
+	tests/TESTS tests/config/README tests/data/allow-extract	   \
+	tests/data/basic.conf tests/data/cmd-fake tests/data/cmd-wrapper   \
+	tests/data/fake-data tests/data/fake-kadmin tests/data/fake-keytab \
+	tests/data/fake-keytab-2 tests/data/fake-keytab-foreign		   \
+	tests/data/fake-keytab-merge tests/data/fake-keytab-old		   \
+	tests/data/fake-keytab-partial					   \
+	tests/data/fake-keytab-partial-result tests/data/fake-keytab-rekey \
+	tests/data/fake-keytab-unknown tests/data/fake-srvtab		   \
+	tests/data/full.conf tests/data/perl.conf tests/data/wallet.conf   \
+	tests/docs/pod-spelling-t tests/docs/pod-t			   \
+	tests/perl/minimum-version-t tests/perl/module-version-t	   \
+	tests/perl/strict-t tests/server/admin-t tests/server/backend-t	   \
+	tests/server/keytab-t tests/server/report-t tests/tap/kerberos.sh  \
+	tests/tap/libtap.sh tests/tap/perl/Test/RRA.pm			   \
+	tests/tap/perl/Test/RRA/Automake.pm				   \
+	tests/tap/perl/Test/RRA/Config.pm				   \
+	tests/tap/perl/Test/RRA/ModuleVersion.pm tests/tap/remctl.sh	   \
 	tests/util/xmalloc-t $(PERL_FILES)
 
 # Supporting convenience libraries used by other targets.
@@ -150,7 +152,7 @@ client_libwallet_a_CPPFLAGS = $(REMCTL_CPPFLAGS) $(KRB5_CPPFLAGS)
 
 # The client and server programs.
 bin_PROGRAMS = client/wallet client/wallet-rekey
-dist_sbin_SCRIPTS = server/keytab-backend server/wallet-admin \
+sbin_SCRIPTS = server/keytab-backend server/wallet-admin \
 	server/wallet-backend server/wallet-report
 client_wallet_CPPFLAGS = $(REMCTL_CPPFLAGS) $(KRB5_CPPFLAGS)
 client_wallet_LDFLAGS = $(REMCTL_LDFLAGS) $(KRB5_LDFLAGS)
@@ -209,14 +211,30 @@ warnings:
 	    KRB5_CPPFLAGS='$(KRB5_CPPFLAGS_GCC)' $(check_PROGRAMS)
 
 # Remove some additional files.
-CLEANFILES = perl/t/lib/Test/RRA.pm perl/t/lib/Test/RRA/Automake.pm \
-	perl/t/lib/Test/RRA/Config.pm
+CLEANFILES = perl/t/lib/Test/RRA.pm perl/t/lib/Test/RRA/Automake.pm	\
+	perl/t/lib/Test/RRA/Config.pm server/keytab-backend		\
+	server/wallet-admin server/wallet-backend server/wallet-report
 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 build-aux/compile		     \
 	build-aux/depcomp build-aux/install-sh build-aux/missing	     \
 	client/wallet.1 config.h.in config.h.in~ configure		     \
 	contrib/wallet-report.8 server/keytab-backend.8			     \
 	server/wallet-admin.8 server/wallet-backend.8 server/wallet-report.8
 
+# For each of the Perl scripts, we need to fill in the path to the Perl
+# binary that was located during configuration.
+server/keytab-backend: $(srcdir)/server/keytab-backend.in Makefile
+	sed 's|\@PERL\@|$(PERL)|' <$(srcdir)/server/keytab-backend.in >$@
+	chmod a+x $@
+server/wallet-admin: $(srcdir)/server/wallet-admin.in Makefile
+	sed 's|\@PERL\@|$(PERL)|' <$(srcdir)/server/wallet-admin.in >$@
+	chmod a+x $@
+server/wallet-backend: $(srcdir)/server/wallet-backend.in Makefile
+	sed 's|\@PERL\@|$(PERL)|' <$(srcdir)/server/wallet-backend.in >$@
+	chmod a+x $@
+server/wallet-report: $(srcdir)/server/wallet-report.in Makefile
+	sed 's|\@PERL\@|$(PERL)|' <$(srcdir)/server/wallet-report.in >$@
+	chmod a+x $@
+
 # Take appropriate actions in the Perl directory as well.  We don't want to
 # always build the Perl directory in all-local, since otherwise Automake does
 # this for every target, which overrides some hacks we have to do for Debian
@@ -236,7 +254,7 @@ perl/blib/lib/Wallet/Config.pm: $(srcdir)/perl/lib/Wallet/Config.pm
 	$(INSTALL_DATA) $(srcdir)/tests/tap/perl/Test/RRA.pm perl/t/lib/Test/
 	$(INSTALL_DATA) $(srcdir)/tests/tap/perl/Test/RRA/Config.pm \
 	    perl/t/lib/Test/RRA/
-	cd perl && perl Build.PL $(WALLET_PERL_FLAGS)
+	cd perl && $(PERL) Build.PL $(WALLET_PERL_FLAGS)
 	cd perl && ./Build
 
 # This is a really ugly hack to only honor prefix when running make install