1# various tests to make sure we dist the win32 stuff (for MSVC builds) right
2
3# the MANIFEST contains all win32 related files that should be disted
4win32 = $(shell cat $(top_srcdir)/win32/MANIFEST)
5
6# wildcard is apparently not portable to other makes, hence the use of find
7# these are library .def files with the symbols to export
8win32defs = $(shell find $(top_srcdir)/win32/common -name '*.def')
9
10# wildcard is apparently not portable to other makes, hence the use of find
11# these are files that need to be disted with CRLF line endings:
12win32crlf = $(shell find $(top_srcdir)/win32 -name '*.dsw' -o -name '*.dsp')
13
14win32-debug:
15	@echo; \
16	echo win32     = $(win32); \
17	echo; \
18	echo win32defs = $(win32defs); \
19	echo; \
20	echo win32crlf = $(win32crlf); \
21	echo
22
23win32-check-crlf:
24	@echo Checking win32 files for CR LF line endings ...; \
25	fail=0 ; \
26	for each in $(win32crlf) ; do \
27	  result=`perl -e 'print grep(/\r\n/,<>)' "$$each" | wc -l`; \
28	  if test "$$result" = 0 ; then \
29	    echo $$each must be fixed to have CRLF line endings ; \
30	    fail=1; \
31	  fi ; \
32	done ; \
33	exit $$fail
34
35# make sure all symbols we export on linux are defined in the win32 .def too
36# (don't care about other unixes for now, it's enough if it works on one of
37# the linux build bots; we assume .so )
38check-exports:
39	@fail=0 ; \
40	for l in $(win32defs); do \
41	  libbase=`basename "$$l" ".def"`; \
42	  libso=`find "$(top_builddir)" -name "$$libbase-@GST_API_VERSION@.so" | grep -v /_build/ | head -n1`; \
43	  libdef="$(top_srcdir)/win32/common/$$libbase.def"; \
44	  if test "x$$libso" != "x"; then \
45	    echo Checking symbols in $$libso; \
46	    if ! ($(top_srcdir)/common/check-exports $$libdef $$libso) ; then \
47	      echo "$$libdef"; \
48	      if test "$$libbase" != "libgstgl"; then \
49	        fail=1; \
50	      fi; \
51	    fi; \
52	  fi; \
53	done ; \
54	if test $$fail != 0; then \
55	  echo '-----------------------------------------------------------'; \
56	  echo 'Run this to update the .def files:'; \
57	  echo 'make update-exports'; \
58	  echo '-----------------------------------------------------------'; \
59	fi; \
60	exit $$fail
61
62update-exports:
63	make check-exports 2>&1 | patch -p1
64	if test -f "$(top_srcdir)/win32/common/libgstgl.def"; then \
65	  git checkout "$(top_srcdir)/win32/common/libgstgl.def";  \
66	fi
67	git add $(top_srcdir)/win32/common/lib*.def
68	git diff --cached -- $(top_srcdir)/win32/common/
69	echo '^^^--- updated and staged changes above'
70
71# complain about nonportable printf format strings (%lld, %llu, %zu etc.)
72check-nonportable-print-format:
73	@fail=0 ; \
74	loc=`find "$(top_srcdir)" -name '*.c' | xargs grep -n -e '%[0-9]*ll[udx]' -e '%[0-9]*z[udx]'`; \
75	if test "x$$loc" != "x"; then \
76	  echo "Please fix the following print format strings:" ; \
77	  find "$(top_srcdir)" -name '*.c' | xargs grep -n -e '%[0-9]*ll[udx]' -e '%[0-9]*z[udx]'; \
78	  fail=1; \
79	fi; \
80	exit $$fail
81
82dist-hook: check-exports win32-check-crlf
83
84
85