Skip to content

Commit 98182c5

Browse files
authored
Merge pull request #3 from remicollet/issue-conf2
review again library search
2 parents 1be5756 + b2f61a9 commit 98182c5

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

config.m4

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,55 @@
11
PHP_ARG_ENABLE(decimal, whether to enable decimal support,
2-
[ --enable-decimal Enable decimal support])
2+
[ --enable-decimal Enable decimal support])
3+
4+
PHP_ARG_WITH(libmpdec-path, for libmpdec custom path,
5+
[ --with-libmpdec-path libmpdec path], no, no)
36

47
if test "$PHP_DECIMAL" != "no"; then
58

6-
AC_MSG_CHECKING([for libmpdec files in default path])
7-
for i in /usr/$PHP_LIBDIR $(locate -e /usr/**/libmpdec.so); do
8-
if test -r $i; then
9-
LIBMPDEC_DIR=$(dirname $i)
9+
MACHINE_INCLUDES=$($CC -dumpmachine)
10+
AC_MSG_CHECKING([for libmpdec library in default path])
11+
for i in $PHP_LIBMPDEC_PATH /usr /usr/local/; do
12+
if test -r $i/$PHP_LIBDIR/libmpdec.$SHLIB_SUFFIX_NAME || test -r $i/$PHP_LIBDIR/libmpdec.a; then
13+
LIBMPDEC_DIR=$i/$PHP_LIBDIR
14+
LIBMPDEC_INC=$i/include
15+
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
16+
break
17+
elif test -r $i/lib/libmpdec.$SHLIB_SUFFIX_NAME || test -r $i/lib/libmpdec.a; then
18+
LIBMPDEC_DIR=$i/lib
19+
LIBMPDEC_INC=$i/include
20+
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
21+
break
22+
elif test -r $i/lib/$MACHINE_INCLUDES/libmpdec.so ; then
23+
LIBMPDEC_DIR=$i/lib/$MACHINE_INCLUDES
24+
LIBMPDEC_INC=$i/include/$MACHINE_INCLUDES
1025
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
1126
break
1227
fi
1328
done
1429

30+
1531
if test -z "$LIBMPDEC_DIR"; then
1632
AC_MSG_RESULT([Could not find libmpdec])
1733
AC_MSG_ERROR([Please reinstall the libmpdec distribution from http://www.bytereef.org/mpdecimal/])
34+
35+
else
36+
AC_MSG_CHECKING([for libmpdec headers in default path])
37+
if test -r $LIBMPDEC_INC/mpdecimal.h; then
38+
PHP_ADD_INCLUDE(LIBMPDEC_INC)
39+
AC_MSG_RESULT(found in $LIBMPDEC_INC)
40+
else
41+
AC_MSG_WARN(not found)
42+
fi
1843
fi
1944

45+
2046
PHP_CHECK_LIBRARY(mpdec, mpd_version, [
21-
PHP_ADD_LIBRARY_WITH_PATH(mpdec, $LIBMPDEC_DIR/$PHP_LIBDIR, DECIMAL_SHARED_LIBADD)
47+
PHP_ADD_LIBRARY_WITH_PATH(mpdec, $LIBMPDEC_DIR, DECIMAL_SHARED_LIBADD)
2248
AC_DEFINE(HAVE_LIBMPDEC, 1, [ ])
2349
],[
2450
AC_MSG_ERROR([Please check your version of libmpdec (~2.4.0)])
2551
],[
26-
-L$LIBMPDEC_DIR/$PHP_LIBDIR -lm
52+
-L$LIBMPDEC_DIR -lm
2753
])
2854

2955
PHP_NEW_EXTENSION(decimal, php_decimal.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)

0 commit comments

Comments
 (0)