diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2021-06-21 13:58:01 +0000 |
---|---|---|
committer | Alex Richardson <arichardson@FreeBSD.org> | 2021-06-21 15:13:54 +0000 |
commit | ab0c68ba4ae37cb83d15e64ce2a33375135ae750 (patch) | |
tree | aaf24cac7eb35b087d02bbba3f332fb7731e1de5 | |
parent | 6fa0b2893f989f1851f3280e3f2e272e887cbce9 (diff) | |
download | src-ab0c68ba4ae37cb83d15e64ce2a33375135ae750.tar.gz src-ab0c68ba4ae37cb83d15e64ce2a33375135ae750.zip |
Emit an error when we seen absolute paths to .o files
This is usually an error caused by using an absolute path in SRCS. This
happened to me in 83c20b8a2da0 due to changing LDADD to SRCS.
I did not notice that this had created a .o file inside the source tree
since .gitignore contains "*.o" and therefore git did not report any
changes.
Adding this warning message to bsd.lib.mk/bsd.prog.mk should prevent
issues like this in the future.
There was exactly one case of an absolute OBJS path in the current source
tree but that was removed in e713d3a013882893fceb84dd14569052271497a9.
Reviewed By: emaste (earlier version), imp
Differential Revision: https://reviews.freebsd.org/D28467
-rw-r--r-- | share/mk/bsd.dep.mk | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index a63b9e46deca..b8dc59d52543 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -192,6 +192,17 @@ DEPEND_MP?= -MP # avoid collisions. DEPEND_FILTER= C,/,_,g .if !empty(OBJS) +.if !defined(_ALLOW_ABSOLUTE_OBJ_PATH) && ${OBJS:M/*} +# Absolute paths to OBJS should be an error inside ${SRCTOP}, but some users +# might be relying on this feature, so add an opt-out mechanism. +.if defined(SRCTOP) && ${OBJS:M${SRCTOP}*} +.error "$$OBJS inside $$SRCTOP not allowed: ${OBJS:M${SRCTOP}*}" +.elif ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*} +.error "$$OBJS absolute path not allowed: ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*}. \ + If this is intended, add them to _ABSOLUTE_PATH_OBJS to silence this error\ + or define _ALLOW_ABSOLUTE_OBJ_PATH to disable this diagnostic." +.endif +.endif DEPENDOBJS+= ${OBJS} .else DEPENDSRCS+= ${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc} |