Skip to content

Commit 3a9b45a

Browse files
committed
review again library search
1 parent a940c1e commit 3a9b45a

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

config.m4

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,54 @@
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+
AC_MSG_CHECKING([for libmpdec library in default path])
10+
for i in $PHP_LIBMPDEC_PATH /usr /usr/local/; do
11+
if test -r $i/$PHP_LIBDIR/libmpdec.$SHLIB_SUFFIX_NAME || test -r $i/$PHP_LIBDIR/libmpdec.a; then
12+
LIBMPDEC_DIR=$i/$PHP_LIBDIR
13+
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
14+
break
15+
elif test -r $i/lib/libmpdec.$SHLIB_SUFFIX_NAME || test -r $i/lib/libmpdec.a; then
16+
LIBMPDEC_DIR=$i/lib
1017
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
1118
break
1219
fi
1320
done
1421

15-
if test -z "$LIBMPDEC_DIR"; then
22+
MACHINE_INCLUDES=$($CC -dumpmachine)
23+
if test -z "$LIBMPDEC_DIR" && test -r /usr/lib/$MACHINE_INCLUDES/libmpdec.so ; then
24+
dnl deb/travis specific case
25+
LIBMPDEC_DIR=/usr/lib/$MACHINE_INCLUDES
26+
LIBMPDEC_INC=/usr/include/$MACHINE_INCLUDES
27+
AC_MSG_RESULT(found in $LIBMPDEC_DIR)
28+
29+
elif test -z "$LIBMPDEC_DIR"; then
1630
AC_MSG_RESULT([Could not find libmpdec])
1731
AC_MSG_ERROR([Please reinstall the libmpdec distribution from http://www.bytereef.org/mpdecimal/])
32+
33+
else
34+
LIBMPDEC_INC=$(dirname $LIBMPDEC_DIR)/include
35+
AC_MSG_CHECKING([for libmpdec headers in default path])
36+
if test -r $LIBMPDEC_INC/mpdecimal.h; then
37+
PHP_ADD_INCLUDE(LIBMPDEC_INC)
38+
AC_MSG_RESULT(found in $LIBMPDEC_INC)
39+
else
40+
AC_MSG_WARN(not found)
41+
fi
1842
fi
1943

44+
2045
PHP_CHECK_LIBRARY(mpdec, mpd_version, [
21-
PHP_ADD_LIBRARY_WITH_PATH(mpdec, $LIBMPDEC_DIR/$PHP_LIBDIR, DECIMAL_SHARED_LIBADD)
46+
PHP_ADD_LIBRARY_WITH_PATH(mpdec, $LIBMPDEC_DIR, DECIMAL_SHARED_LIBADD)
2247
AC_DEFINE(HAVE_LIBMPDEC, 1, [ ])
2348
],[
2449
AC_MSG_ERROR([Please check your version of libmpdec (~2.4.0)])
2550
],[
26-
-L$LIBMPDEC_DIR/$PHP_LIBDIR -lm
51+
-L$LIBMPDEC_DIR -lm
2752
])
2853

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

0 commit comments

Comments
 (0)