/[gentoo-x86]/eclass/linux-mod.eclass
Gentoo

Diff of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.6 Revision 1.10
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.6 2004/12/06 18:33:11 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.10 2004/12/14 18:56:46 johnm Exp $
4 4
5# This eclass provides functions for compiling external kernel modules 5# Description: This eclass is used to interface with linux-info in such a way
6# from source. 6# to provide the functionality required and initial functions
7# required to install external modules against a kernel source
8# tree.
9#
10# Maintainer: John Mylchreest <johnm@gentoo.org>
11# Copyright 2004 Gentoo Linux
12#
13# Please direct your bugs to the current eclass maintainer :)
14
15# A Couple of env vars are available to effect usage of this eclass
16# These are as follows:
17#
18# Env Var Option Default Description
19# KERNEL_DIR <string> /usr/src/linux The directory containing kernel
20# the target kernel sources.
21# BUILD_PARAMS <string> The parameters to pass to make.
22# BUILD_TARGETS <string> clean modules The build targets to pass to make.
23# MODULE_NAMES <string> This is the modules which are
24# to be built automatically using the
25# default pkg_compile/install. They
26# are explained properly below.
27
28
29# MODULE_NAMES - Detailed Overview
30#
31# The structure of each MODULE_NAMES entry is as follows:
32# modulename(libmodulesdir:modulesourcedir)
33# for example:
34# MODULE_NAMES="module_pci(pci:${S}/pci) module_usb(usb:${S}/usb)"
35#
36# what this would do is
37# cd ${S}/pci
38# make ${BUILD_PARAMS} ${BUILD_TARGETS}
39# insinto /lib/modules/${KV_FULL}/pci
40# doins module_pci.${KV_OBJ}
41#
42# cd ${S}/usb
43# make ${BUILD_PARAMS} ${BUILD_TARGETS}
44# insinto /lib/modules/${KV_FULL}/usb
45# doins module_usb.${KV_OBJ}
46#
47# if the modulessourcedir isnt specified, it assumes ${S}
48# if the libmodulesdir isnt specified, it assumes misc.
49# if no seperator is defined ":" then it assumes the argument is modulesourcedir
7 50
8inherit linux-info 51inherit linux-info
9ECLASS=linux-mod 52ECLASS=linux-mod
10INHERITED="$INHERITED $ECLASS" 53INHERITED="$INHERITED $ECLASS"
11EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile 54EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile
13DESCRIPTION="Based on the $ECLASS eclass" 56DESCRIPTION="Based on the $ECLASS eclass"
14SLOT=0 57SLOT=0
15DEPEND="virtual/linux-sources 58DEPEND="virtual/linux-sources
16 sys-apps/sed" 59 sys-apps/sed"
17 60
18
19# This eclass is designed to help ease the installation of external kernel
20# modules into the kernel tree.
21
22
23# eclass utilities 61# eclass utilities
24# ---------------------------------- 62# ----------------------------------
25 63
26use_m() { 64use_m() {
27 # if we haven't determined the version yet, we need too. 65 # if we haven't determined the version yet, we need too.
28 get_version; 66 get_version;
29 67
30 # if the kernel version is greater than 2.6.6 then we should use 68 # if the kernel version is greater than 2.6.6 then we should use
31 # M= instead of SUBDIR= 69 # M= instead of SUBDIRS=
32 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ 70 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
33 return 0 || return 1 71 return 0 || return 1
34} 72}
35 73
36convert_to_m() { 74convert_to_m() {
37 [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument" 75 [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument"
38 if use_m 76 if use_m
39 then 77 then
40 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIR=" 78 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
41 sed -i 's:SUBDIRS=:M=:g' ${1} 79 sed -i 's:SUBDIRS=:M=:g' ${1}
42 eend $? 80 eend $?
43 fi 81 fi
44} 82}
45 83
81 119
82display_postinst() { 120display_postinst() {
83 # if we haven't determined the version yet, we need too. 121 # if we haven't determined the version yet, we need too.
84 get_version; 122 get_version;
85 123
86 local modulename moduledir sourcedir module_temp file i 124 local modulename moduledir sourcedir moduletemp file i
87 125
88 file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR} 126 file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}
89 file=${file/\/\///} 127 file=${file/\/\///}
90 128
91 einfo "If you would like to load this module automatically upon boot" 129 einfo "If you would like to load this module automatically upon boot"
92 einfo "please type the following as root:" 130 einfo "please type the following as root:"
93 for i in ${MODULE_NAMES} 131 for i in ${MODULE_NAMES}
94 do 132 do
95 module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")" 133 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")"
96 modulename="${i/(*/}"
97 moduledir="${module_temp/:*/}" 134 modulename="${moduletemp/ */}"
135 moduletemp="${moduletemp/* /}"
136 # if we specify two args, then we can set moduledir
137 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}"
138 # if we didnt pass the brackets, then we shouldnt accept anything
139 [ -n "${moduletemp/${modulename}/}" ] && sourcedir="${moduletemp/*:/}"
98 moduledir="${moduledir:-misc}" 140 moduledir="${moduledir:-misc}"
99 sourcedir="${module_temp/*:/}"
100 sourcedir="${sourcedir:-${S}}" 141 sourcedir="${sourcedir:-${S}}"
101 142
102 einfo " # echo \"${modulename}\" >> ${file}" 143 einfo " # echo \"${modulename}\" >> ${file}"
103 done 144 done
104 echo 145 echo
114 check_extra_config; 155 check_extra_config;
115 set_kvobj; 156 set_kvobj;
116} 157}
117 158
118linux-mod_src_compile() { 159linux-mod_src_compile() {
119 local modulename moduledir sourcedir module_temp xarch i 160 local modulename moduledir sourcedir moduletemp xarch i
120 xarch="${ARCH}" 161 xarch="${ARCH}"
121 unset ARCH 162 unset ARCH
122 163
123 for i in "${MODULE_NAMES}" 164 for i in ${MODULE_NAMES}
124 do 165 do
125 module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")" 166 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")"
126 modulename="${i/(*/}"
127 moduledir="${module_temp/:*/}" 167 modulename="${moduletemp/ */}"
168 moduletemp="${moduletemp/* /}"
169 # if we specify two args, then we can set moduledir
170 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}"
171 # if we didnt pass the brackets, then we shouldnt accept anything
172 [ -n "${moduletemp/${modulename}/}" ] && sourcedir="${moduletemp/*:/}"
128 moduledir="${moduledir:-misc}" 173 moduledir="${moduledir:-misc}"
129 sourcedir="${module_temp/*:/}"
130 sourcedir="${sourcedir:-${S}}" 174 sourcedir="${sourcedir:-${S}}"
131 175
132 einfo "Preparing ${modulename} module" 176 einfo "Preparing ${modulename} module"
133 cd ${sourcedir} 177 cd ${sourcedir}
134 emake clean || die Unable to make clean.
135 emake ${BUILD_PARAMS} module || die Unable to make ${BUILD_PARAMS} module. 178 emake ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module} || die Unable to make ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module}.
136 done 179 done
137 ARCH="${xarch}" 180 ARCH="${xarch}"
138} 181}
139 182
140linux-mod_src_install() { 183linux-mod_src_install() {
141 local modulename moduledir sourcedir module_temp i 184 local modulename moduledir sourcedir moduletemp i
142 185
143 for i in "${MODULE_NAMES}" 186 for i in ${MODULE_NAMES}
144 do 187 do
145 module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")" 188 moduletemp="$(echo ${i} | sed -e "s:\(.*\)(\(.*\)):\1 \2:")"
146 modulename="${i/(*/}"
147 moduledir="${module_temp/:*/}" 189 modulename="${moduletemp/ */}"
190 moduletemp="${moduletemp/* /}"
191 # if we specify two args, then we can set moduledir
192 [ -z "${moduletemp/*:*/}" ] && moduledir="${moduletemp/:*/}"
193 # if we didnt pass the brackets, then we shouldnt accept anything
194 [ -n "${moduletemp/${modulename}/}" ] && sourcedir="${moduletemp/*:/}"
148 moduledir="${moduledir:-misc}" 195 moduledir="${moduledir:-misc}"
149 sourcedir="${module_temp/*:/}"
150 sourcedir="${sourcedir:-${S}}" 196 sourcedir="${sourcedir:-${S}}"
151 197
152 einfo "Installing ${modulename} module" 198 einfo "Installing ${modulename} module"
153 cd ${sourcedir} 199 cd ${sourcedir}
154 insinto /lib/modules/${KV_FULL}/${moduledir} 200 insinto /lib/modules/${KV_FULL}/${moduledir}

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20