autoconf 简单demo试用

1. 安装工具

yum install  -y automake
1
 
1
yum install  -y automake

2. 基本项目
a. 项目参考结构

├── AUTHORS
├── COPYING
├── ChangeLog
├── Makefile.am
├── NEWS
├── README
├── README.md
├── a.out
├── configure.ac
├── main
└── main.c

b.  configure.ac  Makefile.am  main.c

configure.ac  Makefile.am

configure.ac

AC_INIT([main],[0.0.1])
AC_CONFIG_SRCDIR("main.c")
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.11 -Wall -Werror])
AC_CONFIG_FILES([Makefile])
AC_PROG_CC
AC_OUTPUT

Makefile.am

bin_PROGRAMS = main
main_source =main.c


main.c

#include <stdio.h>

int main (){

 printf("%s","appdemo");
 return 0;

}


c. 生成文档

autoreconf  -i  提示的错误信息如下:

Makefile.am: error: required file './NEWS' not found
Makefile.am: error: required file './README' not found
Makefile.am: error: required file './ChangeLog' not found
Makefile.am: installing './COPYING' using GNU General Public License v3 file
Makefile.am:     Consider adding the COPYING file to the version control system
Makefile.am:     for your code, to avoid questions about which license your project uses
autoreconf: automake failed with exit status: 1


解决方法
list="INSTALL NEWS README AUTHORS ChangeLog COPYING"
touch  $list

重新生成之后  ./configure

d. make && install 

make install 


备注:或者使用autoscan 帮助生成部分代码,也是一个不错的选择
x
 
1
a. 项目参考结构
2
3
├── AUTHORS
4
├── COPYING
5
├── ChangeLog
6
├── Makefile.am
7
├── NEWS
8
├── README
9
├── README.md
10
├── a.out
11
├── configure.ac
12
├── main
13
└── main.c
14
15
b.  configure.ac  Makefile.am  main.c
16
17
configure.ac  Makefile.am
18
19
configure.ac
20
21
AC_INIT([main],[0.0.1])
22
AC_CONFIG_SRCDIR("main.c")
23
AC_CONFIG_AUX_DIR([build-aux])
24
AM_INIT_AUTOMAKE([1.11 -Wall -Werror])
25
AC_CONFIG_FILES([Makefile])
26
AC_PROG_CC
27
AC_OUTPUT
28
29
Makefile.am
30
31
bin_PROGRAMS = main
32
main_source =main.c
33
34
35
main.c
36
37
#include <stdio.h>
38
39
int main (){
40
41
 printf("%s","appdemo");
42
 return 0;
43
44
}
45
46
47
c. 生成文档
48
49
autoreconf  -i  提示的错误信息如下:
50
51
Makefile.am: error: required file './NEWS' not found
52
Makefile.am: error: required file './README' not found
53
Makefile.am: error: required file './ChangeLog' not found
54
Makefile.am: installing './COPYING' using GNU General Public License v3 file
55
Makefile.am:     Consider adding the COPYING file to the version control system
56
Makefile.am:     for your code, to avoid questions about which license your project uses
57
autoreconf: automake failed with exit status: 1
58
59
60
解决方法
61
list="INSTALL NEWS README AUTHORS ChangeLog COPYING"
62
touch  $list
63
64
重新生成之后  ./configure
65
66
d. make && install 
67
68
make install 
69
70
71
备注:或者使用autoscan 帮助生成部分代码,也是一个不错的选择
72
3. 参考资料
https://github.com/rongfengliang/autoconf-demo
https://www.gnu.org/software/autoconf/autoconf.html
1
1
https://github.com/rongfengliang/autoconf-demo
2
https://www.gnu.org/software/autoconf/autoconf.html

猜你喜欢

转载自www.cnblogs.com/rongfengliang/p/9007888.html