diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2f66ed388d1c33962126c015530147b2f677cef8..edf84ede803cf02bf9c45bca6d6dd5943b5834a2 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -395,9 +395,9 @@ $(obj)/%.lds: $(src)/%.lds.S FORCE
 
 # ASN.1 grammar
 # ---------------------------------------------------------------------------
-quiet_cmd_asn1_compiler = ASN.1   $@
+quiet_cmd_asn1_compiler = ASN.1   $(basename $@).[ch]
       cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
-				$(subst .h,.c,$@) $(subst .c,.h,$@)
+				$(basename $@).c $(basename $@).h
 
 $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 	$(call cmd,asn1_compiler)