xref: /freebsd/libexec/rc/rc.d/kldxref (revision 809a8352dd5bb83dca991ff6c82e509208afad26)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: kldxref
7# REQUIRE: FILESYSTEMS
8# BEFORE:  netif
9# KEYWORD: nojail
10
11. /etc/rc.subr
12
13rcvar="kldxref_enable"
14name="kldxref"
15desc="Generate hints for the kernel loader"
16stop_cmd=":"
17start_cmd="kldxref_start"
18
19kldxref_start() {
20	if [ -n "$kldxref_module_path" ]; then
21		MODULE_PATHS="$kldxref_module_path"
22	else
23		MODULE_PATHS=`sysctl -n kern.module_path`
24	fi
25	IFS=';'
26	for MODULE_DIR in $MODULE_PATHS; do
27		if checkyesno kldxref_clobber ||
28		    [ ! -f "$MODULE_DIR/linker.hints" ] &&
29		    [ `echo ${MODULE_DIR}/*.ko` != "${MODULE_DIR}/*.ko" ]; then
30			echo "Building $MODULE_DIR/linker.hints"
31			kldxref "$MODULE_DIR"
32		fi
33	done
34}
35
36load_rc_config $name
37run_rc_command "$1"
38