0
votes

I want Automake to create an .img file in my hobby project (to test the compiled program in a virtual machine).

I can use Automake to compile programs, eg.:

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

But it doesn't work for data files:

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

When I execute autoreconf -i then I get this error message:

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

I'm trying to turn my Makefile into Makefile.am. It was as simle in Makefile as:

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

I studied the Automake manual at the gnu ftp page, and I think there is no possibility to add sources or dependencies to a DATA file in Automake. What should I do? Should I put the .img file into the PROGRAMS primary instead of DATA?

I'm using Automake 1.16.1 and Autoconf 2.69 (if that matters).

1

1 Answers

1
votes

Simply add this to the Makefile.am:

noinst_PROGRAMS = loader.elf
loader_elf_SOURCES = ...

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

(I have changed the $@ and $< to use the explicit names as there are apparently some versions of make which have difficulties with $@ and $< in rules which are defined by explicit file names, instead of by patterns or suffixes.)