Fri Apr 27 20:16:36 2018 UTC ()
mk/tools/create.mk: sort tools before creating the wrapper targets

The TOOLS_CREATE variable is only ever appended to, without checking for
duplicates. In some rare cases, this produces warnings about
doubly-defined make targets. An example is adding USE_TOOLS+=strip to
pkgtools/pkglint:

".../mk/tools/create.mk" line 149: warning:
    duplicate script for target ".../work/.tools/bin/strip" ignored

The above line number 149 is zero-based, which in reality means the
duplicate definition is in line 150.


(rillig)
diff -r1.5 -r1.6 pkgsrc/mk/tools/create.mk

cvs diff -r1.5 -r1.6 pkgsrc/mk/tools/create.mk (expand / switch to unified diff)

--- pkgsrc/mk/tools/create.mk 2013/02/27 12:09:39 1.5
+++ pkgsrc/mk/tools/create.mk 2018/04/27 20:16:36 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: create.mk,v 1.5 2013/02/27 12:09:39 obache Exp $ 1# $NetBSD: create.mk,v 1.6 2018/04/27 20:16:36 rillig Exp $
2# 2#
3# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 3# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
@@ -129,27 +129,27 @@ MKDIR?= mkdir -p @@ -129,27 +129,27 @@ MKDIR?= mkdir -p
129 129
130# If the command line was defined, then we create a wrapper. 130# If the command line was defined, then we create a wrapper.
131# If the real command isn't a full path, then we create a wrapper. 131# If the real command isn't a full path, then we create a wrapper.
132# If some command arguments were given, then we create a wrapper. 132# If some command arguments were given, then we create a wrapper.
133# Otherwise, we create a symlink. 133# Otherwise, we create a symlink.
134# 134#
135# By default, the tool in ${TOOLS_DIR} will be in the "bin" directory 135# By default, the tool in ${TOOLS_DIR} will be in the "bin" directory
136# and will be called <tool>. 136# and will be called <tool>.
137# 137#
138# The default wrapper script will invoke the real command, followed 138# The default wrapper script will invoke the real command, followed
139# by any arguments specified in TOOLS_ARGS.*, followed by any 139# by any arguments specified in TOOLS_ARGS.*, followed by any
140# command-line arguments passed to the wrapper script. 140# command-line arguments passed to the wrapper script.
141# 141#
142.for _t_ in ${TOOLS_CREATE} 142.for _t_ in ${TOOLS_CREATE:O:u}
143TOOLS_CMD.${_t_}?= ${TOOLS_DIR}/bin/${_t_} 143TOOLS_CMD.${_t_}?= ${TOOLS_DIR}/bin/${_t_}
144TOOLS_PATH.${_t_}?= ${FALSE} 144TOOLS_PATH.${_t_}?= ${FALSE}
145TOOLS_SCRIPT_DFLT.${_t_}= \ 145TOOLS_SCRIPT_DFLT.${_t_}= \
146 ${TOOLS_PATH.${_t_}} ${TOOLS_ARGS.${_t_}} "$$@" 146 ${TOOLS_PATH.${_t_}} ${TOOLS_ARGS.${_t_}} "$$@"
147 147
148override-tools: ${TOOLS_CMD.${_t_}} 148override-tools: ${TOOLS_CMD.${_t_}}
149 149
150${TOOLS_CMD.${_t_}}: 150${TOOLS_CMD.${_t_}}:
151 ${RUN} ${TEST} -d ${.TARGET:H:Q} || ${MKDIR} ${.TARGET:H:Q} 151 ${RUN} ${TEST} -d ${.TARGET:H:Q} || ${MKDIR} ${.TARGET:H:Q}
152 ${RUN} \ 152 ${RUN} \
153 if ${TEST} -n ${TOOLS_SCRIPT.${_t_}:Q}""; then \ 153 if ${TEST} -n ${TOOLS_SCRIPT.${_t_}:Q}""; then \
154 create=wrapper; \ 154 create=wrapper; \
155 script=${TOOLS_SCRIPT.${_t_}:Q}; \ 155 script=${TOOLS_SCRIPT.${_t_}:Q}; \