diff --git a/Makefile b/Makefile
index 98a669ed34255da9fd484fb39511378bbc5b3203..39168d7658af3e320de9908f3cb4c2014e4164f3 100644
--- a/Makefile
+++ b/Makefile
@@ -482,10 +482,10 @@ ifneq ($(wildcard .tags-depend),)
 endif
 
 ast_expr2.c:
-	bison -d --name-prefix=ast_yy ast_expr2.y -o ast_expr2.c
+	bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
 
 ast_expr2f.c:
-	flex --full ast_expr2.fl
+	flex -o $@ --full ast_expr2.fl
 
 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
 	gcc -g -c -DSTANDALONE ast_expr2f.c
diff --git a/utils/Makefile b/utils/Makefile
index 3ace5f03c23a9a5dda17544c281fcee3783f1f81..249116f86f8050d3c013e565a3844a33098219a2 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -57,7 +57,13 @@ astman: astman.o ../md5.o
 stereorize: stereorize.o frame.o
 	$(CC) $(CFLAGS) -o stereorize stereorize.o frame.o -lm
 
-.PHONY: ../ast_expr2.c ../ast_expr2f.c ../pbx/ael/aelflex.o ../pbx/ael/aelbison.o ../pbx/pbx_ael.o
+.PHONY: ../pbx/ael/aelflex.o ../pbx/ael/aelbison.o ../pbx/pbx_ael.o
+
+../ast_expr2.c:
+	bison -o $@ -d --name-prefix=ast_yy ../ast_expr2.y
+
+../ast_expr2f.c:
+	flex -o $@ --full ../ast_expr2.fl
 
 ast_expr2.o: ../ast_expr2.c
 	gcc  $(CFLAGS) -c -o $@ $<