autoconf和automake的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jc_deng/article/details/85263007

hasson@PC:~/Desktop/demo$ ls
main.c
hasson@PC:~/Desktop/demo$ cat main.c
#include <stdio.h>

int main(int argc, char** argv)

{

    printf("Hello World!\n");

    return 0;

}
hasson@PC:~/Desktop/demo$ autoscan
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE [^\}]*}/ at /usr/bin/autoscan line 361.
hasson@PC:~/Desktop/demo$ mv configure.scan configure.ac
hasson@PC:~/Desktop/demo$ nano configure.ac
hasson@PC:~/Desktop/demo$ cat configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.69)
AC_INIT(main, 1.0)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(main,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)
hasson@PC:~/Desktop/demo$ aclocal
hasson@PC:~/Desktop/demo$ autoconf
hasson@PC:~/Desktop/demo$ autoheader
hasson@PC:~/Desktop/demo$ touch Makefile.am
hasson@PC:~/Desktop/demo$ ls
aclocal.m4      autoscan.log  configure     main.c
autom4te.cache  config.h.in   configure.ac  Makefile.am
hasson@PC:~/Desktop/demo$ nano Makefile.am
hasson@PC:~/Desktop/demo$ cat Makefile.am
AUTOMAKE_OPTIONS=foreign

bin_PROGRAMS=main

main_SOURCES=main.c
hasson@PC:~/Desktop/demo$ automake --add-missing
configure.ac:8: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.ac:8: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:10: installing './compile'
configure.ac:8: installing './install-sh'
configure.ac:8: installing './missing'
Makefile.am: installing './depcomp'
hasson@PC:~/Desktop/demo$ ./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 whether make supports nested variables... 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 whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
hasson@PC:~/Desktop/demo$ make
make  all-am
make[1]: Entering directory '/home/hasson/Desktop/demo'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc  -g -O2   -o main main.o  
make[1]: Leaving directory '/home/hasson/Desktop/demo'
hasson@PC:~/Desktop/demo$ ./main
Hello World!

猜你喜欢

转载自blog.csdn.net/jc_deng/article/details/85263007