【Linux技术】autotools制作makefile过程详解



 






 


 


 

 

 

1 #                                               -*- Autoconf -*-             
 2 # Process this file with autoconf to produce a configure script.             
 3                                                                              
 4 AC_PREREQ([2.68])                                                            
 5 #AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])               
 6 AC_CONFIG_SRCDIR([hello.c])                                                  
 7 AC_CONFIG_HEADERS([config.h])                                                
 8                                                                              
 9 #add-me-------------                                                         
10 AC_INIT(hello,1.0,infodownzert@gmail.com)                                    
11 AM_INIT_AUTOMAKE(hello,1.0)                                                  
12                                                                              
13 # Checks for programs.                                                       
14 AC_PROG_CC                                                                   
15                                                                              
16 # Checks for libraries.                                                      
17                                                                              
18 # Checks for header files.                                                   
19 AC_CHECK_HEADERS([stdlib.h])                                                 
20                                                                              
21 # Checks for typedefs, structures, and compiler characteristics.             
22                                                                              
23 # Checks for library functions.                                              
24                                                                              
25 AC_CONFIG_FILES([Makefile])                                                  
26 AC_OUTPUT

 


 

 

 

 


 

 

 



AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS= hello
hellohello_SOURCES= hello.c

 

 

 

 


mystery@mystery-dell:~/Desktop/autotools$ ./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... no
checking for mawk... mawk
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 for stdlib.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands

 

 

 

 




mystery@mystery-dell:~/Desktop/autotools$ make
cd . && /bin/bash ./config.status config.h
config.status: creating config.h
make  all-am
make[1]: Entering directory `/home/mystery/Desktop/autotools'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc  -g -O2   -o hello hello.o
cd . && /bin/bash ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make[1]: Leaving directory `/home/mystery/Desktop/autotools'

 

 

mystery@mystery-dell:~/Desktop/autotools$ ./hello
!!!Hello World!!!

 

 


 

 


mystery@mystery-dell:~/Desktop/autotools$ make clean
test -z "hello" || rm -f hello
rm -f *.o

 

 


mystery@mystery-dell:~/Desktop/autotools$ make dist
mystery@mystery-dell:~/Desktop/autotools$ ls hello-1.0-tar.gz
hello-1.0-tar.gz

 

 

 

 

 

相关内容