2
##########################################################
3
# Copyright (C) 1998 VMware, Inc. All rights reserved.
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by the
7
# Free Software Foundation version 2 and no later version.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
##########################################################
21
#### VMware kernel module Makefile to be distributed externally
25
#### SRCROOT _must_ be a relative path.
29
VM_UNAME = $(shell uname -r)
31
# Header directory for the running kernel
32
HEADER_DIR = /lib/modules/$(VM_UNAME)/build/include
34
BUILD_DIR = $(HEADER_DIR)/..
42
vm_check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
43
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
44
vm_check_file = $(shell if test -f $(1); then echo "yes"; else echo "no"; fi)
48
ifeq ($(call vm_check_file,$(BUILD_DIR)/Makefile), yes)
49
ifneq ($(call vm_check_file,$(BUILD_DIR)/Rules.make), yes)
56
ifndef VM_KBUILD_SHOWN
57
ifeq ($(VM_KBUILD), no)
58
VM_DUMMY := $(shell echo >&2 "Using standalone build system.")
60
ifeq ($(VM_KBUILD), 24)
61
VM_DUMMY := $(shell echo >&2 "Using 2.4.x kernel build system.")
63
VM_DUMMY := $(shell echo >&2 "Using 2.6.x kernel build system.")
66
VM_KBUILD_SHOWN := yes
67
export VM_KBUILD_SHOWN
70
ifneq ($(VM_KBUILD), no)
72
VMCCVER := $(shell $(CC) -dumpversion)
74
# If there is no version defined, we are in toplevel pass, not yet in kernel makefiles...
77
ifeq ($(VM_KBUILD), 24)
78
DRIVER_KO := $(DRIVER).o
80
DRIVER_KO := $(DRIVER).ko
85
auto-build: $(DRIVER_KO)
86
cp -f $< $(SRCROOT)/../$(DRIVER).o
88
# $(DRIVER_KO) is a phony target, so compare file times explicitly
89
$(DRIVER): $(DRIVER_KO)
90
if [ $< -nt $@ ] || [ ! -e $@ ] ; then cp -f $< $@; fi
92
# Pass gcc version down the chain, so we can detect if kernel attempts to use unapproved compiler
93
VM_CCVER := $(VMCCVER)
98
MAKEOVERRIDES := $(filter-out CC=%,$(MAKEOVERRIDES))
101
make -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) modules
105
ifneq ($(VM_CCVER), $(VMCCVER))
106
$(warning *** Inappropriate build environment: you wanted to use gcc \
107
version $(VM_CCVER) while kernel attempts to use gcc version $(VMCCVER).)
108
$(error For proper build you'll have to replace $(CC) with symbolic \
114
vm_check_build = $(shell if $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
115
$(CPPFLAGS) $(CFLAGS) $(CFLAGS_KERNEL) \
116
$(EXTRA_CFLAGS) -Iinclude2/asm/mach-default \
117
-DKBUILD_BASENAME=\"$(DRIVER)\" \
118
-Werror -S -o /dev/null -xc $(1) \
119
> /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi)
121
CC_WARNINGS := -Wall -Wstrict-prototypes
122
CC_OPTS := $(GLOBAL_DEFS) $(CC_WARNINGS) -DVMW_USING_KBUILD
124
CC_OPTS += -DVMX86_DEVEL
127
CC_OPTS += -DVMX86_DEBUG
130
include $(SRCROOT)/Makefile.kernel
133
ifeq ($(VM_KBUILD), 24)
135
O_TARGET := $(DRIVER).o
137
obj-y := $($(DRIVER)-y)
139
include $(TOPDIR)/Rules.make
145
include $(SRCROOT)/Makefile.normal