Autotools is a series of tools that first confirm that your Ubuntu system has the following tools installed (can be viewed through the which command):
Aclocal
AutoScan
Autoconf
Autoheader
Automake
---------------------------------------------------------------------------------
Installation method:
[email protected]:~$ sudo apt-get install autoconf
After loading, use the which command to view
As follows:
[Email protected]:~$ which aclocal
/usr/bin/aclocal
[Email protected]:~$ which AutoScan
/usr/bin/autoscan
[Email protected]:~$ which autoconf
/usr/bin/autoconf
[email protected]:~$ which auto header
[Email protected]:~$ automake
Automake: ' configure.ac ' or ' configure.in ' is required
[Email protected]:~$ which automake
/usr/bin/automake
------------------------------------------------------------------------------
The following starts to generate a makefile:
Create the following code file:
Hello.cxx hello.h
Here is a direct way to post my operation:
[Email protected]:~/work/test$AutoScan
[Email protected]:~/work/test$ ls
Autoscan.log Configure.scan hello.cxx hello.h
[Email protected]:~/work/test$MV Configure.scan Configure.ac
[Email protected]:~/work/test$ ls
Autoscan.log configure.ac hello.cxx hello.h
[Email protected]:~/work/test$gedit configure.ac
[Email protected]:~/work/test$aclocal
[Email protected]:~/work/test$ ls
ACLOCAL.M4 Autoscan.log configure.ac~ hello.h
Autom4te.cache Configure.ac Hello.cxx
[Email protected]:~/work/test$autoconf
[Email protected]:~/work/test$ ls
ACLOCAL.M4 Autoscan.log configure.ac Hello.cxx
Autom4te.cache Configure configure.ac~ Hello.h
[Email protected]:~/work/test$Autoheader
[Email protected]:~/work/test$ ls
ACLOCAL.M4 Autoscan.log Configure configure.ac~ hello.h
Autom4te.cache config.h.in configure.ac Hello.cxx
[Email protected]:~/work/test$Touch makefile.am
[Email protected]:~/work/test$gedit makefile.am
[Email protected]:~/work/test$automake-a
Configure.ac:6: Installing './install-sh '
Configure.ac:6: Installing './missing '
Makefile.am:installing './depcomp '
[Email protected]:~/work/test$ ls
ACLOCAL.M4 config.h.in configure.ac~ hello.h makefile.am~
Autom4te.cache Configure Depcomp Install-sh makefile.in
Autoscan.log configure.ac hello.cxx makefile.am missing
[Email protected]:~/work/test$./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 for g++ ... g++
Checking whether the C + + compiler works ... yes
Checking for C + + compiler default output file name ... a.out
Checking for suffix of executables ...
Checking whether we is cross compiling ... no
Checking for suffix of object files ... o
Checking whether we are using the GNU C + + compiler ... yes
Checking whether g++ accepts-g ... yes
Checking for style's include used by make ... Gnu
Checking dependency style of g++ ... gcc3
Checking for gcc ... gcc
Checking whether we are using the GNU C compiler ... yes
Checking whether GCC accepts-g ... yes
Checking for GCC option to accept ISO C89 ... none needed
Checking dependency style of gcc ... gcc3
Configure:creating./config.status
Config.status:creating Makefile
Config.status:creating config.h
config.status:executing depfiles Commands
[Email protected]:~/work/test$Make Hello
g++-dhave_config_h-i. -G-O2-MT HELLO.O-MD-MP-MF. Deps/hello. Tpo-c-O hello.o hello.cxx
Mv-f. Deps/hello. Tpo. Deps/hello. Po
g++-g-o2-o Hello hello.o
[Email protected]:~/work/test$
which
[Email protected]:~/work/test$ gedit configure.ac Edit Configure.ac content as
#-*-Autoconf-*-
# Process This file with autoconf to produce a configure script.
Ac_prereq ([2.68])
Ac_init (hello,1.0)
Am_init_automake (hello,1.0)
Ac_config_srcdir ([Hello.cxx])
Ac_config_headers ([config.h])
# Checks for programs.
Ac_prog_cxx
Ac_prog_cc
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
Ac_config_files ([makefile])
Ac_output
[Email protected]:~/work/test$ gedit makefile.am Edit the contents of makefile.am:
Automake_options=foreign
Bin_programs=hello
Hello_sources=hello.cxx
The final execution. Configure we get the makefile file, and we use the make command to output the executable file Hello
Makefile automatic generation (use of autotools tools)