Makefile automatic generation (use of autotools tools)

Source: Internet
Author: User
Tags automake

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.