ldconfig revision 103019
1#!/bin/sh
2#
3# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $
4# $FreeBSD: head/etc/rc.d/ldconfig 103019 2002-09-06 16:18:05Z gordon $
5#
6
7# PROVIDE: ldconfig
8# REQUIRE: mountall
9# BEFORE:  DAEMON
10# KEYWORD: FreeBSD NetBSD
11
12. /etc/rc.subr
13
14name="ldconfig"
15ldconfig_command="/sbin/ldconfig"
16start_cmd="ldconfig_start"
17stop_cmd=":"
18
19ldconfig_start()
20{
21	case ${OSTYPE} in
22	FreeBSD)
23		ldconfig=${ldconfig_command}
24		checkyesno ldconfig_insecure && ldconfig="${ldconfig} -i"
25		if [ -x "${ldconfig_command}" ]; then
26			case `/usr/bin/objformat` in
27			elf)
28				_LDC=/usr/lib
29				for i in ${ldconfig_paths}; do
30					if [ -d "${i}" ]; then
31						_LDC="${_LDC} ${i}"
32					fi
33				done
34				echo 'ELF ldconfig path:' ${_LDC}
35				${ldconfig} -elf ${_LDC}
36				;;
37			esac
38
39			# Legacy aout support for i386 only
40			case `sysctl -n hw.machine_arch` in
41			i386)
42				# Default the a.out ldconfig path.
43				: ${ldconfig_paths_aout=${ldconfig_paths}}
44				_LDC=/usr/lib/aout
45				for i in ${ldconfig_paths_aout}; do
46					if [ -d "${i}" ]; then
47						_LDC="${_LDC} ${i}"
48					fi
49				done
50				echo 'a.out ldconfig path:' ${_LDC}
51				${ldconfig} -aout ${_LDC}
52				;;
53			esac
54		fi
55		;;
56	NetBSD)
57		if [ -f ${ldconfig_command} ]; then
58			echo "Creating a.out runtime link editor directory cache."
59			${ldconfig_command}
60		fi
61		;;
62	*)
63		;;
64	esac
65}
66
67load_rc_config $name
68run_rc_command "$1"
69