xref: /php-src/sapi/phpdbg/config.m4 (revision 42525450)
1PHP_ARG_ENABLE([phpdbg],
2  [for phpdbg support],
3  [AS_HELP_STRING([--disable-phpdbg],
4    [Disable building of phpdbg])],
5  [yes],
6  [yes])
7
8PHP_ARG_ENABLE([phpdbg-debug],
9  [for phpdbg debug build],
10  [AS_HELP_STRING([--enable-phpdbg-debug],
11    [Build phpdbg in debug mode to enable additional diagnostic output for
12    developing and troubleshooting phpdbg itself])],
13  [no],
14  [no])
15
16PHP_ARG_ENABLE([phpdbg-readline],
17  [for phpdbg readline support],
18  [AS_HELP_STRING([--enable-phpdbg-readline],
19    [Enable readline support in phpdbg (depends on static ext/readline)])],
20  [no],
21  [no])
22
23if test "$PHP_PHPDBG" != "no"; then
24  AC_HEADER_TIOCGWINSZ
25
26  PHP_PHPDBG_CFLAGS="-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
27  AS_VAR_IF([PHP_PHPDBG_DEBUG], [no],,
28    [AS_VAR_APPEND([PHP_PHPDBG_CFLAGS], [" -DPHPDBG_DEBUG=1"])])
29
30  AC_MSG_CHECKING([for phpdbg and readline integration])
31  if test "$PHP_PHPDBG_READLINE" = "yes"; then
32    if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then
33      AC_DEFINE([HAVE_PHPDBG_READLINE], [1],
34        [Define to 1 if the phpdbg SAPI has libedit/readline integration.])
35      PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
36      AC_MSG_RESULT([ok])
37    else
38      AC_MSG_RESULT([readline is not available])
39    fi
40  else
41    AC_MSG_RESULT([disabled])
42  fi
43
44  AH_TEMPLATE([HAVE_USERFAULTFD_WRITEFAULT],
45    [Define to 1 if faulting on write-protected memory support can be compiled
46    for userfaultfd.])
47
48  AC_CHECK_DECL([UFFDIO_WRITEPROTECT_MODE_WP],
49    [AS_VAR_IF([enable_zts], [yes],
50      [AC_DEFINE([HAVE_USERFAULTFD_WRITEFAULT], [1])],
51      [AC_MSG_CHECKING([working pthreads])
52        AS_VAR_IF([pthreads_working], [yes], [
53          AC_MSG_RESULT([$ac_cv_pthreads_cflags -l$ac_cv_pthreads_lib])
54          AS_VAR_APPEND([PHP_PHPDBG_CFLAGS], [" $ac_cv_pthreads_cflags"])
55          AS_VAR_APPEND([PHPDBG_EXTRA_LIBS], [" -l$ac_cv_pthreads_lib"])
56          AC_DEFINE([HAVE_USERFAULTFD_WRITEFAULT], [1])
57        ], [
58          AC_MSG_RESULT([no])
59          AC_MSG_WARN([pthreads not available])
60        ])
61      ])
62    ],,
63    [#include <linux/userfaultfd.h>])
64
65  PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag],
66    [$abs_srcdir/sapi/phpdbg],
67    [sapi/phpdbg])
68  PHP_SELECT_SAPI([phpdbg],
69    [program],
70    m4_normalize([
71      phpdbg_bp.c
72      phpdbg_break.c
73      phpdbg_btree.c
74      phpdbg_cmd.c
75      phpdbg_frame.c
76      phpdbg_help.c
77      phpdbg_info.c
78      phpdbg_io.c
79      phpdbg_lexer.c
80      phpdbg_list.c
81      phpdbg_out.c
82      phpdbg_parser.c
83      phpdbg_print.c
84      phpdbg_prompt.c
85      phpdbg_set.c
86      phpdbg_sigsafe.c
87      phpdbg_utils.c
88      phpdbg_watch.c
89      phpdbg.c
90    ]),
91    [$PHP_PHPDBG_CFLAGS])
92
93  SAPI_PHPDBG_PATH="sapi/phpdbg/phpdbg"
94  SAPI_PHPDBG_SHARED_PATH="sapi/phpdbg/libphpdbg.la"
95
96  BUILD_PHPDBG="\$(LIBTOOL) --tag=CC --mode=link \
97        \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
98                \$(PHP_GLOBAL_OBJS:.lo=.o) \
99                \$(PHP_BINARY_OBJS:.lo=.o) \
100                \$(PHP_PHPDBG_OBJS:.lo=.o) \
101                \$(EXTRA_LIBS) \
102                \$(PHPDBG_EXTRA_LIBS) \
103                \$(ZEND_EXTRA_LIBS) \
104                \$(PHP_FRAMEWORKS) \
105         -o \$(SAPI_PHPDBG_PATH)"
106
107  BUILD_PHPDBG_SHARED="\$(LIBTOOL) --tag=CC --mode=link \
108        \$(CC) -shared -Wl,-soname,libphpdbg.so -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
109                \$(PHP_GLOBAL_OBJS) \
110                \$(PHP_BINARY_OBJS) \
111                \$(PHP_PHPDBG_OBJS) \
112                \$(EXTRA_LIBS) \
113                \$(PHPDBG_EXTRA_LIBS) \
114                \$(ZEND_EXTRA_LIBS) \
115         -o \$(SAPI_PHPDBG_SHARED_PATH)"
116
117  PHP_SUBST([PHPDBG_EXTRA_LIBS])
118  PHP_SUBST([SAPI_PHPDBG_PATH])
119  PHP_SUBST([SAPI_PHPDBG_SHARED_PATH])
120  PHP_SUBST([BUILD_PHPDBG])
121  PHP_SUBST([BUILD_PHPDBG_SHARED])
122
123  AC_CONFIG_FILES([sapi/phpdbg/phpdbg.1])
124fi
125