• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1##
2##  Copyright (c) 1999-2010, International Business Machines Corporation and
3##  others. All Rights Reserved.
4##
5##
6##  THE PURPOSE OF THIS TEST
7##
8##     This tests all public header files (
9##
10##     To run it simply type 'make check'. You SHOULD see:
11##
12##  unicode/uchar.h -	0
13##  unicode/uchriter.h -	0
14##  unicode/ucnv.h -	0
15##
16##    .. etc.  Anything other than zero is an error. (except for the deprecation tests, where '1' is the correct value)
17##
18##
19##  If a header fails the C compile because it's a C++ header, add it to the
20##  file named 'cxxfiles.txt' in this directory.
21##
22##  If a header fails because it is deprecated, add it to the 'dfiles.txt'
23##
24##
25
26## Source directory information
27srcdir = @srcdir@
28top_srcdir = @top_srcdir@
29
30top_builddir = ../..
31subdir = test/hdrtst
32
33include $(shell icu-config --incfile)
34DIRS=$(prefix)/include/unicode
35LDIRS=$(prefix)/include/layout
36ECHO_T=@ECHO_T@
37ECHO_C=@ECHO_C@
38ECHO_N=@ECHO_N@
39
40all:
41	@echo Please read this Makefile for more information.
42	@echo run \'$(MAKE) check\' to run the test
43
44E_NUM=8
45E_D="[1/$(E_NUM)] Deprecated: "
46E_C="[2/$(E_NUM)] C  : "
47E_CXX="[3/$(E_NUM)] C++: "
48E_CXX_L="[4/$(E_NUM)] C++ layout: "
49E_DRF="[5/$(E_NUM)] Hide Draft: "
50E_DEP="[6/$(E_NUM)] Hide Deprecated: "
51E_INT="[7/$(E_NUM)] Hide Internal: "
52E_OBS="[8/$(E_NUM)] Hide Obsolete: "
53
54check: dtest ctest cpptest lotest doclean drafttest deprtest internaltest obsoletetest
55	@echo "All header tests have finished. If deprecation #errors appeared, "
56	@echo "       add files to hdrtst/dfiles.txt"
57	@echo "#################################################################"
58	@echo
59
60# break dependency
61doclean:
62	make clean
63
64cpptest:
65	@echo "C++ test #######################################################"
66	@rm -f Makefile.sub
67	@echo 'Testing all header files under C++'
68	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
69	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
70	  incfile=`basename $$file .h` ; \
71	  echo $(ECHO_N) "$(E_CXX) unicode/$$incfile.h 	- $(ECHO_C)" ; \
72	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
73	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
74          $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp ; \
75	  echo $$? ; \
76	done
77
78lotest:
79	@echo "Layout test #######################################################"
80	@rm -f Makefile.sub
81	@echo 'Testing all layout  files under C++'
82	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
83	@for file in $(prefix)/include/layout/*.h; do \
84	  incfile=`basename $$file .h` ; \
85	  echo $(ECHO_N) "$(E_CXX_L) layout/$$incfile.h 	- $(ECHO_C)" ; \
86	  echo '#include "'layout/$$incfile'.h"' > ht_$$incfile.cpp ; \
87	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
88          $(COMPILE.cc) -c $(cppflags) -I$(prefix)/include/layout ht_$$incfile.cpp ; \
89	  echo $$? ; \
90	done
91
92dtest:
93	@rm -f Makefile.sub
94	@echo "Deprecation #######################################################"
95	@echo 'Should be 1 in each case if file is properly obsoleted.'
96	@for stub in `cat $(srcdir)/dfiles.txt | grep -v '^#'` ; do \
97	  file=unicode/$$stub \
98	  incfile=`basename $$file .h` ; \
99	  echo $(ECHO_N) "$(E_D) unicode/$$incfile.h 	- $(ECHO_C)" ; \
100	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
101	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
102	  echo > ht_dep.junk ; \
103          $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp 2>&1 | sed -e 's/^.*#error[^"]*"//' | fgrep -v ht_ | tee ht_dep.junk | fgrep -v "$$incfile.h header is obsolete" ; \
104	  RES=$$? ; \
105	  echo $$RES ; \
106	  fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || echo "** FAIL Header unicode/$$incfile.h is not obsoleted properly" ; \
107	  rm -f unicode/$$stub ; \
108	done
109	@echo "$(E_D): Done. (It is possible there are no deprecated headers at the moment.)"
110
111#  < ht_dep.junk &&  ; \
112
113
114ctest:
115	@echo "C Test #######################################################"
116	@echo "  (if any C++ files show up here, stop the test and add them to hdrtst/cxxfiles.txt) "
117	@rm -f Makefile.sub
118	@echo Building test harness for header files in ../../common and ../../i18n
119	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
120	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/cxxfiles.txt | tee cfiles.txt`; do \
121	  incfile=`basename $$file .h` ; \
122	  echo $(ECHO_N) "$(E_C) unicode/$$incfile.h 	- $(ECHO_C)" ; \
123	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.c ; \
124	  echo 'void junk(void);' >> ht_$$incfile.c ; \
125	  echo 'void junk(){}' >> ht_$$incfile.c ; \
126          $(COMPILE.c) -c $(cppflags) ht_$$incfile.c ; \
127	  RES=$$? ; \
128	  echo $$RES ; \
129	done
130
131drafttest:
132	@echo "U_HIDE_DRAFT_API Test #######################################################"
133	@rm -f Makefile.sub
134	@echo Building test harness for header files in ../../common and ../../i18n
135	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
136	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
137	  incfile=`basename $$file .h` ; \
138	  echo $(ECHO_N) "$(E_DRF) unicode/$$incfile.h 	- $(ECHO_C)" ; \
139	  echo '#define U_HIDE_DRAFT_API' > hd_$$incfile.c; \
140	  echo '#include "'unicode/$$incfile'.h"' >> ht_$$incfile.c ; \
141	  echo 'void junk(void);' >> hd_$$incfile.c ; \
142	  echo 'void junk(){}' >> hd_$$incfile.c ; \
143          $(COMPILE.cc) -c $(cppflags) hd_$$incfile.c ; \
144	  RES=$$? ; \
145	  echo $$RES ; \
146	done
147
148deprtest:
149	@echo "U_HIDE_DEPRECATED_API Test #######################################################"
150	@rm -f Makefile.sub
151	@echo Building test harness for header files in ../../common and ../../i18n
152	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
153	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
154	  incfile=`basename $$file .h` ; \
155	  echo $(ECHO_N) "$(E_DEP) unicode/$$incfile.h 	- $(ECHO_C)" ; \
156	  echo '#define U_HIDE_DEPRECATED_API' > hdp_$$incfile.c; \
157	  echo '#include "'unicode/$$incfile'.h"' >> hdp_$$incfile.c ; \
158	  echo 'void junk(void);' >> hdp_$$incfile.c ; \
159	  echo 'void junk(){}' >> hdp_$$incfile.c ; \
160          $(COMPILE.cc) -c $(cppflags) hdp_$$incfile.c ; \
161	  RES=$$? ; \
162	  echo $$RES ; \
163	done
164
165internaltest:
166	@echo "U_HIDE_INTERNAL_API Test #######################################################"
167	@rm -f Makefile.sub
168	@echo Building test harness for header files in ../../common and ../../i18n
169	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
170	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
171	  incfile=`basename $$file .h` ; \
172	  echo $(ECHO_N) "$(E_INT) unicode/$$incfile.h 	- $(ECHO_C)" ; \
173	  echo '#define U_HIDE_INTERNAL_API' > hin_$$incfile.c; \
174	  echo '#include "'unicode/$$incfile'.h"' >> hin_$$incfile.c ; \
175	  echo 'void junk(void);' >> hin_$$incfile.c ; \
176	  echo 'void junk(){}' >> hin_$$incfile.c ; \
177          $(COMPILE.cc) -c $(cppflags) hin_$$incfile.c ; \
178	  RES=$$? ; \
179	  echo $$RES ; \
180	done
181
182obsoletetest:
183	@echo "U_HIDE_OBSOLETE_API Test #######################################################"
184	@rm -f Makefile.sub
185	@echo Building test harness for header files in ../../common and ../../i18n
186	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
187	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
188	  incfile=`basename $$file .h` ; \
189	  echo $(ECHO_N) "$(E_OBS) unicode/$$incfile.h 	- $(ECHO_C)" ; \
190	  echo '#define U_HIDE_OBSOLETE_API' > hob_$$incfile.c; \
191	  echo '#include "'unicode/$$incfile'.h"' >> hob_$$incfile.c ; \
192	  echo 'void junk(void);' >> hob_$$incfile.c ; \
193	  echo 'void junk(){}' >> hob_$$incfile.c ; \
194          $(COMPILE.cc) -c $(cppflags) hob_$$incfile.c ; \
195	  RES=$$? ; \
196	  echo $$RES ; \
197	done
198
199clean:
200	-@echo cleaning..
201	-@rm -f *.h *.c *.cpp *.o *.junk cfiles.txt
202
203distclean: clean
204	-@rm -f Makefile
205
206Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
207	cd $(top_builddir) \
208	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
209
210
211
212.PHONY:	doclean check all cpptest lotest dtest ctest clean distclean
213
214