diff --git a/build/autoMakefile.am b/build/autoMakefile.am
index e101bef7117a7c4f9bcacd177443d0a5d69aa903..15e8a3fceb8dd3481fa8e698602c156cf2d6cee5 100644
--- a/build/autoMakefile.am
+++ b/build/autoMakefile.am
@@ -10,7 +10,7 @@ EXTRA_DIST := Makefile Makefile.in.toplevel		       \
 
 CONFIG_CLEAN_FILES := lustre.spec
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 
 distclean: distclean-recursive
 	@true
diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4
index 90753fd30013c7fbd2b32b69d7b2f03240d0323e..77cd0755dd755ed2ab606fcd2a03e898cd4f7f46 100644
--- a/build/autoconf/lustre-build.m4
+++ b/build/autoconf/lustre-build.m4
@@ -492,6 +492,9 @@ LC_CONFIG_FILES
 
 AC_SUBST(ac_configure_args)
 
+MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c'
+AC_SUBST(MOSTLYCLEANFILES)
+
 AC_OUTPUT
 
 cat <<_ACEOF
diff --git a/lnet/klnds/gmlnd/autoMakefile.am b/lnet/klnds/gmlnd/autoMakefile.am
index f09d65888b4ab3c9ce9ae08a096e30ce59aeb8e6..8c3b7c015d33c7fe2e50c152d8a6f29e78311968 100644
--- a/lnet/klnds/gmlnd/autoMakefile.am
+++ b/lnet/klnds/gmlnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kgmnal-objs:%.o=%.c) gmnal.h
diff --git a/lnet/klnds/iiblnd/autoMakefile.am b/lnet/klnds/iiblnd/autoMakefile.am
index e60af1aaf31b91a179f1c521d20cde3d606985c7..d61ffe75bc83adf8a2cafae0788b29ad99ef3b7e 100644
--- a/lnet/klnds/iiblnd/autoMakefile.am
+++ b/lnet/klnds/iiblnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kiibnal-objs:%.o=%.c) iibnal.h
diff --git a/lnet/klnds/lolnd/autoMakefile.am b/lnet/klnds/lolnd/autoMakefile.am
index c09dcacd2675d58c0d2ea467a82817619c511a9b..f7d04f7a493aea3d02567d0b4dd482fa7c34fa1a 100644
--- a/lnet/klnds/lolnd/autoMakefile.am
+++ b/lnet/klnds/lolnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(klonal-objs:%.o=%.c) lonal.h
diff --git a/lnet/klnds/openiblnd/autoMakefile.am b/lnet/klnds/openiblnd/autoMakefile.am
index 1da49883612c27ccec3c4a9f23396a6f5db0f846..6f564216e8d7ff62cbf61f4b6a452739bbc197d0 100644
--- a/lnet/klnds/openiblnd/autoMakefile.am
+++ b/lnet/klnds/openiblnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kopenibnal-objs:%.o=%.c) openibnal.h
diff --git a/lnet/klnds/qswlnd/autoMakefile.am b/lnet/klnds/qswlnd/autoMakefile.am
index 21d717b6c359f62424056bab18a5bbedd0f2bbbe..228689db744a800674e63edceb9b1db72754e875 100644
--- a/lnet/klnds/qswlnd/autoMakefile.am
+++ b/lnet/klnds/qswlnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kqswnal-objs:%.o=%.c) qswnal.h
diff --git a/lnet/klnds/ralnd/autoMakefile.am b/lnet/klnds/ralnd/autoMakefile.am
index 2828d48dd7f4a5295504963c6d797ebd7d9ae762..3bb7642096a935b2f39481ae02152be38e55b16f 100644
--- a/lnet/klnds/ralnd/autoMakefile.am
+++ b/lnet/klnds/ralnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kranal-objs:%.o=%.c) ranal.h
diff --git a/lnet/klnds/socklnd/autoMakefile.am b/lnet/klnds/socklnd/autoMakefile.am
index c7a1ae4678656adc23ff816713263443448f3ab1..71a3633f4aa8b8dcc6ba48c469d8625f680708bf 100644
--- a/lnet/klnds/socklnd/autoMakefile.am
+++ b/lnet/klnds/socklnd/autoMakefile.am
@@ -29,4 +29,4 @@ endif # DARWIN
 EXTRA_DIST := $(plist_DATA)
 install-data-hook: $(install_data_hook)
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c socknal_lib.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  socknal_lib.c
diff --git a/lnet/klnds/viblnd/autoMakefile.am b/lnet/klnds/viblnd/autoMakefile.am
index 6db28b3185f9b2652b746b9a62783967d0c26aa4..f90fbf289678fd6931e3e83880013108ec9dfb58 100644
--- a/lnet/klnds/viblnd/autoMakefile.am
+++ b/lnet/klnds/viblnd/autoMakefile.am
@@ -11,5 +11,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kvibnal-objs:%.o=%.c) vibnal.h vibnal_wire.h
diff --git a/lnet/libcfs/autoMakefile.am b/lnet/libcfs/autoMakefile.am
index ea3b47c73fa87ec1115e3418088e2e341b190608..10ff9012f075ac9bc0e72b471c1e45e9d46d1134 100644
--- a/lnet/libcfs/autoMakefile.am
+++ b/lnet/libcfs/autoMakefile.am
@@ -41,6 +41,6 @@ install-data-hook: $(install_data_hook)
 
 EXTRA_DIST := Info.plist
 
-MOSTLYCLEANFILES := .*.flags *.o *.ko *.mod.c linux-*.c 
-MOSTLYCLEANFILES += linux/*.o darwin/*.o libcfs
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  linux-*.c 
+MOSTLYCLEANFILES += linux darwin/*.o libcfs
 DIST_SOURCES := $(libcfs-all-objs:%.o=%.c) tracefile.h
diff --git a/lnet/lnet/autoMakefile.am b/lnet/lnet/autoMakefile.am
index b8d9aec424198c3a5e6a8c6bda764b0718493690..bd05e93895dae6171b1c862c4432401df3eddbfb 100644
--- a/lnet/lnet/autoMakefile.am
+++ b/lnet/lnet/autoMakefile.am
@@ -42,5 +42,5 @@ install-data-hook: $(install_data_hook)
 
 EXTRA_DIST := Info.plist
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c portals
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  portals
 DIST_SOURCES = $(portals-objs:%.o=%.c)
diff --git a/lnet/router/autoMakefile.am b/lnet/router/autoMakefile.am
index 699bd808ab7643ce5a31fa4420c46f4b0fa7e788..070b00824a2b7515fbe28780b80df4dc9aac44e8 100644
--- a/lnet/router/autoMakefile.am
+++ b/lnet/router/autoMakefile.am
@@ -13,5 +13,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 DIST_SOURCES = $(kptlrouter-objs:%.o=%.c) router.h
diff --git a/lnet/tests/autoMakefile.am b/lnet/tests/autoMakefile.am
index 426105d7c06e417403adab4d0aca3bf1a64eb876..f6118680ee8c680384256be4aaa76d1f405fd05f 100644
--- a/lnet/tests/autoMakefile.am
+++ b/lnet/tests/autoMakefile.am
@@ -16,5 +16,5 @@ endif
 endif
 endif
 
-MOSTLYCLEANFILES = .*.flags *.o *.ko *.mod.c pingsrv.c pingcli.c spingsrv.c spingcli.c
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  pingsrv.c pingcli.c spingsrv.c spingcli.c
 DIST_SOURCES = ping_srv.c ping_cli.c sping_srv.c sping_cli.c ping.h