工程文件夹的根目录为example,在该目录运行tree命令得到如下的树:
.
├── include
│ └── double_list.h
├── lib
│ ├── double_list.c
│ └── double_list.h
└── src
└── operation_double_list.c
1) 在example目录执行autoscan,生成configure.scan文件,重命名该文件为configure.in,并修改其内容为(红色的为新增或修改的):
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT(double-list,0.1)
AC_CONFIG_SRCDIR([src/operation_double_list.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
AC_PROG_RANLIB
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_OUTPUT(Makefile src/Makefilelib/Makefile)
2) 在example目录下执行aclocal、autoheader、autoconf,并在example、lib、src目录分别新建Makefile.am文件,内容分别为:
example/Makefile.am:
AUTOMAKE_OPTIONS=foreign
SUBDIRS=lib src
lib/Makefile.am:
AUTOMAKE_OPTIONS=foreign
noinst_LIBRARIES=libdoublelist.a
libdoublelist_a_SOURCES=double_list.hdouble_list.c
src/Makefile.am:
AUTOMAKE_OPTIONS=foreign
INCLUDES=-I../include
bin_PROGRAMS=demo
demo_SOURCES=operation_double_list.c
demo_LDADD=../lib/libdoublelist.a
3) 在example目录下执行automake –add-missing
4) 在example目录下执行./configure生成Makefile,然后make编译生成可执行文件。
https://www.cnblogs.com/DjangoBlog/p/6912936.html
http://blog.csdn.net/fd315063004/article/details/7785504
http://www.cppblog.com/isware/archive/2011/06/01/147849.html
https://www.cnblogs.com/shenlian/archive/2011/10/21/2220367.html