Subject: Makefile structure in htdocs
To: None <netbsd-docs@NetBSD.org>
From: Roland Illig <rillig@NetBSD.org>
List: netbsd-docs
Date: 10/09/2005 13:50:40
Hi,

the way the Makefiles are structured in htdocs/ seems a little weird to 
me. For example, I have discovered that de/Ports/i386/Makefile does not 
include ../../../Makefile.inc, but Ports/i386/Makefile does.

I would like to change the structure of the Makefiles, so that they look 
like:

# $NetBSD$
#

XML_DOCS=   foo.xml

.include "Makefile.inc"
# EOF

In leaf directories, where there is no "Makefile.inc", it should be 
replaced with "../Makefile.inc". The "Makefile.inc" files should all 
look like:

# $NetBSD$
#

SOME_VAR?=    foo bar
OTHER_VAR?=   baz

.include "../Makefile.inc"
# EOF

The top-level "Makefile.inc" should then include 
"${WEB_PREFIX}/share/mk/web.site.mk".

That way we can make sure that the toplevel "Makefile.inc" is included 
in each subdirectory. Another simplification would be that the top-level 
"Makefile.inc" has the following code:

.if exists(robots.txt)
WEB_PREFIX?= ${.CURDIR}
.elif exists(../robots.txt)
WEB_PREFIX?= ${.CURDIR}/..
.elif exists(../../robots.txt)
WEB_PREFIX?= ${.CURDIR}/../..
.elif exists(../../../robots.txt)
WEB_PREFIX?= ${.CURDIR}/../../..
.elif exists(../../../../robots.txt)
WEB_PREFIX?= ${.CURDIR}/../../../..
.endif

This saves one line in every subdirectory Makefile.

Roland