How to modernize your autotools scripts

I have many old projects using autotools as build system, but for oldest projects, some files need to be updated.
A basic overview of how the main autotools components fit together
Source diagram, available under a
 Creative Commons Attribution-ShareAlike 3.0 Unported License

Filename changes

The configure.in file needs to be renamed to configure.ac.
All .texinfo files must be renamed .texi. You also need to change Makefile.am's references to these files, typically in the *_TEXINFOS lines.

The AM_INIT_AUTOMAKE macro

This warning tells you that two- and three-arguments forms are deprecated and gives you this link. This macro is at the beginning of the configure.ac file and is actually used like this :

AC_INIT(src/main.cpp)
AM_INIT_AUTOMAKE(projectname, 0.0.0)
and you must replace this with :
AC_INIT([projectname], [0.0.0])
AC_CONFIG_SRCDIR([src/main.cpp])
AM_INIT_AUTOMAKE

The does not appear in AM_CONDITIONAL error

This error message comes with macro name and should be found in a Makefile.am file.
You're probably using a variable in a if statement without defining it in AM_CONDITIONAL.

For this project, I'm searching for a tool and conditionally add sources if found in Makefile.am :
if INKSCAPE_FOUND
  SOURCES+=global-view.png
endif
In the m4 file, I'm initializing the INKSCAPE_FOUND maro
AC_ARG_VAR([TOOL_INKSCAPE], [Define the path to the inkscape executable])
  AC_PATH_PROG(TOOL_INKSCAPE, inkscape, [no])
  case $TOOL_INKSCAPE in
    no)
      dnl Nothing
      dot_was_found=false
      ;;    
    *)   
      AC_DEFINE([HAVE_INKSCAPE], [], [Defines if the inkscape tool was found])
      AC_DEFINE(HAVE_INKSCAPE)
      dot_was_found=true
      ;;
  esac  
  AM_CONDITIONAL(INKSCAPE_FOUND, test x$dot_was_found = xtrue)
The does not appear in AM_CONDITIONAL error occurs here if you remove the last line.

Comments

Popular posts from this blog

Building openmw on Debian Jessie

How to make a clickable label in Gtk2/ruby