• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1##
2## Copyright (C) 2016 and later: Unicode, Inc. and others.
3## License & terms of use: http://www.unicode.org/copyright.html
4##  Copyright (c) 1999-2011, International Business Machines Corporation and
5##  others. All Rights Reserved.
6##
7##
8##  THE PURPOSE OF THIS TEST
9##
10##     This tests all public header files  - as installed.  icu-config needs to be on the PATH
11##
12##     To run it simply type 'make check' after ICU is installed. You SHOULD see:
13##
14##  unicode/uchar.h -	0
15##  unicode/uchriter.h -	0
16##  unicode/ucnv.h -	0
17##
18##    .. etc.  Anything other than zero is an error. (except for the deprecation tests, where '1' is the correct value)
19##
20##  If a header fails the C compile test it is likely because the header is a
21##  C++ header and it isn't properly guarded by the U_SHOW_CPLUSPLUS_API macro.
22##
23##  If a header fails the cppguardtest test it is likely because the header doesn't
24##  include the utypes.h header first *before* using the macro U_SHOW_CPLUSPLUS_API.
25##
26##  If a header fails because it is deprecated, add it to the 'dfiles.txt'
27##
28##
29
30## Source directory information
31srcdir = @srcdir@
32top_srcdir = @top_srcdir@
33
34top_builddir = ../..
35subdir = test/hdrtst
36
37include $(shell icu-config --incfile)
38
39all:
40	@echo Please read this Makefile for more information.
41	@echo run \'$(MAKE) check\' to run the test "(use -k if you don't want to stop on errs)"
42
43check: dtest ctest cpptest drafttest deprtest internaltest obsoletetest cppguardtest
44
45headertest:
46	@FAIL=0;stub=ht_stub_$(NAME.headers).$(SUFFIX.headers); for file in "$(prefix)/include/unicode"/*.h ; do \
47		incfile=`basename $$file` ; \
48		echo "$(NAME.headers) unicode/$$incfile" ; \
49		echo "#include <unicode/$$incfile>" > $$stub ; \
50		echo 'void junk(){}' >> $$stub ; \
51		$(COMPILE.headers) $(cppflags) $(FLAGS.headers) $$stub || FAIL=1 ; \
52		rm -f $$stub; \
53	done ; \
54	exit $$FAIL
55
56ctest:
57	$(MAKE) headertest \
58		NAME.headers=$@ \
59		COMPILE.headers="$(COMPILE.c)" \
60		SUFFIX.headers=c \
61		FLAGS.headers=
62
63cpptest:
64	$(MAKE) headertest \
65		NAME.headers=$@ \
66		COMPILE.headers="$(COMPILE.cc)" \
67		SUFFIX.headers=cpp \
68		FLAGS.headers=
69
70drafttest:
71	$(MAKE) headertest \
72		NAME.headers=$@ \
73		COMPILE.headers="$(COMPILE.cc)" \
74		SUFFIX.headers=cpp \
75		FLAGS.headers="-DU_HIDE_DRAFT_API"
76
77deprtest:
78	$(MAKE) headertest \
79		NAME.headers=$@ \
80		COMPILE.headers="$(COMPILE.cc)" \
81		SUFFIX.headers=cpp \
82		FLAGS.headers="-DU_HIDE_DEPRECATED_API"
83
84internaltest:
85	$(MAKE) headertest \
86		NAME.headers=$@ \
87		COMPILE.headers="$(COMPILE.cc)" \
88		SUFFIX.headers=cpp \
89		FLAGS.headers="-DU_HIDE_INTERNAL_API"
90
91obsoletetest:
92	$(MAKE) headertest \
93		NAME.headers=$@ \
94		COMPILE.headers="$(COMPILE.cc)" \
95		SUFFIX.headers=cpp \
96		FLAGS.headers="-DU_HIDE_OBSOLETE_API"
97
98dtest:
99	@FAIL=0;NONE="(No deprecated headers)";stub=ht_stub_dtest.cpp;for incfile in `cat $(srcdir)/dfiles.txt | grep -v '^#' | sort` ; do \
100		NONE= ; \
101		echo "$@ unicode/$$incfile" ; \
102		echo "#include <unicode/$$incfile>" > $$stub ; \
103		echo 'void junk(){}' >> $$stub ; \
104		$(COMPILE.cc) $(cppflags) $$stub 2>&1 | tee $$stub.out || FAIL=1 ; \
105		if ! cat $$stub.out | sed -e 's/^.*#error[^"]*"//' | grep -v ht_ | grep -v "$$incfile header is obsolete"; then \
106			echo "** FAIL Header unicode/$$incfile is not obsoleted properly" ; \
107			FAIL=1 ; \
108		fi ; \
109		rm -f $$stub*; \
110	done ; \
111	echo "$@: $$NONE - exit status $$FAIL" ; \
112	exit $$FAIL
113
114cppguardtest:
115	@FAIL=0;stub=ht_stub_cppguardtest.cpp; for file in "$(prefix)/include/unicode"/*.h ; do \
116		incfile=`basename $$file` ; \
117		if grep -q "U_SHOW_CPLUSPLUS_API" $$file ; then \
118			echo "$@ unicode/$$incfile" ; \
119			echo "#include <unicode/$$incfile>" > $$stub ; \
120			echo 'void junk(){}' >> $$stub ; \
121			echo '#if !defined(U_SHOW_CPLUSPLUS_API)' >> $$stub ; \
122			echo "#error The header '$$incfile' refers to the macro U_SHOW_CPLUSPLUS_API (defined in utypes.h) but either does not include utypes.h or does so incorrectly." >> $$stub ; \
123			echo '#endif' >> $$stub ; \
124			$(COMPILE.cc) $(cppflags) $$stub || FAIL=1 ; \
125			rm -f $$stub; \
126		else \
127			echo "$@ skipping unicode/$$incfile" ; \
128		fi ; \
129	done ; \
130	exit $$FAIL
131
132clean:
133	-@rm -f ht_*
134
135distclean: clean
136	-@rm -f Makefile
137
138Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
139	cd $(top_builddir) \
140	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
141
142.PHONY:	doclean check all headertest cpptest dtest cppguardtest ctest clean distclean
143