Subject: [RFC] framework for platform tools
To: None <tech-pkg@netbsd.org>
From: Roland Illig <roland.illig@gmx.de>
List: tech-pkg
Date: 04/07/2005 12:27:04
This is a multi-part message in MIME format.
--------------000601050503050508080502
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi all,
I tried to port pkgsrc to HP-UX some days ago. One thing I really didn't
like about it was creating the file mk/platform/HP-UX.mk. So I wrote the
attached file, which is meant to be included at the end of a mk/platform
file. I could shorten the NetBSD.mk file by about 50 lines.
I already discussed the framework with wiz, and these are some results
of it:
Pros:
* only the "non-standard" tools need to be mentioned
in the ${OPSYS}.mk file.
* new tools (like diff(1), cvs(1)) can be added without
touching {NUMBER_OF_PLATFORM} different files.
* There's a definite, single list for the list of platform tools
(lines 26..46)
* Each tool has a ${TOOL_FLAGS} variable, which makes the tools
consistent. To fully exploit this, the ${TOOL_FLAGS} must be used by
the rest of the pkgsrc infrastructure, but it is already done
partly.
Cons:
* heavier file system usage (about 120 x stat(2))
Notes:
* I could not measure any timing differences between the old and the
new version, so perhaps the Con argument is bogus.
Roland
--------------000601050503050508080502
Content-Type: text/plain;
name="platform.default.mk"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="platform.default.mk"
# $NetBSD$
#
# Default tool definitions for all operating systems.
#
# For each program _t_ in ${_PLATFORM_TOOLS}, a variable named ${_t_:tu}
# (the uppercase name) is defined to the first program that is found in
# ${_PLATFORM_EXECDIRS}, and a variable ${_t_:tu}_FLAGS is defined to the
# empty string.
#
# For some of the tool names, there already exist environment variables
# of the same name (for example GZIP). Therefore these tools are defined
# using the variable ${_t_:tu}_CMD.
#
# Examples:
# After inclusion of this file, the variable MKDIR points to a
# mkdir(1) tool, and MKDIR_FLAGS is empty, unless it had been
# defined before. Similarly, GZIP_CMD points to a gzip(1) tool,
# and GZIP_FLAGS is also empty, unless it had been defined before.
#
.if !defined(_MK_PLATFORM_DEFAULT_MK)
_MK_PLATFORM_DEFAULT_MK= # defined
_PLATFORM_EXECDIRS?= /bin /usr/bin /sbin /usr/sbin
_PLATFORM_TOOLS+= awk
_PLATFORM_TOOLS+= basename
_PLATFORM_TOOLS+= cat chmod chown chgrp cmp cp cpp cut
_PLATFORM_TOOLS+= date dirname
_PLATFORM_TOOLS+= echo echo_n egrep env expr
_PLATFORM_TOOLS+= false fgrep find
_PLATFORM_TOOLS+= gmake grep groupadd gtar gzcat
_PLATFORM_TOOLS+= head
_PLATFORM_TOOLS+= id
_PLATFORM_TOOLS+= ldconfig ln ls
_PLATFORM_TOOLS+= m4 mkdir mtree mv
_PLATFORM_TOOLS+= nice
_PLATFORM_TOOLS+= patch pax perl5 ps
_PLATFORM_TOOLS+= rm rmdir rsh
_PLATFORM_TOOLS+= sed sh shlock sort su
_PLATFORM_TOOLS+= tail tar tee test touch tr true tsort type
_PLATFORM_TOOLS+= useradd
_PLATFORM_TOOLS+= wc
_PLATFORM_TOOLS+= xargs
_PLATFORM_CMD_TOOLS+= file gunzip gzip hostname mail pwd
#
# Define TOOL and TOOL_FLAGS for most tools.
# If the tool cannot be found, fall back to the tool name without a path.
#
.for _t_ in ${_PLATFORM_TOOLS}
. for _d_ in ${_PLATFORM_EXECDIRS}
. if exists(${_d_}/${_t_})
${_t_:tu}?= ${_d_}/${_t_}
${_t_:tu}_FLAGS?= # empty
. endif
. endfor
${_t_:tu}?= ${_t_}
.endfor
#
# Define TOOL_CMD and TOOL_FLAGS for some other tools.
# If the tool cannot be found, fall back to the tool name without a path.
#
.for _t_ in ${_PLATFORM_CMD_TOOLS}
. for _d_ in ${_PLATFORM_EXECDIRS}
. if exists(${_d_}/${_t_})
${_t_:tu}_CMD?= ${_d_}/${_t_}
${_t_:tu}_FLAGS?= # empty
. endif
. endfor
${_t_:tu}_CMD?= ${_t_}
.endfor
.endif
--------------000601050503050508080502--