Skip to content

Commit 946032f

Browse files
author
foobar
committed
- Cleaned up and made less error-prone
- Changed --enable-mime-magic -> --with-mime-magic[=FILE] to allow specifying of the file during configure.
1 parent b9a7918 commit 946032f

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

ext/mime_magic/config.m4

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1+
dnl
12
dnl $Id$
2-
dnl config.m4 for extension mime_magic
3+
dnl
34

4-
PHP_ARG_ENABLE(mime-magic, whether to enable mime_magic support,
5-
[ --enable-mime-magic Enable mime_magic support])
5+
PHP_ARG_WITH(mime-magic, whether to include mime_magic support,
6+
[ --with-mime-magic[=FILE] Include mime_magic support. FILE is the optional
7+
pathname to the magic.mime file.])
68

7-
if test "$PHP_MIME_MAGIC" = "yes"; then
8-
dnl PHP_SUBST(MIME_MAGIC_SHARED_LIBADD)
9+
if test "$PHP_MIME_MAGIC" != "no"; then
910

1011
PHP_NEW_EXTENSION(mime_magic, mime_magic.c, $ext_shared)
1112

12-
# Try to see if we can find the path of the magic file in its
13-
# default locations.
14-
if test -f /usr/share/magic.mime ; then
15-
PHP_MIME_MAGIC_FILE_PATH=/usr/share/magic.mime
16-
elif test -f /usr/share/magic ; then
17-
PHP_MIME_MAGIC_FILE_PATH=/usr/share/magic
18-
elif test -f /usr/share/misc/magic.mime ; then
19-
PHP_MIME_MAGIC_FILE_PATH=/usr/share/misc/magic.mime
20-
elif test -f /etc/magic ; then
21-
PHP_MIME_MAGIC_FILE_PATH=/etc/magic.mime
13+
PHP_MIME_MAGIC_FILE_PATH=
14+
15+
dnl
16+
dnl Try to see if we can find the path of the magic file in its default locations.
17+
dnl
18+
if test "$PHP_MIME_MAGIC" = "yes"; then
19+
if test -f $PHP_MIME_MAGIC; then
20+
PHP_MIME_MAGIC_FILE_PATH=$PHP_MIME_MAGIC
21+
else
22+
AC_MSG_ERROR([File '$PHP_MIME_MAGIC' not found!])
23+
fi
2224
else
23-
PHP_MIME_MAGIC_FILE_PATH=""
24-
fi
25+
MAGIC_MIME_LOCATIONS="/usr/share/magic.mime /usr/share/misc/magic.mime /etc/magic.mime"
2526

27+
for i in $MAGIC_MIME_LOCATIONS; do
28+
if test -f $i; then
29+
PHP_MIME_MAGIC_FILE_PATH=$i
30+
break
31+
fi
32+
done
33+
fi
34+
2635
AC_DEFINE_UNQUOTED(PHP_MIME_MAGIC_FILE_PATH,"$PHP_MIME_MAGIC_FILE_PATH",[magic file path])
2736

2837
fi

0 commit comments

Comments
 (0)