git: mkdep(1): Fix target conflicts by prepending relative subdirs
Aaron LI
aly at crater.dragonflybsd.org
Fri Aug 28 00:23:02 PDT 2026
commit dec8bf51d1d328f09ffaaf9e4c5a458a346ef590
Author: Aaron LI <aly at aaronly.me>
Date: Mon Aug 24 13:21:08 2026 +0800
mkdep(1): Fix target conflicts by prepending relative subdirs
* mkdep(1) calls cc/c++ to generate the dependency lists for the source
files. However, the targets in the output are bare names (e.g.,
`example.o`), so multiple sources share a file name in different
subdirectories have the same targets, which can cause build failures
or broken output.
To fix this problem, introduce the '-S srcdir' option to specify the
root directory of the source files on the command line, and use it to
determine the relative subdirectories that are prepended to each
target. As a result, the targets and their sources are 1:1 correlated
and the duplicate targets are avoided.
* Further add a check to catch duplicate targets and fail the generation
if there are any.
* Introduce MKDEPSRCDIR in <bsd.dep.mk> to set the new option for
mkdep(1).
* Fix depend generation and building for gnu/usr.bin/gmp.
- Set MKDEPSRCDIR for mkdep(1) to fix duplicate targets in the depend
file.
- Fix the explicit rule to use ${.IMPSRC} instead of ${.ALLSRC},
because the latter now contains all the dependencies (e.g., various
headers) that are defined in the generated .depend file.
We were lucky that the erroneous .depend didn't cause real harm before,
because the duplicate targets were not actually used. For example,
there were duplicate 'add.o' targets for 'mpf/add.c',
'mpn/generic/add.c', and 'mpz/add.c', but there is no root-level
'add.c', so all the generated 'add.o' targets were actually ignored by
make.
This feature is also required by the forthcoming new GDB.
Summary of changes:
gnu/usr.bin/gmp/Makefile | 4 ++-
share/mk/bsd.dep.mk | 13 +++++++-
usr.bin/mkdep/mkdep.1 | 71 +++++++++++++++++++++++++++++++++--------
usr.bin/mkdep/mkdep.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 154 insertions(+), 17 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/dec8bf51d1d328f09ffaaf9e4c5a458a346ef590
--
DragonFly BSD source repository
More information about the Commits
mailing list