xref: /freebsd/libexec/rc/rc.d/ldconfig (revision 0696600c41600d80bcd993bfd8e675d0ae6951fe)
1*0696600cSBjoern A. Zeeb#!/bin/sh
2*0696600cSBjoern A. Zeeb#
3*0696600cSBjoern A. Zeeb# $FreeBSD$
4*0696600cSBjoern A. Zeeb#
5*0696600cSBjoern A. Zeeb
6*0696600cSBjoern A. Zeeb# PROVIDE: ldconfig
7*0696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS
8*0696600cSBjoern A. Zeeb# BEFORE:  DAEMON
9*0696600cSBjoern A. Zeeb
10*0696600cSBjoern A. Zeeb. /etc/rc.subr
11*0696600cSBjoern A. Zeeb
12*0696600cSBjoern A. Zeebname="ldconfig"
13*0696600cSBjoern A. Zeebdesc="Configure the shared library cache"
14*0696600cSBjoern A. Zeebldconfig_command="/sbin/ldconfig"
15*0696600cSBjoern A. Zeebstart_cmd="ldconfig_start"
16*0696600cSBjoern A. Zeebstop_cmd=":"
17*0696600cSBjoern A. Zeeb
18*0696600cSBjoern A. Zeebldconfig_start()
19*0696600cSBjoern A. Zeeb{
20*0696600cSBjoern A. Zeeb	local _files _ins
21*0696600cSBjoern A. Zeeb
22*0696600cSBjoern A. Zeeb	_ins=
23*0696600cSBjoern A. Zeeb	ldconfig=${ldconfig_command}
24*0696600cSBjoern A. Zeeb	checkyesno ldconfig_insecure && _ins="-i"
25*0696600cSBjoern A. Zeeb	if [ -x "${ldconfig_command}" ]; then
26*0696600cSBjoern A. Zeeb		_LDC="/lib /usr/lib"
27*0696600cSBjoern A. Zeeb		for i in ${ldconfig_local_dirs}; do
28*0696600cSBjoern A. Zeeb			if [ -d "${i}" ]; then
29*0696600cSBjoern A. Zeeb				_files=`find ${i} -type f`
30*0696600cSBjoern A. Zeeb				if [ -n "${_files}" ]; then
31*0696600cSBjoern A. Zeeb					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
32*0696600cSBjoern A. Zeeb				fi
33*0696600cSBjoern A. Zeeb			fi
34*0696600cSBjoern A. Zeeb		done
35*0696600cSBjoern A. Zeeb		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
36*0696600cSBjoern A. Zeeb			if [ -r "${i}" ]; then
37*0696600cSBjoern A. Zeeb				_LDC="${_LDC} ${i}"
38*0696600cSBjoern A. Zeeb			fi
39*0696600cSBjoern A. Zeeb		done
40*0696600cSBjoern A. Zeeb		check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
41*0696600cSBjoern A. Zeeb		${ldconfig} -elf ${_ins} ${_LDC}
42*0696600cSBjoern A. Zeeb
43*0696600cSBjoern A. Zeeb		case `sysctl -n hw.machine_arch` in
44*0696600cSBjoern A. Zeeb		amd64|mips64|powerpc64)
45*0696600cSBjoern A. Zeeb			for i in ${ldconfig_local32_dirs}; do
46*0696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
47*0696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
48*0696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
49*0696600cSBjoern A. Zeeb						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
50*0696600cSBjoern A. Zeeb					fi
51*0696600cSBjoern A. Zeeb				fi
52*0696600cSBjoern A. Zeeb			done
53*0696600cSBjoern A. Zeeb			_LDC=""
54*0696600cSBjoern A. Zeeb			for i in ${ldconfig32_paths}; do
55*0696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
56*0696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
57*0696600cSBjoern A. Zeeb				fi
58*0696600cSBjoern A. Zeeb			done
59*0696600cSBjoern A. Zeeb			check_startmsgs &&
60*0696600cSBjoern A. Zeeb			    echo '32-bit compatibility ldconfig path:' ${_LDC}
61*0696600cSBjoern A. Zeeb			${ldconfig} -32 ${_ins} ${_LDC}
62*0696600cSBjoern A. Zeeb			;;
63*0696600cSBjoern A. Zeeb		esac
64*0696600cSBjoern A. Zeeb
65*0696600cSBjoern A. Zeeb		case `sysctl -n hw.machine_arch` in
66*0696600cSBjoern A. Zeeb		armv[67])
67*0696600cSBjoern A. Zeeb			for i in ${ldconfig_localsoft_dirs}; do
68*0696600cSBjoern A. Zeeb				if [ -d "${i}" ]; then
69*0696600cSBjoern A. Zeeb					_files=`find ${i} -type f`
70*0696600cSBjoern A. Zeeb					if [ -n "${_files}" ]; then
71*0696600cSBjoern A. Zeeb						ldconfigsoft_paths="${ldconfigsoft_paths} `cat ${_files} | sort -u`"
72*0696600cSBjoern A. Zeeb					fi
73*0696600cSBjoern A. Zeeb				fi
74*0696600cSBjoern A. Zeeb			done
75*0696600cSBjoern A. Zeeb			_LDC=""
76*0696600cSBjoern A. Zeeb			for i in ${ldconfigsoft_paths}; do
77*0696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
78*0696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
79*0696600cSBjoern A. Zeeb				fi
80*0696600cSBjoern A. Zeeb			done
81*0696600cSBjoern A. Zeeb			check_startmsgs &&
82*0696600cSBjoern A. Zeeb			    echo 'Soft Float compatibility ldconfig path:' ${_LDC}
83*0696600cSBjoern A. Zeeb			${ldconfig} -soft ${_ins} ${_LDC}
84*0696600cSBjoern A. Zeeb			;;
85*0696600cSBjoern A. Zeeb		esac
86*0696600cSBjoern A. Zeeb
87*0696600cSBjoern A. Zeeb		# Legacy aout support for i386 only
88*0696600cSBjoern A. Zeeb		case `sysctl -n hw.machine_arch` in
89*0696600cSBjoern A. Zeeb		i386)
90*0696600cSBjoern A. Zeeb			# Default the a.out ldconfig path.
91*0696600cSBjoern A. Zeeb			: ${ldconfig_paths_aout=${ldconfig_paths}}
92*0696600cSBjoern A. Zeeb			_LDC=""
93*0696600cSBjoern A. Zeeb			for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do
94*0696600cSBjoern A. Zeeb				if [ -r "${i}" ]; then
95*0696600cSBjoern A. Zeeb					_LDC="${_LDC} ${i}"
96*0696600cSBjoern A. Zeeb				fi
97*0696600cSBjoern A. Zeeb			done
98*0696600cSBjoern A. Zeeb			check_startmsgs && echo 'a.out ldconfig path:' ${_LDC}
99*0696600cSBjoern A. Zeeb			${ldconfig} -aout ${_ins} ${_LDC}
100*0696600cSBjoern A. Zeeb			;;
101*0696600cSBjoern A. Zeeb		esac
102*0696600cSBjoern A. Zeeb	fi
103*0696600cSBjoern A. Zeeb}
104*0696600cSBjoern A. Zeeb
105*0696600cSBjoern A. Zeebload_rc_config $name
106*0696600cSBjoern A. Zeebrun_rc_command "$1"
107