$NetBSD$

--- src/mesa/x86/Makefile.orig	2007-06-21 18:10:55.000000000 -0400
+++ src/mesa/x86/Makefile
@@ -21,11 +21,19 @@ clean:
 
 
 gen_matypes: gen_matypes.c
-	$(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
+	$(LIBTOOL) --mode=link --tag=CC \
+		$(CC) $(INCLUDE_DIRS) $(CFLAGS) -no-install \
+		gen_matypes.c -o gen_matypes
 
 # need some special rules here, unfortunately
+ifdef CROSS_COMPILING
+matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes.c
+	CFLAGS="${INCLUDE_DIRS} ${CFLAGS}" \
+	$(LIBTOOL) --mode=execute ./gen_matypes.sh > matypes.h
+else
 matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
-	./gen_matypes > matypes.h
+	$(LIBTOOL) --mode=execute ./gen_matypes > matypes.h
+endif
 
 common_x86_asm.o: matypes.h
 3dnow_normal.o: matypes.h
