|
| 1 | +dnl config.m4 for extension helloworld |
| 2 | + |
| 3 | +dnl Comments in this file start with the string 'dnl'. |
| 4 | +dnl Remove where necessary. |
| 5 | + |
| 6 | +dnl If your extension references something external, use 'with': |
| 7 | + |
| 8 | +dnl PHP_ARG_WITH([helloworld], |
| 9 | +dnl [for helloworld support], |
| 10 | +dnl [AS_HELP_STRING([--with-helloworld], |
| 11 | +dnl [Include helloworld support])]) |
| 12 | + |
| 13 | +dnl Otherwise use 'enable': |
| 14 | + |
| 15 | +PHP_ARG_ENABLE([helloworld], |
| 16 | + [whether to enable helloworld support], |
| 17 | + [AS_HELP_STRING([--enable-helloworld], |
| 18 | + [Enable helloworld support])], |
| 19 | + [no]) |
| 20 | + |
| 21 | +if test "$PHP_HELLOWORLD" != "no"; then |
| 22 | + dnl Write more examples of tests here... |
| 23 | + |
| 24 | + dnl Remove this code block if the library does not support pkg-config. |
| 25 | + dnl PKG_CHECK_MODULES([LIBFOO], [foo]) |
| 26 | + dnl PHP_EVAL_INCLINE($LIBFOO_CFLAGS) |
| 27 | + dnl PHP_EVAL_LIBLINE($LIBFOO_LIBS, HELLOWORLD_SHARED_LIBADD) |
| 28 | + |
| 29 | + dnl If you need to check for a particular library version using PKG_CHECK_MODULES, |
| 30 | + dnl you can use comparison operators. For example: |
| 31 | + dnl PKG_CHECK_MODULES([LIBFOO], [foo >= 1.2.3]) |
| 32 | + dnl PKG_CHECK_MODULES([LIBFOO], [foo < 3.4]) |
| 33 | + dnl PKG_CHECK_MODULES([LIBFOO], [foo = 1.2.3]) |
| 34 | + |
| 35 | + dnl Remove this code block if the library supports pkg-config. |
| 36 | + dnl --with-helloworld -> check with-path |
| 37 | + dnl SEARCH_PATH="/usr/local /usr" # you might want to change this |
| 38 | + dnl SEARCH_FOR="/include/helloworld.h" # you most likely want to change this |
| 39 | + dnl if test -r $PHP_HELLOWORLD/$SEARCH_FOR; then # path given as parameter |
| 40 | + dnl HELLOWORLD_DIR=$PHP_HELLOWORLD |
| 41 | + dnl else # search default path list |
| 42 | + dnl AC_MSG_CHECKING([for helloworld files in default path]) |
| 43 | + dnl for i in $SEARCH_PATH ; do |
| 44 | + dnl if test -r $i/$SEARCH_FOR; then |
| 45 | + dnl HELLOWORLD_DIR=$i |
| 46 | + dnl AC_MSG_RESULT(found in $i) |
| 47 | + dnl fi |
| 48 | + dnl done |
| 49 | + dnl fi |
| 50 | + dnl |
| 51 | + dnl if test -z "$HELLOWORLD_DIR"; then |
| 52 | + dnl AC_MSG_RESULT([not found]) |
| 53 | + dnl AC_MSG_ERROR([Please reinstall the helloworld distribution]) |
| 54 | + dnl fi |
| 55 | + |
| 56 | + dnl Remove this code block if the library supports pkg-config. |
| 57 | + dnl --with-helloworld -> add include path |
| 58 | + dnl PHP_ADD_INCLUDE($HELLOWORLD_DIR/include) |
| 59 | + |
| 60 | + dnl Remove this code block if the library supports pkg-config. |
| 61 | + dnl --with-helloworld -> check for lib and symbol presence |
| 62 | + dnl LIBNAME=HELLOWORLD # you may want to change this |
| 63 | + dnl LIBSYMBOL=HELLOWORLD # you most likely want to change this |
| 64 | + |
| 65 | + dnl If you need to check for a particular library function (e.g. a conditional |
| 66 | + dnl or version-dependent feature) and you are using pkg-config: |
| 67 | + dnl PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, |
| 68 | + dnl [ |
| 69 | + dnl AC_DEFINE(HAVE_HELLOWORLD_FEATURE, 1, [ ]) |
| 70 | + dnl ],[ |
| 71 | + dnl AC_MSG_ERROR([FEATURE not supported by your helloworld library.]) |
| 72 | + dnl ], [ |
| 73 | + dnl $LIBFOO_LIBS |
| 74 | + dnl ]) |
| 75 | + |
| 76 | + dnl If you need to check for a particular library function (e.g. a conditional |
| 77 | + dnl or version-dependent feature) and you are not using pkg-config: |
| 78 | + dnl PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, |
| 79 | + dnl [ |
| 80 | + dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $HELLOWORLD_DIR/$PHP_LIBDIR, HELLOWORLD_SHARED_LIBADD) |
| 81 | + dnl AC_DEFINE(HAVE_HELLOWORLD_FEATURE, 1, [ ]) |
| 82 | + dnl ],[ |
| 83 | + dnl AC_MSG_ERROR([FEATURE not supported by your helloworld library.]) |
| 84 | + dnl ],[ |
| 85 | + dnl -L$HELLOWORLD_DIR/$PHP_LIBDIR -lm |
| 86 | + dnl ]) |
| 87 | + dnl |
| 88 | + dnl PHP_SUBST(HELLOWORLD_SHARED_LIBADD) |
| 89 | + |
| 90 | + dnl In case of no dependencies |
| 91 | + AC_DEFINE(HAVE_HELLOWORLD, 1, [ Have helloworld support ]) |
| 92 | + |
| 93 | + PHP_NEW_EXTENSION(helloworld, helloworld.c, $ext_shared) |
| 94 | +fi |
0 commit comments