How to use GNU autotools

Source: Internet
Author: User
Tags automake

Reprinted from http://blog.csdn.net/scucj/article/details/6079052

Collection

Writing makefile by hand is a very interesting thing, and for a relatively large project, if there is a tool to do it, it is a good thing. In the Linux system development environment, the GNU Autotools has undoubtedly played an important role. (in the development environment of Windows systems, IDE tools, such as visual Studio, are also handy for managing projects.) )

This article takes a simple project as an example to describe the use of a list of the GNU Autotools Tools and their commands.

Autotools is a series of tools, consisting mainly of autoconf, Automake, Perl locales, and M4, and contains five commands:
(1) aclocal
(2) AutoScan
(3) autoconf
(4) Autoheader
(5) Automake

first, prepare source code

(1) Directory project contains a main.c file and two subdirectory lib with a test.h in the Include;lib directory containing a test.c,include directory. In the system, it appears as follows:

[C-sharp] view plain copy [root@localhost project]# ls include lib main.c [root@localhost project]# [Roo T@localhost project]# ls include/test.h [root@localhost project]# ls lib/test.c [root@localhost project]#

(2) The source code is as follows:

[CPP] view plain Copy/* project/main.c/#include <stdio.h> #include "include/test.h" int main ()       {printf ("main entrance./n");       Test_method ();   return 0; }

[C-sharp] View plain Copy/* project/lib/test.c/#include <stdio.h> #include ".   /include/test.h "void Test_method () {printf (" Test method./n "); }

[CPP] view plain copy/* project/include/test.h*/void Test_method ();

second, the use of autotools steps

2.1 Using the AutoScan command, it scans the working directory and generates Configure.scan files.    [C-sharp] view plain copy [root@localhost project]# autoscan autom4te:configure.ac:no such file or directory AutoScan:/usr/bin/autom4te failed with exit status:1 [root@localhost project]# ls autoscan.log configure.scan i Nclude Lib Main.c [root@localhost project]#

2.2 Rename the Configure.scan file to Configure.ac and make the appropriate modifications. In Configure.ac, the line at the beginning of the # number is a comment, and the other is M4 macro command; The main function of the macros in Configure.ac is to detect the system.

[C-sharp]  View plain Copy [root@localhost project]mv configure.scan configure.ac   [ root@localhost project]# ls   autoscan.log  configure.ac include   lib  main.c   [root@localhost project]#   [root@localhost project]#  cat configure.ac   #                                                 -* - autoconf -*-   # process this file with autoconf to  produce a configure script.   ac_prereq (2.59)    Ac_init (Full-package-name,  version, bug-report-address)    Ac_config_srcdir ([main.c])    Ac_config_header ([ Config.h])    # Checks for programs.   ac_prog_cc  

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.