Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaosf/ebe1698582e7544991a6 to your computer and use it in GitHub Desktop.
Save kaosf/ebe1698582e7544991a6 to your computer and use it in GitHub Desktop.

./configure && make && make install && make uninstall

Step 1.

A simple minimal project that you can only do ./configure and make.

Environment

  • OS: Ubuntu 14.04
  • automake: (GNU automake) 1.14.1
  • autoconf: (GNU autoconf) 2.69

sudo apt-get install build-essential automake

Experiment log

mkdir myapp && cd myapp

autoscan
# "configure.scan" is generated.
# It is a template for "configure.ac".
mv configure.scan configure.ac

autoconf
# "configure" is generated from "configure.ac".

# But, this "configure.ac" dosen't include "AC_CONFIG_FILES([Makefile])".
# It is needed for automake.
mv configure.ac configure.ac-without-Makefile.am
touch Makefile.am
autoscan
mv configure.scan configure.ac
diff configure.ac-without-Makefile.am configure.ac
# 16a17
# > AC_CONFIG_FILES([Makefile])
rm configure.ac-without-Makefile.am

automake #=> Error
# configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
# configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
# configure.ac: that aclocal.m4 is present in the top-level directory,
# configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)
# Makefile.am: error: required file './INSTALL' not found
# Makefile.am:   'automake --add-missing' can install 'INSTALL'
# Makefile.am: error: required file './NEWS' not found
# Makefile.am: error: required file './README' not found
# Makefile.am: error: required file './AUTHORS' not found
# Makefile.am: error: required file './ChangeLog' not found
# Makefile.am: error: required file './COPYING' not found
# Makefile.am:   'automake --add-missing' can install 'COPYING'

# Create necesary files.
touch INSTALL
touch NEWS
touch README
touch AUTHORS
touch ChangeLog
touch COPYING

automake #=> Error
# configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
# configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
# configure.ac: that aclocal.m4 is present in the top-level directory,
# configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)

# Insert "AM_INIT_AUTOMAKE" after the line of
# "AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])"
X=`grep AC_INIT configure.ac -n | cut -d : -f 1` # Detect the line number
head -${X} configure.ac > temp # Cut the head part
echo AM_INIT_AUTOMAKE >> temp
tail -n +$((X+1)) configure.ac >> temp # Cut the tail part and append it
mv temp configure.ac

automake #=> Error
# configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
# configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
# configure.ac: that aclocal.m4 is present in the top-level directory,
# configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)

# Need to run "aclocal" and run "autoconf" again.
aclocal
autoconf

automake #=> Error
# configure.ac:6: error: required file './install-sh' not found
# configure.ac:6:   'automake --add-missing' can install 'install-sh'
# configure.ac:6: error: required file './missing' not found
# configure.ac:6:   'automake --add-missing' can install 'missing'

automake --add-missing
# Symbolic links of "install-sh" and "missing" are generated.
# "--add-missing" option can be shortened to "-a"
# If you want to copy "install-sh" and "missing" instead of symlinks, run
# "automake --add-missing --copy" or "automake -ac"

./configure
# checking for a BSD-compatible install... /usr/bin/install -c
# checking whether build environment is sane... yes
# checking for a thread-safe mkdir -p... /bin/mkdir -p
# checking for gawk... no
# checking for mawk... mawk
# checking whether make sets $(MAKE)... yes
# checking whether make supports nested variables... yes
# checking that generated files are newer than configure... done
# configure: creating ./config.status
# config.status: creating Makefile
make
# make: Nothing to be done for `all'.

Conclusion

mkdir myapp
cd myapp
touch Makefile.am
autoscan
mv configure.scan configure.ac
autoconf
touch INSTALL
touch NEWS
touch README
touch AUTHORS
touch ChangeLog
touch COPYING
X=`grep AC_INIT configure.ac -n | cut -d : -f 1`
head -${X} configure.ac > temp
echo AM_INIT_AUTOMAKE >> temp
tail -n +$((X+1)) configure.ac >> temp
mv temp configure.ac
aclocal
autoconf
automake -a # or automake -ac
./configure
make

Ignore files

.gitignore is generated with this link by gitignore.io - Create useful .gitignore files for your project.

But, I think that following files should also be ignored.

/autoscan.log
/config.log
/config.status
/Makefile

So, I create .gitignore by following commands.

curl www.gitignore.io/api/autotools > .gitignore
echo '/autoscan.log'  >> .gitignore
echo '/config.log'    >> .gitignore
echo '/config.status' >> .gitignore
echo '/Makefile'      >> .gitignore

References

automake, autotools

autoscan

automake example

About "no proper invocation of AM_INIT_AUTOMAKE was found" error

About "install-sh" and "missing" missing

About "--copy" option of "automake"

TODO

  • Modify configure.ac and Makefile.am for my own project
  • ./configure --prefix=$HOME/local && make install && make uninstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment