xref: /PHP-8.0/ext/fileinfo/config.m4 (revision c3eeab01)
1PHP_ARG_ENABLE([fileinfo],
2  [for fileinfo support],
3  [AS_HELP_STRING([--disable-fileinfo],
4    [Disable fileinfo support])],
5  [yes])
6
7if test "$PHP_FILEINFO" != "no"; then
8
9  libmagic_sources=" \
10    libmagic/apprentice.c libmagic/apptype.c libmagic/ascmagic.c \
11    libmagic/cdf.c libmagic/cdf_time.c libmagic/compress.c \
12    libmagic/encoding.c libmagic/fsmagic.c libmagic/funcs.c \
13    libmagic/is_json.c libmagic/is_tar.c libmagic/magic.c libmagic/print.c \
14    libmagic/readcdf.c libmagic/softmagic.c libmagic/der.c \
15    libmagic/buffer.c libmagic/is_csv.c"
16
17  AC_MSG_CHECKING([for strcasestr])
18  AC_RUN_IFELSE([AC_LANG_SOURCE([[
19#include <string.h>
20#include <strings.h>
21#include <stdlib.h>
22
23int main(void)
24{
25        char *s0, *s1, *ret;
26
27        s0 = (char *) malloc(42);
28        s1 = (char *) malloc(8);
29
30        memset(s0, 'X', 42);
31        s0[24] = 'Y';
32        s0[26] = 'Z';
33        s0[41] = '\0';
34        memset(s1, 'x', 8);
35        s1[0] = 'y';
36        s1[2] = 'Z';
37        s1[7] = '\0';
38
39        ret = strcasestr(s0, s1);
40
41        return !(NULL != ret);
42}
43  ]])],[
44    dnl using the platform implementation
45    AC_MSG_RESULT(yes)
46  ],[
47    AC_MSG_RESULT(no)
48    AC_MSG_NOTICE(using libmagic strcasestr implementation)
49    libmagic_sources="$libmagic_sources libmagic/strcasestr.c"
50  ],[AC_MSG_RESULT([skipped, cross-compiling])])
51
52  PHP_NEW_EXTENSION(fileinfo, fileinfo.c $libmagic_sources, $ext_shared,,-I@ext_srcdir@/libmagic)
53  PHP_ADD_BUILD_DIR($ext_builddir/libmagic)
54
55  AC_CHECK_FUNCS([utimes strndup])
56
57  PHP_ADD_MAKEFILE_FRAGMENT
58fi
59