c - gengetopt 和 Automake

标签 c autotools automake getopt

我正在尝试将 cmdline.c 文件的生成(来自 gengetopt 的默认值)包含在我的 Makefile.am 文件中。

该文件当前的内容如下:

bin_PROGRAMS = myprog

myprog_SOURCES = main.c cmdline.c
myprog_DEPENDENCIES = gen_cmdline $(myprog_SOURCES) # somewhere I read that setting DEPENDENCIES inhibits automake from calculating those

gen_cmdline:
    gengetopt < myprog.ggo

但是,如果我仅修改 myprog.ggo,则 cmdline.c 及其所有依赖项将不会重新编译。我在这里缺少什么?

最佳答案

gen_cmdline 是 .PHONY 目标吗?如果 gengetopt 创建一个名为 cmdline.c 的文件,那么您的 Makefile.am 可能应如下所示:

bin_PROGRAMS = myprog

myprog_SOURCES = main.c cmdline.c
BUILT_SOURCES = cmdline.c
cmdline.c: myprog.ggo
    gengetopt < $(srcdir)/myprog.ggo

关于c - gengetopt 和 Automake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13883202/

相关文章:

c - 如何将二维矩阵作为参数传递给函数?

c - C 中的指针数组排序有意外的输出

c - 将数组与结构一起使用

homebrew - 运行 "could not symlink"时如何修复 `brew link automake` 错误?

autotools - 如何确保将 check_SCRIPTS 添加到发行版中?

c - C函数中是否可以有变量输入

c++ - 与 OpenMP、MPI 和 CUDA 链接时的 Autotools 问题

autotools - 附加到 AM_CXXFLAGS 不起作用

linux - 设置环境变量并在自动工具构建中启用核心转储

c++ - "configure"脚本如何检测我的系统是否支持某些头文件或 cpp 功能?