Automatic generation of Makefile__linux using Autotools in Linux

Source: Internet
Author: User
Tags automake
About the use of Autotools

We know that under Linux if you compile a larger project, we can do it in a makefile way.

But, we have the egg ache, makefile has the complex grammatical structure, even lets the person be difficult to comprehend, when our project is very big, the maintenance makefile will become a very troublesome matter. So we have the Autotools tool, which is designed to generate makefile, which allows us to greatly reduce the difficulty of development.

Autotools is not a tool, but a series of tools:

1. AutoScan

2. aclocal

3. autoconf

4. Autoheader

5. Automake

Remember, this series of tools looks complex, and the ultimate goal is to generate makefile


In general, this series of tools is installed by default in the system, and if not, the following command can be installed in Centeros:

[Plain] View plain copy sudo yum install Automake


C source files under the same directory of the use of Autotools

If your source files are all placed under the same directory, it will be a lot simpler to use Autotools. The more famous open source software memcache is also placed in the same directory, you can go to see its source code package.

The following steps are followed to implement the use of the Autotools tool in the same directory.


1. Source code example

Entry file Main.c

[cpp]  View plain  copy     #include  <stdio.h>     #include   <stdlib.h>     #include  <unistd.h>     #include   " Sum.h "     #include  " get.h "               //Portal main function      int main ()  {          int x = 10;         int y =  20;         int z = sum (&x, &y);          puts ("This is main");          printf ("z:%d\n",  z);         x = 20;          z = get (&x, &y);          printf ("z:%d\n",  z);         return 1;     }   

Sum.h and SUM.C

[CPP] View plain copy #include <stdio.h> #include <stdlib.h> #include <unistd.h> int sum (   int *x, int *y); [CPP] View plain copy #include "sum.h" #include "val.h" int

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.