- 1、准备
- $ cd /tmp
- $ mkdir hello
- $ mkdir src
- $ cd src
- $ vim hello.c
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- printf("Hello, World!\n");
- return 0;
- }
- $ vim Makefile.am
- AUTOMAKE_OPTIONS=foreign
- AM_CFLAGS =\
- -Wall\
- -g
- bin_PROGRAMS = hello
- hello_SOURCES = hello.c
- $ cd /tmp/hello
- $ vim Makefile.am
- AUTOMAKE_OPTIONS=foreign
- SUBDIRS=src
- 2、autoscan
- $ autoscan
- $ mv configure.scan configure.in
- modify configure.in
- # -*- Autoconf -*-
- # Process this file with autoconf to produce a configure script.
- AC_PREREQ([2.67])
- AC_INIT([hello], [1.0], [sunsea1026@gmail.com])
- AC_CONFIG_SRCDIR([src/hello.c])
- AC_CONFIG_HEADERS([config.h])
- AM_INIT_AUTOMAKE(hello, 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_CONFIG_FILES([Makefile
- src/Makefile])
- AC_OUTPUT
- 3、aclocal
- $ aclocal
- 4、autoconf
- $ autoconf
- 5、autoheader
- $ autoheader
- 6、automake
- $ automake --add-missing
- 7、./configure
- $ ./configure
- 8、make
- $ make
- 9、run
- $ ./src/hello
使用autotool工具自动生成 Makefile
最新推荐文章于 2020-08-26 22:58:00 发布