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