Skip to content

Commit fad5c3e

Browse files
committed
Move ext/tidy to pkg-config
It seems most distributions i.e. Debian/Gentoo/Fedora have all moved over to html-tidy as the tidy library they ship. It ships a pkg-config file, so we can just simply check for that and omit the various alternatives to check for. I'm not sure if the checks for library functionality are needed anymore if we assume the html5 tidy fork either.
1 parent 19eabc6 commit fad5c3e

File tree

2 files changed

+20
-71
lines changed

2 files changed

+20
-71
lines changed

ext/tidy/config.m4

Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,29 @@
11
PHP_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

66
if 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.])

ext/tidy/tidy.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,8 @@
2626
#include "php_ini.h"
2727
#include "ext/standard/info.h"
2828

29-
#ifdef HAVE_TIDY_H
3029
#include "tidy.h"
31-
#elif defined(HAVE_TIDYP_H)
32-
#include "tidyp.h"
33-
#endif
34-
35-
#ifdef HAVE_TIDYBUFFIO_H
3630
#include "tidybuffio.h"
37-
#else
38-
#include "buffio.h"
39-
#endif
4031

4132
#include "tidy_arginfo.h"
4233

0 commit comments

Comments
 (0)