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 0Make sure these tools live in your system.
1
autoconf2
automake3
m44
perl5
libtool(if you need shared libs)
Step 11 Autoscan
cd ~/test/autoMakefile autoscan2 Modify the configure.scan like this
3 Rename
configure.scan to
configure.inStep 2Aclocal
Step 3Autoconf
Step 4Edit Makefile.am
Step 5Automake --add-missing
Figure it out with
autoheader(generate file
config.h.in)
And then redo
automake.
Step 6Run
./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 7Compile the project,type
makeStep 8Make
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.oSource for this HowTo can download from here,you can do it yourself.
|
文件: | autoMakefile.tar.gz |
大小: | 17KB |
下载: | 下载 |
|
.
djstava