xref: /freebsd/libexec/rc/rc.d/ldconfig (revision 9da3dfff9a07ff861719a001bad4d6ade71e31f6)
10696600cSBjoern A. Zeeb#!/bin/sh
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb# $FreeBSD$
40696600cSBjoern A. Zeeb#
50696600cSBjoern A. Zeeb
60696600cSBjoern A. Zeeb# PROVIDE: ldconfig
70696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS
80696600cSBjoern A. Zeeb# BEFORE:  DAEMON
90696600cSBjoern A. Zeeb
100696600cSBjoern A. Zeeb. /etc/rc.subr
110696600cSBjoern A. Zeeb
120696600cSBjoern A. Zeebname="ldconfig"
130696600cSBjoern A. Zeebdesc="Configure the shared library cache"
140696600cSBjoern A. Zeebldconfig_command="/sbin/ldconfig"
150696600cSBjoern A. Zeebstart_cmd="ldconfig_start"
160696600cSBjoern A. Zeebstop_cmd=":"
170696600cSBjoern A. Zeeb
180696600cSBjoern A. Zeebldconfig_start()
190696600cSBjoern A. Zeeb{
200696600cSBjoern A. Zeeb	local _files _ins
210696600cSBjoern A. Zeeb
220696600cSBjoern A. Zeeb	_ins=
230696600cSBjoern A. Zeeb	ldconfig=${ldconfig_command}
240696600cSBjoern A. Zeeb	checkyesno ldconfig_insecure && _ins="-i"
250696600cSBjoern A. Zeeb	if [ -x "${ldconfig_command}" ]; then
260696600cSBjoern A. Zeeb		_LDC="/lib /usr/lib"
270696600cSBjoern A. Zeeb		for i in ${ldconfig_local_dirs}; do
280696600cSBjoern A. Zeeb			if [ -d "${i}" ]; then
290696600cSBjoern A. Zeeb				_files=`find ${i} -type f`
300696600cSBjoern A. Zeeb				if [ -n "${_files}" ]; then
310696600cSBjoern A. Zeeb					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
320696600cSBjoern A. Zeeb				fi
330696600cSBjoern A. Zeeb			fi
340696600cSBjoern A. Zeeb		done
350696600cSBjoern A. Zeeb		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
360696600cSBjoern A. Zeeb			if [ -r "${i}" ]; then
370696600cSBjoern A. Zeeb				_LDC="${_LDC} ${i}"
380696600cSBjoern A. Zeeb			fi
390696600cSBjoern A. Zeeb		done
400696600cSBjoern A. Zeeb		check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
410696600cSBjoern A. Zeeb		${ldconfig} -elf ${_ins} ${_LDC}
420696600cSBjoern A. Zeeb
43*9da3dfffSMateusz Guzik		machine_arch=$(sysctl -n hw.machine_arch)
44*9da3dfffSMateusz Guzik
45*9da3dfffSMateusz Guzik		case ${machine_arch} in
460696600cSBjoern A. Zeeb		amd64|mips64|powerpc64)
470696600cSBjoern A. Zeeb			for i in ${ldconfig_local32_dirs}; do
480696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
490696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
500696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
510696600cSBjoern A. Zeeb						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
520696600cSBjoern A. Zeeb					fi
530696600cSBjoern A. Zeeb				fi
540696600cSBjoern A. Zeeb			done
550696600cSBjoern A. Zeeb			_LDC=""
560696600cSBjoern A. Zeeb			for i in ${ldconfig32_paths}; do
570696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
580696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
590696600cSBjoern A. Zeeb				fi
600696600cSBjoern A. Zeeb			done
610696600cSBjoern A. Zeeb			check_startmsgs &&
620696600cSBjoern A. Zeeb			    echo '32-bit compatibility ldconfig path:' ${_LDC}
630696600cSBjoern A. Zeeb			${ldconfig} -32 ${_ins} ${_LDC}
640696600cSBjoern A. Zeeb			;;
650696600cSBjoern A. Zeeb		esac
660696600cSBjoern A. Zeeb
67*9da3dfffSMateusz Guzik		case ${machine_arch} in
680696600cSBjoern A. Zeeb		armv[67])
690696600cSBjoern A. Zeeb			for i in ${ldconfig_localsoft_dirs}; do
700696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
710696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
720696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
730696600cSBjoern A. Zeeb						ldconfigsoft_paths="${ldconfigsoft_paths} `cat ${_files} | sort -u`"
740696600cSBjoern A. Zeeb					fi
750696600cSBjoern A. Zeeb				fi
760696600cSBjoern A. Zeeb			done
770696600cSBjoern A. Zeeb			_LDC=""
780696600cSBjoern A. Zeeb			for i in ${ldconfigsoft_paths}; do
790696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
800696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
810696600cSBjoern A. Zeeb				fi
820696600cSBjoern A. Zeeb			done
830696600cSBjoern A. Zeeb			check_startmsgs &&
840696600cSBjoern A. Zeeb			    echo 'Soft Float compatibility ldconfig path:' ${_LDC}
850696600cSBjoern A. Zeeb			${ldconfig} -soft ${_ins} ${_LDC}
860696600cSBjoern A. Zeeb			;;
870696600cSBjoern A. Zeeb		esac
880696600cSBjoern A. Zeeb
890696600cSBjoern A. Zeeb		# Legacy aout support for i386 only
90*9da3dfffSMateusz Guzik		case ${machine_arch} in
910696600cSBjoern A. Zeeb		i386)
920696600cSBjoern A. Zeeb			# Default the a.out ldconfig path.
930696600cSBjoern A. Zeeb			: ${ldconfig_paths_aout=${ldconfig_paths}}
940696600cSBjoern A. Zeeb			_LDC=""
950696600cSBjoern A. Zeeb			for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do
960696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
970696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
980696600cSBjoern A. Zeeb				fi
990696600cSBjoern A. Zeeb			done
1000696600cSBjoern A. Zeeb			check_startmsgs && echo 'a.out ldconfig path:' ${_LDC}
1010696600cSBjoern A. Zeeb			${ldconfig} -aout ${_ins} ${_LDC}
1020696600cSBjoern A. Zeeb			;;
1030696600cSBjoern A. Zeeb		esac
1040696600cSBjoern A. Zeeb	fi
1050696600cSBjoern A. Zeeb}
1060696600cSBjoern A. Zeeb
1070696600cSBjoern A. Zeebload_rc_config $name
1080696600cSBjoern A. Zeebrun_rc_command "$1"
109