Why is "autoreconf" not used often? - linux

I am newbie of Autotools. From my understanding, one would use the following basic steps to build software using Autotools:
autoreconf --install
./configure
make
However, I noticed that most open source software packages (on Linux) does not need the 1st step. Most of the time they just need step 2 and 3 to build. It seems that they already are packaged with a Makefile.in. I am wondering why? Do they manually code the Makefile.in, or does the software developer use autoreconf to generate the Makefile.in before creating the software package?

The software developer who creates the tarball (or who checks out the sources from a version control system) will usually invoke autoreconf from a script called bootstrap.sh or autogen.sh which may do other stuff. autoreconf might be invoked by Makefile as well (like when configure.ac has changed).
Most users will never need to run autoreconf, even those who are making some modifications to source (e.g. patches). Only those who need to make modifications to the package itself (making changes to configure.ac and/or Makefile.am) will need autoreconf.

Running autoreconf requires having the correct version of autotools installed already. This leads to a chicken-and-egg problem -- how do you get autotools installed in the first place? It also adds an extra dependency that most end-users don't really need.
As a result, most packagers run autoreconf before producing the source tarballs that they distribute. This means that if you download such a tarball, you can configure and build it without needing to install autotools first.

Related

Make - Make Install and Linux update

I am trying my hands new on Linux.
The following command is very useful:
sudo apt-get install <application>;
As it adds the application into the linux programs list and automatically upgrades it while running the update manager.
But I would like to get more knowledge on installing the programs from the .tar.gz archives as well.
So I do:
Extract the archive
./configure;
make;
make install;
I have two questions in this process:
1) I read in the forum that "make install" is not good if we are updating the binaries.
So should I just do "make" and the "install" ?
2) Second question is that is there a way to add the program installed in such manner to the Linux Software Update list so that I do not have to use the terminal for every new version that is released
Installing programs from tarballs:
You really do not want to install packages from .tar.gz when they are in the repositories. It is much harder to update or remove it manually than you could do with apt-get.
If you really have to compile the program yourself use checkinstall instead of make install. This creates a package you can install it via the package management and later remove using apt-get. This is much cleaner.
Also you may want to type
./configure && make && sudo checkinstall
instead of the commands you wrote. This way the program is only compiled if the configuration succeeded. The package is only built if the compilation succeeded. With ; instead of && all processes would be attempted no matter if its prerequisites are matched.
Graphical package managers
You can install your packages from GUI programs. Kubuntu uses for example uses muon for this, but the programs vary between distributions.
make install is "not good" if you want to be able to easily remove the files associated with a package as there is no log of the work it does and often no easy way to reverse the process. That has little to nothing to do with updating the software though (though updates can certainly run into related issues).
No, you can't add the manually compiled and installed software to your distributions list of packaged software (other than through something like checkinstall or creating a package yourself) since that's exactly what you were avoiding in the first place.
That all being said if the package exists for your distribution and you want to build it from source yourself you can often just build a more-or-less official version of the package from the distributions source package.

Workflow for compiling and installing software with Puppet

I need to manually compile and install FFMPEG as one of my dependencies using Puppet manifests. I want to do this myself to customize the configuration of FFMPEG to the needs of my project.
I'm not sure as to how to structure the entire process with classes. The logic should go something like this:
If /usr/local/bin/ffmpeg doesn't exist, compile:
Install build dependencies from apt-get.
Create a directory for the library sources /tmp/ffmpeg
Download and compile the Yasm assembler
Download.
Extract.
Configure
Make
Make Install
Download and compile x264
Clone the source.
Configure.
Make
Make Install
Download and compile fdk-aac:
...
....
I can easily branch all of these out into their own modules and declare them as dependencies of FFMPEG, that's not the problem.
My main problem is understanding how to do the whole download/extract/compile process for each module only if it's not already present on the system.
How do I structure my classes to only act if the software is not already installed?
Regardless of how you go about it, you need a way to check whether your custom installation has been installed.
Common methods include
checking a file and running a command only if it is not present: http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-creates
running a command only if another command returns 0: http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-onlyif (alternatively, the unless attribute)

How to to build src from a CygPort?

I have a question about the structure of the source code from a cygport package.
Here is the contents of a Cygports source file:
the actual source bundle for the project (tar.gz, tar.bz2, etc.)
the any number of *.patch files.
a .cygport file
I am trying to build gedit-3.4.2 from cygports repository.
How does the .cygport file help me run the proper options in the ./configure ?
For instance, in gedit if i don't specify --disable-spell it won't proceed due to error. How do I get the list of ./configure options that were used to build the project when the cygport was built?
Is there some way we can use the cygport executable to build the cygport and change the prefix too?
Here is the contents of gedit-3.4.2-1.cygport:
inherit python gnome2
DESCRIPTION="GNOME text editor"
PATCH_URI="3.4.2-cygwin.patch"
DEPEND="gnome-common gtk-doc
girepository(Gtk-3.0)
pkgconfig(enchant)
pkgconfig(gtksourceview-3.0)
pkgconfig(libpeas-gtk-1.0)"
PKG_NAMES="${PN} ${PN}-devel"
PKG_HINTS="setup devel"
gedit_CONTENTS="--exclude=gtk-doc --exclude=libgedit* etc/ usr/bin/ usr/lib/gedit/ ${PYTHON_SITELIB#/} usr/share/"
gedit_devel_CONTENTS="usr/include/ usr/lib/gedit/libgedit* usr/lib/pkgconfig/ usr/share/gtk-doc/"
DIFF_EXCLUDES="*.desktop.in *.schemas.in *-marshal.h"
CYGCONF_ARGS="--libexecdir=/usr/lib --enable-python"
KEEP_LA_FILES="none"
EDIT Someone from Cygwin Ports mailing list said:
"The configure options are
--libexecdir=/usr/lib --enable-python
Which is from CYGCONF_ARGS."
Here is the contents of a Cygports source file:
You'd do better to think of it as a Cygwin package source file.
cygport is simply a tool for automating the creation of Cygwin binary and source packages. It is the primary tool available, but unlike with some other packaging systems, there's really nothing forcing you to use it. It is quite possible to build a Cygwin package entirely by hand, since it is really nothing more than a tarball that Cygwin's setup.exe can blindly unpack into the Cygwin root directory (typically c:\cygwin) with the expectation that this will put the package's files in sensible locations.
Before cygport existed, people did build their own ad hoc packaging systems. Many Cygwin package maintainers still use these tools they created. (Yours truly included; two of my three packages use cygport, but the third still uses a custom build system.)
Ultimately, you want to read the cygport manual, in /usr/share/doc/cygport/manual.html.
(Yes, I know, "RTFM" answers are frowned on here. But, as one who currently maintains two cygport based packages in the official Cygwin package repository, please believe me when I tell you that the manual is still the single best resource available on this topic.)
How does the .cygport file help me run the proper options in the ./configure ?
As you found out through other resources, you'd first need to edit the CYGCONF_ARGS value in the .cygport file.
The simplest possible step after that is cygport gedit-3.4.2-1.cygport all. That attempts to rebuild all the binary packages in a single step. It also builds a new source package containing updated .cygport and patch files.
If something breaks in the all build process, it is usually faster to switch to using the sub-commands contained by all instead of completely restarting the process. The all step just runs prep, compile, install, package, and finish for you, in that order. For instance, if all fails during the compilation step, there's probably no need to repeat the prep step.
(It is exceptionally uncommon for cygport or a sane build system to wreck the build tree, forcing you to re-run prep. Far more commonly, you end up needing to re-do prep when you manually wreck the build tree while trying to get a new package to build for the first time and need to start over.)
For instance, in gedit if i don't specify --disable-spell it won't proceed due to error.
You can probably fix that by installing the libaspell-devel package from the official Cygwin package repository with setup.exe.
Personally, I wouldn't disable any feature unless it meant installing unofficial packages, such as those from the Cygwin Ports project.[*] It is nice to have Cygwin Ports repository, but because it contains so many packages, installing one can end up creating an "install the world" situation: package A depends on packages B, C and D, and C depends on E, F, G, H, and G depends on I, J, K, and... Dependency hierarchies within the Cygwin package repo tend to be flatter and narrower than those in the Cygports repo.
Is there some way we can use the cygport executable to build the cygport and change the prefix too?
You have guessed that you just add --prefix=/my/private/program/tree to CYGCONF_ARGS, I trust.
[*] If you are feeling confused about "Cygwin Ports" and cygport, the naming similarity is no coincidence. cygport is a tool created by Yaakov Selkowitz for himself when creating the Cygwin Ports package repository. Later, it became popular enough among other Cygwin package maintainers that it pushed out most of the competing build systems.

Should a "configure" script be distributed if configure.ac is available?

Currently, our installation instructions are:
autoreconf -fi
./configure
...
The autoreconf step generates the configure file from configure.ac and Makefile.in from Makefile.in. If one of the dependencies (say pkg-config) is not installed, both configure and autoreconf fail although the latter prints a cryptic error message.
When releasing source tarballs, should the configure script be supplied in the package or not? What other files need to be included if it has to be distributed? The directories build-aux and autom4te.cache and files aclocal.m4 were also created.
In an SCM repository, nothing autogenerated should be present (including configure — but developer opinions digress here). A tarball should contain the state after autoreconf -fi and/or autogen.sh (or whichever name you chose for it). Third, you could also use make dist, though it requires that all files that shall appear in the tarball are also listed in the Makefiles.
Your installation instructions are horribly broken. The user should not need to have the autotool chain installed to build your software. You must distribute the configure script in your tarball. Note that you should not include the configure script in your version control system. (You should not use your version control system as a distribution system.)
The configure script should be built by the maintainer and distributed in the tarball. End users should never have to touch it, and it is a good idea to ensure this via AM_MAINTAINER_MODE if you are using automake. If not, make sure your Makefile.in doesn't re-generate configure when running for end users.
Let automake generate a distribution for you if you want to know what else belongs there. The auxiliary directory build-aux and aclocal.m4 do, automat4e.cache doesn't.

Makefile.am ... what are those?

I've stumbled on a make file "Makefile.am" and I tried to use "make -f Makefile.am" on it to no avail. What am I doing wrong?
It's an automake script/makefile. You can learn everything about automake, autoconf, libtool and such through the called autobook.
Basically, the steps would be to run automake, then autoconf, then configure, then make to build the software you have. These steps are neccessary to build the configure script, that automatically search for needed libraries and such on your system.
The process is not easy, unless your software also includes an already generated "configure" file. If so, the only thing you have to do (mostly) is to just run ./configure, then make, then make install to install the software to a default location. If you want to change configure options, you can also look at ./configure --help.
You stumbled upon an automake file, which is used to create a Makefile from the source, in this case Makefile.am.
From http://developer.gnome.org/doc/GGAD/z70.html, they explain it as:
automake processes Makefile.am to produce a standards-compliant Makefile.in. automake does a lot of work for you: it keeps up with dependencies between source files, for example. It creates all the standard targets, such as install and clean. It also creates more complex targets: simply typing make dist creates a standard .tar.gz file if your Makefile.am is correct.
Basically, you should run 'automake' to make the Makefile, and you will probably run into the same situation with the configure script with 'autoconf'.
Automake: http://www.gnu.org/software/automake/
Wikipedia article on automake: http://en.wikipedia.org/wiki/Automake
If you are trying to compile a 3rd party application from source, there is usually a 'configure' script located at the top of the source tree. If you run ./configure --help from that location, you'll get a list of options you can set. Usually, --prefix is the most common to use.
After running the script, you'll get standard Makefile's generated from the automake files. From there, you can just execute make normally.
Standard build steps for linux packages are:
./configure
make
make install
see "man automake" or google for autotools. likely you'll want to run something like autogen.sh first.

Resources