make
c代码:
#include <stdio.h>
int main(int argc, char** argv){
printf("Hello, Linux World!\n");
return 0;
}
makefile:
app:helloworld.o
gcc helloworld.o -o app
helloworld.o:helloworld.c
gcc helloworld.c -c -o helloworld.o
automake
在存放源代码的目录下执行autoscan命令生成configure.scan文件。
将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)
<br />3. 执行aclocal、autoconf两个命令,分别生成aclocal.m4、configure文件。<br /><br /><br />~~4. 执行autoheader命令,分别生成config.h.in文件。~~<br /><br />5. 创建一个名为Makefile.am的文件,并输入相应的内容。<br />
```makefile
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.c
执行automake —add-missing,它根据Makefile.am文件,生成Makefile.in。
执行./configure脚本文件,它根据Makefile.in文件,生成最终的Makefile文件。
autoreconf
- 在存放源代码的目录下执行autoscan命令生成configure.scan文件。
2. 将configure.scan文件改名为configure.in,并对其默认配置进行修改。
3. 创建一个名为Makefile.am的文件,并输入相应的内容。
4. 执行autoreconf —install,它根据Makefile.am,configure.in文件,生成Makefile.in,configure,config.h.in。
5. 执行./configure脚本文件,它根据Makefile.in文件,生成最终的Makefile文件。
6.make实战编译git项目
https://github.com/teg/rpcbind
rpcbind-wip.zip
如果提示缺少“No package ‘libtirpc’ found”等时,可以使用apt-cache search libtirpc这个包,然后apt-get install libtirpc-devel就行了
编译成功[