Sunday, February 28, 2016

How to Compile the Latest Development Version of GNU Package - Findutils

In this post, I will discuss how to download and compile the latest development version of findutils GNU package. Findutils package consists of find, locate, updatedb, and xargs. More info and stable releases of this package can be found at http://www.gnu.org/software/findutils/. This post intends to help people contribute to free and open source packages and programs, as GNU/Linux and GPL have changed the world significantly, and we can be all part of the movement. Although I will only discuss the Findutils package here, most of other GNU packages can be obtained in the similar manner.

The instruction here will be based on Ubuntu 14.04 LTS 64bit version.
We need to install necessary packages first as usual:
$ sudo apt-get install -y autoconf automake git gettext m4 dejagnu autopoint bison texinfo

If you are trying to build the package on Mac OS X, you will need to install development tools first.
$ sudo xcode-select --install

Then you would want to install homebrew.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then, you will need to install the necessary packages with
$ brew install autoconf automake git gettext dejagnu bison texinfo

Finally, you will need to create a symlink of autopoint
$ sudo ln -s /usr/local/Cellar/gettext/0.19.7/bin/autopoint /usr/local/bin/autopoint

Now, you are ready to follow along for both Linux and Mac OS X.

We will download the latest development version using git
$ git clone git://git.sv.gnu.org/findutils

When complete, go to the findutils directory and run bootstrap
$ cd findutils && ./bootstrap

It will probably complain about gettext version.
autopoint: *** The AM_GNU_GETTEXT_VERSION declaration in your configure.ac
               file requires the infrastructure from gettext-0.19.3 but this version
               is older. Please upgrade to gettext-0.19.3 or newer.
autopoint: *** Stop.

To see what version of gettext is currently installed, we can run
$ gettext --version
I am getting 0.18.3 as of now. This is the latest version available from the Ubuntu repository. We can manually install the newer version by building the executable from the source.

Let's then download and build the latest gettext!
$ cd .. && wget https://ftp.gnu.org/gnu/gettext/gettext-latest.tar.gz

Unarchive the source files
$ tar xfz gettext-latest.tar.gz

Let's configure it!
$ mkdir gettext-0.19.7/build && cd gettext-0.19.7/build
$ ../configure

When complete, we can compile it
$ make -j 2
where the number 2 represents the desired # of cores to use when compiling.

By the way, if you intend to debug the source code, you may want to define a macro DEBUG
$ make -j 2 CFLAGS="-D DEBUG -g"
which sets the option -D DEBUG and -g to the compiler.

After some time, it should build successfully. We are now ready to install the latest get text on the system.
$ sudo make install

Finally, we should now have the latest version of gettext
$ gettext --version
which returns 0.19.7 as expected.

OK, let's go back to findutils and continue our process of bootstrapping
$ cd ../../findutils/ && ./bootstrap

The last step is to simply configure and compile!
$ mkdir build && cd build
$ ./configure
$ make -j 2

When complete, we can execute the new program and verify if it works
$ find/find --version
$ xargs/xargs --version
$ locate/locate --version

They all should say version 4.7.0-git as of today. The latest stable release findutils version is 4.6.0 as can be seen from http://ftp.gnu.org/pub/gnu/findutils/.

You could install it on the system if you want, but I would not recommend so, as it is not a stable release version yet.


No comments:

Post a Comment