Learn notes--c++ Autotools tools using __c++

Source: Internet
Author: User
Tags automake

2017.04.05
GNU Autotools Installation
Several files are required to install Autotools
Automake,autoconf,m4
The order of installation is M4-> autoconf-> automake (important)

To install the required commands:
Tar zxvf * *
./configure
Make
Make install

Under Mac:
Brew Install autoconf
Brew Install Automake
(not installed M4 also normal use)

Autotools Use
The source directory is as follows

Main.cpp
inc/test.h
src/test.cpp

1. Hand-written makefile.am this document

#Makefile. Am  
utomake_options = foreign
bin_programs    = Main  
main_sources     = main.cpp inc/test.h Src/test.cpp  
Mian_cppflags    =-I include/

2. Run AutoScan at the top level of the source directory tree. Then manually modify the Configure.scan file and rename it to Configure.ac
and modify the content:

Ac_init (Full-package-name, VERSION, bug-report-address)  
is modified to: Ac_init (main,0.0.1,abc@qq.com) 

in Ac_init (main , 0.0.1,abc@qq.com) Add
am_init_automake (main,0.0.1) to the next line add

ac_config_files on the Ac_output line
([Makefile]) 

3. Using the aclocal command, scan the configure.ac file to generate ACLOCAL.M4 files,
This file mainly handles the local macro definition, which defines the macro set required by the Configure.ac file to the file ACLOCAL.M4 based on the macros already installed, user-defined macros, and macro in the Acinclude.m4 file.

4. Generate configure files using the autoconf command. This command expands the macros in the Configure.ac file to generate the Configure script. This process may be used to use macros defined in ACLOCAL.M4.

5. Generate config.h.in files using the Autoheader command. This command typically copies the user-appended symbol definitions from the "acconfig.h" file. There is no additional symbol definition in this example, so you do not need to create a "acconfig.h" file

6. Run automake–add-missing, which generates makefile.in based on makefile.am content.

7. Run configure, which will generate makefile this file based on makefile.in content.

8. After obtaining the makefile file, we can use the make program to manage our project.

第3-7 steps can be written as build.sh

 #!/bin/bash aclocal autoconf autoheader touch NEWS README AUTHORS changelog. Automake--add-missing 

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.