1#!/usr/bin/make -f
2
3# This is probably only going to work with GNU Make.
4# This in a separate file instead of in Makefile.am because Automake complains
5# about the GNU Make-isms.
6
7EXEEXT = @EXEEXT@
8
9PACKAGE_VERSION = @PACKAGE_VERSION@
10
11HOST_TRIPLET = @HOST_TRIPLET@
12
13SRC_BINDIR = @SRC_BINDIR@
14TEST_BINDIR = @TEST_BINDIR@
15
16LIBRARY := $(SRC_BINDIR)libsndfile.so.$(LIB_VERSION)
17
18LIB_VERSION := $(shell echo $(PACKAGE_VERSION) | sed -e 's/[a-z].*//')
19
20TESTNAME = libsndfile-testsuite-$(HOST_TRIPLET)-$(PACKAGE_VERSION)
21
22TARBALL = $(TESTNAME).tar.gz
23
24# Find the test programs by grepping the script for the programs it executes.
25testprogs := $(shell grep '^\./' tests/test_wrapper.sh | sed -e "s|./||" -e "s/ .*//" | sort | uniq)
26# Also add the programs not found by the above.
27testprogs += tests/sfversion$(EXEEXT) tests/stdin_test$(EXEEXT) tests/stdout_test$(EXEEXT) \
28				tests/cpp_test$(EXEEXT) tests/win32_test$(EXEEXT)
29
30libfiles := $(shell if test ! -z $(EXEEXT) ; then echo "src/libsndfile-1.def src/.libs/libsndfile-1.dll" ; elif test -f $(LIBRARY) ; then echo $(LIBRARY) ; fi  ; fi)
31
32testbins := $(testprogs) $(libfiles)
33
34all : $(TARBALL)
35
36clean :
37	rm -rf $(TARBALL) $(TESTNAME)/
38
39check : $(TESTNAME)/test_wrapper.sh
40	(cd ./$(TESTNAME)/ && ./test_wrapper.sh)
41
42$(TARBALL) : $(TESTNAME)/test_wrapper.sh
43	tar zcf $@ $(TESTNAME)
44	rm -rf $(TESTNAME)
45	@echo
46	@echo "Created : $(TARBALL)"
47	@echo
48
49$(TESTNAME)/test_wrapper.sh : tests/test_wrapper.sh tests/pedantic-header-test.sh
50	rm -rf $(TESTNAME)
51	mkdir -p $(TESTNAME)/tests/
52	echo
53	echo $(testbins)
54	echo
55	cp $(testbins) $(TESTNAME)/tests/
56	cp tests/test_wrapper.sh $(TESTNAME)/
57	cp tests/pedantic-header-test.sh $(TESTNAME)/tests/
58	chmod u+x $@
59
60tests/test_wrapper.sh : tests/test_wrapper.sh.in
61	make $@
62