xref: /PHP-8.3/ext/tidy/config.m4 (revision 3b9d33dc)
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
8  if test "$PHP_TIDY" != "yes"; then
9    TIDY_SEARCH_DIRS=$PHP_TIDY
10  else
11    TIDY_SEARCH_DIRS="/usr/local /usr"
12  fi
13
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
29
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,
50  [
51    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,
61  [
62    AC_DEFINE(HAVE_TIDYRELEASEDATE,1,[ ])
63  ], [], [])
64
65  PHP_ADD_LIBRARY_WITH_PATH($TIDY_LIB_NAME, $TIDY_LIBDIR, TIDY_SHARED_LIBADD)
66  PHP_ADD_INCLUDE($TIDY_INCDIR)
67
68  dnl Add -Wno-ignored-qualifiers as this is an issue upstream
69  TIDY_COMPILER_FLAGS="$TIDY_CFLAGS -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
70  PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, $TIDY_COMPILER_FLAGS)
71  PHP_SUBST(TIDY_SHARED_LIBADD)
72  AC_DEFINE(HAVE_TIDY,1,[ ])
73fi
74