Adding libtool Support

Adding libtool Support

Libtool handles the different ways of linking against libraries on different platform, especially shared libraries (if possible). Therefore it should be used, whenever an external library is used or whenever a project should build and install libraries. As this simple project so far does non of these, libtool is not necessary here. The next step will add gettext, so libtool might be usefull, as gettext has libraries to link against. But gettext allows the developer to compile the necessary functions directly into the project. So for gettext libtool is not a must. Lateron wxWindows libraries are used and then libtool support does make sence. As adding libtool is a small step often required, it is done here. 

The drawback should be mentioned as well: the size of the compressed source tarball increases by about 150kB, the number of checks 'configure' performs is much larger (which takes time) and the compilation itself takes more time.

Adding libtool support is quite easy: just run libtoolize.
# libtoolize
Remember to add `AC_PROG_LIBTOOL' to `configure.ac'.
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
You should update your `aclocal.m4' by running aclocal.
The output gives an important hint: configure.ac needs a small change:

configure.ac

...
AM_INIT_AUTOMAKE
AC_PROG_RANLIB
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL

...
AC_LIBTOOL_DLOPEN was recommended to use by the libtool documentation, so it was added as well. The hint "run aclocal" does not work here: aclocal just prints some warnings but does not change aclocal.m4, even if --force was given. Instead adding acinclude.m4 helped:
# ln -s /usr/local/share/libtool/libltdl/acinclude.m4 acinclude.m4

Rebuilding the Project

Afterwards, a new 'configure' can be created. If all environment variables were correctly set during the creation of the current Makefile's (they should be correctly set now, too!), 'make' does the job. It will call all necessary auto tools, and run configure. It will not recompile, as the sources are not changed. To force a recompile, 'make clean' should be run first.
# gmake
cd . && aclocal19

...

 cd . && automake19 --gnu
cd . && autoconf259
/bin/sh ./config.status --recheck
running /bin/sh ./configure   --no-create --no-recursion
checking for a BSD-compatible install... /usr/bin/install -c

...

config.status: executing depfiles commands
cd . && autoheader259

...

The configue script itself now does a lot more tests. Some of th test results go into config.h: e
# cat config.h 
/* config.h.  Generated by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

...
To get libtool support directly from a cvs checkout, createFromCvs needs a small change:

createFromCvs.freebsd

#!/bin/sh
libtoolize
ln -s /usr/local/share/libtool/libltdl/acinclude.m4 acinclude.m4
${ACLOCAL}

...
On gentoo, acinclude.m4 has a different location:

createFromCvs.gentoo

#!/bin/sh
libtoolize
ln -s /usr/share/libtool/libltdl/acinclude.m4 acinclude.m4
aclocal

...
The result source code can be downloaded  here .

Next, the internationalization of a project is discussed.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值