Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2095335
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2010-07-12 15:12:17

Writting an Makefile is too hard for someone who program with c/c++ language under linux,especially for large project.Let's face it,do not type the source file to the Makefile template one by one any more.Here is a small HowTo to generate an Makefile automatically using autoconf and automake tools.Follow me right now.


Step 0
Make sure these tools live in your system.

1 autoconf
2 automake
3 m4
4 perl
5 libtool(if you need shared libs)

Step 1
1 Autoscan


    cd ~/test/autoMakefile
    autoscan


2 Modify the configure.scan like this


3 Rename configure.scan to configure.in

Step 2
Aclocal

Step 3
Autoconf

Step 4
Edit Makefile.am

Step 5
Automake --add-missing

Figure it out with autoheader(generate file config.h.in)

And then redo automake.

Step 6
Run ./configure to generate Makefile

djstava@Gateway:~/test/autoMakefile$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for memory.h... (cached) yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/timeb.h usability... yes
checking sys/timeb.h presence... yes
checking for sys/timeb.h... yes
checking for unistd.h... (cached) yes
checking for uint32_t... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for ftime... yes
checking for gethostbyname... yes
checking for memset... yes
checking for select... yes
checking for socket... yes
checking for strtoul... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands

Step 7
Compile the project,type make


Step 8
Make Makefile perfectly.


As you can see,make command generate the object under project root directory.We move them to their source directory by modify the Makefile.


Add add these lines to the clean tag

    @rm -f example/rtsp_example.o
    @rm -f lib/rtsp.o
    @rm -f lib/rtsp.o


Source for this HowTo can download from here,you can do it yourself.
文件:autoMakefile.tar.gz
大小:17KB
下载:下载
.


djstava
阅读(2671) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~