Index: share/mk/bsd.links.mk =================================================================== --- share/mk/bsd.links.mk +++ share/mk/bsd.links.mk @@ -13,10 +13,27 @@ afterinstall: _installlinks .ORDER: realinstall _installlinks +# If the source and destination file are the same file (e.g. Mail/mail on a +# case-insensitive file-system) we have to pass -S to install(1) to avoid +# deleting the source file. _installlinks: .for s t in ${LINKS} +.if ${s:tl} == ${t:tl} + if test "${DESTDIR}${t}" -ef "${DESTDIR}${s}"; then \ + echo "Note: requested hard link from ${t} to ${s} on case-insensitive file system."; \ + fi + ${INSTALL_LINK} -S ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t} +.else ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t} +.endif .endfor .for s t in ${SYMLINKS} +.if ${s:tl} == ${t:tl} + if test "${DESTDIR}${t}" -ef "${DESTDIR}${s}"; then \ + echo "Note: requested symlink from ${t} to ${s} on case-insensitive file system."; \ + fi + ${INSTALL_SYMLINK} -S ${TAG_ARGS} ${s} ${DESTDIR}${t} +.else ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}${t} +.endif .endfor Index: share/mk/bsd.man.mk =================================================================== --- share/mk/bsd.man.mk +++ share/mk/bsd.man.mk @@ -226,8 +226,20 @@ .endif # ${MK_MANCOMPRESS} == "no" .endif .for l t in ${_MANLINKS} +.if ${l:tl} == ${t:tl} + # If the source and destination file are the same file (e.g. Mail/mail + # on a case-insensitive file-system) we have to pass -S to install to avoid + # deleting the source file. + if test "${DESTDIR}${l}${ZEXT}" -ef "${DESTDIR}${t}${ZEXT}"; then \ + echo "Note: requested man link from ${t} to ${s} on case-insensitive file system."; \ + else \ + rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ + fi + ${INSTALL_MANLINK} -S ${TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} +.else rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ ${INSTALL_MANLINK} ${TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} +.endif .endfor manlint: