diff --git a/common.mk b/common.mk
index 43bc06bbe7097f0dc2147a08928ecd7e50bfc373..fe5b740aec126d2218ab255c30bd6b6e6527129e 100644
--- a/common.mk
+++ b/common.mk
@@ -117,6 +117,13 @@ endif
 define KERNEL_VERSION
 $(shell cd $(LINUX_PATH) && $(MAKE) --no-print-directory kernelversion)
 endef
+
+# Read stdin, expand ${VAR} environment variables, output to stdout
+# http://superuser.com/a/302847
+define expand-env-var
+awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH -3);gsub("[$$]{"var"}",ENVIRON[var])}}1'
+endef
+
 DEBUG ?= 0
 
 ################################################################################
diff --git a/hikey.mk b/hikey.mk
index 248915ee299bc63a6c888aac1cf759604d0e821b..8ea81c13da6e469d58c254440c388e70039a8afe 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -243,12 +243,6 @@ strace-cleaner: strace-clean
 ################################################################################
 # Root FS
 ################################################################################
-# Read stdin, expand ${VAR} environment variables, output to stdout
-# http://superuser.com/a/302847
-define expand-env-var
-awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH -3);gsub("[$$]{"var"}",ENVIRON[var])}}1'
-endef
-
 .PHONY: filelist-tee
 filelist-tee: filelist-tee-common
 	env TOP=$(ROOT) $(expand-env-var) <$(PATCHES_PATH)/rootfs/initramfs-add-files.txt >> $(GEN_ROOTFS_FILELIST)
diff --git a/hikey960.mk b/hikey960.mk
index 2181ab631b04b758c29e09b6821764944bdb0949..abf93244fd23f61ab68515434057136f040e4117 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -258,12 +258,6 @@ strace-cleaner: strace-clean
 ################################################################################
 # Root FS
 ################################################################################
-# Read stdin, expand ${VAR} environment variables, output to stdout
-# http://superuser.com/a/302847
-define expand-env-var
-awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH -3);gsub("[$$]{"var"}",ENVIRON[var])}}1'
-endef
-
 .PHONY: filelist-tee
 filelist-tee: filelist-tee-common
 	env TOP=$(ROOT) $(expand-env-var) <$(PATCHES_PATH)/rootfs/initramfs-add-files.txt >> $(GEN_ROOTFS_FILELIST)