xref: /PHP-8.4/ext/tidy/config.m4 (revision fef55bc8)
1PHP_ARG_WITH([tidy],
2  [for TIDY support],
3  [AS_HELP_STRING([[--with-tidy[=DIR]]],
4    [Include TIDY support])])
5
6if 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])
10
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
27
28  AS_VAR_IF([TIDY_DIR],, [AC_MSG_ERROR([Cannot find libtidy])])
29
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.])])
36
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  dnl Add -Wno-ignored-qualifiers as this is an issue upstream. Fixed in
66  dnl tidy-html5 5.7.20: https://github.com/htacg/tidy-html5/issues/866
67  PHP_NEW_EXTENSION([tidy],
68    [tidy.c],
69    [$ext_shared],,
70    [-Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
71  PHP_SUBST([TIDY_SHARED_LIBADD])
72  AC_DEFINE([HAVE_TIDY], [1],
73    [Define to 1 if the PHP extension 'tidy' is available.])
74fi
75