Makefile.am - 手动目标先决条件 +添加前缀?

发布于 2024-10-01 15:43:36 字数 2202 浏览 8 评论 0原文

我有一个自动工具项目,其中部分源代码是从网络动态下载的(因为IP权利阻止直接重新分发)然后构建。

我有一个可以运行的 Makefile.am,但我对其某些方面不满意。

就是这样:

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/ 子目录中并对其进行一些修补。

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

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

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 是一个尚未使用这些文件中的符号的存根)

第二个问题是这条规则:

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

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

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

如果我尝试使用通配符,那么 autoreconf 会抱怨,而且它也不起作用......(模式以某种方式不匹配)。

失败细节:

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.
...

西尔万

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.

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

Here it is:

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}

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

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.

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'
...

(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

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

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

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

Failure detail:

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.
...

Sylvain

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最舍不得你 2024-10-08 15:43:36

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

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

如果这个理论被证明是正确的,您可以说服 autoconf 使用 GNUMake,或者为它正在使用的版本编写。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文