Makefile revision bbf3d430bae83177ab9ce3097f49d89cc873e7c0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# $Revision$
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte## @file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Makefile for the VirtualBox Linux Host Driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Copyright (C) 2006-2010 Oracle Corporation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This file is part of VirtualBox Open Source Edition (OSE), as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# available from http://www.virtualbox.org. This file is free software;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# you can redistribute it and/or modify it under the terms of the GNU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# General Public License (GPL) as published by the Free Software
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Foundation, in version 2 as it comes in the "COPYING" file of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# The contents of this file may alternatively be used under the terms
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# of the Common Development and Distribution License Version 1.0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# VirtualBox OSE distribution, in which case the provisions of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# CDDL are applicable instead of those of the GPL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You may elect to license modified versions of this file under the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# terms and conditions of either the GPL or the CDDL or both.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# First, figure out which architecture we're targeting and the build type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# (We have to support basic cross building (ARCH=i386|x86_64).)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# While at it, warn about BUILD_* vars found to help with user problems.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH_DEF := amd64
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteelse
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH_DEF := x86
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH :=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(BUILD_TARGET_ARCH),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifeq ($(ARCH),x86_64)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH := amd64
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifeq ($(ARCH),i386)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH := x86
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteelse
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TYPE :=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(BUILD_TYPE),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUILD_TYPE := release
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteelse
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifneq ($(BUILD_TYPE),release)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# override is required by the Debian guys
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteoverride MODULE = vboxdrv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOBJS = \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linux/SUPDrv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUPDrv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SUPDrvSem.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/alloc-r0drv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/initterm-r0drv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/memobj-r0drv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/mpnotification-r0drv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/powernotification-r0drv.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/assert-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/alloc-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/initterm-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/memobj-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/memuserkernel-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/mp-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/mpnotification-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/process-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/semevent-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/semeventmulti-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/semfastmutex-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/semmutex-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/spinlock-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/thread-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/thread2-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/time-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/timer-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/generic/semspinmutex-r0drv-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/alloc/alloc.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/checksum/crc32.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/checksum/ipv4.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/checksum/ipv6.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/err/RTErrConvertFromErrno.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/err/RTErrConvertToErrno.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/log.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/logellipsis.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/logrel.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/logrelellipsis.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/logcom.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/log/logformat.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg1Weak.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2Add.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2AddWeak.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2AddWeakV.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2Weak.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/RTAssertMsg2WeakV.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/assert.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/handletable.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/misc/handletablectx.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/string/strformat.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/string/strformatrt.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/string/strformattype.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/string/strprintf.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/string/strtonum.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte common/time/time.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r0drv/linux/RTLogWriteDebugger-r0drv-linux.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/RTAssertShouldPanic-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/RTLogWriteStdErr-stub-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/RTLogWriteStdOut-stub-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/RTLogWriteUser-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/RTTimerCreate-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte generic/uuid-generic.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte VBox/log-vbox.o
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(BUILD_TARGET_ARCH),x86)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOBJS += math/gcc/divdi3.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte math/gcc/moddi3.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte math/gcc/qdivrem.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte math/gcc/udivdi3.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte math/gcc/divdi3.o \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte math/gcc/umoddi3.o
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(BUILD_TARGET_ARCH),amd64)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOBJS += common/alloc/heapsimple.o
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteendif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifneq ($(MAKECMDGOALS),clean)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteifeq ($(KERNELRELEASE),)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # building from this directory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte #
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # kernel base directory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifndef KERN_DIR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # build for the current kernel, version check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KERN_DIR := /lib/modules/$(shell uname -r)/build
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KERN_DIR := /usr/src/linux
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(error Error: unable to find the sources of your current Linux kernel. \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Specify KERN_DIR=<directory> and run Make again)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $(warning Warning: using /usr/src/linux as the source directory of your \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Linux kernel. If this is not correct, specify \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KERN_DIR=<directory> and run Make again.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte endif
# check if versions match -- works only for later 2.6 kernels
VBOX_KERN_VER := $(shell $(MAKE) -sC $(KERN_DIR) --no-print-directory kernelrelease 2> /dev/null || true)
ifneq ($(VBOX_KERN_VER),)
ifneq ($(VBOX_KERN_VER),$(shell uname -r))
$(error Error: /usr/src/linux (version $(VBOX_KERN_VER)) does not match \
the current kernel (version $(shell uname -r)))
endif
endif
else
# build for a dedicated kernel, no version check
ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
$(error Error: KERN_DIR does not point to a directory)
endif
endif
# includes
ifndef KERN_INCL
KERN_INCL = $(KERN_DIR)/include
endif
ifneq ($(shell if test -d $(KERN_INCL); then echo yes; fi),yes)
$(error Error: unable to find the include directory for your current Linux \
kernel. Specify KERN_INCL=<directory> and run Make again)
endif
# module install dir, only for current kernel
ifneq ($(filter install install_rpm,$(MAKECMDGOALS)),)
ifndef MODULE_DIR
MODULE_DIR_TST := /lib/modules/$(shell uname -r)
ifeq ($(shell if test -d $(MODULE_DIR_TST); then echo yes; fi),yes)
MODULE_DIR := $(MODULE_DIR_TST)/misc
else
$(error Unable to find the folder to install the support driver to)
endif
endif # MODULE_DIR unspecified
endif
else # neq($(KERNELRELEASE),)
#
# building from kbuild (make -C <kernel_directory> M=`pwd`)
#
endif # neq($(KERNELRELEASE),)
# debug - show guesses.
ifdef DEBUG
$(warning dbg: KERN_DIR = $(KERN_DIR))
$(warning dbg: KERN_INCL = $(KERN_INCL))
$(warning dbg: MODULE_DIR = $(MODULE_DIR))
endif
KBUILD_VERBOSE ?= 1
#
# Compiler options
#
ifndef INCL
INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
ifndef KBUILD_EXTMOD
KBUILD_EXTMOD := $(shell pwd)
endif
INCL += $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
INCL += $(addprefix -I$(KBUILD_EXTMOD)/vboxdrv,/ /include /r0drv/linux)
export INCL
endif
KFLAGS := -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
-DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING
ifdef VBOX_REDHAT_KABI
KFLAGS += -DVBOX_REDHAT_KABI
endif
ifndef CONFIG_VBOXDRV_FIXEDMAJOR
KFLAGS += -DCONFIG_VBOXDRV_AS_MISC
endif
ifeq ($(BUILD_TARGET_ARCH),amd64)
KFLAGS += -DRT_ARCH_AMD64
else
KFLAGS += -DRT_ARCH_X86
endif
# must be consistent with Config.kmk!
KFLAGS += -DVBOX_WITH_64_BITS_GUESTS
ifeq ($(BUILD_TYPE),debug)
KFLAGS += -DDEBUG -DDEBUG_$(USER) -g
# IPRT_DEBUG_SEMS indicates thread wrt sems state via the comm field.
#KFLAGS += -DIPRT_DEBUG_SEMS
endif
# 2.6 and later
MODULE_EXT := ko
$(MODULE)-y := $(OBJS)
# build defs
EXTRA_CFLAGS += $(INCL) $(KFLAGS) $(KDEBUG)
all: $(MODULE)
obj-m += $(MODULE).o
$(MODULE):
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) modules
install: $(MODULE)
@mkdir -p $(MODULE_DIR); \
install -m 0664 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
PATH="$(PATH):/bin:/sbin" depmod -a; \
rm -f /etc/vbox/module_not_compiled
install_rpm: $(MODULE)
@mkdir -p $(MODULE_DIR); \
install -m 0664 $(MODULE).$(MODULE_EXT) $(MODULE_DIR)
else # eq ($(MAKECMDGOALS),clean)
ifndef KERN_DIR
KERN_DIR := /lib/modules/$(shell uname -r)/build
ifeq ($(wildcard $(KERN_DIR)/Makefile),)
KERN_DIR := /usr/src/linux
endif
endif
ifeq ($(wildcard $(KERN_DIR)/Makefile),)
clean:
find . \( -name \*.o -o -name \*.cmd \) -print0 | xargs -0 rm -f
rm -rf .tmp_ver* $(MODULE).* Module.symvers Modules.symvers modules.order
else
clean:
$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) -C $(KERN_DIR) clean
endif
endif # eq($(MAKECMDGOALS),clean)