Makefile.am-手动目标先决条件+ addprefix? [英] Makefile.am - Manual target prerequisite + addprefix?

查看:322
本文介绍了Makefile.am-手动目标先决条件+ addprefix?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自动工具项目,其中的部分源代码是从网上动态下载的(由于IP权限阻止了直接重新分配),然后构建了它.

I have a autotool project where part of the source code is downloaded dynamically from the net (because of IP rights preventing direct redistribution) and then built.

我有一个可以正常工作的Makefile.am,但我对某些方面不满意.

I have a Makefile.am that works but I'm not happy about some of it's aspects.

这里是:

INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
AM_CFLAGS = -fPIC -Wall ${SYMBOL_VISIBILITY}

LIBVERSION=0:0:0

REFSRC_PATH=refsrc
REFSRC_SRC=refsrc/dtx.c refsrc/globdefs.c refsrc/host.c refsrc/mathhalf.c refsrc/sp_enc.c refsrc/sp_rom.c refsrc/vad.c refsrc/err_conc.c refsrc/homing.c refsrc/mathdp31.c refsrc/sp_dec.c refsrc/sp_frm.c refsrc/sp_sfrm.c

${REFSRC_PATH}/.downloaded:
        ./fetch_sources.py "${REFSRC_PATH}"
        for f in `ls -1 "${REFSRC_PATH}"/*.{c,h}`; do   \
                sed -i -e"s/round/round_l2s/" "$$f";    \
        done
        touch $@

${REFSRC_PATH}/dtx.c: ${REFSRC_PATH}/.downloaded

lib_LTLIBRARIES = libgsmhr.la
libgsmhr_la_SOURCES = libgsmhr.c $(REFSRC_SRC)

clean-local:
        -rm -rf ${REFSRC_PATH}

从本质上讲,libgsmhr.c是我的主要包装,然后将源代码下载到refsrc/子目录中并对其进行一些修补.

So essentially, libgsmhr.c is my main wrapper, then I download the source code in a refsrc/ subdirectory and patch it a little.

第一个问题是,在REFSRC_SRC中,我很想使用$(addprefix ...),而不是在每个.c文件前重复refsrc/.但这似乎不起作用,autoreconf有点抱怨.

First problem is that in REFSRC_SRC I would have loved to use a $(addprefix ...) instead of repeating refsrc/ in front of each .c file. But that doesn't seem to work and autoreconf complains a little.

故障详细信息(当从REFSRC_SRC =删除refsrc/前缀并在依赖项列表上使用$(addprefix $ {REFSRC_PATH}/,$ {REFSRC_SRC}时):

Failure details (when removing the refsrc/ prefix from REFSRC_SRC= and using $(addprefix ${REFSRC_PATH}/, ${REFSRC_SRC}) on the dependency list):

bash$ autoreconf -i
libgsmhr/Makefile.am:19: addprefix ${REFSRC_PATH}/, ${REFSRC_SRC}: non-POSIX variable name
libgsmhr/Makefile.am:19: (probably a GNU make extension)

(configure works fine)

bash$ make
...
make[2]: Entering directory `/tmp/ram/gapk.build/libgsmhr'
  CC     libgsmhr.lo
  CCLD   libgsmhr.la
make[2]: Leaving directory `/tmp/ram/gapk.build/libgsmhr'
...

(因此,如您所见,它根本不包含任何已下载的.c文件,甚至根本都没有下载它们.编译工作是因为libgsmhr.c是一个存根,它不使用那些文件中的符号

(So as you see it didn't include any of the downloaded .c files, didn't even download them at all. The compile works because libgsmhr.c is a stub that doesn't use the symbols in those file yet)

第二个问题是这个规则:

Second problem is this rule:

${REFSRC_PATH}/dtx.c: ${REFSRC_PATH}/.downloaded

我必须明确列出第一个文件(dtx.c),而不要使用通配符,例如:

I have to explicitely list the first file (dtx.c) instead of using a wildcard like:

${REFSRC_PATH}/%.c: ${REFSRC_PATH}/.downloaded

如果我尝试使用通配符,则autoreconf会抱怨并且它也不起作用...(模式与某种方式不匹配).

If I try to use the wildcard, then autoreconf complains and also it just doesn't work ... (pattern doesn't match somehow).

故障详细信息:

bash$ autoreconf -i
libgsmhr/Makefile.am:16: `%'-style pattern rules are a GNU make extension

(configure works fine)

bash$ make
...
make[2]: *** No rule to make target `refsrc/dtx.c', needed by `dtx.lo'.  Stop.
...

西尔万

推荐答案

您似乎正在编写GNUMake风格的makefile,但实际上正在运行其他版本的Make.如果不清楚autoreconf在调用什么,则可以在makefile中插入一条规则:

You seem to be writing a makefile in GNUMake style, but actually running some other version of Make. If it's not obvious what autoreconf is calling, you could insert a rule in the makefile:

dummy:
    @echo using $(MAKE)
    $(MAKE) -v

如果该理论被证明是正确的,则可以说服autoconf使用GNUMake,也可以为其使用的版本编写代码.

If this theory proves correct, you can either persuade autoconf to use GNUMake, or write for the version it's using.

这篇关于Makefile.am-手动目标先决条件+ addprefix?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆