Automake Construction Project Example explanation

Source: Internet
Author: User
Tags automake

Construction of Automake environment

"Server Environment"

Linux version: Ubuntu 9.10

Automake version: (GNU automake) 1.11

Autoconf version: (GNU autoconf) 2.64

Introduced

Although the Automake and autoconf tools are mentioned above, the autoscan,aclocal tools are needed in the actual use. Which means we need to use

Autoscan,aclocal,autoconf,automake these few tools. In Ubuntu, we use the Apt-get Install command, the system will automatically install all the tools for us, do not need to manually download. After these commands are executed, the Configure file is generated in the compiled directory, and then we can compile and install the code through the familiar "./configure", "make", "Made Install" commands.

Here are some simple introduction to these tools, online, there are some of the following excerpts from the Internet, in fact, just beginning to learn Automake no need to fully understand what these tools are doing, you can skip.

AutoScan is used to scan the source code directory to generate Configure.scan files. AutoScan can be used as a parameter, but if you do not use parameters, then AutoScan will assume that the current directory is used. AutoScan will scan the source files in the directory you specify and create Configure.scan files. The Configure.scan contains basic options for system configuration, all of which are macro definitions. In the actual use process, we often change the Configure.scan file into configure.in or configure.ac files.

Note:-note:configure.in is the name used for autoconf files, now deprecated. (from: http://mij.oltrelinux.com/devel/autoconf-automake/) Although the manual is not recommended to configure.in, but we can ignore.

Aclocal is a Perl scripting program. Aclocal automatically generates ACLOCAL.M4 files based on the contents of the Configure.in file. The definition of aclocal is: "Aclocal-create aclocal.m4 by scanning configure.ac".

Note: aclocal.m4 file. At that time in the study, very tangled in this M4 suffix in the end is what meaning, although it is a matter of no concern, but every time I see this file, always to figure out what this suffix represents a what dongdong. In fact, very simple, M4 is to represent the meaning of macro, that is, there are 4 letters m behind, Daniel's thinking is indeed inconsistent with ordinary people. :)

Autoconf is used to produce configure files. Configure is a script that sets up the source program to accommodate a variety of operating system platforms, and generates the appropriate makefile based on different systems so that your source code can be compiled on different operating system platforms. The contents of the Configure.in file are macros that, after autoconf processing, become shell scripts that check system characteristics, environment variables, and software-required parameters. The order of the macros in the configure.in file is not specified, but you must add Ac_init macros and Ac_output macros to the front and end of all macros respectively.

Automake is used to generate makefile.in files. Those. In the files is used by autoconf scripts to produce the final makefiles (is used to generate makefile files, so is the more important file)

Overall, the process diagram is like this


As long as the figure can be seen clearly, the generation of makefile will not be confused order.

The following engineering directory, is my new directory, I based on this directory to explain how to build a compilation project.

"Engineering Catalogue"

  

Module Comments:

Driver: Driver code

Software: module code root directory

-alarm Alarm Module

-common Public Module

-config Configuration Module

-ctrl Main control Module

-lib Store the so dynamic library after compiling

-lib_source the source code of the third Party library

-PTZ PTZ Control Module

-RTP RTP Streaming Media module

-sdkserver SDK Service Module

-server Message Communication Service Module

-storage Storage Module

-webclient CGI Module

-xml Store XML configuration file

"Execution Process"

Step 1: In the software directory, use AutoScan to scan the current directory (it automatically scans subdirectories, so you only need to do it once in the root directory), will be generated under the software Configure.scan file, as mentioned earlier, we need to rename the Configure.scan file to configure.in, otherwise can not be recognized by other tools

1.autoscan

2.MV Configure.scan configure.in

After renaming, we also need to according to own actual situation, the configure.in file changes. The versions of the tools are different, and the resulting configure.in files may be different, but we just need to focus on a very small part.

Note: In the actual use of the process, you only need to pay attention to the Red Arrows I identified a few macro commands on it, other macro commands are many, you need to access the manual according to the actual situation to obtain the use of the method.

Step 2.

Execute the aclocal command under software to generate the Aclocal.m4 file. (ACLOCAL.M4 file cannot be generated if the autoscan.in file is missing Ac_init_automake macros)

Step 3.

Execute the autoconf command under software to generate the Configure file.

Note: autoconf is a tool used to generate automatic configuration software source code scripts (configure). Configure scripts can be run independently of autoconf, and in the course of running, no user intervention is required to generate configure, and ACLOCAL.M4 must be used.


Step 4.

The Configure script is created, and if you execute the./configure command at this time, you will be prompted with an error, as follows

Config.status:error:cannot Find input file: ' makefile.in '

Because so far, we have not yet produced makefile.in files, then how to generate makefile.in it. We first need to write makefile.am file, look at suffix name. Am, we can know that this makefile.am is for the Automake tool, through makefile.am file, we generate makefile.in, and then through. The Configure command reads the execution makefile.in and generates the makefile. And finally our "make" and "Make Install"

It should be said that automake as long as the step-by-step, in order to knock a few commands is very easy, the only trouble is to write makefile.am files, we need to participate in the compilation of each subdirectory under the creation of a makefile.am file. Although makefile.am is the most tedious step in the entire creation process (given the likelihood that subdirectories may be more), it's much easier than writing every Makefile file.

1. We first create the software/makefile.am file, how to write it.

As you can see, I set up two variables inside, Subdirs and automake_options. These are the variables that are brought by the system, similar to the variables that come with the system itself.

Subdirs variable, as the name implies, is the meaning of subdirectories, should be software is the project root directory, so we just need to indicate in this makefile.am what the subdirectory can be, in the implementation process, will automatically go to the subdirectory below to find the corresponding makefile.am , so it's quite simple.

Automake_options variable, look at the picture will know, do not explain.

2. Create a good root directory of the makefile.am, then the child directory that is the child module of the makefile.am how to write it. Look together.

I chose the SOFTWARE/RTP module as the Tutorial directory, and its makefile.am is written in this way. Assuming the RTP module has only one stream.cpp in the file below, we'll write it like this, as shown in

One thing to say about Bin_programs is that after make install, the generated bin file will be copied to the/usr/local/bin system directory, if you do not want to copy, to prevent the original file is overwritten, you can use the Noinst_ PROGRAMS Replace Bin_programs (Noinst is not install abbreviation, you know)


OK, the makefile.am of the other catalogue, you can refer to my example above, dots, very simple.

Step 5.

After you have all the makefile.am, you can execute the automake--add-missing command in the software directory, and after the execution, the makefile.in file will be automatically generated under each directory. The final implementation of the Linux installation files trilogy, "Configure", "make", "made Install", you can casually execute.


The point of knowledge is that it involves a very small part of the Automake, wants to know more, and suggests to look at the technical articles written by others or look at the Official handbook.

There is also a better way, the next few open source code, to figure out how they are written.

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.