make

c代码:

  1. #include <stdio.h>
  2. int main(int argc, char** argv){
  3. printf("Hello, Linux World!\n");
  4. return 0;
  5. }

makefile:

  1. app:helloworld.o
  2. gcc helloworld.o -o app
  3. helloworld.o:helloworld.c
  4. gcc helloworld.c -c -o helloworld.o

image.png

automake

  1. 在存放源代码的目录下执行autoscan命令生成configure.scan文件。
    image.png

  2. 将configure.scan文件改名为configure.in或者configure.ac,并对其默认配置进行修改。 ```makefile

    -- Autoconf --

    Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69]) AC_INIT(hellworld, 1.0, dengxiaohong@ruijie.com.cn) AC_CONFIG_SRCDIR([helloworld.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE(helloworld,1.0)

Checks for programs.

AC_PROG_CC

Checks for libraries.

Checks for header files.

Checks for typedefs, structures, and compiler characteristics.

Checks for library functions.

AC_OUTPUT(Makefile)


![image.png](https://cdn.nlark.com/yuque/0/2022/png/599030/1644228729399-3d3b80c6-6b7e-499a-bc24-91d24c491c1b.png#clientId=ued1e9998-057c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=407&id=u847bc04a&margin=%5Bobject%20Object%5D&name=image.png&originHeight=509&originWidth=1105&originalType=binary&ratio=1&rotation=0&showTitle=false&size=218966&status=done&style=none&taskId=u6cb17361-3087-4e83-9369-f1b59a90ae8&title=&width=884)<br />3. 执行aclocal、autoconf两个命令,分别生成aclocal.m4、configure文件。<br />![image.png](https://cdn.nlark.com/yuque/0/2022/png/599030/1644228804259-b48cdcef-c2da-40f5-8f1f-26ef1f3489ac.png#clientId=ued1e9998-057c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=296&id=u9d182682&margin=%5Bobject%20Object%5D&name=image.png&originHeight=370&originWidth=751&originalType=binary&ratio=1&rotation=0&showTitle=false&size=111127&status=done&style=none&taskId=u04a4d0ea-99b2-41c3-b601-4c49f8148bc&title=&width=600.8)<br />![image.png](https://cdn.nlark.com/yuque/0/2022/png/599030/1644228853837-7f916ccb-9440-4517-a883-34cd0ddc708d.png#clientId=ued1e9998-057c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=323&id=ude55d8fb&margin=%5Bobject%20Object%5D&name=image.png&originHeight=404&originWidth=791&originalType=binary&ratio=1&rotation=0&showTitle=false&size=139186&status=done&style=none&taskId=uf22d7456-e013-496a-8116-4b963949468&title=&width=632.8)<br />~~4. 执行autoheader命令,分别生成config.h.in文件。~~<br />![image.png](https://cdn.nlark.com/yuque/0/2022/png/599030/1644228976663-bdccc258-7c95-45c5-827f-88dc22d6dfff.png#clientId=ued1e9998-057c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=355&id=u2e522495&margin=%5Bobject%20Object%5D&name=image.png&originHeight=444&originWidth=875&originalType=binary&ratio=1&rotation=0&showTitle=false&size=172816&status=done&style=none&taskId=u3701d919-9ef6-4f07-9a60-66fd789dd2d&title=&width=700)<br />5. 创建一个名为Makefile.am的文件,并输入相应的内容。<br />![image.png](https://cdn.nlark.com/yuque/0/2022/png/599030/1644228922988-d451614f-721e-43d0-b717-248812c399d6.png#clientId=ued1e9998-057c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=346&id=ua59b520f&margin=%5Bobject%20Object%5D&name=image.png&originHeight=432&originWidth=779&originalType=binary&ratio=1&rotation=0&showTitle=false&size=157739&status=done&style=none&taskId=ued41d210-7ad5-43f9-a6a1-0f18d58f4ac&title=&width=623.2)
```makefile
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.c
  1. 执行automake —add-missing,它根据Makefile.am文件,生成Makefile.in。
    image.png

  2. 执行./configure脚本文件,它根据Makefile.in文件,生成最终的Makefile文件。
    image.png

8.make生成可执行程序
image.png
image.png

autoreconf

  1. 在存放源代码的目录下执行autoscan命令生成configure.scan文件。
    image.png
    2. 将configure.scan文件改名为configure.in,并对其默认配置进行修改。
    image.png
    3. 创建一个名为Makefile.am的文件,并输入相应的内容。
    image.png
    4. 执行autoreconf —install,它根据Makefile.am,configure.in文件,生成Makefile.in,configure,config.h.in。
    image.png
    5. 执行./configure脚本文件,它根据Makefile.in文件,生成最终的Makefile文件。
    image.png
    6.make
    image.png

    实战编译git项目

    https://github.com/teg/rpcbind
    rpcbind-wip.zip

如果提示缺少“No package ‘libtirpc’ found”等时,可以使用apt-cache search libtirpc这个包,然后apt-get install libtirpc-devel就行了

编译成功
image.png[

](https://blog.csdn.net/vevenlcf/article/details/48134313)