~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to modules/linux/vmxnet3/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-10-23 15:32:00 UTC
  • mfrom: (1.1.2 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081023153200-gc1bfx89hj35c799
Tags: 2008.10.10-123053-2
* Correcting typo in dh_installinit call.
* Downgrading depends on module-assistant to recommends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/make -f
 
2
##########################################################
 
3
# Copyright (C) 1998 VMware, Inc. All rights reserved.
 
4
#
 
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.
 
8
#
 
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
 
12
# for more details.
 
13
#
 
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
 
17
#
 
18
##########################################################
 
19
 
 
20
####
 
21
####  VMware kernel module Makefile to be distributed externally
 
22
####
 
23
 
 
24
####
 
25
#### SRCROOT _must_ be a relative path.
 
26
####
 
27
SRCROOT = .
 
28
 
 
29
VM_UNAME = $(shell uname -r)
 
30
 
 
31
# Header directory for the running kernel
 
32
HEADER_DIR = /lib/modules/$(VM_UNAME)/build/include
 
33
 
 
34
BUILD_DIR = $(HEADER_DIR)/..
 
35
 
 
36
DRIVER := vmxnet3
 
37
PRODUCT := @PRODUCT@
 
38
 
 
39
# Grep program
 
40
GREP = /bin/grep
 
41
 
 
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)
 
45
 
 
46
ifndef VM_KBUILD
 
47
VM_KBUILD := no
 
48
ifeq ($(call vm_check_file,$(BUILD_DIR)/Makefile), yes)
 
49
ifneq ($(call vm_check_file,$(BUILD_DIR)/Rules.make), yes)
 
50
VM_KBUILD := 26
 
51
endif
 
52
endif
 
53
export VM_KBUILD
 
54
endif
 
55
 
 
56
ifndef VM_KBUILD_SHOWN
 
57
ifeq ($(VM_KBUILD), no)
 
58
VM_DUMMY := $(shell echo >&2 "Using standalone build system.")
 
59
else
 
60
ifeq ($(VM_KBUILD), 24)
 
61
VM_DUMMY := $(shell echo >&2 "Using 2.4.x kernel build system.")
 
62
else
 
63
VM_DUMMY := $(shell echo >&2 "Using 2.6.x kernel build system.")
 
64
endif
 
65
endif
 
66
VM_KBUILD_SHOWN := yes
 
67
export VM_KBUILD_SHOWN
 
68
endif
 
69
 
 
70
ifneq ($(VM_KBUILD), no)
 
71
 
 
72
VMCCVER := $(shell $(CC) -dumpversion)
 
73
 
 
74
# If there is no version defined, we are in toplevel pass, not yet in kernel makefiles...
 
75
ifeq ($(VERSION),)
 
76
 
 
77
ifeq ($(VM_KBUILD), 24)
 
78
DRIVER_KO := $(DRIVER).o
 
79
else
 
80
DRIVER_KO := $(DRIVER).ko
 
81
endif
 
82
 
 
83
.PHONY: $(DRIVER_KO)
 
84
 
 
85
auto-build: $(DRIVER_KO)
 
86
        cp -f $< $(SRCROOT)/../$(DRIVER).o
 
87
 
 
88
# $(DRIVER_KO) is a phony target, so compare file times explicitly
 
89
$(DRIVER): $(DRIVER_KO)
 
90
        if [ $< -nt $@ ] || [ ! -e $@ ] ; then cp -f $< $@; fi
 
91
 
 
92
# Pass gcc version down the chain, so we can detect if kernel attempts to use unapproved compiler
 
93
VM_CCVER := $(VMCCVER)
 
94
export VM_CCVER
 
95
VM_CC := $(CC)
 
96
export VM_CC
 
97
 
 
98
MAKEOVERRIDES := $(filter-out CC=%,$(MAKEOVERRIDES))
 
99
 
 
100
$(DRIVER_KO):
 
101
        make -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) modules
 
102
 
 
103
else
 
104
 
 
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 \
 
109
 link to $(VM_CC))
 
110
endif
 
111
 
 
112
endif
 
113
 
 
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)
 
120
 
 
121
CC_WARNINGS := -Wall -Wstrict-prototypes
 
122
CC_OPTS := $(GLOBAL_DEFS) $(CC_WARNINGS) -DVMW_USING_KBUILD
 
123
ifdef VMX86_DEVEL
 
124
CC_OPTS += -DVMX86_DEVEL
 
125
endif
 
126
ifdef VMX86_DEBUG
 
127
CC_OPTS += -DVMX86_DEBUG
 
128
endif
 
129
 
 
130
include $(SRCROOT)/Makefile.kernel
 
131
 
 
132
ifdef TOPDIR
 
133
ifeq ($(VM_KBUILD), 24)
 
134
 
 
135
O_TARGET := $(DRIVER).o
 
136
 
 
137
obj-y := $($(DRIVER)-y)
 
138
 
 
139
include $(TOPDIR)/Rules.make
 
140
endif
 
141
endif
 
142
 
 
143
else
 
144
 
 
145
include $(SRCROOT)/Makefile.normal
 
146
 
 
147
endif
 
148
 
 
149
#.SILENT: