How To Handle Two Versions of autoconf?
Have two versions of autoconf in your system? And you require both frequently? Learn how to handle the situation.
Although I mentioned Autoconf exclusively, but the same steps can be followed for any other program too. For example if you want to manage multiple versions of
make
,vim
, etc.
What is autoconf?
GNU Autoconf is a tool for producing configure scripts for building, installing and packaging software on computer systems where a Bourne shell is available. Autoconf is agnostic about the programming languages used, but it is often used for projects using C, C++, Fortran, Fortran 77, Erlang or Objective-C.
Wikipedia contributors. (2019, June 22). Autoconf. In Wikipedia, The Free Encyclopedia. Retrieved 19:20, June 26, 2019, from https://en.wikipedia.org/w/index.php?title=Autoconf&oldid=903003352
Hello Readers,
For my GSoC project, I need to port some codes in Newlib. As other good projects, Newlib also uses Autoconf tools for producing “Makefile.in” and various other useful scripts.
Newlib can be cloned from its git repository.
git clone git://sourceware.org/git/newlib-cygwin.git
The situation is, inside its source tree, newlib-cygwin/
uses autoconf tools version 2.64.
Whereas newlib-cygwin/newlib/libc
uses autoconf tools version 2.69
.
As I mostly work on terminal, when I run autoconf
command, it calls the 2.69 version.
Linux Environment Variable “$PATH”
Ever wondered whenever you run a program in a shell, how the shell is able to locate it and run it?
For example, the command, whoami
is present inside /usr/bin
directory. How your shell identifies to pick this particular program from its specific location?
Well, it doesn’t. To get clear, open your terminal and run the command $PATH
.
This the path variable of my Linux Environment: /usr/local/bin:/usr/local/sbin:/usr/bin:/opt/cuda/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/varodek/.gem/ruby/2.6.0/bin
.
What happens when you run "whoami”
command?
Linux doesn’t know what is whoami
and where it is located. It does everything with the help of its environment variable $PATH
.
The locations are written in priority order in $PATH
variable. When you run whoami
command:
- First it checks inside
usr/local/bin
directory for any program with that name. - Then it checks inside
usr/local/sbin
directory. - Then it checks inside
usr/bin
directory. Here it found a program namewhoami
, hence it runs it. - As the program is found, it will never check the other mentioned paths.
Since the autoconf version 2.69 is stored inside /usr/bin
, whenever I run it, it calls 2.69 version
.
Download “autoconf 2.64” source and build it
As I needed autoconf 2.64 , I downloaded it from here. I downloaded the autoconf-2.64.tar.gz file and placed it inside /opt/
directory.
Extract it.
Move inside extracted folder, and open the terminal in that directory. Run following commands:
./configure
make
You will find your compiled 2.64 version of autoconf tools inside bin
folder.
Now the path of your autoconf tools version 2.64 is /opt/autoconf-2.64/bin
.
Adding it to the “$PATH”
Now, we know how $PATH
works. So to run 2.64 version, we what we need to do is, we need to add the path to 2.64 version in the beginning of $PATH
variable. Hence when we will call autoconf
, it will first search inside /opt/autoconf-2.64/bin
directory, find the program and run it.
To do this, simply run:
export PATH=/opt/autoconf-2.64/bin:$PATH
Now run $PATH
, you can see the output will be like: /opt/autoreconf-2.64/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:........so on
.
Hence the path to 2.64 version tools is prefixed to $PATH
. Thus it gets the highest priority. Thus, when we will run any of the autoconf tools, it will run the 2.64 version.
(Note if you run export PATH=$PATH:/opt/autoconf-2.64/bin
instead of export PATH=/opt/autoconf-2.64/bin:$PATH
, the path will get suffixed, and it will get the least priority.).
Managing the versions.
As now we have figured out the way to run 2.64 version, whenever I need to run autoreconf -fvi
(2.64) version, I just run export PATH=/opt/autoconf-2.64/bin:$PATH
before it.
And when I need to run autoreconf -fvi
(2.69) version, I just run export PATH=/usr/bin:$PATH
before it.
Let’s get connected
Follow/ Connect with me anytime.
- LinkedIn- https://www.linkedin.com/in/varodek/
- GitHub- https://www.github.com/VARoDeK
- Facebook- https://www.facebook.com/vaibhav.gupta.1004837
- Twitter- https://twitter.com/varodek
Follow this Publication for more stories on this subject. If you find this blog helpful, please click the 👏 button and share to help others find it! Feel free to leave a comment 💬 below :).