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