diff --git a/configure.ac b/configure.ac
index ea35aaf93ba1f4701b5b8c4f5a9aaed896bc834d..0ecbd14c53c97c112b14b8b12834b8099f62fddf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -414,8 +414,6 @@ AC_CONFIG_FILES([Makefile
 		 auxdir/Makefile
 		 contribs/Makefile
 		 contribs/cray/Makefile
-		 contribs/cray/opt_modulefiles_slurm
-		 contribs/cray/slurmconfgen.py
 		 contribs/lua/Makefile
 		 contribs/mic/Makefile
 		 contribs/pam/Makefile
diff --git a/contribs/cray/Makefile.am b/contribs/cray/Makefile.am
index 76f76c7ca8616659086e5e1760173e8fe38b2093..96b5f39c82753d7e4fb095691e7ccbf0a8d96dd3 100644
--- a/contribs/cray/Makefile.am
+++ b/contribs/cray/Makefile.am
@@ -7,12 +7,27 @@ AUTOMAKE_OPTIONS = foreign
 EXTRA_DIST = \
 	etc_sysconfig_slurm		\
 	libalps_test_programs.tar.gz	\
-	opt_modulefiles_slurm		\
-	pam_job.c
+	opt_modulefiles_slurm.in	\
+	pam_job.c 			\
+	slurm.conf.template		\
+	slurmconfgen.py.in
 
 if HAVE_NATIVE_CRAY
 sbin_SCRIPTS = slurmconfgen.py
-sysconf_DATA = slurm.conf.template
-else
-EXTRA_DIST += slurmconfgen.py slurm.conf.template
+noinst_DATA = opt_modulefiles_slurm
 endif
+
+if HAVE_CRAY_NETWORK
+noinst_DATA = opt_modulefiles_slurm
+endif
+
+# Don't rely on autoconf to replace variables outside of makefiles
+opt_modulefiles_slurm: opt_modulefiles_slurm.in Makefile
+	sed -e 's|@prefix[@]|$(prefix)|g' \
+	    -e 's|@MUNGE_DIR[@]|$(MUNGE_DIR)|g' \
+	    -e 's|@libdir[@]|$(libdir)|g' \
+	    opt_modulefiles_slurm.in >opt_modulefiles_slurm
+
+slurmconfgen.py: slurmconfgen.py.in Makefile
+	sed -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
+	    slurmconfgen.py.in >slurmconfgen.py