xref: /dragonfly/etc/rc.d/ldconfig (revision 1d1731fa)
1#!/bin/sh
2#
3# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $
4# $FreeBSD: src/etc/rc.d/ldconfig,v 1.7 2003/06/30 15:02:05 trhodes Exp $
5# $DragonFly: src/etc/rc.d/ldconfig,v 1.1 2003/07/24 06:35:37 dillon Exp $
6#
7
8# PROVIDE: ldconfig
9# REQUIRE: mountall mountcritremote
10# BEFORE:  DAEMON
11# KEYWORD: DragonFly FreeBSD NetBSD
12
13. /etc/rc.subr
14
15name="ldconfig"
16ldconfig_command="/sbin/ldconfig"
17start_cmd="ldconfig_start"
18stop_cmd=":"
19
20ldconfig_start()
21{
22	case ${OSTYPE} in
23	DragonFly)
24		_ins=
25                ldconfig=${ldconfig_command}
26                checkyesno ldconfig_insecure && _ins="-i"
27                if [ -x "${ldconfig_command}" ]; then
28                        _LDC=/usr/lib
29                        for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
30                                if [ -r "${i}" ]; then
31                                        _LDC="${_LDC} ${i}"
32                                fi
33                        done
34                        echo 'ELF ldconfig path:' ${_LDC}
35                        ${ldconfig} -elf ${_ins} ${_LDC}
36                        # Legacy aout support for i386 only
37                        case `sysctl -n hw.machine_arch` in
38                        i386)
39                                # Default the a.out ldconfig path.
40                                : ${ldconfig_paths_aout=${ldconfig_paths}}
41                                _LDC=/usr/lib/aout
42                                for i in ${ldconfig_paths_aout} /etc/ld.so.conf; do
43					if [ -r "${i}" ]; then
44                                                _LDC="${_LDC} ${i}"
45                                        fi
46                                done
47                                echo 'a.out ldconfig path:' ${_LDC}
48                                ${ldconfig} -aout ${_ins} ${_LDC}
49                                ;;
50                        esac
51                fi
52                ;;
53
54	FreeBSD)
55		_ins=
56		ldconfig=${ldconfig_command}
57		checkyesno ldconfig_insecure && _ins="-i"
58		if [ -x "${ldconfig_command}" ]; then
59			_LDC=/usr/lib
60			for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
61				if [ -r "${i}" ]; then
62					_LDC="${_LDC} ${i}"
63				fi
64			done
65			echo 'ELF ldconfig path:' ${_LDC}
66			${ldconfig} -elf ${_ins} ${_LDC}
67
68			# Legacy aout support for i386 only
69			case `sysctl -n hw.machine_arch` in
70			i386)
71				# Default the a.out ldconfig path.
72				: ${ldconfig_paths_aout=${ldconfig_paths}}
73				_LDC=/usr/lib/aout
74				for i in ${ldconfig_paths_aout} /etc/ld.so.conf; do
75					if [ -r "${i}" ]; then
76						_LDC="${_LDC} ${i}"
77					fi
78				done
79				echo 'a.out ldconfig path:' ${_LDC}
80				${ldconfig} -aout ${_ins} ${_LDC}
81				;;
82			esac
83		fi
84		;;
85	NetBSD)
86		if [ -f ${ldconfig_command} ]; then
87			echo "Creating a.out runtime link editor directory cache."
88			${ldconfig_command}
89		fi
90		;;
91	*)
92		;;
93	esac
94}
95
96load_rc_config $name
97run_rc_command "$1"
98