Re: [dev] Automatic C header dependency tracking for the redo build-system

From: David Demelier <markand_AT_malikania.fr>
Date: Tue, 07 Jun 2022 15:21:49 +0200

On Mon, 2022-06-06 at 15:13 +0200, Georg Lehner wrote:
> Hi,
>
> The topic of header dependency tracking is already addressed since
> the
> inception of redo by DJB.

About C header dependencies, you can actually do it using POSIX Make
(in the next version, the -include statement is not available yet but
widely supported).

SRCS= foo.c bar.c baz.c
OBJS= ${SRCS:.c=.o}
DEPS= ${SRCS:.c=.d}

.c.o:
    ${CC} -o $_AT_ -MMD -c $< ${CFLAGS}

all: hello

-include ${DEPS}

hello: ${OBJS}
    ${CC} -o $_AT_ ${OBJS}

And you're done. On a fresh directory the -include ${DEPS} will
silently fail and rebuild everything. Then .d files will be generated
and touching any file will rebuild exactly what should be.

The only non portable thing is the -MMD option (gcc and clang support
though).

HTH

-- 
David
Received on Tue Jun 07 2022 - 15:21:49 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 07 2022 - 15:36:08 CEST