Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the job of autogen.sh when building a c++ package on Linux [duplicate]

Tags:

I saw a common pattern when installing a c/c++ package from source on Linux (Ubuntu 16.04):

  1. ./autogen.sh
  2. ./configure
  3. make
  4. make install

I understand make and make install, and I guess configure creates a Makefile based on user preferences, but I don't see why autogen.sh is necessary.

Does anyone know what it is there for?

like image 301
Elad Weiss Avatar asked Apr 26 '18 13:04

Elad Weiss


People also ask

What is a configure AC file?

The configure.ac file is used to create the ./configure script. It consists of a series of macros which are processed and expanded by autoconf . These macros can check for packages and libraries, handle --enable and --with switches, and generate various files.

What is Autotools configure?

Autotools configurationThis file is used by autoconf to create the configure shell script that users run before building. The file must contain, at the very least, the AC_INIT and AC_OUTPUT M4 macros.

How do I run a Makefile in Linux?

Makefile.am files are compiled to Makefiles using automake. in the directory, which should create the configure script (you will need to have the Autotools suite installed to run this). After that, you should have a configure script that you can run.

What does configure do in Linux?

A configuration file, also known as a config file, is a local file that controls the operations of a program, utility or process. Linux configuration files contain the settings and instructions for different systems, utilities, applications and processes.


2 Answers

The steps:

  1. The autogen.sh script generates the configure script (from configure.ac, using autoconf) and any files it needs (like creating Makefile.in from Makefile.am using automake). This requires autotools to be installed on your system, and it must be run when checking out the project from source control (if configure isn’t checked in). People who download source tarballs can usually skip this step, because output of this step is included in source tarballs.

    Note This is usually equivalent to autoreconf --install. If there is not autogen.sh file, then just run autoreconf --install instead. If you have inherited a project with an autogen.sh, consider deleting it if you can use autoreconf --install.

  2. The configure script generates Makefile and other files needed to build. Typically Makefile.in is used as a template to generate Makefile (and config.h.in to generate config.h). This process happens using only standard tools installed on your system, like sed and awk, and doesn't require autotools to be installed.

  3. The make command builds the software.

  4. The make install command installs it.

These are broken into different steps because they are often run at different times. The autogen.sh step is traditionally run by people who are developing the software, since they are expected to install autoconf on their systems and they make changes to configure.ac. End-users are not expected to have autotools installed.

These expectations have been changed a bit now that end-users are more likely to check a project out of source control instead of downloading source releases.

like image 134
Dietrich Epp Avatar answered Oct 16 '22 04:10

Dietrich Epp


This applies only to programs / libraries, which are built using the autotools build chain. It generates the files, which are configured by the configure script. The configure script then populates .in files and generates Makefiles from Makefile.am templates. Which can finally be used to compile, link and install the program / library.

It's becoming slowly obsolete with the move to multi platform packages. CMake and more modern tool chains are state of the art.

like image 33
Kaveh Vahedipour Avatar answered Oct 16 '22 05:10

Kaveh Vahedipour