automake编译多目录结构工程

1. 工程目录文件结构

工程文件夹的根目录为example,在该目录运行tree命令得到如下的树:

.

├── include

│   └── double_list.h

├── lib

│   ├── double_list.c

│   └── double_list.h

└── src

└── operation_double_list.c

2. automake编译

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编译生成可执行文件。

3. 参考

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


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值