文章目录


一、构建POPT库

​1.1.安装依赖包​

apt-get install gcc make autoconf automake autopoint libtool-bin

​1.2.下载源码​

git clone https://github.com/devzero2000/POPT.git

​1.3.配置编译环境​

cd POPT
./autogen.sh #生成configure文件
mkdir install
./configure --prefix=/usr1/anqixiang/soft/POPT-master/install/

ubuntu源码编译logrotate_logrotate
make && make install

构建好后会在/usr1/anqixiang/soft/POPT-master/install/生成“include lib share” 三个目录,其中lib目录有logrotate编译和运行需要的库文件,include目录有编译logrotate需要的头文件。

二、编译logrotate

​2.1.下载源码包​

wget https://github.com/logrotate/logrotate/releases/download/3.16.0/logrotate-3.16.0.tar.gz

​2.2.源码编译​

tar xvf logrotate-3.16.0.tar.gz
cd logrotate-3.16.0
./autogen.sh
./configure --prefix=/usr/local/bin/logrotate/ LDFLAGS=-L/usr1/anqixiang/soft/POPT-master/install/lib CPPFLAGS=-I/usr1/anqixiang/soft/POPT-master/install/include

其中LDFLAGS指定logrotate编译依赖库lpopt路径;而CPPFLAGS指定logrotate编译依赖头文件popt.h路径。
ubuntu源码编译logrotate_编译环境_02
make && make install

三、使用logrotate

cp /usr/local/bin/logrotate/sbin/logrotate /usr/sbin/
logrotate --version
ubuntu源码编译logrotate_源码编译_03