• 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 the header test is run for a particular UCONFIG_NO_XXX=1 variation (see uconfig.h)
21##  then invoke the test with 'make UCONFIG_NO="-DUCONFIG_NO_XXX=1 check'.
22##  For standard header test run the UCONFIG_NO variable will evaluate to empty string.
23##
24##  If a header fails the C compile test it is likely because the header is a
25##  C++ header and it isn't properly guarded by the U_SHOW_CPLUSPLUS_API macro.
26##
27##  If a header fails the cppguardtest test it is likely because the header doesn't
28##  include the utypes.h header first *before* using the macro U_SHOW_CPLUSPLUS_API.
29##
30##  If a header fails because it is deprecated, add it to the 'dfiles.txt'
31##
32##
33
34## Source directory information
35srcdir = @srcdir@
36top_srcdir = @top_srcdir@
37
38top_builddir = ../..
39subdir = test/hdrtst
40
41include $(shell icu-config --incfile)
42
43all:
44	@echo Please read this Makefile for more information.
45	@echo run \'$(MAKE) check\' to run the test "(use -k if you don't want to stop on errs)"
46
47check: dtest ctest cpptest drafttest deprtest internaltest obsoletetest cppguardtest
48
49headertest:
50	@FAIL=0;stub=ht_stub_$(NAME.headers).$(SUFFIX.headers); for file in "$(prefix)/include/unicode"/*.h ; do \
51		incfile=`basename $$file` ; \
52		echo "$(NAME.headers) unicode/$$incfile" ; \
53		echo "#include <unicode/$$incfile>" > $$stub ; \
54		echo 'void junk(){}' >> $$stub ; \
55		$(COMPILE.headers) $(cppflags) $(FLAGS.headers) $(UCONFIG_NO) $$stub || FAIL=1 ; \
56		rm -f $$stub; \
57	done ; \
58	exit $$FAIL
59
60ctest:
61	$(MAKE) headertest \
62		NAME.headers=$@ \
63		COMPILE.headers="$(COMPILE.c)" \
64		SUFFIX.headers=c \
65		FLAGS.headers=
66
67cpptest:
68	$(MAKE) headertest \
69		NAME.headers=$@ \
70		COMPILE.headers="$(COMPILE.cc)" \
71		SUFFIX.headers=cpp \
72		FLAGS.headers=
73
74drafttest:
75	$(MAKE) headertest \
76		NAME.headers=$@ \
77		COMPILE.headers="$(COMPILE.cc)" \
78		SUFFIX.headers=cpp \
79		FLAGS.headers="-DU_HIDE_DRAFT_API"
80
81deprtest:
82	$(MAKE) headertest \
83		NAME.headers=$@ \
84		COMPILE.headers="$(COMPILE.cc)" \
85		SUFFIX.headers=cpp \
86		FLAGS.headers="-DU_HIDE_DEPRECATED_API"
87
88internaltest:
89	$(MAKE) headertest \
90		NAME.headers=$@ \
91		COMPILE.headers="$(COMPILE.cc)" \
92		SUFFIX.headers=cpp \
93		FLAGS.headers="-DU_HIDE_INTERNAL_API"
94
95obsoletetest:
96	$(MAKE) headertest \
97		NAME.headers=$@ \
98		COMPILE.headers="$(COMPILE.cc)" \
99		SUFFIX.headers=cpp \
100		FLAGS.headers="-DU_HIDE_OBSOLETE_API"
101
102dtest:
103	@FAIL=0;NONE="(No deprecated headers)";stub=ht_stub_dtest.cpp;for incfile in `cat $(srcdir)/dfiles.txt | grep -v '^#' | sort` ; do \
104		NONE= ; \
105		echo "$@ unicode/$$incfile" ; \
106		echo "#include <unicode/$$incfile>" > $$stub ; \
107		echo 'void junk(){}' >> $$stub ; \
108		$(COMPILE.cc) $(cppflags) $$stub 2>&1 | tee $$stub.out || FAIL=1 ; \
109		if ! cat $$stub.out | sed -e 's/^.*#error[^"]*"//' | grep -v ht_ | grep -v "$$incfile header is obsolete"; then \
110			echo "** FAIL Header unicode/$$incfile is not obsoleted properly" ; \
111			FAIL=1 ; \
112		fi ; \
113		rm -f $$stub*; \
114	done ; \
115	echo "$@: $$NONE - exit status $$FAIL" ; \
116	exit $$FAIL
117
118cppguardtest:
119	@FAIL=0;stub=ht_stub_cppguardtest.cpp; for file in "$(prefix)/include/unicode"/*.h ; do \
120		incfile=`basename $$file` ; \
121		if grep -q "U_SHOW_CPLUSPLUS_API" $$file ; then \
122			echo "$@ unicode/$$incfile" ; \
123			echo "#include <unicode/$$incfile>" > $$stub ; \
124			echo 'void junk(){}' >> $$stub ; \
125			echo '#if !defined(U_SHOW_CPLUSPLUS_API)' >> $$stub ; \
126			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 ; \
127			echo '#endif' >> $$stub ; \
128			$(COMPILE.cc) $(cppflags) $(UCONFIG_NO) $$stub || FAIL=1 ; \
129			rm -f $$stub; \
130		else \
131			echo "$@ skipping unicode/$$incfile" ; \
132		fi ; \
133	done ; \
134	exit $$FAIL
135
136clean:
137	-@rm -f ht_*
138
139distclean: clean
140	-@rm -f Makefile
141
142Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
143	cd $(top_builddir) \
144	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
145
146.PHONY:	doclean check all headertest cpptest dtest cppguardtest ctest clean distclean
147