Search code examples
gnu-makeautotoolsautomake

I need a Makefile.am rule to update include file


I have a Makefile.am that looks something like this:

bin_PROGRAMS = prog

AM_CFLAGS = $(prog_CFLAGS)

prog_SOURCES = \
    data.h \
    src1.c \
    src2.c \
    ...
    src30.c

The data.h file is sometimes updated by a update_data.pl perl script depending on certain conditions. I tried adding this to the end of Makefile.am:

.PHONY: data.h
data.h:
    perl update_data.pl

but the script never runs. I'm sure I'm missing something simple, but I just can't figure it out.


Solution

  • This is how I finally got it to work. Using $(shell) may not be the best way, but it works.

    bin_PROGRAMS = prog
    
    AM_CFLAGS = $(prog_CFLAGS)
    
    update_data := $(shell ./update_data.pl > /dev/tty)
    
    prog_SOURCES = \
        data.h \
        src1.c \
        src2.c \
        ...
        src30.c