1639a2e50SGarrett Wollman# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 27f3dea24SPeter Wemm# $FreeBSD$ 353996fadSWolfram Schneider# 41f089616SRuslan Ermilov# The include file <bsd.kmod.mk> handles building and installing loadable 51f089616SRuslan Ermilov# kernel modules. 653996fadSWolfram Schneider# 753996fadSWolfram Schneider# 853996fadSWolfram Schneider# +++ variables +++ 953996fadSWolfram Schneider# 1053996fadSWolfram Schneider# CLEANFILES Additional files to remove for the clean and cleandir targets. 1153996fadSWolfram Schneider# 121f089616SRuslan Ermilov# EXPORT_SYMS A list of symbols that should be exported from the module, 131f089616SRuslan Ermilov# or the name of a file containing a list of symbols, or YES 141f089616SRuslan Ermilov# to export all symbols. If not defined, no symbols are 151f089616SRuslan Ermilov# exported. 161f089616SRuslan Ermilov# 17fe3cac87SNick Hibma# KMOD The name of the kernel module to build. 1853996fadSWolfram Schneider# 193bdfa9e5SDavid E. O'Brien# KMODDIR Base path for kernel modules (see kld(4)). [/boot/kernel] 2053996fadSWolfram Schneider# 211f089616SRuslan Ermilov# KMODOWN Module file owner. [${BINOWN}] 2253996fadSWolfram Schneider# 231f089616SRuslan Ermilov# KMODGRP Module file group. [${BINGRP}] 2453996fadSWolfram Schneider# 251f089616SRuslan Ermilov# KMODMODE Module file mode. [${BINMODE}] 2653996fadSWolfram Schneider# 27fe3cac87SNick Hibma# KMODLOAD Command to load a kernel module [/sbin/kldload] 287bc830bbSWolfram Schneider# 29fe3cac87SNick Hibma# KMODUNLOAD Command to unload a kernel module [/sbin/kldunload] 307bc830bbSWolfram Schneider# 311f089616SRuslan Ermilov# PROG The name of the kernel module to build. 321f089616SRuslan Ermilov# If not supplied, ${KMOD}.ko is used. 331f089616SRuslan Ermilov# 341f089616SRuslan Ermilov# SRCS List of source files. 351f089616SRuslan Ermilov# 366aec1278SMax Laier# FIRMWS List of firmware images in format filename:shortname:version 376aec1278SMax Laier# 3841e80f2aSFlorent Thoumie# FIRMWARE_LICENSE 397bd6fde3SFlorent Thoumie# Set to the name of the license the user has to agree on in 407bd6fde3SFlorent Thoumie# order to use this firmware. See /usr/share/doc/legal 417bd6fde3SFlorent Thoumie# 421f089616SRuslan Ermilov# DESTDIR The tree where the module gets installed. [not set] 430b3178a4SMike Smith# 4453996fadSWolfram Schneider# +++ targets +++ 4553996fadSWolfram Schneider# 4653996fadSWolfram Schneider# install: 4717d6c636SRuslan Ermilov# install the kernel module; if the Makefile 4853996fadSWolfram Schneider# does not itself define the target install, the targets 4953996fadSWolfram Schneider# beforeinstall and afterinstall may also be used to cause 5053996fadSWolfram Schneider# actions immediately before and after the install target 5153996fadSWolfram Schneider# is executed. 5253996fadSWolfram Schneider# 5353996fadSWolfram Schneider# load: 541f089616SRuslan Ermilov# Load a module. 5553996fadSWolfram Schneider# 5653996fadSWolfram Schneider# unload: 571f089616SRuslan Ermilov# Unload a module. 5853996fadSWolfram Schneider# 59639a2e50SGarrett Wollman 60b7bbb709SDavid E. O'BrienAWK?= awk 61fe3cac87SNick HibmaKMODLOAD?= /sbin/kldload 62fe3cac87SNick HibmaKMODUNLOAD?= /sbin/kldunload 63f6611608SSheldon HearnOBJCOPY?= objcopy 647bc830bbSWolfram Schneider 650ac2fc87SRuslan Ermilov.include <bsd.init.mk> 66b0a8d404SWarner Losh# Grab all the options for a kernel build. For backwards compat, we need to 67b0a8d404SWarner Losh# do this after bsd.own.mk. 68b0a8d404SWarner Losh.include "kern.opts.mk" 699215d178SBrooks Davis.include <bsd.compiler.mk> 7035c4406dSWarner Losh.include "config.mk" 71639a2e50SGarrett Wollman 7212f05b84SWarner Losh.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m 73639a2e50SGarrett Wollman 743a0d123eSWarner Losh# amd64 and mips use direct linking for kmod, all others use shared binaries 753a0d123eSWarner Losh.if ${MACHINE_CPUARCH} != amd64 && ${MACHINE_CPUARCH} != mips 763a0d123eSWarner Losh__KLD_SHARED=yes 773a0d123eSWarner Losh.else 783a0d123eSWarner Losh__KLD_SHARED=no 793a0d123eSWarner Losh.endif 803a0d123eSWarner Losh 81f165cb7cSRuslan Ermilov.if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing) 82db0cd7e1SDavid E. O'BrienCFLAGS+= -fno-strict-aliasing 83db0cd7e1SDavid E. O'Brien.endif 845d3b2922SRuslan ErmilovWERROR?= -Werror 85daaea395SWarner LoshCFLAGS+= ${WERROR} 8648aea4daSRuslan ErmilovCFLAGS+= -D_KERNEL 878fe644b2SMike SmithCFLAGS+= -DKLD_MODULE 884a2d2630SBruce Evans 89021886ffSBruce Evans# Don't use any standard or source-relative include directories. 9006d6e4fcSTom RhodesNOSTDINC= -nostdinc 91da3bcc92SAlexander KabaevCFLAGS:= ${CFLAGS:N-I*} ${NOSTDINC} ${INCLMAGIC} ${CFLAGS:M-I*} 928fa793d0SBrian Feldman.if defined(KERNBUILDDIR) 930c063641SGleb SmirnoffCFLAGS+= -DHAVE_KERNEL_OPTION_HEADERS -include ${KERNBUILDDIR}/opt_global.h 948fa793d0SBrian Feldman.endif 95021886ffSBruce Evans 961f089616SRuslan Ermilov# Add -I paths for system headers. Individual module makefiles don't 97021886ffSBruce Evans# need any -I paths for this. Similar defaults for .PATH can't be 98021886ffSBruce Evans# set because there are no standard paths for non-headers. 99528013d5SWarner LoshCFLAGS+= -I. -I${SYSDIR} 1004a2d2630SBruce Evans 10122ba0b2fSWarner LoshCFLAGS.gcc+= -finline-limit=${INLINE_LIMIT} 102cc4a90c4SGleb SmirnoffCFLAGS.gcc+= -fms-extensions 10322ba0b2fSWarner LoshCFLAGS.gcc+= --param inline-unit-growth=100 10422ba0b2fSWarner LoshCFLAGS.gcc+= --param large-function-growth=1000 1052a51529fSPeter Wemm 1060b3178a4SMike Smith# Disallow common variables, and if we end up with commons from 1070b3178a4SMike Smith# somewhere unexpected, allocate storage for them in the module itself. 1080b3178a4SMike SmithCFLAGS+= -fno-common 1090b3178a4SMike SmithLDFLAGS+= -d -warn-common 1100b3178a4SMike Smith 1119e4be63dSBruce EvansCFLAGS+= ${DEBUG_FLAGS} 1123a0d123eSWarner Losh.if ${MACHINE_CPUARCH} == amd64 1132565edc4SAndriy GaponCFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 11483c457dcSIan Dowse.endif 1159e4be63dSBruce Evans 116b54c389fSIan Lepore# Temporary workaround for PR 196407, which contains the fascinating details. 117c6f7b900SIan Lepore# Don't allow clang to use fpu instructions or registers in kernel modules. 118b54c389fSIan Lepore.if ${MACHINE_CPUARCH} == arm 119b54c389fSIan LeporeCFLAGS.clang+= -mllvm -arm-use-movt=0 120c6f7b900SIan LeporeCFLAGS.clang+= -mfpu=none 1211b23f9b9SAndrew TurnerCFLAGS+= -funwind-tables 122b54c389fSIan Lepore.endif 123b54c389fSIan Lepore 1243a0d123eSWarner Losh.if ${MACHINE_CPUARCH} == powerpc 12555a5dcc8SPeter GrehanCFLAGS+= -mlongcall -fno-omit-frame-pointer 126fded756eSPeter Grehan.endif 127fded756eSPeter Grehan 1283a0d123eSWarner Losh.if ${MACHINE_CPUARCH} == mips 1296f3c6327SNeel NatuCFLAGS+= -G0 -fno-pic -mno-abicalls -mlong-calls 1306f3c6327SNeel Natu.endif 1316f3c6327SNeel Natu 13269745d38SAlexander Leidinger.if defined(DEBUG) || defined(DEBUG_FLAGS) 13369745d38SAlexander LeidingerCTFFLAGS+= -g 13469745d38SAlexander Leidinger.endif 13569745d38SAlexander Leidinger 1366aec1278SMax Laier.if defined(FIRMWS) 137528013d5SWarner Losh${KMOD:S/$/.c/}: ${SYSDIR}/tools/fw_stub.awk 138528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g} \ 1397bd6fde3SFlorent Thoumie ${FIRMWARE_LICENSE:C/.+/-l/}${FIRMWARE_LICENSE} 1406aec1278SMax Laier 1416aec1278SMax LaierSRCS+= ${KMOD:S/$/.c/} 1426aec1278SMax LaierCLEANFILES+= ${KMOD:S/$/.c/} 1436aec1278SMax Laier 1446aec1278SMax Laier.for _firmw in ${FIRMWS} 1456aec1278SMax Laier${_firmw:C/\:.*$/.fwo/}: ${_firmw:C/\:.*$//} 1466aec1278SMax Laier @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}} 147009b3d3dSMax Laier @if [ -e ${_firmw:C/\:.*$//} ]; then \ 1485b6dc2efSSimon J. Gerraty ${LD} -b binary --no-warn-mismatch ${_LDFLAGS} \ 149ba6a2bb3SMarcel Moolenaar -r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \ 150ff8e7669SMax Laier else \ 151ff8e7669SMax Laier ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \ 1525b6dc2efSSimon J. Gerraty ${LD} -b binary --no-warn-mismatch ${_LDFLAGS} \ 153ba6a2bb3SMarcel Moolenaar -r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \ 154ff8e7669SMax Laier rm ${_firmw:C/\:.*$//}; \ 155ff8e7669SMax Laier fi 1566aec1278SMax Laier 1576aec1278SMax LaierOBJS+= ${_firmw:C/\:.*$/.fwo/} 1586aec1278SMax Laier.endfor 1596aec1278SMax Laier.endif 1606aec1278SMax Laier 16135c4406dSWarner Losh# Conditionally include SRCS based on kernel config options. 16235c4406dSWarner Losh.for _o in ${KERN_OPTS} 16335c4406dSWarner LoshSRCS+=${SRCS.${_o}} 16435c4406dSWarner Losh.endfor 16535c4406dSWarner Losh 166639a2e50SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 167639a2e50SGarrett Wollman 168639a2e50SGarrett Wollman.if !defined(PROG) 16990f60fc9SMike SmithPROG= ${KMOD}.ko 17090f60fc9SMike Smith.endif 171639a2e50SGarrett Wollman 172817b59bfSRuslan Ermilov.if !defined(DEBUG_FLAGS) 173f6611608SSheldon HearnFULLPROG= ${PROG} 174f6611608SSheldon Hearn.else 175f6611608SSheldon HearnFULLPROG= ${PROG}.debug 1761558abf6SRuslan Ermilov${PROG}: ${FULLPROG} ${PROG}.symbols 1771558abf6SRuslan Ermilov ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.symbols\ 17898b45a8fSRuslan Ermilov ${FULLPROG} ${.TARGET} 1791558abf6SRuslan Ermilov${PROG}.symbols: ${FULLPROG} 18098b45a8fSRuslan Ermilov ${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET} 181f6611608SSheldon Hearn.endif 182f6611608SSheldon Hearn 1833a0d123eSWarner Losh.if ${__KLD_SHARED} == yes 184f6611608SSheldon Hearn${FULLPROG}: ${KMOD}.kld 1855b6dc2efSSimon J. Gerraty ${LD} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${KMOD}.kld 186817b59bfSRuslan Ermilov.if !defined(DEBUG_FLAGS) 187817b59bfSRuslan Ermilov ${OBJCOPY} --strip-debug ${.TARGET} 1884c293d35SRuslan Ermilov.endif 1894d6bcc83SPeter Wemm.endif 19009be11baSPeter Wemm 19193f03548SMike SmithEXPORT_SYMS?= NO 19293f03548SMike Smith.if ${EXPORT_SYMS} != YES 1931f089616SRuslan ErmilovCLEANFILES+= export_syms 1940b3178a4SMike Smith.endif 1950b3178a4SMike Smith 1963a0d123eSWarner Losh.if ${__KLD_SHARED} == yes 19709be11baSPeter Wemm${KMOD}.kld: ${OBJS} 1984d6bcc83SPeter Wemm.else 1994d6bcc83SPeter Wemm${FULLPROG}: ${OBJS} 2004d6bcc83SPeter Wemm.endif 2015b6dc2efSSimon J. Gerraty ${LD} ${_LDFLAGS} -r -d -o ${.TARGET} ${OBJS} 202724afafaSWarner Losh.if ${MK_CTF} != "no" 203cd49c2e8SMax Khon ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} 204cd49c2e8SMax Khon.endif 2050b3178a4SMike Smith.if defined(EXPORT_SYMS) 20693f03548SMike Smith.if ${EXPORT_SYMS} != YES 2070b3178a4SMike Smith.if ${EXPORT_SYMS} == NO 2088b3ae668SDag-Erling Smørgrav :> export_syms 2090b3178a4SMike Smith.elif !exists(${.CURDIR}/${EXPORT_SYMS}) 2101f089616SRuslan Ermilov echo ${EXPORT_SYMS} > export_syms 2110b3178a4SMike Smith.else 2121f089616SRuslan Ermilov grep -v '^#' < ${EXPORT_SYMS} > export_syms 2130b3178a4SMike Smith.endif 2140b3178a4SMike Smith awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \ 2151f089616SRuslan Ermilov export_syms | xargs -J% ${OBJCOPY} % ${.TARGET} 21693f03548SMike Smith.endif 2170b3178a4SMike Smith.endif 2183a0d123eSWarner Losh.if !defined(DEBUG_FLAGS) && ${__KLD_SHARED} == no 2194d6bcc83SPeter Wemm ${OBJCOPY} --strip-debug ${.TARGET} 2204d6bcc83SPeter Wemm.endif 2210b3178a4SMike Smith 222528013d5SWarner Losh_ILINKS=machine 223915b4b09SNathan Whitehorn.if ${MACHINE} != ${MACHINE_CPUARCH} 224915b4b09SNathan Whitehorn_ILINKS+=${MACHINE_CPUARCH} 225df3a103dSWarner Losh.endif 226544de89dSJohn Baldwin.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 227544de89dSJohn Baldwin_ILINKS+=x86 228544de89dSJohn Baldwin.endif 22931a01497SSean BrunoCLEANFILES+=${_ILINKS} 230639a2e50SGarrett Wollman 231b25a566dSRuslan Ermilovall: objwarn ${PROG} 2324a2d2630SBruce Evans 233db00e6c5SDavid E. O'Brienbeforedepend: ${_ILINKS} 234985f41afSWarner Losh 235f3cc9575SWarner Losh# Ensure that the links exist without depending on it when it exists which 236f3cc9575SWarner Losh# causes all the modules to be rebuilt when the directory pointed to changes. 237f3cc9575SWarner Losh.for _link in ${_ILINKS} 238f3cc9575SWarner Losh.if !exists(${.OBJDIR}/${_link}) 2398cf80600SSimon J. Gerraty${OBJS}: ${_link} 240f3cc9575SWarner Losh.endif 241f3cc9575SWarner Losh.endfor 2424a2d2630SBruce Evans 2439a8631b3SWarner Losh# Search for kernel source tree in standard places. 2449a8631b3SWarner Losh.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys 245776f50b9SRuslan Ermilov.if !defined(SYSDIR) && exists(${_dir}/kern/) 2469a8631b3SWarner LoshSYSDIR= ${_dir} 2479a8631b3SWarner Losh.endif 2489a8631b3SWarner Losh.endfor 249776f50b9SRuslan Ermilov.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) 2509a8631b3SWarner Losh.error "can't find kernel source tree" 2519a8631b3SWarner Losh.endif 2529a8631b3SWarner Losh 2537750ad47SMarcel Moolenaar.NOPATH: ${_ILINKS} 2543c4368b2SMark Johnston 2554a2d2630SBruce Evans${_ILINKS}: 2569a8631b3SWarner Losh @case ${.TARGET} in \ 257df3a103dSWarner Losh machine) \ 258df3a103dSWarner Losh path=${SYSDIR}/${MACHINE}/include ;; \ 259544de89dSJohn Baldwin *) \ 2603c4368b2SMark Johnston path=${SYSDIR}/${.TARGET:T}/include ;; \ 26108a04a89SPeter Wemm esac ; \ 26208a04a89SPeter Wemm path=`(cd $$path && /bin/pwd)` ; \ 2633c4368b2SMark Johnston ${ECHO} ${.TARGET:T} "->" $$path ; \ 2643c4368b2SMark Johnston ln -sf $$path ${.TARGET:T} 2654a2d2630SBruce Evans 26674465532SRuslan ErmilovCLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} 267361186e5SMaxime Henrion 268817b59bfSRuslan Ermilov.if defined(DEBUG_FLAGS) 2691558abf6SRuslan ErmilovCLEANFILES+= ${FULLPROG} ${PROG}.symbols 270361186e5SMaxime Henrion.endif 271639a2e50SGarrett Wollman 272639a2e50SGarrett Wollman.if !target(install) 273639a2e50SGarrett Wollman 274ea87b3cbSDavid E. O'Brien_INSTALLFLAGS:= ${INSTALLFLAGS} 275e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 276e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 277e902c1bbSTim Vanderhoek.endfor 278e902c1bbSTim Vanderhoek 2792b06260dSRuslan Ermilov.if !target(realinstall) 2802b06260dSRuslan Ermilovrealinstall: _kmodinstall 2812b06260dSRuslan Ermilov.ORDER: beforeinstall _kmodinstall 2822b06260dSRuslan Ermilov_kmodinstall: 283d2893b16SRuslan Ermilov ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ 2842b06260dSRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} 285cd95660fSDavid E. O'Brien.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} != "no" 28698b45a8fSRuslan Ermilov ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ 2871558abf6SRuslan Ermilov ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR} 288d24864f7SRuslan Ermilov.endif 2892b06260dSRuslan Ermilov 2902b06260dSRuslan Ermilov.include <bsd.links.mk> 2912b06260dSRuslan Ermilov 2924875819cSJake Burkholder.if !defined(NO_XREF) 2932b06260dSRuslan Ermilovafterinstall: _kldxref 2942b06260dSRuslan Ermilov.ORDER: realinstall _kldxref 2952b06260dSRuslan Ermilov.ORDER: _installlinks _kldxref 2962b06260dSRuslan Ermilov_kldxref: 297be1d673dSRuslan Ermilov @if type kldxref >/dev/null 2>&1; then \ 298be1d673dSRuslan Ermilov ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \ 299be1d673dSRuslan Ermilov kldxref ${DESTDIR}${KMODDIR}; \ 300be1d673dSRuslan Ermilov fi 301505222d3SPeter Wemm.endif 30222a8b405SMaxime Henrion.endif # !target(realinstall) 303639a2e50SGarrett Wollman 30422a8b405SMaxime Henrion.endif # !target(install) 305639a2e50SGarrett Wollman 306639a2e50SGarrett Wollman.if !target(load) 3079a8631b3SWarner Loshload: ${PROG} 3081f089616SRuslan Ermilov ${KMODLOAD} -v ${.OBJDIR}/${PROG} 309639a2e50SGarrett Wollman.endif 310639a2e50SGarrett Wollman 311639a2e50SGarrett Wollman.if !target(unload) 312fe3cac87SNick Hibmaunload: 3131f089616SRuslan Ermilov ${KMODUNLOAD} -v ${PROG} 31408a04a89SPeter Wemm.endif 3151aa57be3SGarrett Wollman 3166b1bb559SWarner Losh.if defined(KERNBUILDDIR) 3176b1bb559SWarner Losh.PATH: ${KERNBUILDDIR} 3186b1bb559SWarner LoshCFLAGS+= -I${KERNBUILDDIR} 3196b1bb559SWarner Losh.for _src in ${SRCS:Mopt_*.h} 3206b1bb559SWarner LoshCLEANFILES+= ${_src} 3216b1bb559SWarner Losh.if !target(${_src}) 3226b1bb559SWarner Losh${_src}: 32340244cc2SDavid E. O'Brien ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET} 3246b1bb559SWarner Losh.endif 3256b1bb559SWarner Losh.endfor 3266b1bb559SWarner Losh.else 3274fea6704SBruce Evans.for _src in ${SRCS:Mopt_*.h} 3284fea6704SBruce EvansCLEANFILES+= ${_src} 3294fea6704SBruce Evans.if !target(${_src}) 3304fea6704SBruce Evans${_src}: 3318b3ae668SDag-Erling Smørgrav :> ${.TARGET} 3324fea6704SBruce Evans.endif 3334fea6704SBruce Evans.endfor 3346b1bb559SWarner Losh.endif 3354fea6704SBruce Evans 3363fd1e05bSAlexander Leidinger# Respect configuration-specific C flags. 33762769330SAlexander LeidingerCFLAGS+= ${CONF_CFLAGS} 33862769330SAlexander Leidinger 339a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Mvnode_if.c) 34078b2c868SBrian FeldmanCLEANFILES+= vnode_if.c 341528013d5SWarner Loshvnode_if.c: ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src 342528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -c 3434fea6704SBruce Evans.endif 34478b2c868SBrian Feldman 345a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Mvnode_if.h) 3469f73f0e8SRuslan ErmilovCLEANFILES+= vnode_if.h vnode_if_newproto.h vnode_if_typedef.h 347528013d5SWarner Loshvnode_if.h vnode_if_newproto.h vnode_if_typedef.h: ${SYSDIR}/tools/vnode_if.awk \ 348528013d5SWarner Losh ${SYSDIR}/kern/vnode_if.src 3499f73f0e8SRuslan Ermilovvnode_if.h: vnode_if_newproto.h vnode_if_typedef.h 350528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -h 3519f73f0e8SRuslan Ermilovvnode_if_newproto.h: 352528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -p 3539f73f0e8SRuslan Ermilovvnode_if_typedef.h: 354528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -q 35578b2c868SBrian Feldman.endif 3561aa57be3SGarrett Wollman 35712f05b84SWarner Losh# Build _if.[ch] from _if.m, and clean them when we're done. 3588cad626fSWarner Losh.if !defined(_MPATH) 35912f05b84SWarner Losh__MPATH!=find ${SYSDIR:tA}/ -name \*_if.m 36012f05b84SWarner Losh_MPATH=${__MPATH:H:O:u} 3618cad626fSWarner Losh.endif 36212f05b84SWarner Losh.PATH.m: ${_MPATH} 363160c44feSWarner Losh.for _i in ${SRCS:M*_if.[ch]} 364*fd449cdfSWarner Losh#removes too much, comment out until it's more constrained. 365*fd449cdfSWarner Losh#CLEANFILES+= ${_i} 366160c44feSWarner Losh.endfor # _i 36712f05b84SWarner Losh.m.c: ${SYSDIR}/tools/makeobjops.awk 36812f05b84SWarner Losh ${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -c 36912f05b84SWarner Losh 37012f05b84SWarner Losh.m.h: ${SYSDIR}/tools/makeobjops.awk 37112f05b84SWarner Losh ${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -h 37212f05b84SWarner Losh 3734e91eaf2SWarner Losh.for _i in mii pccard 374a7d30e5fSDavid E. O'Brien.if !empty(SRCS:M${_i}devs.h) 375dba6dd17SWarner LoshCLEANFILES+= ${_i}devs.h 376528013d5SWarner Losh${_i}devs.h: ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs 377528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs 3782d3ce713SDavid E. O'Brien.endif 379dba6dd17SWarner Losh.endfor # _i 3802d3ce713SDavid E. O'Brien 381a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Musbdevs.h) 3824e91eaf2SWarner LoshCLEANFILES+= usbdevs.h 383528013d5SWarner Loshusbdevs.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs 384528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -h 3854e91eaf2SWarner Losh.endif 3864e91eaf2SWarner Losh 387a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Musbdevs_data.h) 3884e91eaf2SWarner LoshCLEANFILES+= usbdevs_data.h 389528013d5SWarner Loshusbdevs_data.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs 390528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -d 3914e91eaf2SWarner Losh.endif 3924e91eaf2SWarner Losh 393a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Macpi_quirks.h) 394684c1c1dSNate LawsonCLEANFILES+= acpi_quirks.h 395528013d5SWarner Loshacpi_quirks.h: ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks 396528013d5SWarner Losh ${AWK} -f ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks 397684c1c1dSNate Lawson.endif 398684c1c1dSNate Lawson 399a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Massym.s) 400705d63cdSIan DowseCLEANFILES+= assym.s genassym.o 401705d63cdSIan Dowseassym.s: genassym.o 40288314df8SJohn Baldwin.if defined(KERNBUILDDIR) 40388314df8SJohn Baldwingenassym.o: opt_global.h 40488314df8SJohn Baldwin.endif 405528013d5SWarner Loshassym.s: ${SYSDIR}/kern/genassym.sh 406528013d5SWarner Losh sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET} 4077dd824c3SEd Mastegenassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c 4080c0fde95SWarner Loshgenassym.o: ${SRCS:Mopt_*.h} 409705d63cdSIan Dowse ${CC} -c ${CFLAGS:N-fno-common} \ 4107dd824c3SEd Maste ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c 411705d63cdSIan Dowse.endif 412705d63cdSIan Dowse 413766f7d6eSMark Murraylint: ${SRCS} 414bbb467cdSRuslan Ermilov ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c} 415766f7d6eSMark Murray 41688314df8SJohn Baldwin.if defined(KERNBUILDDIR) 41788314df8SJohn Baldwin${OBJS}: opt_global.h 41888314df8SJohn Baldwin.endif 41988314df8SJohn Baldwin 42068e00b92SJordan K. Hubbard.include <bsd.dep.mk> 42147da63c3SBruce Evans 42274465532SRuslan Ermilovcleandepend: cleanilinks 42374465532SRuslan Ermilov# .depend needs include links so we remove them only together. 42474465532SRuslan Ermilovcleanilinks: 42574465532SRuslan Ermilov rm -f ${_ILINKS} 42674465532SRuslan Ermilov 427f2bffe0fSRuslan Ermilov.if !exists(${.OBJDIR}/${DEPENDFILE}) 428589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 42947da63c3SBruce Evans.endif 43047da63c3SBruce Evans 431afba897fSBruce Evans.include <bsd.obj.mk> 432ddc474a8SRuslan Ermilov.include "kern.mk" 433