免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3716 | 回复: 3
打印 上一主题 下一主题

使用automake时,怎样在Makefile.am中应用通配符? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-28 17:37 |只看该作者 |倒序浏览
例子工程目录如下:
-- test
   |-- include
   |   `-- func.h
   `-- src
       |-- func.c
       `-- main.c


各文件如下:
// test/include/func.h

#ifndef FUNC_H
#define FUNC_H
void print();
#endif


// test/src/func.c

#include "../include/func.h"
#include <stdio.h>
void print() {
    printf("Hi!\n");
}


// test/src/main.c

#include "../include/func.h"
int main() {
&nbsp;&nbsp;&nbsp;&nbsp;print();
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
}


这是configure.in:
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(test, 1.0, test@test.com)
AC_CONFIG_SRCDIR([include/func.h])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(test, 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)


这是我写的Makefile.am:
AUTOMAKE_OPTIONS = foreign

bin_PROGRAMS = test
test_SOURCES = $(shell ls include/*.h) $(shell ls src/*.c)


“automake -a”和“./configure”时都没问题,但是make时报错。看了一下,大概是o文件没生成造成的:
make  all-am
make[1]: 正在进入目录 `/home/func/test'
gcc  -g -O2   -o test   
gcc: 没有输入文件
make[1]: *** [test] 错误 1
make[1]:正在离开目录 `/home/func/test'
make: *** [all] 错误 2


请问怎样才能写出没问题的支持通配符的Makefile.am?
实际项目中,目录结构与例子类似但更复杂,我不想在底层目录中再布置Makefile.am,希望一个Makefile.am就搞定整个工程。
而且由于文件众多,如果不把Makefile.am写得通用点,一个个文件写进去的话,有些麻烦。所以需要应用通配符。

该怎么做呢?

谢谢!

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
2 [报告]
发表于 2008-11-28 20:53 |只看该作者
建议楼主先看看make的手册 比如(http://www.linuxsir.org/main/doc ... _CN_html/index.html)。

这个里面4。4 讲到统配符,你先看看。

论坛徽章:
0
3 [报告]
发表于 2008-11-28 21:33 |只看该作者

论坛徽章:
0
4 [报告]
发表于 2008-11-28 21:37 |只看该作者
原帖由 rdcwayx 于 2008-11-28 20:53 发表
建议楼主先看看make的手册 比如(http://www.linuxsir.org/main/doc ... _CN_html/index.html)。

这个里面4。4 讲到统配符,你先看看。

谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP