|
1 |
| -dnl config.m4 for extension %EXTNAME% |
| 1 | +dnl Autotools config.m4 for PHP extension %EXTNAME% |
2 | 2 |
|
3 |
| -dnl Comments in this file start with the string 'dnl'. |
| 3 | +dnl Comments in this file start with the string 'dnl' (discard to next line). |
4 | 4 | dnl Remove where necessary.
|
5 | 5 |
|
6 |
| -dnl If your extension references something external, use 'with': |
7 |
| - |
| 6 | +dnl If extension references and depends on an external library package, use |
| 7 | +dnl the '--with-%EXTNAME%' configure option: |
8 | 8 | dnl PHP_ARG_WITH([%EXTNAME%],
|
9 | 9 | dnl [for %EXTNAME% support],
|
10 | 10 | dnl [AS_HELP_STRING([--with-%EXTNAME%],
|
11 | 11 | dnl [Include %EXTNAME% support])])
|
12 | 12 |
|
13 |
| -dnl Otherwise use 'enable': |
14 |
| - |
| 13 | +dnl Otherwise use the '--enable-%EXTNAME%' configure option: |
15 | 14 | PHP_ARG_ENABLE([%EXTNAME%],
|
16 | 15 | [whether to enable %EXTNAME% support],
|
17 | 16 | [AS_HELP_STRING([--enable-%EXTNAME%],
|
18 | 17 | [Enable %EXTNAME% support])],
|
19 | 18 | [no])
|
20 | 19 |
|
21 |
| -if test "$PHP_%EXTNAMECAPS%" != "no"; then |
22 |
| - dnl Write more examples of tests here... |
| 20 | +AS_VAR_IF([PHP_%EXTNAMECAPS%], [no],, [ |
| 21 | + dnl This section is executed when extension is enabled with one of the above |
| 22 | + dnl configure options. Adjust and add tests here. |
23 | 23 |
|
24 |
| - dnl Remove this code block if the library does not support pkg-config. |
| 24 | + dnl |
| 25 | + dnl Use and adjust this code block if extension depends on external library |
| 26 | + dnl package which supports pkg-config. |
| 27 | + dnl |
| 28 | + dnl Find library package with pkg-config. |
25 | 29 | dnl PKG_CHECK_MODULES([LIBFOO], [foo])
|
26 |
| - dnl PHP_EVAL_INCLINE([$LIBFOO_CFLAGS]) |
27 |
| - dnl PHP_EVAL_LIBLINE([$LIBFOO_LIBS], [%EXTNAMECAPS%_SHARED_LIBADD]) |
28 |
| - |
29 |
| - dnl If you need to check for a particular library version using PKG_CHECK_MODULES, |
| 30 | + dnl |
| 31 | + dnl Or if you need to check for a particular library version with pkg-config, |
30 | 32 | dnl you can use comparison operators. For example:
|
31 | 33 | dnl PKG_CHECK_MODULES([LIBFOO], [foo >= 1.2.3])
|
32 | 34 | dnl PKG_CHECK_MODULES([LIBFOO], [foo < 3.4])
|
33 | 35 | 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-%EXTNAME% -> check with-path |
37 |
| - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this |
38 |
| - dnl SEARCH_FOR="/include/%EXTNAME%.h" # you most likely want to change this |
39 |
| - dnl if test -r $PHP_%EXTNAMECAPS%/$SEARCH_FOR; then # path given as parameter |
40 |
| - dnl %EXTNAMECAPS%_DIR=$PHP_%EXTNAMECAPS% |
41 |
| - dnl else # search default path list |
42 |
| - dnl AC_MSG_CHECKING([for %EXTNAME% files in default path]) |
43 |
| - dnl for i in $SEARCH_PATH ; do |
44 |
| - dnl if test -r $i/$SEARCH_FOR; then |
45 |
| - dnl %EXTNAMECAPS%_DIR=$i |
46 |
| - dnl AC_MSG_RESULT([found in $i]) |
47 |
| - dnl fi |
48 |
| - dnl done |
49 |
| - dnl fi |
50 | 36 | dnl
|
51 |
| - dnl if test -z "$%EXTNAMECAPS%_DIR"; then |
52 |
| - dnl AC_MSG_RESULT([not found]) |
53 |
| - dnl AC_MSG_ERROR([Please reinstall the %EXTNAME% distribution]) |
54 |
| - dnl fi |
55 |
| - |
56 |
| - dnl Remove this code block if the library supports pkg-config. |
57 |
| - dnl --with-%EXTNAME% -> add include path |
58 |
| - dnl PHP_ADD_INCLUDE([$%EXTNAMECAPS%_DIR/include]) |
59 |
| - |
60 |
| - dnl Remove this code block if the library supports pkg-config. |
61 |
| - dnl --with-%EXTNAME% -> check for lib and symbol presence |
62 |
| - dnl LIBNAME=%EXTNAMECAPS% # you may want to change this |
63 |
| - dnl LIBSYMBOL=%EXTNAMECAPS% # you most likely want to change this |
64 |
| - |
| 37 | + dnl Add library compilation and linker flags to extension. |
| 38 | + dnl PHP_EVAL_INCLINE([$LIBFOO_CFLAGS]) |
| 39 | + dnl PHP_EVAL_LIBLINE([$LIBFOO_LIBS], [%EXTNAMECAPS%_SHARED_LIBADD]) |
| 40 | + dnl |
| 41 | + dnl Check for library and symbol presence. |
| 42 | + dnl LIBNAME=%EXTNAME% # you may want to change this |
| 43 | + dnl LIBSYMBOL=%EXTNAME% # you most likely want to change this |
| 44 | + dnl |
65 | 45 | dnl If you need to check for a particular library function (e.g. a conditional
|
66 | 46 | dnl or version-dependent feature) and you are using pkg-config:
|
67 | 47 | dnl PHP_CHECK_LIBRARY([$LIBNAME], [$LIBSYMBOL],
|
68 |
| - dnl [AC_DEFINE([HAVE_%EXTNAMECAPS%_FEATURE], [1], [ ])], |
| 48 | + dnl [AC_DEFINE([HAVE_%EXTNAMECAPS%_FEATURE], [1], |
| 49 | + dnl [Define to 1 if %EXTNAME% has the 'FEATURE'.])], |
69 | 50 | dnl [AC_MSG_ERROR([FEATURE not supported by your %EXTNAME% library.])],
|
70 | 51 | dnl [$LIBFOO_LIBS])
|
| 52 | + dnl |
71 | 53 |
|
| 54 | + dnl |
| 55 | + dnl Or use and adjust this code block if extension depends on external library |
| 56 | + dnl package, which does not support pkg-config. |
| 57 | + dnl |
| 58 | + dnl Path to library package can be given as parameter (--with-%EXTNAME%=<DIR>) |
| 59 | + dnl SEARCH_PATH="/usr/local /usr" # you might want to change this |
| 60 | + dnl SEARCH_FOR="/include/%EXTNAME%.h" # you most likely want to change this |
| 61 | + dnl AS_IF([test -r $PHP_%EXTNAMECAPS%/$SEARCH_FOR], |
| 62 | + dnl [%EXTNAMECAPS%_DIR=$PHP_%EXTNAMECAPS%], |
| 63 | + dnl [ |
| 64 | + dnl for i in $SEARCH_PATH; do |
| 65 | + dnl AS_IF([test -r $i/$SEARCH_FOR], |
| 66 | + dnl [%EXTNAMECAPS%_DIR=$i; break;]) |
| 67 | + dnl done |
| 68 | + dnl ]) |
| 69 | + dnl |
| 70 | + dnl AC_MSG_CHECKING([for %EXTNAME% library package]) |
| 71 | + dnl AS_VAR_IF([%EXTNAMECAPS%_DIR],, [ |
| 72 | + dnl AC_MSG_RESULT([not found]) |
| 73 | + dnl AC_MSG_ERROR([Please reinstall the %EXTNAME% library package]) |
| 74 | + dnl ], [AC_MSG_RESULT([found in $%EXTNAMECAPS%_DIR])]) |
| 75 | + dnl |
| 76 | + dnl Add include flag where library package headers are located on the system. |
| 77 | + dnl PHP_ADD_INCLUDE([$%EXTNAMECAPS%_DIR/include]) |
| 78 | + dnl |
| 79 | + dnl Check for library and symbol presence. |
| 80 | + dnl LIBNAME=%EXTNAME% # you may want to change this |
| 81 | + dnl LIBSYMBOL=%EXTNAME% # you most likely want to change this |
| 82 | + dnl |
72 | 83 | dnl If you need to check for a particular library function (e.g. a conditional
|
73 | 84 | dnl or version-dependent feature) and you are not using pkg-config:
|
74 |
| - dnl PHP_CHECK_LIBRARY([$LIBNAME], [$LIBSYMBOL], |
75 |
| - dnl [PHP_ADD_LIBRARY_WITH_PATH([$LIBNAME], |
76 |
| - dnl [$%EXTNAMECAPS%_DIR/$PHP_LIBDIR], |
77 |
| - dnl [%EXTNAMECAPS%_SHARED_LIBADD]) |
78 |
| - dnl AC_DEFINE([HAVE_%EXTNAMECAPS%_FEATURE], [1], [ ]) |
| 85 | + dnl PHP_CHECK_LIBRARY([$LIBNAME], [$LIBSYMBOL], [ |
| 86 | + dnl PHP_ADD_LIBRARY_WITH_PATH([$LIBNAME], |
| 87 | + dnl [$%EXTNAMECAPS%_DIR/$PHP_LIBDIR], |
| 88 | + dnl [%EXTNAMECAPS%_SHARED_LIBADD]) |
| 89 | + dnl AC_DEFINE([HAVE_%EXTNAMECAPS%_FEATURE], [1], |
| 90 | + dnl [Define to 1 if %EXTNAME% has the 'FEATURE'.]) |
79 | 91 | dnl ],
|
80 | 92 | dnl [AC_MSG_ERROR([FEATURE not supported by your %EXTNAME% library.])],
|
81 | 93 | dnl [-L$%EXTNAMECAPS%_DIR/$PHP_LIBDIR -lm])
|
82 | 94 | dnl
|
| 95 | + |
| 96 | + dnl Add linked libraries flags for shared extension to the generated Makefile. |
83 | 97 | dnl PHP_SUBST([%EXTNAMECAPS%_SHARED_LIBADD])
|
84 | 98 |
|
85 |
| - dnl In case of no dependencies |
86 |
| - AC_DEFINE(HAVE_%EXTNAMECAPS%, 1, [ Have %EXTNAME% support ]) |
| 99 | + dnl Define a preprocessor macro to indicate that this PHP extension can |
| 100 | + dnl be dynamically loaded as a shared module or is statically built into PHP. |
| 101 | + AC_DEFINE([HAVE_%EXTNAMECAPS%], [1], |
| 102 | + [Define to 1 if PHP extension '%EXTNAME%' is available.]) |
87 | 103 |
|
| 104 | + dnl Configure extension sources and compilation flags. |
88 | 105 | PHP_NEW_EXTENSION([%EXTNAME%],
|
89 | 106 | [%EXTNAME%.c],
|
90 | 107 | [$ext_shared],,
|
91 | 108 | [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
|
92 |
| -fi |
| 109 | +]) |
0 commit comments