[笔记]PHP阅读源码随笔(一)
几位同事大牛,做了一个开源文档项目 《PHP内核分析》 http://php-internal.com ,内容甚是精彩,也是几位大牛几年经验的总结。
因此,我也开始拜读。学习中。
第一步,准备环境。
在漫长的svn co出PHP 5.3 的源码后,准备buildconf。但是出现了如下的问题。
[[email protected]:/root/php/php-src-5.3/] $ ./buildconf buildconf: checking installation... buildconf: autoconf version 2.59 (ok) buildconf: Your version of autoconf likely contains buggy cache code. Running vcsclean for you. To avoid this, install autoconf-2.13. rebuilding aclocal.m4 rebuilding configure rebuilding acconfig.h rebuilding main/php_config.h.in autoheader: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot' autoheader: WARNING: and `config.h.top', to define templates for `config.h.in' autoheader: WARNING: is deprecated and discouraged. autoheader: autoheader: WARNING: Using the third argument of `AC_DEFINE' and autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without autoheader: WARNING: `acconfig.h': autoheader: autoheader: WARNING: AC_DEFINE([NEED_FUNC_MAIN], 1, autoheader: [Define if a function `main' is needed.]) autoheader: autoheader: WARNING: More sophisticated templates can also be produced, see the autoheader: WARNING: documentation. [[email protected]:/root/php/php-src-5.3/]
其中,问题是在于autoconf 貌似版本过高,因此,yum search了一下(CentOS这样就是方便啊啊啊啊啊啊!!!!——我也咆哮体一下)
[[email protected]:/root/php/php-src-5.3/] $ yum search autoconf Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Reducing CentOS-5 Testing to included packages only Finished ================= Matched: autoconf ========================== kdevelop.i386 : C++/C 的集成开发环境 autoconf.noarch : 用来自动配置源码的 GNU 工具。 autoconf213.noarch : 用来自动配置源码的 GNU 工具。 automake.noarch : 自动创建 Makefiles 的 GNU 工具。 libdhcp.i386 : A library for network interface configuration with DHCP libtool.i386 : GNU 的可移植库工具 libtool-ltdl.i386 : GNU Libtool 动态模块加载程序的运行时库函数 m4.i386 : GNU 宏程序处理器。 [[email protected]:/root/php/php-src-5.3/] $ yum install autoconf213 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Reducing CentOS-5 Testing to included packages only Finished Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package autoconf213.noarch 0:2.13-12.1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================== Package Arch Version Repository Size ============================================================== Installing: autoconf213 noarch 2.13-12.1 base 252 k Transaction Summary ============================================================== Install 1 Package(s) Upgrade 0 Package(s) Total download size: 252 k Is this ok [y/N]: y Downloading Packages: autoconf213-2.13-12.1.noarch.rpm | 252 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : autoconf213 1/1 Installed: autoconf213.noarch 0:2.13-12.1 Complete! [[email protected]:/root/php/php-src-5.3/] $
再次尝试buildconf
[[email protected]:/root/php/php-src-5.3/] $ ./buildconf buildconf: checking installation... buildconf: autoconf version 2.59 (ok) buildconf: Your version of autoconf likely contains buggy cache code. Running vcsclean for you. To avoid this, install autoconf-2.13. rebuilding aclocal.m4 rebuilding configure rebuilding acconfig.h rebuilding main/php_config.h.in autoheader: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot' autoheader: WARNING: and `config.h.top', to define templates for `config.h.in' autoheader: WARNING: is deprecated and discouraged. autoheader: autoheader: WARNING: Using the third argument of `AC_DEFINE' and autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without autoheader: WARNING: `acconfig.h': autoheader: autoheader: WARNING: AC_DEFINE([NEED_FUNC_MAIN], 1, autoheader: [Define if a function `main' is needed.]) autoheader: autoheader: WARNING: More sophisticated templates can also be produced, see the autoheader: WARNING: documentation. [[email protected]:/root/php/php-src-5.3/]
继续失败
查询原因,在php官方网站中(SVN Access部分 http://www.php.net/svn.php#buildconf_fail ),建议的autoconf、libtool和automake的组合是:
autoconf, automake and libtool information
There seem to be problems with libtool 1.4.2. It is suggested that you use libtool 1.4, along with autoconf 2.13 and automake 1.4. You should also ensure that autoconf, automake and libtool are installed in the same directory. libtool 1.5 will not work.
The following combinations are known to work:
* autoconf 2.13, automake 1.4 and libtool 1.4.3
* autoconf 2.13, automake 1.5 and libtool 1.4.3
* autoconf 2.63, automake 1.11 and libtool 2.2.6 (with many warnings)
If you have multiple versions of autoconf installed on your computer, as is common for many UNIXes, you can set the PHP_AUTOCONF and PHP_AUTOHEADER variables when running buildconf to indicate which versions it should use e.g.:
PHP_AUTOCONF=autoconf213 PHP_AUTOHEADER=autoheader213 ./buildconf
看来是我目前系统中的版本太高。需要降版本。——担心各种依赖 =。=
由于我是CentOS5.5的系统,一直勤快的使用yum update,因此,系统的软件包肯定是发行版中最新的。
故开始卸载:
[[email protected]:/root/php/php-src-5.3/] $ rpm -e autoconf-2.59-12 error: Failed dependencies: autoconf >= 2.58 is needed by (installed) automake-1.9.6-2.3.el5.noarch autoconf >= 2.50 is needed by (installed) libtool-1.5.22-7.el5_4.i386 autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 [[email protected]:/root/php/php-src-5.3/] $ rpm -e autoconf-2.59-12 automake libtool error: Failed dependencies: autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 [[email protected]:/root/php/php-src-5.3/] $ rpm -e autoconf automake libtool error: Failed dependencies: autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 [[email protected]:/root/php/php-src-5.3/] $ rpm -e autoconf automake libtool automake17 error: Failed dependencies: autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386 [[email protected]:/root/php/php-src-5.3/] $ rpm -e autoconf automake libtool automake17 php-devel libtool-libs [[email protected]:/root/php/php-src-5.3/]
libtool-libs 是对libtool包版本敏感的。卸载 libtool就必须修卸载libs包。故——干掉。
后期安装时,发现:
[[email protected]:/root/php/tools/] $ rpm -ivh *.rpm warning: automake-1.4p5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID db42a60e Preparing... ########################################### [100%] file /usr/lib/libltdl.so.3 from install of libtool-libs-1.4.3-5.i386 conflicts with file from package libtool-ltdl-1.5.22-7.el5_4.i386 [[email protected]:/root/php/tools/] $ rpm -aq | grep libtool-ltdl libtool-ltdl-1.5.22-7.el5_4 [[email protected]:/root/php/tools/] $ rpm -e libtool-ltdl error: Failed dependencies: libltdl.so.3 is needed by (installed) guile-1.8.0-8.20060831cvs.i386 libltdl.so.3 is needed by (installed) mysql-connector-odbc-3.51.26r1127-1.el5.i386 [[email protected]:/root/php/tools/] $ rpm -e --nodeps libtool-ltdl [[email protected]:/root/php/tools/]
终于,这个世界清静了。——这就是我为什么讨厌没有外网,没有Yum的原因。
下面找AutoTools相关的各种包。根据php官方的建议,找到这些古董版本的包:
[[email protected]:/root/php/tools/] $ ll 总计 1032 -rw-r--r-- 1 root root 229965 03-18 13:58 autoconf-2.13-5.noarch.rpm -rw-r--r-- 1 root root 309067 03-18 14:02 automake-1.4p5-4.noarch.rpm -rw-r--r-- 1 root root 477714 03-18 13:52 libtool-1.4.3-5.i386.rpm -rw-r--r-- 1 root root 19472 03-18 13:55 libtool-libs-1.4.3-5.i386.rpm [[email protected]:/root/php/tools/] $ rpm -ivh *.rpm warning: automake-1.4p5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID db42a60e Preparing... ########################################### [100%] 1:automake ########################################### [ 25%] 2:autoconf ########################################### [ 50%] 3:libtool-libs ########################################### [ 75%] 4:libtool ########################################### [100%] [[email protected]:/root/php/tools/]
淡定鸟。。。
继续编译php
[[email protected]:/root/php/php-src-5.3/] $ ./buildconf buildconf: checking installation... buildconf: autoconf version 2.13 (ok) [[email protected]:/root/php/php-src-5.3/] ./configure ... ... ... 此处省略1w字 ... ... ... checking if libtool supports shared libraries... yes checking whether to build shared libraries... no checking whether to build static libraries... yes creating libtool appending configuration tag "CXX" to libtool Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating main/php_config.h config.status: executing default commands [[email protected]:/root/php/php-src-5.3/]
…..埋坑儿