I'm assuming that input.txt
is a source file that is distributed, that you do not want to distribute generated.c
(i.e., it must be built by each user), and that generator
is a program built by your package too.
EXTRA_DIST = input.txt
bin_PROGRAMS = prog
noinst_PROGRAMS = generator
# Source files for the generator
generator_SOURCES = generator.c ...
# Source files for prog
prog_SOURCES = prog.c ...
nodist_prog_SOURCES = generated.c
# generated.c is a built source that must be cleaned
CLEANFILES = generated.c
# Build rule for generated.c
generated.c: $(srcdir)/input.txt generator$(EXEEXT)
./generator$(EXEEXT) $(srcdir)/input.txt
In some situations, like when generating header files, it is important to generate the file before the rest of the sources are compiled, so it can be included. In that case you should also list the generated file in the variable BUILT_SOURCES
(The Automake manual has many example in its Built sources section. In the above case it is not necessary.
EDIT: I have fixed the above Makefile.am
example to declare generator
as a non-installed program.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…