File: build.xml

package info (click to toggle)
php-doc 20081024-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 57,752 kB
  • ctags: 3,858
  • sloc: xml: 686,554; php: 19,446; perl: 610; cpp: 500; makefile: 336; sh: 114; awk: 28
file content (205 lines) | stat: -rw-r--r-- 7,786 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?xml version="1.0" encoding="ISO-8859-1" ?>
 <!-- $Revision: 1.3 $ -->
 <sect2 xml:id="internals2.ze1.zendapi.build" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> 
  <title>PHP's Automatic Build System</title> 
  <para>
   PHP 4 features an automatic build system that's very flexible.
   All modules reside in a subdirectory of the
   <filename>ext</filename> directory. In addition to its own sources,
   each module consists of a config.m4 file, for extension configuration. (for example, see 
   <link xlink:href="http://www.gnu.org/software/m4/manual/m4.html">http://www.gnu.org/software/m4/manual/m4.html</link>)
  </para> 
  <para>
   All these stub files are generated automatically, along with
   <filename>.cvsignore</filename>, by a little shell script named
   <filename>ext_skel</filename> that resides in the
   <filename>ext</filename> directory. As argument it takes the name
   of the module that you want to create. The shell script then
   creates a directory of the same name, along with the appropriate
   stub files.
  </para> 
  <para>
   Step by step, the process looks like
   this:
   <screen>
<![CDATA[
:~/cvs/php4/ext:> ./ext_skel --extname=my_module
Creating directory my_module
Creating basic files: config.m4 .cvsignore my_module.c php_my_module.h CREDITS EXPERIMENTAL tests/001.phpt my_module.php [done].

To use your new extension, you will have to execute the following steps:

1.  $ cd ..
2.  $ vi ext/my_module/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-my_module
5.  $ make
6.  $ ./php -f ext/my_module/my_module.php
7.  $ vi ext/my_module/my_module.c
8.  $ make

Repeat steps 3-6 until you are satisfied with ext/my_module/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.
]]>
   </screen>
   This instruction creates the
   aforementioned files. To include the new module in the automatic
   configuration and build process, you have to run
   <filename>buildconf</filename>, which regenerates the
   <filename>configure</filename> script by searching through the
   <filename>ext</filename> directory and including all found
   <filename>config.m4</filename> files.
  </para> 
  <para>
   The default <filename>config.m4</filename> shown in 
   <xref linkend="internals2.ze1.zendapi.example.config.m4"/> is a bit more complex:
  </para> 
  <example xml:id="internals2.ze1.zendapi.example.config.m4"> 
   <title>The default <filename>config.m4</filename>.</title> 
   <programlisting role="autoconf">
<![CDATA[
dnl $Id: build.xml,v 1.3 2007/11/01 16:40:36 rquadling Exp $
dnl config.m4 for extension my_module

dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.

dnl If your extension references something external, use with:

dnl PHP_ARG_WITH(my_module, for my_module support,
dnl Make sure that the comment is aligned:
dnl [  --with-my_module             Include my_module support])

dnl Otherwise use enable:

dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,
dnl Make sure that the comment is aligned:
dnl [  --enable-my_module           Enable my_module support])

if test "$PHP_MY_MODULE" != "no"; then
  dnl Write more examples of tests here...

  dnl # --with-my_module -> check with-path
  dnl SEARCH_PATH="/usr/local /usr"     # you might want to change this
  dnl SEARCH_FOR="/include/my_module.h"  # you most likely want to change this
  dnl if test -r $PHP_MY_MODULE/; then # path given as parameter
  dnl   MY_MODULE_DIR=$PHP_MY_MODULE
  dnl else # search default path list
  dnl   AC_MSG_CHECKING([for my_module files in default path])
  dnl   for i in $SEARCH_PATH ; do
  dnl     if test -r $i/$SEARCH_FOR; then
  dnl       MY_MODULE_DIR=$i
  dnl       AC_MSG_RESULT(found in $i)
  dnl     fi
  dnl   done
  dnl fi
  dnl
  dnl if test -z "$MY_MODULE_DIR"; then
  dnl   AC_MSG_RESULT([not found])
  dnl   AC_MSG_ERROR([Please reinstall the my_module distribution])
  dnl fi

  dnl # --with-my_module -> add include path
  dnl PHP_ADD_INCLUDE($MY_MODULE_DIR/include)

  dnl # --with-my_module -> chech for lib and symbol presence
  dnl LIBNAME=my_module # you may want to change this
  dnl LIBSYMBOL=my_module # you most likely want to change this 

  dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
  dnl [
  dnl   PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $MY_MODULE_DIR/lib, MY_MODULE_SHARED_LIBADD)
  dnl   AC_DEFINE(HAVE_MY_MODULELIB,1,[ ])
  dnl ],[
  dnl   AC_MSG_ERROR([wrong my_module lib version or lib not found])
  dnl ],[
  dnl   -L$MY_MODULE_DIR/lib -lm -ldl
  dnl ])
  dnl
  dnl PHP_SUBST(MY_MODULE_SHARED_LIBADD)

  PHP_NEW_EXTENSION(my_module, my_module.c, $ext_shared)
fi
]]>
   </programlisting> 
  </example> 
  <para>
   If you're unfamiliar with M4 files (now is certainly a good
   time to get familiar), this might be a bit confusing at first; but
   it's actually quite easy.
  </para>
  <para>
   <emphasis>Note:</emphasis> Everything prefixed with
   <literal>dnl</literal> is treated as a comment and is not
   parsed.
  </para> 
  <para>
   The <filename>config.m4</filename> file is responsible for
   parsing the command-line options passed to
   <filename>configure</filename> at configuration time. This means
   that it has to check for required external files and do similar
   configuration and setup tasks.
  </para> 
  <para>
   The default file creates two configuration directives in the
   <filename>configure</filename> script:
   <literal>--with-my_module</literal> and
   <literal>--enable-my_module</literal>. Use the first option when
   referring external files (such as the
   <literal>--with-apache</literal> directive that refers to the
   Apache directory). Use the second option when the user simply has
   to decide whether to enable your extension. Regardless of which
   option you use, you should uncomment the other, unnecessary one;
   that is, if you're using <literal>--enable-my_module</literal>, you
   should remove support for <literal>--with-my_module</literal>, and
   vice versa.
  </para> 
  <para>
   By default, the <filename>config.m4</filename> file created by
   <filename>ext_skel</filename> accepts both directives and
   automatically enables your extension. Enabling the extension is
   done by using the <literal>PHP_EXTENSION</literal> macro. To change
   the default behavior to include your module into the PHP binary
   when desired by the user (by explicitly specifying
   <literal>--enable-my_module</literal> or
   <literal>--with-my_module</literal>), change the test for
   <literal>$PHP_MY_MODULE</literal> to <literal>== "yes"</literal>:
   <programlisting>if test "$PHP_MY_MODULE" == "yes"; then dnl
    Action.. PHP_EXTENSION(my_module, $ext_shared)
    fi</programlisting>This would require you to use
   <literal>--enable-my_module</literal> each time when reconfiguring
   and recompiling PHP.
  </para>
  <para>
   <emphasis>Note:</emphasis> Be sure to run
   <filename>buildconf</filename> every time you change
   <filename>config.m4</filename>!
  </para> 
  <para>
   We'll go into more details on the M4 macros available to your
   configuration scripts later in this chapter. For now, we'll simply
   use the default files. 
  </para> 
 </sect2>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->