Browse Source

test: Use a static pattern rule to copy data to $(builddir)

The version with an implicit pattern rule tended to fail if test/
was built in an "out-of-tree" build directory not below test/, for
example:

    cd SDL
    mkdir _build-test
    ( cd _build-test; ../test/configure )
    make -C _build-test

as a result of the pattern rule first checking for axis.bmp, then for
../test/axis.bmp, then ../test/../test/axis.bmp, and so on until the
maximum path length was reached.

Note that this requires GNU make. The FreeBSD ports file for SDL seems
to use GNU make (gmake) already, so presumably SDL's build system is
already relying on GNU make extensions.

Signed-off-by: Simon McVittie <[email protected]>
Simon McVittie 4 years ago
parent
commit
2e3a415bdc
1 changed files with 16 additions and 18 deletions
  1. 16 18
      test/Makefile.in

+ 16 - 18
test/Makefile.in

@@ -336,26 +336,24 @@ distclean: clean
 	rm -f config.status config.cache config.log
 	rm -rf $(srcdir)/autom4te*
 
-ifneq ($(srcdir), .)
-%.bmp: $(srcdir)/%.bmp
-	cp $< $@
+DATA = \
+	axis.bmp \
+	button.bmp \
+	controllermap.bmp \
+	controllermap_back.bmp \
+	icon.bmp \
+	moose.dat \
+	sample.bmp \
+	sample.wav \
+	testgles2_sdf_img_normal.bmp \
+	testgles2_sdf_img_sdf.bmp \
+	testyuv.bmp \
+	$(NULL)
 
-%.wav: $(srcdir)/%.wav
-	cp $< $@
-
-%.dat: $(srcdir)/%.dat
+ifneq ($(srcdir), .)
+$(DATA) : %: $(srcdir)/% Makefile
 	cp $< $@
 endif
 
-copydatafiles: copybmpfiles copywavfiles copydatfiles
+copydatafiles: $(DATA)
 .PHONY : copydatafiles
-
-copybmpfiles: $(foreach bmp,$(wildcard $(srcdir)/*.bmp),$(notdir $(bmp)))
-.PHONY : copybmpfiles
-
-copywavfiles: $(foreach wav,$(wildcard $(srcdir)/*.wav),$(notdir $(wav)))
-.PHONY : copywavfiles
-
-copydatfiles: $(foreach dat,$(wildcard $(srcdir)/*.dat),$(notdir $(dat)))
-.PHONY : copydatfiles
-