Logrotate is an important tool for log management in Linux, which can automatically truncate (or round) logs, compress, and delete old log files. In the distribution of the desktop or server Linux system This tool is generally easier to install, or default has been brought, but embedded systems generally need to build their own through the source code.
This article explains how to construct logrotate by cross-tool chain.
Since Logrotate relies on the popt library, it is necessary to build the Popt library to build logrotate and then build popt with the Logrotate library.
First, build popt libraryDownload the latest Master branch source package from Https://github.com/devzero2000/POPT Popt-master.zip
1. Extract Popt-master.zip to/home/warmbobo/tools/popt-master/directory, enter this source directory
2. Generate the Configure file
#./autogen.sh
3. Configuring the Cross-compilation environment
1) Create the installation directory
# mkdir Install
2) Add Cross tool chain environment variables
# Export path= $PATH:/home/warmbobo/crosstool/arm-unknown-linux-gnueabi/bin/
3) Configuring the compilation Environment
#./configure--prefix=/home/warmbobo/tools/popt-master/install/--host=arm-linux
4. Build
1) Make
2) make install
The build will generate "include Lib share" three directories in/home/warmbobo/tools/popt-master/install/, where the Lib directory has logrotate compile and run the required library files, The Include directory has the header files we need to compile logrotate.
ii. Construction of LogrotateDownload the latest source code Logrotate-master.zip from Https://github.com/logrotate/logrotate.
1. Unzip and enter the source path/home/warmbobo/tools/logrotate-master/
2. Generate the Configure file
#./autogen.sh
3. Configuring the Cross-compilation environment
1) Add Cross tool chain environment variables
# Export path= $PATH:/home/warmbobo/crosstool/arm-unknown-linux-gnueabi/bin/
2) Configuring the compilation Environment
#./configure--host=arm-linux--prefix=/home/warmbobo/tools/logrotate-master/install/ldflags=-l/home/warmbobo/ Tools/popt-master/install/lib Cppflags=-i/home/warmbobo/tools/popt-master/install/include
Where ldflags specifies logrotate to compile the dependent library lpopt path, whereas cppflags specifies logrotate to compile the dependent header file Popt.h path.
4. Build
1) Make
2) make install
The Sbin/logrotate file is generated in the/home/warmbobo/tools/logrotate-master/install/directory when it is built.
Three, single board operationCopy the compiled generated logrotate file to the/sbin directory of the board, and copy all lib/* files generated by the popt compilation to the single Board/lib/directory:
Then you can run the logrotate command.