html.mk

static html creation framework using make(1) and cpp(1)
Log | Files | Refs | README | LICENSE

commit 1432ba5d17e68b1b822a7a2f44f15ccc13679c20
parent d666891675d13f2130f3dd295ac8e0c9d667d157
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Fri, 30 Jul 2021 01:09:12 +0000

mk: make depend target better

Use `.d' files instead of `.depend' to match other dependency generation tools.

Instead of concatenating all `.d' files into a single `.depend' that make
reads automatically, explicitly include for `.d' files for any files in SRCS.

Diffstat:
Mbsd.html.mk | 24+++++++++++++-----------
Mt/dep_simple.t | 8+++-----
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bsd.html.mk b/bsd.html.mk @@ -31,26 +31,28 @@ all: ${SRCS:S/.in$/.html/} _SUBDIRUSE .in.html: cpp ${CPPFLAGS} -I${.OBJDIR} -P -o ${.OBJDIR}/$@ $< +# +# Main dependency target. Create `.d' files containing deps from `.in' files. +# +depend: ${SRCS:.in=.d} _SUBDIRUSE # # Use the C preprocessor to generate dependency files from input source -# files. Respects the CPPFLAGS variable. +# files. Respect the CPPFLAGS variable. # -# -I: XXX # -M: generate Makefile dependency target instead of preprocessing # -MG: assume missing files are generated files -# -MF: write dependency list to .depend file where make will look for it +# -MF: write dependency list to .d file where we will include it # -MT: override target name # -.SUFFIXES: .depend -.in.depend: - cpp ${CPPFLAGS} -M -MG -MF $@ -MT ${@:.depend=.html} $< +.SUFFIXES: .d +.in.d: + cpp ${CPPFLAGS} -M -MG -MF $@ -MT ${@:.d=.html} $< -# Create the final `.depend' file from all of the individual dependency files. -.if !empty(SRCS) -depend: ${SRCS:.in=.depend} _SUBDIRUSE - cat ${.ALLSRC} > .depend -.endif +# Silently include any dependency files found. +.for s in ${SRCS} + -include ${s:.in=.d} +.endfor # diff --git a/t/dep_simple.t b/t/dep_simple.t @@ -4,7 +4,7 @@ use Modern::Perl; use Test::File; use Test::Cmd; -use Test::More tests => 19; +use Test::More tests => 18; my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' ); @@ -20,14 +20,12 @@ EOF # $cmd->run( args => 'depend', chdir => $cmd->curdir ); -my $o = "cpp .* -MF index.depend -MT index.html index.in"; +my $o = "cpp .* -MF index.d -MT index.html index.in"; like( $cmd->stdout, qr{$o}, 'make depend stdout' ); is( $cmd->stderr, '', 'make depend stderr' ); is( $? >> 8, 0, 'make depend exit status' ); -# XXX: index.depend and .depend should have identical contents. -file_exists_ok( $cmd->workpath . '/index.depend' ); -file_exists_ok( $cmd->workpath . '/.depend' ); +file_exists_ok( $cmd->workpath . '/index.d' ); # # 2) `make'