xref: /php-src/ext/skeleton/config.m4.in (revision dcdcb3cb)
1dnl Autotools config.m4 for PHP extension %EXTNAME%
2
3dnl Comments in this file start with the string 'dnl' (discard to next line).
4dnl Remove where necessary.
5
6dnl If extension references and depends on an external library package, use
7dnl the '--with-%EXTNAME%' configure option:
8dnl PHP_ARG_WITH([%EXTNAME%],
9dnl   [for %EXTNAME% support],
10dnl   [AS_HELP_STRING([--with-%EXTNAME%],
11dnl     [Include %EXTNAME% support])])
12
13dnl Otherwise use the '--enable-%EXTNAME%' configure option:
14PHP_ARG_ENABLE([%EXTNAME%],
15  [whether to enable %EXTNAME% support],
16  [AS_HELP_STRING([--enable-%EXTNAME%],
17    [Enable %EXTNAME% support])],
18  [no])
19
20AS_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
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.
29  dnl PKG_CHECK_MODULES([LIBFOO], [foo])
30  dnl
31  dnl Or if you need to check for a particular library version with pkg-config,
32  dnl you can use comparison operators. For example:
33  dnl PKG_CHECK_MODULES([LIBFOO], [foo >= 1.2.3])
34  dnl PKG_CHECK_MODULES([LIBFOO], [foo < 3.4])
35  dnl PKG_CHECK_MODULES([LIBFOO], [foo = 1.2.3])
36  dnl
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
45  dnl If you need to check for a particular library function (e.g. a conditional
46  dnl or version-dependent feature) and you are using pkg-config:
47  dnl PHP_CHECK_LIBRARY([$LIBNAME], [$LIBSYMBOL],
48  dnl   [AC_DEFINE([HAVE_%EXTNAMECAPS%_FEATURE], [1],
49  dnl     [Define to 1 if %EXTNAME% has the 'FEATURE'.])],
50  dnl   [AC_MSG_FAILURE([FEATURE not supported by your %EXTNAME% library.])],
51  dnl   [$LIBFOO_LIBS])
52  dnl
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
83  dnl If you need to check for a particular library function (e.g. a conditional
84  dnl or version-dependent feature) and you are not using pkg-config:
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'.])
91  dnl   ],
92  dnl   [AC_MSG_FAILURE([FEATURE not supported by your %EXTNAME% library.])],
93  dnl   [-L$%EXTNAMECAPS%_DIR/$PHP_LIBDIR -lm])
94  dnl
95
96  dnl Add linked libraries flags for shared extension to the generated Makefile.
97  dnl PHP_SUBST([%EXTNAMECAPS%_SHARED_LIBADD])
98
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 the PHP extension '%EXTNAME%' is available.])
103
104  dnl Configure extension sources and compilation flags.
105  PHP_NEW_EXTENSION([%EXTNAME%],
106    [%EXTNAME%.c],
107    [$ext_shared],,
108    [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
109])
110