Skip to content

Commit 0ad17f7

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 7d99a9c commit 0ad17f7

File tree

2 files changed

+10
-62
lines changed

2 files changed

+10
-62
lines changed

ext/tidy/config.m4

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,27 @@
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+
PKG_CHECK_MODULES([TIDY], [tidy])
78

8-
if test "$PHP_TIDY" != "yes"; then
9-
TIDY_SEARCH_DIRS=$PHP_TIDY
10-
else
11-
TIDY_SEARCH_DIRS="/usr/local /usr"
12-
fi
9+
PHP_EVAL_LIBLINE([$TIDY_LIBS], [TIDY_SHARED_LIBADD])
10+
PHP_EVAL_INCLINE([$TIDY_CFLAGS])
1311

14-
for i in $TIDY_SEARCH_DIRS; do
15-
for j in tidy tidyp; do
16-
if test -f $i/include/$j/$j.h; then
17-
TIDY_DIR=$i
18-
TIDY_INCDIR=$i/include/$j
19-
TIDY_LIB_NAME=$j
20-
break
21-
elif test -f $i/include/$j.h; then
22-
TIDY_DIR=$i
23-
TIDY_INCDIR=$i/include
24-
TIDY_LIB_NAME=$j
25-
break
26-
fi
27-
done
28-
done
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-
if test -z "$TIDY_DIR"; then
31-
AC_MSG_ERROR(Cannot find libtidy)
32-
else
33-
dnl Check for tidybuffio.h (as opposed to simply buffio.h) which indicates
34-
dnl that we are building against tidy-html5 and not the legacy htmltidy. The
35-
dnl two are compatible, except for with regard to this header file.
36-
if test -f "$TIDY_INCDIR/tidybuffio.h"; then
37-
AC_DEFINE(HAVE_TIDYBUFFIO_H,1,[defined if tidybuffio.h exists])
38-
fi
39-
fi
40-
41-
TIDY_LIBDIR=$TIDY_DIR/$PHP_LIBDIR
42-
if test "$TIDY_LIB_NAME" == 'tidyp'; then
43-
AC_DEFINE(HAVE_TIDYP_H,1,[defined if tidyp.h exists])
44-
else
45-
AC_DEFINE(HAVE_TIDY_H,1,[defined if tidy.h exists])
46-
fi
47-
48-
49-
PHP_CHECK_LIBRARY($TIDY_LIB_NAME,tidyOptGetDoc,
16+
PHP_CHECK_LIBRARY(tidy,tidyOptGetDoc,
5017
[
5118
AC_DEFINE(HAVE_TIDYOPTGETDOC,1,[ ])
52-
],[
53-
PHP_CHECK_LIBRARY(tidy5,tidyOptGetDoc,
54-
[
55-
TIDY_LIB_NAME=tidy5
56-
AC_DEFINE(HAVE_TIDYOPTGETDOC,1,[ ])
57-
], [], [])
58-
],[])
59-
60-
PHP_CHECK_LIBRARY($TIDY_LIB_NAME,tidyReleaseDate,
19+
], [], [])
20+
PHP_CHECK_LIBRARY(tidy, tidyReleaseDate,
6121
[
6222
AC_DEFINE(HAVE_TIDYRELEASEDATE,1,[ ])
6323
], [], [])
6424

65-
PHP_ADD_LIBRARY_WITH_PATH($TIDY_LIB_NAME, $TIDY_LIBDIR, TIDY_SHARED_LIBADD)
66-
PHP_ADD_INCLUDE($TIDY_INCDIR)
67-
6825
dnl Add -Wno-ignored-qualifiers as this is an issue upstream
6926
TIDY_COMPILER_FLAGS="$TIDY_CFLAGS -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
7027
PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, $TIDY_COMPILER_FLAGS)

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)