Home | History | Annotate | Download | only in hdrtst
      1 ##
      2 ##  Copyright (c) 1999-2008, 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
     27 srcdir = @srcdir@
     28 top_srcdir = @top_srcdir@
     29 
     30 top_builddir = ../..
     31 subdir = test/hdrtst
     32 
     33 include $(shell icu-config --incfile)
     34 DIRS=$(prefix)/include/unicode
     35 LDIRS=$(prefix)/include/layout
     36 ECHO_T=@ECHO_T@
     37 ECHO_C=@ECHO_C@
     38 ECHO_N=@ECHO_N@
     39 
     40 all: 
     41 	@echo Please read this Makefile for more information.
     42 	@echo run \'$(MAKE) check\' to run the test 
     43 	
     44 E_NUM=8
     45 E_D="[1/$(E_NUM)] Deprecated: "
     46 E_C="[2/$(E_NUM)] C  : "
     47 E_CXX="[3/$(E_NUM)] C++: "
     48 E_CXX_L="[4/$(E_NUM)] C++ layout: "
     49 E_DRF="[5/$(E_NUM)] Hide Draft: "
     50 E_DEP="[6/$(E_NUM)] Hide Deprecated: "
     51 E_INT="[7/$(E_NUM)] Hide Internal: "
     52 E_OBS="[8/$(E_NUM)] Hide Obsolete: "
     53 
     54 check: 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
     61 doclean:
     62 	make clean
     63 
     64 cpptest:
     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 
     78 lotest:
     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 
     92 dtest:
     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 
    114 ctest:
    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     
    131 drafttest:
    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     
    148 deprtest:
    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 
    165 internaltest:
    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 
    182 obsoletetest:
    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     
    199 clean:
    200 	-@rm -f *.h *.c *.cpp *.o *.junk
    201 
    202 distclean: clean
    203 	-@rm -f Makefile
    204 
    205 Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
    206 	cd $(top_builddir) \
    207 	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
    208 
    209 
    210 
    211 .PHONY:	doclean check all cpptest lotest dtest ctest clean distclean
    212 
    213