@@ -5,20 +5,23 @@ system.
55
66## Index
77
8- * [ 1. Directory structure] ( #1-directory-structure )
9- * [ 2. Build system diagram] ( #2-build-system-diagram )
10- * [ 3. Build requirements] ( #3-build-requirements )
11- * [ 4. The configure command-line options] ( #4-the-configure-command-line-options )
12- * [ 5. Determining platform] ( #5-determining-platform )
13- * [ 6. Common checks] ( #6-common-checks )
14- * [ 6.1. Testing if program works] ( #61-testing-if-program-works )
15- * [ 6.1.1. AC\_ COMPILE\_ IFELSE] ( #611-ac_compile_ifelse )
16- * [ 6.1.2. AC\_ LINK\_ IFELSE] ( #612-ac_link_ifelse )
17- * [ 6.1.3. AC\_ RUN\_ IFELSE] ( #613-ac_run_ifelse )
18- * [ 6.2. Functions] ( #62-functions )
19- * [ 7. GNU Autoconf Archive] ( #7-gnu-autoconf-archive )
20- * [ 8. Parser and lexer files] ( #8-parser-and-lexer-files )
21- * [ 9. See more] ( #9-see-more )
8+ * [ 1. Introduction] ( #1-introduction )
9+ * [ 2. Directory structure] ( #2-directory-structure )
10+ * [ 3. Build system diagram] ( #3-build-system-diagram )
11+ * [ 4. Build requirements] ( #4-build-requirements )
12+ * [ 5. The configure command-line options] ( #5-the-configure-command-line-options )
13+ * [ 6. Determining platform] ( #6-determining-platform )
14+ * [ 7. Common checks] ( #7-common-checks )
15+ * [ 7.1. Testing if program works] ( #71-testing-if-program-works )
16+ * [ 7.1.1. AC\_ COMPILE\_ IFELSE] ( #711-ac_compile_ifelse )
17+ * [ 7.1.2. AC\_ LINK\_ IFELSE] ( #712-ac_link_ifelse )
18+ * [ 7.1.3. AC\_ RUN\_ IFELSE] ( #713-ac_run_ifelse )
19+ * [ 7.2. Functions] ( #72-functions )
20+ * [ 8. GNU Autoconf Archive] ( #8-gnu-autoconf-archive )
21+ * [ 9. Parser and lexer files] ( #9-parser-and-lexer-files )
22+ * [ 10. See more] ( #10-see-more )
23+
24+ ## 1. Introduction
2225
2326\* nix build system (Linux, macOS, FreeBSD, OpenBSD, Solaris, Haiku, etc.) in PHP
2427uses [ Autoconf] ( https://www.gnu.org/software/autoconf/ ) to build a ` configure `
@@ -74,7 +77,7 @@ installation dependencies. Autotools is a veteran build system present since
7477early C/C++ days. It is used for most Linux ecosystem out there and it might
7578cause issues for C developers today.
7679
77- ## 1 . Directory structure
80+ ## 2 . Directory structure
7881
7982PHP build system is a collection of various files across the php-src repository:
8083
@@ -126,11 +129,11 @@ PHP build system is a collection of various files across the php-src repository:
126129 └─ configure.ac # Autoconf main input file for creating configure script
127130` ` `
128131
129- # # 2 . Build system diagram
132+ # # 3 . Build system diagram
130133
131134! [PHP * nix build system using Autotools](/docs/images/autotools.svg)
132135
133- # # 3 . Build requirements
136+ # # 4 . Build requirements
134137
135138Before you can build PHP on Linux and other Unix-like systems, you must first
136139install certain third-party requirements. It' s important to note that the names
@@ -156,7 +159,7 @@ Additionally required when building from Git repository source code:
156159* bison
157160* re2c
158161
159- ## 4 . The configure command-line options
162+ ## 5 . The configure command-line options
160163
161164Configuration can be passed on the command line at the configuration phase:
162165
@@ -194,7 +197,7 @@ Some common arguments can be passed to command-line options:
194197* Some options accept multiple arguments separated by comma (`,`). For example,
195198 passing the library location and similar: `--with-EXT=shared,/usr`
196199
197- ## 5 . Determining platform
200+ ## 6 . Determining platform
198201
199202With Autotools there are several shell variables that help determine the
200203platform characteristics such as CPU, operating system and vendor name. When
@@ -214,9 +217,9 @@ AS_CASE([$host_alias], [*freebsd*|*openbsd*],
214217 [AC_MSG_NOTICE([Action that is run only on FreeBSD and OpenBSD systems.])])
215218```
216219
217- ## 6 . Common checks
220+ ## 7 . Common checks
218221
219- ### 6 .1. Testing if program works
222+ ### 7 .1. Testing if program works
220223
221224There are 3 main Autoconf macros that check if certain test code is successful.
222225
@@ -225,14 +228,15 @@ Let's check a simple C program:
225228` ` ` c
226229# include <stdio.h>
227230
228- int main(void) {
231+ int main(void)
232+ {
229233 printf(" Hello World" );
230234
231235 return 0;
232236}
233237` ` `
234238
235- # ### 6 .1.1. AC_COMPILE_IFELSE
239+ # ### 7 .1.1. AC_COMPILE_IFELSE
236240
237241` ` ` m4
238242AC_COMPILE_IFELSE([AC_LANG_PROGRAM([# include <stdio.h>],
@@ -241,12 +245,13 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],
241245 [php_cv_func_printf_works= no])
242246` ` `
243247
244- The ` AC_LANG_PROGRAM` macro will expand this into:
248+ The ` AC_LANG_PROGRAM` macro will expand this into something like this :
245249
246250` ` ` c
247251# include <stdio.h>
248252
249- int main(void) {
253+ int main(void)
254+ {
250255 printf(" Hello World" )
251256 ;
252257 return 0;
@@ -259,7 +264,7 @@ The `AC_COMPILE_IFELSE` will run the compilation step, for example:
259264gcc -o out -c hello_world.c
260265` ` `
261266
262- # ### 6 .1.2. AC_LINK_IFELSE
267+ # ### 7 .1.2. AC_LINK_IFELSE
263268
264269` ` ` m4
265270AC_LINK_IFELSE([AC_LANG_PROGRAM([# include <stdio.h>],
@@ -274,7 +279,7 @@ This will run compilation and linking:
274279gcc -o out hello_world.c
275280` ` `
276281
277- # ### 6 .1.3. AC_RUN_IFELSE
282+ # ### 7 .1.3. AC_RUN_IFELSE
278283
279284This will compile, link and also run the program to check if the return code is
2802850.
@@ -299,7 +304,7 @@ gcc -o out hello_world.c
299304./out
300305` ` `
301306
302- # ## 6 .2. Functions
307+ # ## 7 .2. Functions
303308
304309Testing if function exists within the given header.
305310
@@ -331,7 +336,7 @@ sees the function. They can be used like this:
331336# endif
332337` ` `
333338
334- # # 7 . GNU Autoconf Archive
339+ # # 8 . GNU Autoconf Archive
335340
336341To reuse the code there is a community collection of Autoconf macros available
337342at [autoconf-archive](https://github.com/autoconf-archive/autoconf-archive).
@@ -358,13 +363,14 @@ AC_CONFIG_MACRO_DIR([path/to/m4/dir])
358363
359364However, the ` aclocal` from Automake is needed for this to work.
360365
361- # # 8 . Parser and lexer files
366+ # # 9 . Parser and lexer files
362367
363368Parser and lexer files are generated upon the build step (` make` ) with ` bison`
364369and ` re2c` tools based on the targets in ` Makefile.frag` files.
365370
366371There is also a helper shell script available that generates these files when
367- developing or releasing PHP source code, otherwise they.
372+ developing or releasing PHP source code, otherwise they are generated during the
373+ build phase upon the ` make` invocation.
368374
369375` ` ` sh
370376./scripts/dev/genfiles
@@ -381,6 +387,12 @@ Autotools-based PHP build system files related to `bison` and `re2c`:
381387 └─ Makefile.frag # Makefile fragment
382388 └─ pdo/
383389 └─ Makefile.frag # Makefile fragment
390+ └─ pdo_mysql/
391+ └─ Makefile.frag # Makefile fragment
392+ └─ pdo_pgsql/
393+ └─ Makefile.frag # Makefile fragment
394+ └─ pdo_sqlite/
395+ └─ Makefile.frag # Makefile fragment
384396 └─ phar/
385397 └─ Makefile.frag # Makefile fragment
386398 └─ standard/
@@ -396,7 +408,7 @@ Autotools-based PHP build system files related to `bison` and `re2c`:
396408 └─ configure.ac # Minimum re2c and bison versions settings
397409` ` `
398410
399- # # 9 . See more
411+ # # 10 . See more
400412
401413Useful resources to learn more about Autoconf and Autotools in general:
402414
0 commit comments