Home | History | Annotate | Download | only in hdrtst
      1 ##
      2 ##  Copyright (c) 1999-2006, 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 
     27 include $(shell icu-config --incfile)
     28 srcdir=.
     29 DIRS=$(prefix)/include/unicode
     30 LDIRS=$(prefix)/include/layout
     31 
     32 all: 
     33 	@echo Please read this Makefile for more information.
     34 	@echo run \'$(MAKE) check\' to run the test 
     35 
     36 check: dtest ctest cpptest lotest doclean drafttest deprtest internaltest obsoletetest
     37 	@echo "All header tests have finished. If deprecation #errors appeared, "
     38 	@echo "       add files to hdrtst/dfiles.txt"
     39 	@echo "#################################################################"
     40 	@echo
     41 
     42 # break dependency
     43 doclean:
     44 	make clean
     45 
     46 cpptest:
     47 	@echo "C++ test #######################################################"
     48 	@rm -f Makefile.sub
     49 	@echo 'Testing all header files under C++'
     50 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
     51 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
     52 	  incfile=`basename $$file .h` ; \
     53 	  echo -n "C++  unicode/$$incfile.h 	- " ; \
     54 	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
     55 	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
     56           $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp ; \
     57 	  echo $$? ; \
     58 	done
     59 
     60 lotest:
     61 	@echo "Layout test #######################################################"
     62 	@rm -f Makefile.sub
     63 	@echo 'Testing all layout  files under C++'
     64 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
     65 	@for file in $(prefix)/include/layout/*.h; do \
     66 	  incfile=`basename $$file .h` ; \
     67 	  echo -n "C++  layout/$$incfile.h 	- " ; \
     68 	  echo '#include "'layout/$$incfile'.h"' > ht_$$incfile.cpp ; \
     69 	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
     70           $(COMPILE.cc) -c $(cppflags) -I$(prefix)/include/layout ht_$$incfile.cpp ; \
     71 	  echo $$? ; \
     72 	done
     73 
     74 dtest:
     75 	@rm -f Makefile.sub
     76 	@echo "Deprecation #######################################################"
     77 	@echo 'Should be 1 in each case if file is properly obsoleted.'
     78 	@for stub in `cat $(srcdir)/dfiles.txt | grep -v '^#'` ; do \
     79 	  file=unicode/$$stub \
     80 	  incfile=`basename $$file .h` ; \
     81 	  echo -n "C++  unicode/$$incfile.h 	- " ; \
     82 	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
     83 	  echo 'void junk(){}' >> ht_$$incfile.cpp ; \
     84 	  echo > ht_dep.junk ; \
     85           $(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" ; \
     86 	  RES=$$? ; \
     87 	  echo $$RES ; \
     88 	  fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || echo "** FAIL Header unicode/$$incfile.h is not obsoleted properly" ; \
     89 	  rm -f unicode/$$stub ; \
     90 	done
     91 
     92 #  < ht_dep.junk &&  ; \
     93 
     94 
     95 ctest:
     96 	@echo "C Test #######################################################"
     97 	@echo "  (if any C++ files show up here, stop the test and add them to hdrtst/cxxfiles.txt) "
     98 	@rm -f Makefile.sub
     99 	@echo Building test harness for header files in ../../common and ../../i18n
    100 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
    101 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/cxxfiles.txt | tee cfiles.txt`; do \
    102 	  incfile=`basename $$file .h` ; \
    103 	  echo -n "C    unicode/$$incfile.h 	- " ; \
    104 	  echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.c ; \
    105 	  echo 'void junk(void);' >> ht_$$incfile.c ; \
    106 	  echo 'void junk(){}' >> ht_$$incfile.c ; \
    107           $(COMPILE.c) -c $(cppflags) ht_$$incfile.c ; \
    108 	  RES=$$? ; \
    109 	  echo $$RES ; \
    110 	done
    111     
    112 drafttest:
    113 	@echo "U_HIDE_DRAFT_API Test #######################################################"
    114 	@rm -f Makefile.sub
    115 	@echo Building test harness for header files in ../../common and ../../i18n
    116 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
    117 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
    118 	  incfile=`basename $$file .h` ; \
    119 	  echo -n "    unicode/$$incfile.h 	- " ; \
    120 	  echo '#define U_HIDE_DRAFT_API' > hd_$$incfile.c; \
    121 	  echo '#include "'unicode/$$incfile'.h"' >> ht_$$incfile.c ; \
    122 	  echo 'void junk(void);' >> hd_$$incfile.c ; \
    123 	  echo 'void junk(){}' >> hd_$$incfile.c ; \
    124           $(COMPILE.cc) -c $(cppflags) hd_$$incfile.c ; \
    125 	  RES=$$? ; \
    126 	  echo $$RES ; \
    127 	done
    128     
    129 deprtest:
    130 	@echo "U_HIDE_DEPRECATED_API Test #######################################################"
    131 	@rm -f Makefile.sub
    132 	@echo Building test harness for header files in ../../common and ../../i18n
    133 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
    134 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
    135 	  incfile=`basename $$file .h` ; \
    136 	  echo -n "    unicode/$$incfile.h 	- " ; \
    137 	  echo '#define U_HIDE_DEPRECATED_API' > hdp_$$incfile.c; \
    138 	  echo '#include "'unicode/$$incfile'.h"' >> hdp_$$incfile.c ; \
    139 	  echo 'void junk(void);' >> hdp_$$incfile.c ; \
    140 	  echo 'void junk(){}' >> hdp_$$incfile.c ; \
    141           $(COMPILE.cc) -c $(cppflags) hdp_$$incfile.c ; \
    142 	  RES=$$? ; \
    143 	  echo $$RES ; \
    144 	done
    145 
    146 internaltest:
    147 	@echo "U_HIDE_INTERNAL_API Test #######################################################"
    148 	@rm -f Makefile.sub
    149 	@echo Building test harness for header files in ../../common and ../../i18n
    150 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
    151 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
    152 	  incfile=`basename $$file .h` ; \
    153 	  echo -n "    unicode/$$incfile.h 	- " ; \
    154 	  echo '#define U_HIDE_INTERNAL_API' > hin_$$incfile.c; \
    155 	  echo '#include "'unicode/$$incfile'.h"' >> hin_$$incfile.c ; \
    156 	  echo 'void junk(void);' >> hin_$$incfile.c ; \
    157 	  echo 'void junk(){}' >> hin_$$incfile.c ; \
    158           $(COMPILE.cc) -c $(cppflags) hin_$$incfile.c ; \
    159 	  RES=$$? ; \
    160 	  echo $$RES ; \
    161 	done
    162 
    163 obsoletetest:
    164 	@echo "U_HIDE_OBSOLETE_API Test #######################################################"
    165 	@rm -f Makefile.sub
    166 	@echo Building test harness for header files in ../../common and ../../i18n
    167 	@echo 'the number after the hyphen (-) refers to the exit code - should be zero!'
    168 	@for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
    169 	  incfile=`basename $$file .h` ; \
    170 	  echo -n "   unicode/$$incfile.h 	- " ; \
    171 	  echo '#define U_HIDE_OBSOLETE_API' > hob_$$incfile.c; \
    172 	  echo '#include "'unicode/$$incfile'.h"' >> hob_$$incfile.c ; \
    173 	  echo 'void junk(void);' >> hob_$$incfile.c ; \
    174 	  echo 'void junk(){}' >> hob_$$incfile.c ; \
    175           $(COMPILE.cc) -c $(cppflags) hob_$$incfile.c ; \
    176 	  RES=$$? ; \
    177 	  echo $$RES ; \
    178 	done
    179     
    180 clean:
    181 	-@rm -f *.h *.c *.cpp *.o *.junk
    182 
    183 distclean: clean
    184 	-@rm -f Makefile
    185 
    186 
    187 .PHONY:	doclean check all cpptest lotest dtest ctest clean distclean
    188 
    189