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## 21## If a header fails the C compile because it's a C++ header, add it to the 22## file named 'cxxfiles.txt' in this directory. 23## 24## If a header fails because it is deprecated, add it to the 'dfiles.txt' 25## 26## 27 28## Source directory information 29srcdir = @srcdir@ 30top_srcdir = @top_srcdir@ 31 32top_builddir = ../.. 33subdir = test/hdrtst 34 35include $(shell icu-config --incfile) 36DIRS=$(prefix)/include/unicode 37LDIRS=$(prefix)/include/layout 38ECHO_T=@ECHO_T@ 39ECHO_C=@ECHO_C@ 40ECHO_N=@ECHO_N@ 41 42all: 43 @echo Please read this Makefile for more information. 44 @echo run \'$(MAKE) check\' to run the test "(use -k if you don't want to stop on errs)" 45 46E_NUM=8 47E_D="[1/$(E_NUM)] Deprecated: " 48E_C="[2/$(E_NUM)] C : " 49E_CXX="[3/$(E_NUM)] C++: " 50E_CXX_L="[4/$(E_NUM)] C++ layout: " 51E_DRF="[5/$(E_NUM)] Hide Draft: " 52E_DEP="[6/$(E_NUM)] Hide Deprecated: " 53E_INT="[7/$(E_NUM)] Hide Internal: " 54E_OBS="[8/$(E_NUM)] Hide Obsolete: " 55 56check: dtest ctest cpptest doclean drafttest deprtest internaltest obsoletetest 57ifeq ($(MAKECMDGOALS),check) 58 $(MAKE) clean 59else 60 @echo "(not cleaning automatically)" 61endif 62 63# break dependency 64doclean: 65 make clean 66 67cpptest: 68 @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ 69 incfile=`basename $$file .h` ; \ 70 echo "$@ unicode/$$incfile.h" ; \ 71 echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \ 72 echo 'void junk(){}' >> ht_$$incfile.cpp ; \ 73 $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp || FAIL=1 ; \ 74 done ;\ 75 exit $$FAIL 76 77# layout is removed 78 79dtest: 80 @FAIL=0;NONE="(No deprecated headers)";for stub in `cat $(srcdir)/dfiles.txt | grep -v '^#'` ; do \ 81 file=unicode/$$stub ; \ 82 NONE="" ; \ 83 incfile=`basename $$file .h` ; \ 84 echo "$@ unicode/$$incfile.h" ; \ 85 echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \ 86 echo 'void junk(){}' >> ht_$$incfile.cpp ; \ 87 echo > ht_dep.junk ; \ 88 $(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" ; \ 89 RES=$$? ; \ 90 echo $$RES ; \ 91 fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || echo "** FAIL Header unicode/$$incfile.h is not obsoleted properly" ; \ 92 fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || FAIL=1 ; \ 93 rm -f unicode/$$stub ; \ 94 done ; \ 95 echo "$@: $$NONE - exit status $$FAIL" ; \ 96 exit $$FAIL 97 98# < ht_dep.junk && ; \ 99 100 101ctest: 102 @echo Building test harness for header files in ../../common and ../../i18n 103 @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/cxxfiles.txt | tee cfiles.txt`; do \ 104 incfile=`basename $$file .h` ; \ 105 echo "$@ unicode/$$incfile.h" ; \ 106 echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.c ; \ 107 echo 'void junk(void);' >> ht_$$incfile.c ; \ 108 echo 'void junk(){}' >> ht_$$incfile.c ; \ 109 $(COMPILE.c) -c $(cppflags) ht_$$incfile.c || FAIL=1 ; \ 110 done ;\ 111 exit $$FAIL 112 113drafttest: 114 @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ 115 incfile=`basename $$file .h` ; \ 116 echo "$@ unicode/$$incfile.h" ; \ 117 echo '#define U_HIDE_DRAFT_API' > hd_$$incfile.cpp ; \ 118 echo '#include "'unicode/$$incfile'.h"' >> hd_$$incfile.cpp ; \ 119 echo 'void junk(void);' >> hd_$$incfile.cpp ; \ 120 echo 'void junk(){}' >> hd_$$incfile.cpp ; \ 121 $(COMPILE.cc) -c $(cppflags) hd_$$incfile.cpp ||FAIL=1 ; \ 122 done ;\ 123 exit $$FAIL 124 125deprtest: 126 @FAIL=0; for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ 127 incfile=`basename $$file .h` ; \ 128 echo "$@ unicode/$$incfile.h" ; \ 129 echo '#define U_HIDE_DEPRECATED_API' > hdp_$$incfile.cpp ; \ 130 echo '#include "'unicode/$$incfile'.h"' >> hdp_$$incfile.cpp ; \ 131 echo 'void junk(void);' >> hdp_$$incfile.cpp ; \ 132 echo 'void junk(){}' >> hdp_$$incfile.cpp ; \ 133 $(COMPILE.cc) -c $(cppflags) hdp_$$incfile.cpp || FAIL=1; \ 134 done ; \ 135 exit $$FAIL 136 137internaltest: 138 @FAIL=0;\ 139 for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ 140 incfile=`basename $$file .h` ; \ 141 echo "$@ unicode/$$incfile.h" ; \ 142 echo '#define U_HIDE_INTERNAL_API' > hin_$$incfile.cpp ; \ 143 echo '#include "'unicode/$$incfile'.h"' >> hin_$$incfile.cpp ; \ 144 echo 'void junk(void);' >> hin_$$incfile.cpp ; \ 145 echo 'void junk(){}' >> hin_$$incfile.cpp ; \ 146 $(COMPILE.cc) -c $(cppflags) hin_$$incfile.cpp || FAIL=1 ; \ 147 done ; \ 148 exit $$FAIL 149 150obsoletetest: 151 @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \ 152 incfile=`basename $$file .h` ; \ 153 echo "$@ unicode/$$incfile.h" ; \ 154 echo '#define U_HIDE_OBSOLETE_API' > hob_$$incfile.cpp ; \ 155 echo '#include "'unicode/$$incfile'.h"' >> hob_$$incfile.cpp ; \ 156 echo 'void junk(void);' >> hob_$$incfile.cpp ; \ 157 echo 'void junk(){}' >> hob_$$incfile.cpp ; \ 158 $(COMPILE.cc) -c $(cppflags) hob_$$incfile.cpp || FAIL=1 ; \ 159 done ; \ 160 exit $$FAIL 161 162clean: 163 -@echo cleaning.. 164 -@rm -f *.h *.c *.cpp *.o *.junk cfiles.txt 165 166distclean: clean 167 -@rm -f Makefile 168 169Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 170 cd $(top_builddir) \ 171 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status 172 173.PHONY: doclean check all cpptest dtest ctest clean distclean 174 175