11PHP_ARG_WITH([ tidy] ,
22 [ for TIDY support] ,
3- [ AS_HELP_STRING ( [ [ --with-tidy[ =DIR ] ] ] ,
3+ [ AS_HELP_STRING ( [ --with-tidy] ,
44 [ Include TIDY support] ) ] )
55
66if test "$PHP_TIDY" != "no"; then
7- AS_VAR_IF ( [ PHP_TIDY] , [ yes] ,
8- [ TIDY_SEARCH_DIRS="/usr/local /usr"] ,
9- [ TIDY_SEARCH_DIRS=$PHP_TIDY] )
7+ PKG_CHECK_MODULES([ TIDY] , [ tidy] )
108
11- for i in $TIDY_SEARCH_DIRS; do
12- for j in tidy tidyp; do
13- AS_IF ( [ test -f $i/include/$j/$j.h] , [
14- TIDY_DIR=$i
15- TIDY_INCDIR=$i/include/$j
16- TIDY_LIB_NAME=$j
17- break 2
18- ] ,
19- [ test -f $i/include/$j.h] , [
20- TIDY_DIR=$i
21- TIDY_INCDIR=$i/include
22- TIDY_LIB_NAME=$j
23- break 2
24- ] )
25- done
26- done
9+ PHP_EVAL_LIBLINE([ $TIDY_LIBS] , [ TIDY_SHARED_LIBADD] )
10+ PHP_EVAL_INCLINE([ $TIDY_CFLAGS] )
2711
28- AS_VAR_IF ( [ TIDY_DIR] ,, [ AC_MSG_ERROR ( [ Cannot find libtidy] ) ] )
12+ dnl We used to check for tidybuffio, but it seems almost everyone has moved
13+ dnl to using the html5 tidy fork which uses that name.
14+ dnl This also means the library name is 'tidy'.
2915
30- dnl Check for tidybuffio.h (as opposed to simply buffio.h) which indicates
31- dnl that we are building against tidy-html5 and not the legacy htmltidy. The
32- dnl two are compatible, except for with regard to this header file.
33- AS_IF ( [ test -f "$TIDY_INCDIR/tidybuffio.h"] ,
34- [ AC_DEFINE ( [ HAVE_TIDYBUFFIO_H] , [ 1] ,
35- [ Define to 1 if you have the <tidybuffio.h> header file.] ) ] )
16+ PHP_CHECK_LIBRARY(tidy,tidyOptGetDoc,
17+ [
18+ AC_DEFINE ( HAVE_TIDYOPTGETDOC ,1 ,[ ] )
19+ ] , [ ] , [ ] )
20+ PHP_CHECK_LIBRARY(tidy, tidyReleaseDate,
21+ [
22+ AC_DEFINE ( HAVE_TIDYRELEASEDATE ,1 ,[ ] )
23+ ] , [ ] , [ ] )
3624
37- TIDY_LIBDIR=$TIDY_DIR/$PHP_LIBDIR
38- AS_VAR_IF ( [ TIDY_LIB_NAME] , [ tidyp] ,
39- [ AC_DEFINE ( [ HAVE_TIDYP_H] , [ 1] ,
40- [ Define to 1 if you have the <tidyp.h> header file.] ) ] ,
41- [ AC_DEFINE ( [ HAVE_TIDY_H] , [ 1] ,
42- [ Define to 1 if you have the <tidy.h> header file.] ) ] )
43-
44- PHP_CHECK_LIBRARY([ $TIDY_LIB_NAME] , [ tidyOptGetDoc] ,
45- [ AC_DEFINE ( [ HAVE_TIDYOPTGETDOC] , [ 1] ,
46- [ Define to 1 if Tidy library has the 'tidyOptGetDoc' function.] ) ] ,
47- [ PHP_CHECK_LIBRARY([ tidy5] , [ tidyOptGetDoc] ,
48- [ TIDY_LIB_NAME=tidy5
49- AC_DEFINE ( [ HAVE_TIDYOPTGETDOC] , [ 1] ) ] ,
50- [ ] ,
51- [ -L$TIDY_LIBDIR] )] ,
52- [ -L$TIDY_LIBDIR] )
53-
54- PHP_CHECK_LIBRARY([ $TIDY_LIB_NAME] , [ tidyReleaseDate] ,
55- [ AC_DEFINE ( [ HAVE_TIDYRELEASEDATE] , [ 1] ,
56- [ Define to 1 if Tidy library has the 'tidyReleaseDate' function.] ) ] ,
57- [ ] ,
58- [ -L$TIDY_LIBDIR] )
59-
60- PHP_ADD_LIBRARY_WITH_PATH([ $TIDY_LIB_NAME] ,
61- [ $TIDY_LIBDIR] ,
62- [ TIDY_SHARED_LIBADD] )
63- PHP_ADD_INCLUDE([ $TIDY_INCDIR] )
64-
65- old_CPPFLAGS=$CPPFLAGS
66- CPPFLAGS=-I$TIDY_INCDIR
25+ old_CPPFLAGS="$CPPFLAGS"
26+ CPPFLAGS="-I$TIDY_INCDIR"
6727
6828 dnl The tidyOptGetCategory function (added in tidy-html5 5.4.0) is only
6929 dnl useable if TidyInternalCategory (added in tidy-html5 5.6.0) is also
@@ -84,14 +44,12 @@ if test "$PHP_TIDY" != "no"; then
8444 [ Define to 1 if Tidy library has the 'tidyOptGetCategory' function and
8545 supports the 'TidyInternalCategory' enumeration.] ) ] )
8646
87- CPPFLAGS=$old_CPPFLAGS
47+ CPPFLAGS=" $old_CPPFLAGS"
8848
8949 dnl Add -Wno-ignored-qualifiers as this is an issue upstream. Fixed in
9050 dnl tidy-html5 5.7.20: https://github.com/htacg/tidy-html5/issues/866
91- PHP_NEW_EXTENSION([ tidy] ,
92- [ tidy.c] ,
93- [ $ext_shared] ,,
94- [ -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1] )
51+ TIDY_COMPILER_FLAGS="$TIDY_CFLAGS -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
52+ PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, $TIDY_COMPILER_FLAGS)
9553 PHP_SUBST([ TIDY_SHARED_LIBADD] )
9654 AC_DEFINE ( [ HAVE_TIDY] , [ 1] ,
9755 [ Define to 1 if the PHP extension 'tidy' is available.] )
0 commit comments