]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/hdrtst/Makefile.in
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / hdrtst / Makefile.in
index 55e833943d57b2646fd005d054f0efed8db7608e..af0e8485843e40a03ec33782ac1456eb331b6111 100644 (file)
 ##  unicode/ucnv.h -   0
 ##
 ##    .. etc.  Anything other than zero is an error. (except for the deprecation tests, where '1' is the correct value)
-##              
 ##
-##  If a header fails the C compile because it's a C++ header, add it to the
-##  file named 'cxxfiles.txt' in this directory.
+##  If a header fails the C compile test it is likely because the header is a
+##  C++ header and it isn't properly guarded by the U_SHOW_CPLUSPLUS_API macro.
+##
+##  If a header fails the cppguardtest test it is likely because the header doesn't
+##  include the utypes.h header first *before* using the macro U_SHOW_CPLUSPLUS_API.
 ##
 ##  If a header fails because it is deprecated, add it to the 'dfiles.txt'
 ##
@@ -33,135 +35,102 @@ top_builddir = ../..
 subdir = test/hdrtst
 
 include $(shell icu-config --incfile)
-DIRS=$(prefix)/include/unicode
-LDIRS=$(prefix)/include/layout
-ECHO_T=@ECHO_T@
-ECHO_C=@ECHO_C@
-ECHO_N=@ECHO_N@
 
 all: 
        @echo Please read this Makefile for more information.
        @echo run \'$(MAKE) check\' to run the test "(use -k if you don't want to stop on errs)"
 
-E_NUM=8
-E_D="[1/$(E_NUM)] Deprecated: "
-E_C="[2/$(E_NUM)] C  : "
-E_CXX="[3/$(E_NUM)] C++: "
-E_CXX_L="[4/$(E_NUM)] C++ layout: "
-E_DRF="[5/$(E_NUM)] Hide Draft: "
-E_DEP="[6/$(E_NUM)] Hide Deprecated: "
-E_INT="[7/$(E_NUM)] Hide Internal: "
-E_OBS="[8/$(E_NUM)] Hide Obsolete: "
-
-check: dtest ctest cpptest doclean drafttest deprtest internaltest obsoletetest
-ifeq ($(MAKECMDGOALS),check)
-       $(MAKE) clean
-else
-       @echo "(not cleaning automatically)"
-endif
-
-# break dependency
-doclean:
-       make clean
-
-cpptest:
-       @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
-         echo 'void junk(){}' >> ht_$$incfile.cpp ; \
-          $(COMPILE.cc) -c $(cppflags) ht_$$incfile.cpp || FAIL=1 ; \
-       done ;\
-       exit $$FAIL
-
-# layout is removed
+check: dtest ctest cpptest drafttest deprtest internaltest obsoletetest cppguardtest
 
-dtest:
-       @FAIL=0;NONE="(No deprecated headers)";for stub in `cat $(srcdir)/dfiles.txt | grep -v '^#'` ; do \
-         file=unicode/$$stub ; \
-         NONE="" ; \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.cpp ; \
-         echo 'void junk(){}' >> ht_$$incfile.cpp ; \
-         echo > ht_dep.junk ; \
-          $(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" ; \
-         RES=$$? ; \
-         echo $$RES ; \
-         fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || echo "** FAIL Header unicode/$$incfile.h is not obsoleted properly" ; \
-         fgrep -q "$$incfile.h header is obsolete" ht_dep.junk || FAIL=1 ; \
-         rm -f unicode/$$stub ; \
+headertest:
+       @FAIL=0;stub=ht_stub_$(NAME.headers).$(SUFFIX.headers); for file in "$(prefix)/include/unicode"/*.h ; do \
+               incfile=`basename $$file` ; \
+               echo "$(NAME.headers) unicode/$$incfile" ; \
+               echo "#include <unicode/$$incfile>" > $$stub ; \
+               echo 'void junk(){}' >> $$stub ; \
+               $(COMPILE.headers) $(cppflags) $(FLAGS.headers) $$stub || FAIL=1 ; \
+               rm -f $$stub; \
        done ; \
-       echo "$@: $$NONE - exit status $$FAIL" ; \
        exit $$FAIL
 
-#  < ht_dep.junk &&  ; \
-
-
 ctest:
-       @echo Building test harness for header files in ../../common and ../../i18n
-       @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/cxxfiles.txt | tee cfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#include "'unicode/$$incfile'.h"' > ht_$$incfile.c ; \
-         echo 'void junk(void);' >> ht_$$incfile.c ; \
-         echo 'void junk(){}' >> ht_$$incfile.c ; \
-          $(COMPILE.c) -c $(cppflags) ht_$$incfile.c || FAIL=1 ; \
-       done ;\
-       exit $$FAIL
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.c)" \
+               SUFFIX.headers=c \
+               FLAGS.headers=
+
+cpptest:
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.cc)" \
+               SUFFIX.headers=cpp \
+               FLAGS.headers=
 
 drafttest:
-       @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#define U_HIDE_DRAFT_API' > hd_$$incfile.cpp ; \
-         echo '#include "'unicode/$$incfile'.h"' >> hd_$$incfile.cpp ; \
-         echo 'void junk(void);' >> hd_$$incfile.cpp ; \
-         echo 'void junk(){}' >> hd_$$incfile.cpp ; \
-          $(COMPILE.cc) -c $(cppflags) hd_$$incfile.cpp ||FAIL=1 ; \
-       done ;\
-       exit $$FAIL
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.cc)" \
+               SUFFIX.headers=cpp \
+               FLAGS.headers="-DU_HIDE_DRAFT_API"
 
 deprtest:
-       @FAIL=0; for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#define U_HIDE_DEPRECATED_API' > hdp_$$incfile.cpp ; \
-         echo '#include "'unicode/$$incfile'.h"' >> hdp_$$incfile.cpp ; \
-         echo 'void junk(void);' >> hdp_$$incfile.cpp ; \
-         echo 'void junk(){}' >> hdp_$$incfile.cpp ; \
-          $(COMPILE.cc) -c $(cppflags) hdp_$$incfile.cpp || FAIL=1; \
-       done ; \
-       exit $$FAIL
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.cc)" \
+               SUFFIX.headers=cpp \
+               FLAGS.headers="-DU_HIDE_DEPRECATED_API"
 
 internaltest:
-       @FAIL=0;\
-        for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#define U_HIDE_INTERNAL_API' > hin_$$incfile.cpp ; \
-         echo '#include "'unicode/$$incfile'.h"' >> hin_$$incfile.cpp ; \
-         echo 'void junk(void);' >> hin_$$incfile.cpp ; \
-         echo 'void junk(){}' >> hin_$$incfile.cpp ; \
-          $(COMPILE.cc) -c $(cppflags) hin_$$incfile.cpp || FAIL=1 ; \
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.cc)" \
+               SUFFIX.headers=cpp \
+               FLAGS.headers="-DU_HIDE_INTERNAL_API"
+
+obsoletetest:
+       $(MAKE) headertest \
+               NAME.headers=$@ \
+               COMPILE.headers="$(COMPILE.cc)" \
+               SUFFIX.headers=cpp \
+               FLAGS.headers="-DU_HIDE_OBSOLETE_API"
+
+dtest:
+       @FAIL=0;NONE="(No deprecated headers)";stub=ht_stub_dtest.cpp;for incfile in `cat $(srcdir)/dfiles.txt | grep -v '^#' | sort` ; do \
+               NONE= ; \
+               echo "$@ unicode/$$incfile" ; \
+               echo "#include <unicode/$$incfile>" > $$stub ; \
+               echo 'void junk(){}' >> $$stub ; \
+               $(COMPILE.cc) $(cppflags) $$stub 2>&1 | tee $$stub.out || FAIL=1 ; \
+               if ! cat $$stub.out | sed -e 's/^.*#error[^"]*"//' | grep -v ht_ | grep -v "$$incfile header is obsolete"; then \
+                       echo "** FAIL Header unicode/$$incfile is not obsoleted properly" ; \
+                       FAIL=1 ; \
+               fi ; \
+               rm -f $$stub*; \
        done ; \
+       echo "$@: $$NONE - exit status $$FAIL" ; \
        exit $$FAIL
 
-obsoletetest:
-       @FAIL=0;for file in `ls $(prefix)/include/unicode/*.h | fgrep -v -f $(srcdir)/pfiles.txt`; do \
-         incfile=`basename $$file .h` ; \
-         echo "$@ unicode/$$incfile.h" ; \
-         echo '#define U_HIDE_OBSOLETE_API' > hob_$$incfile.cpp ; \
-         echo '#include "'unicode/$$incfile'.h"' >> hob_$$incfile.cpp ; \
-         echo 'void junk(void);' >> hob_$$incfile.cpp ; \
-         echo 'void junk(){}' >> hob_$$incfile.cpp ; \
-          $(COMPILE.cc) -c $(cppflags) hob_$$incfile.cpp || FAIL=1 ; \
+cppguardtest:
+       @FAIL=0;stub=ht_stub_cppguardtest.cpp; for file in "$(prefix)/include/unicode"/*.h ; do \
+               incfile=`basename $$file` ; \
+               if grep -q "U_SHOW_CPLUSPLUS_API" $$file ; then \
+                       echo "$@ unicode/$$incfile" ; \
+                       echo "#include <unicode/$$incfile>" > $$stub ; \
+                       echo 'void junk(){}' >> $$stub ; \
+                       echo '#if !defined(U_SHOW_CPLUSPLUS_API)' >> $$stub ; \
+                       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 ; \
+                       echo '#endif' >> $$stub ; \
+                       $(COMPILE.cc) $(cppflags) $$stub || FAIL=1 ; \
+                       rm -f $$stub; \
+               else \
+                       echo "$@ skipping unicode/$$incfile" ; \
+               fi ; \
        done ; \
        exit $$FAIL
 
 clean:
-       -@echo cleaning..
-       -@rm -f *.h *.c *.cpp *.o *.junk cfiles.txt
+       -@rm -f ht_*
 
 distclean: clean
        -@rm -f Makefile
@@ -170,5 +139,4 @@ Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
        cd $(top_builddir) \
        && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
-.PHONY:        doclean check all cpptest dtest ctest clean distclean
-
+.PHONY:        doclean check all headertest cpptest dtest cppguardtest ctest clean distclean