xref: /PHP-8.2/sapi/phpdbg/config.m4 (revision d57a7767)
1PHP_ARG_ENABLE([phpdbg],
2  [for phpdbg support],
3  [AS_HELP_STRING([--enable-phpdbg],
4    [Build 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])],
12  [no],
13  [no])
14
15PHP_ARG_ENABLE([phpdbg-readline],
16  [for phpdbg readline support],
17  [AS_HELP_STRING([--enable-phpdbg-readline],
18    [Enable readline support in phpdbg (depends on static ext/readline)])],
19  [no],
20  [no])
21
22if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
23  AC_HEADER_TIOCGWINSZ
24  AC_DEFINE(HAVE_PHPDBG, 1, [ ])
25
26  if test "$PHP_PHPDBG_DEBUG" != "no"; then
27    AC_DEFINE(PHPDBG_DEBUG, 1, [ ])
28  else
29    AC_DEFINE(PHPDBG_DEBUG, 0, [ ])
30  fi
31
32  PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
33  PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_io.c phpdbg_out.c"
34
35  AC_MSG_CHECKING([for phpdbg and readline integration])
36  if test "$PHP_PHPDBG_READLINE" = "yes"; then
37    if test "$PHP_READLINE" != "no" -o  "$PHP_LIBEDIT" != "no"; then
38  	  AC_DEFINE(HAVE_PHPDBG_READLINE, 1, [ ])
39  	  PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
40  	  AC_MSG_RESULT([ok])
41  	else
42  	  AC_MSG_RESULT([readline is not available])
43    fi
44  else
45    AC_MSG_RESULT([disabled])
46  fi
47
48  AC_CACHE_CHECK([for userfaultfd faulting on write-protected memory support], ac_cv_phpdbg_userfaultfd_writefault, AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
49    #include <linux/userfaultfd.h>
50    #ifndef UFFDIO_WRITEPROTECT_MODE_WP
51    # error userfaults on write-protected memory not supported
52    #endif
53  ]])], [ac_cv_phpdbg_userfaultfd_writefault=yes], [ac_cv_phpdbg_userfaultfd_writefault=no]))
54  if test "$ac_cv_phpdbg_userfaultfd_writefault" = "yes"; then
55    if test "$enable_zts" != "yes"; then
56      CFLAGS_SAVE="$CFLAGS"
57      LIBS_SAVE="$LIBS"
58
59      PTHREADS_CHECK
60      AC_MSG_CHECKING([working pthreads]);
61
62      if test "$pthreads_working" = "yes"; then
63      	AC_MSG_RESULT([$ac_cv_pthreads_cflags -l$ac_cv_pthreads_lib]);
64      	PHP_PHPDBG_CFLAGS="$PHP_PHPDBG_CFLAGS $ac_cv_pthreads_cflags"
65      	PHPDBG_EXTRA_LIBS="$PHPDBG_EXTRA_LIBS -l$ac_cv_pthreads_lib"
66      	AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
67      else
68        AC_MSG_WARN([pthreads not available])
69      fi
70
71      CFLAGS="$CFLAGS_SAVE"
72      LIBS="$LIBS_SAVE"
73    else
74      AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
75    fi
76  fi
77
78  PHP_SUBST(PHP_PHPDBG_CFLAGS)
79  PHP_SUBST(PHP_PHPDBG_FILES)
80  PHP_SUBST(PHPDBG_EXTRA_LIBS)
81
82  PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag], [$abs_srcdir/sapi/phpdbg], [$abs_builddir/sapi/phpdbg])
83  PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)])
84
85  BUILD_BINARY="sapi/phpdbg/phpdbg"
86  BUILD_SHARED="sapi/phpdbg/libphpdbg.la"
87
88  BUILD_PHPDBG="\$(LIBTOOL) --tag=CC --mode=link \
89        \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
90                \$(PHP_GLOBAL_OBJS:.lo=.o) \
91                \$(PHP_BINARY_OBJS:.lo=.o) \
92                \$(PHP_PHPDBG_OBJS:.lo=.o) \
93                \$(EXTRA_LIBS) \
94                \$(PHPDBG_EXTRA_LIBS) \
95                \$(ZEND_EXTRA_LIBS) \
96                \$(PHP_FRAMEWORKS) \
97         -o \$(BUILD_BINARY)"
98
99  BUILD_PHPDBG_SHARED="\$(LIBTOOL) --tag=CC --mode=link \
100        \$(CC) -shared -Wl,-soname,libphpdbg.so -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \
101                \$(PHP_GLOBAL_OBJS) \
102                \$(PHP_BINARY_OBJS) \
103                \$(PHP_PHPDBG_OBJS) \
104                \$(EXTRA_LIBS) \
105                \$(PHPDBG_EXTRA_LIBS) \
106                \$(ZEND_EXTRA_LIBS) \
107                \-DPHPDBG_SHARED \
108         -o \$(BUILD_SHARED)"
109
110  PHP_SUBST(BUILD_BINARY)
111  PHP_SUBST(BUILD_SHARED)
112  PHP_SUBST(BUILD_PHPDBG)
113  PHP_SUBST(BUILD_PHPDBG_SHARED)
114
115  PHP_OUTPUT(sapi/phpdbg/phpdbg.1)
116fi
117