Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always make shared library IDs absolute on Darwin #70

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions mk/check/check-shlibs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
#
# Default value: yes
#
# CHECK_SHLIBS_AUTOFIX
# If set to yes, there is an attempt to fix errors automatically.
# Currently only works for Mach-O.
#
# Possible values: yes, no.
#

_VARGROUPS+= check-shlibs
_USER_VARS.check-shlibs= CHECK_SHLIBS
_PKG_VARS.check-shlibs= CHECK_SHLIBS_SUPPORTED
_PKG_VARS.check-shlibs= CHECK_SHLIBS_SUPPORTED CHECK_SHLIBS_AUTOFIX

.if ${PKG_DEVELOPER:Uno} != "no"
CHECK_SHLIBS?= yes
Expand All @@ -44,6 +50,7 @@ CHECK_SHLIBS?= no
.endif
CHECK_SHLIBS_SUPPORTED?= yes
CHECK_SHLIBS_SKIP?= # none
CHECK_SHLIBS_AUTOFIX?= no

# All binaries and shared libraries.
_CHECK_SHLIBS_ERE= (bin/|sbin/|libexec/|\.(dylib|sl|so)$$|lib/lib.*\.(dylib|sl|so))
Expand Down Expand Up @@ -79,7 +86,7 @@ CHECK_SHLIBS_NATIVE_ENV+= CHECK_SHLIBS_BLACKLIST=${CHECK_SHLIBS_BLACKLIST:Q}
. endif

privileged-install-hook: _check-shlibs
_check-shlibs: error-check .PHONY
_check-shlibs: error-check _check-shlibs-autofix .PHONY
@${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"
${RUN} rm -f ${ERROR_DIR}/${.TARGET}
${RUN} \
Expand All @@ -95,3 +102,25 @@ _check-shlibs: error-check .PHONY
done | \
${PKGSRC_SETENV} ${CHECK_SHLIBS_NATIVE_ENV} ${AWK} -f ${CHECK_SHLIBS_NATIVE} > ${ERROR_DIR}/${.TARGET}
.endif

.if !empty(CHECK_SHLIBS_AUTOFIX:M[Yy][Ee][Ss]) && ${OBJECT_FMT} == "Mach-O"
privileged-install-hook: _check-shlibs-autofix
_check-shlibs-autofix: error-check .PHONY
@${STEP_MSG} "Attempting to fix missing run-time search paths in ${PKGNAME}"
${RUN} rm -f ${ERROR_DIR}/${.TARGET}
${RUN}
cd ${DESTDIR:Q}${PREFIX:Q}; \
${_CHECK_SHLIBS_FILELIST_CMD} | \
${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} | \
while read file; do \
case "$$file" in \
${CHECK_SHLIBS_SKIP:@p@${p}) continue ;;@} \
*) ;; \
esac; \
install_name_tool -id ${PREFIX:Q}"/""$$file" "$$file" >${WARNING_DIR}/${.TARGET} 2>&1 \
done \
.else
_check-shlibs-autofix: .PHONY
@${DO_NADA}
.endif

7 changes: 7 additions & 0 deletions mk/platform/Darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,10 @@ WRAPPER_BIN_SH?= /bin/ksh
.if ${OS_VERSION:R} < 11
_OPSYS_MISSING_FEATURES+= strnlen
.endif

# This option enables the use of install_name_tool(1).
_WRAP_EXTRA_ARGS.LD+= -headerpad_max_install_names
CWRAPPERS_APPEND.ld+= -headerpad_max_install_names

# Enables _check-shlibs-autofix.
CHECK_SHLIBS_AUTOFIX?= yes