转自我的博客:http://www.anger6.com/?p=621
在linux环境下通过源码安装程序,我们通常只需要下载源码包,解压,然后执行如下命令:
./configure
make
sudo make install.
之所以能这么easy,背后是autotools的功劳。
使用autotools的基本流程如下:通常我们只需要编写Makefile.am和configure.ac文件。
说了原理,我们再来看一个使用autotools的示例:
if [ -e autodemo ];
then
rm -rf autodemo
fi
mkdir -p autodemo
cat > hello.c <<\
“—————“
include
int main()
{
printf(“hello autotools.\r\n”);
return 0;
}
cat > Makefile.am <<\
“———“