【问题标题】:Create data file by Automake通过 Automake 创建数据文件
【发布时间】:2019-11-18 19:35:04
【问题描述】:

我希望 Automake 在我的爱好项目中创建一个 .img 文件(在虚拟机中测试编译后的程序)。

我可以使用Automake编译程序,例如:

noinst_PROGRAMS = loader.elf

loader_elf_SOURCES = init.s console.c disk.c elf.c ext2.c fat.c lib.c loader.c multiboot.c
loader_elf_LDFLAGS = $(AM_LDFLAGS) -T $(srcdir)/loader.ld
loader_elf_LDADD = $(LDADD) -lgcc

但它不适用于数据文件:

noinst_DATA = x.img
x_img_DEPENDENCIES = loader.elf
x_img_LINK = makeimg.sh

当我执行 autoreconf -i 时,我会收到以下错误消息:

automake: warnings are treated as errors
arch/i386/emulator/Makefile.am:14: warning: variable 'x_img_DEPENDENCIES' is defined but no program or
arch/i386/emulator/Makefile.am:14: library has 'x_img' as canonical name (possible typo)
autoreconf: automake failed with exit status: 1

我正在尝试将我的 Makefile 转换为 Makefile.am。在 Makefile 中很简单:

x.img: loader.elf
    makeimg.sh $@ $<

我在 gnu ftp 页面上研究了 Automake 手册,我认为不可能在 Automake 中将源或依赖项添加到 DATA 文件中。我该怎么办?我应该将 .img 文件放入 PROGRAMS 主文件而不是 DATA 文件中吗?

我正在使用 Automake 1.16.1 和 Autoconf 2.69(如果重要的话)。

【问题讨论】:

    标签: automake


    【解决方案1】:

    只需将此添加到Makefile.am

    noinst_PROGRAMS = loader.elf
    loader_elf_SOURCES = ...
    
    noinst_DATA = x.img
    x.img: loader.elf
        makeimg.sh x.img loader.elf
    

    (我已将$@$&lt; 更改为使用显式名称,因为make 的某些版本在由显式文件名定义的规则中与$@$&lt; 存在困难,而不是模式或后缀。)

    【讨论】:

      猜你喜欢
      • 2012-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2021-10-28
      相关资源
      最近更新 更多