Fixup freedren bison/lex usage

All the calls to bison and flex were duplicated.

The bison calls were missing the M4 env variable
causing the usage of m4 from $PATH instead of prebuilts.

Seems like mesa had already in place a way to make
use use proper calls to flex, we augment that to also
support bison ( depending Android version )

Change-Id: Ibe4e9224b23c7574975df1c7101c69581bc353b4
diff --git a/Android.mk b/Android.mk
index aea610b..2a60410 100644
--- a/Android.mk
+++ b/Android.mk
@@ -54,8 +54,10 @@
 MESA_PYTHON3 := python3
 ifeq ($(filter 5 6 7 8 9 10, $(MESA_ANDROID_MAJOR_VERSION)),)
 MESA_LEX     := M4=$(M4) $(LEX)
+MESA_BISON   := M4=$(M4) $(BISON)
 else
 MESA_LEX     := $(LEX)
+MESA_BISON   := $(BISON)
 endif
 
 # Lists to convert driver names to boolean variables
diff --git a/src/freedreno/Android.ir3.mk b/src/freedreno/Android.ir3.mk
index c46564e..a3059da 100644
--- a/src/freedreno/Android.ir3.mk
+++ b/src/freedreno/Android.ir3.mk
@@ -78,8 +78,7 @@
 $(intermediates)/ir3/ir3_lexer.c: $(ir3_lexer_deps) $(LEX) $(M4)
 	@mkdir -p $(dir $@)
 	@echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
-	$(hide) $(MESA_LEX) -o $@ $<
-	$(hide) M4=$(M4) $(LEX) --nounistd -o$@ $<
+	$(hide) $(MESA_LEX) --nounistd -o$@ $<
 
 $(intermediates)/ir3/ir3_nir_imul.c: $(prebuilt_intermediates)/ir3/ir3_nir_imul.c
 	cp -a $< $@
@@ -90,14 +89,12 @@
 $(intermediates)/ir3/ir3_parser.c: $(ir3_parser_deps) $(BISON) $(BISON_DATA) $(M4)
 	@mkdir -p $(dir $@)
 	@echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
-	$(hide) $(BISON) $< --name-prefix=ir3_yy --output=$@
-	$(hide) M4=$(M4) $(BISON) $< --name-prefix=ir3_yy --output=$@
+	$(hide) $(MESA_BISON) $< --name-prefix=ir3_yy --output=$@
 
 $(intermediates)/ir3/ir3_parser.h: $(ir3_parser_deps) $(BISON) $(BISON_DATA) $(M4)
 	@mkdir -p $(dir $@)
 	@echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
-	$(hide) $(BISON) $< --name-prefix=ir3_yy --defines=$@ --output=$@.tab.c
-	$(hide) M4=$(M4) $(BISON) $< --name-prefix=ir3_yy --defines=$@ --output=$@.tab.c
+	$(hide) $(MESA_BISON) $< --name-prefix=ir3_yy --defines=$@ --output=$@.tab.c
 
 include $(MESA_COMMON_MK)
 include $(BUILD_STATIC_LIBRARY)