MYSQL 编译configure向cmake过渡指南
网址:http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
从mysql5.5起,mysql源码安装开始使用cmake了。下面是介绍configure选项如何映射到CMake的等值参数。
1. 命令语法:
configure command | cmake command |
./configure | cmake . |
./configure –help | cmake . -LH or ccmake . |
重新编译时,需要清除旧的对象文件和缓存信息
# make clean
# rm -f CMakeCache.txt
2.安装选项
parameter | configure option | cmake option |
Install base dir | –prefix=/usr/local/mysql | -DCMAKE_INSTALL_PREFIX=/usr/local/mysql |
Mysqld dir | –libexecdir=/usr/local/mysql/sbin | -DINSTALL_SBINDIR=sbin |
Data dir | –datadir=/mydata | -DMYSQL_DATADIR=/mydata |
Config dir | –sysconfdir=/etc/mysql | -DSYSCONFDIR=/etc/mysql |
Plugin dir | –with-plugindir=/usr/local/mysql/lib/mysql/plugin | -DINSTALL_PLUGINDIR=lib/mysql/plugin |
Manpage dir | –mandir=/usr/local/mysql/share/man | -DINSTALL_MANDIR=share/man |
Shared-data dir | –sharedstaedir=/usr/local/mysql/share/mysql | -DINSTALL_SHAREDIR=share |
Library install dir | –libdir=/usr/local/mysql/lib/mysql | -DINSTALL_LIBDIR=lib/mysql |
Header install dir | –includedir=/usr/local/mysql/include/mysql | -DINSTALL_INCLUDEDIR=include/mysql |
Info doc dir | –infodir=/usr/local/mysql/share/info | -DINSTALL_INFODIR=share/info |
CMAKE_INSTALL_PREFIX值是安装的基本目录,其他cmake选项值是不包括前缀,是相对路径名,绝对路径包括CMAKE_INSTALL_PREFIX路径。如-DINSTALL_SBINDIR=sbin的绝对路径是/usr/local/mysql/sbin
3.存储引擎选项
mysql存储引擎是插件式的,因此插件控制选项可以指定那个存储引擎安装。
configure编译插件选项–with-plugins=csv,myisam,myisammrg,heap,innobase,
archive,blackhole在cmake中没有直接对应的相同选项。对于csv,myisam,myisammrg,heap在cmake中是不需要明确指定存储引擎的名称,因为它们是强制性安装。
可以使用以下选择来安装innodb,archive,blackhole存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
(1可以使用on代替)
如果既不是-DWITH_<ENGINE>_STORAGE_ENGINE 也不是 -DWITHOUT_<ENGINE>_STORAGE_ENGINE来指定存储引擎,该存储引擎将安装成共享模块式的。如果不是共享模块式的将排除在外。共享模块安装时必须使用INSTALL PLUGIN语句或–plugin-load才可以使用。
4.lib库选项
parameter | configure option | cmake option |
readline library | –with-readline | -DWITH_READLINE=1 |
SSL library | –with-ssl=/usr | -DWITH_SSL=system |
zlib library | –with-zlib-dir/usr | -DWITH_ZLIB=system |
Libwrap library | –without-libwrap | -DWITH_LIBWRAP=0 |
有关插件的CMake的选项的其他信息,请查阅:
http://forge.mysql.com/wiki/MySQL_Internals_Support_for_Plug-Ins
5.其他选项
之前MySQL的编译选项大多数都支持。新旧版本之间的安装选项映射成大写字母,删除选项前面破折号,中间字符间的破折号替换成下划线。如:
–with-debug => WITH_DEBUG=1
–with-embedded-server => WITH_EMBEDDED_SERVER
Parameter |
configure Option |
CMake Option |
CMake Notes |
TCP/IP port number |
--with-tcp-port-=3306 |
-DMYSQL_TCP_PORT=3306 |
|
UNIX socket file |
--with-unix-socket-path=/tmp/mysqld.sock |
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock |
|
Enable LOCAL for LOAD DATA |
--enable-local-infile |
-DENABLED_LOCAL_INFILE=1 |
|
Extra charsets |
--with-extra-charsets=all |
-DEXTRA_CHARSETS=all |
default is "all" |
Default charset |
--with-charset=utf8 |
-DDEFAULT_CHARSET=utf8 |
|
Default collation |
--with-collation=utf8_general_ci |
-DDEFAULT_COLLATION=utf8_general_ci |
|
Build the server |
--with-server |
none |
|
Build the embedded server |
--with-embedded-server |
-DWITH_EMBEDDED_SERVER=1 |
|
libmysqld privilege control |
--with-embedded-privilege-control |
none |
always enabled? |
Install the documentation |
--without-docs |
none |
|
Big tables |
--with-big-tables, --without-big-tables |
none |
tables are big by default |
mysqld user |
--with-mysqld-user=mysql |
-DMYSQL_USER=mysql |
mysql is the default |
Debugging |
--without-debug |
-DWITH_DEBUG=0 |
default is debugging disabled |
GIS support |
--with-geometry |
none |
always enabled? |
Community features |
--enable-community-features |
none |
always enabled |
Profiling |
--disable-profiling |
-DENABLE_PROFILING=0 |
enabled by default |
pstack |
--without-pstack |
none |
pstack is removed |
Assembler string functions |
--enable-assembler |
none |
|
Build type |
--build=x86_64-pc-linux-gnu |
no equivalent |
unneeded? |
Cross-compile host |
--host=x86_64-pc-linux-gnu |
no equivalent |
unneeded? |
Client flag |
--with-client-ldflags=-lstdc++ |
none |
unneeded |
Client flag |
--enable-thread-safe-client |
none |
unneeded, clients are always thread safe |
Comment |
--with-comment='string' |
-DWITH_COMMENT='string' |
|
Shared/static binaries |
--enable-shared --enable-static |
none |
there is only DISABLE_SHARED |
Memory use |
--with-low-memory |
none |
unneeded |
6.调试配置过程
使用configure编译完将生成config.log和config.status文件。
使用cmake编译完在CMakeFiles目录下生成CMakeError.log 和CMakeOutput.log文件。
7.第三方接口工具
在之前的版本,第三方工具从MySQL顶层源目录中读取源configure.in文件来确定mysql版本。如:对5.5.7 – RC版本的AC_INIT线看起来像这样:
AC_INIT([MySQL Server], [5.5.7-rc], [], [mysql])
现在的版本可以直接读取版本文件。如:如果版本是5.5.8,文件看起来像这样的:
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=8
MYSQL_VERSION_EXTRA=
如果源码包不是GA版,MYSQL_VERSION_EXTRA的值将非空。如:对于一个发布RC版本是这样的:
MYSQL_VERSION_EXTRA=rc
构建5位数字的版本号,使用下面公式:
MYSQL_VERSION_MAJOR*10000 + MYSQL_VERSION_MINOR*100 + MYSQL_VERSION_PATCH