C语言开发 之 编译工具(一)

欢迎来到编译的世界!

compile-tools-00.png

hello

1
vim hello.c
1
2
3
4
5
6
7
#include <stdio.h>

int main()
{
printf("Hello World\n");
return 0;
}
1
2
3
4
gcc hello.c -o hello

./hello
# Hello World

compile-tools-01.png

项目渐渐复杂 => Linux Kernel Stable: 5.17.9

make

1
GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files
  • Make gets its knowledge of how to build your program from a file called the makefile
1
2
3
Makefile lists each of the non-source files and how to compute it from other files

When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program

compile-tools-02.png

makefile渐渐复杂 => Linux Kernel Makefile Stable: 5.17.9

configure

  • Configure is an executable script
1
2
3
This script is given arguments which describe the kind of machine and system you want to compile the program for

The configure script must record the configuration options so that they affect compilation
  • Makefile.in can be used by configure scripts to generate a working Makefile

compile-tools-03.png

autoconf

1
Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages

compile-tools-04.png

automake

1
GNU Automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards

compile-tools-05.png

autoscan

1
2
3
Examine source files in the directory tree rooted at SRCDIR, or the current directory if none is given

Search the source files for common portability problems, check for incompleteness of 'configure.ac', and create a file 'configure.scan' which is a preliminary 'configure.ac' for that package

compile-tools-06.png

参考