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 vmmemctl Makefile to be distributed externally
24
vm_check_build = $(shell if $(CC) $(CC_OPTS) $(INCLUDE) \
25
-Werror -S -o /dev/null -xc $(1) \
26
> /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi)
28
DRIVERNAME = $(DRIVER)-$(VM_UNAME)
30
ifneq (,$(filter x86_64%, $(shell $(CC) -dumpmachine)))
37
#### You must compile with at least -O level of optimization
38
#### or the module won't load.
39
#### If desparate, I think that bringing in <linux/bitops.h> might
42
CC_WARNINGS := -Wall -Wstrict-prototypes
43
# Don't use -pipe or egcs-2.91.66 (shipped with RedHat) will die
44
CC_KFLAGS := -D__KERNEL__ -fno-strength-reduce -fno-omit-frame-pointer \
45
-fno-common -DKBUILD_MODNAME=$(DRIVER)
46
CC_KFLAGS += $(call vm_check_gcc,-falign-loops=2 -falign-jumps=2 -falign-functions=2, \
47
-malign-loops=2 -malign-jumps=2 -malign-functions=2)
48
CC_KFLAGS += $(call vm_check_gcc,-fno-strict-aliasing,)
49
ifeq ($(MACHINE),x86_64)
50
CC_KFLAGS += -mno-red-zone -mcmodel=kernel
52
# Gcc 3.0 deprecates -m486 --hpreg
53
CC_KFLAGS += -DCPU=586 $(call check_gcc,-march=i586,-m486)
56
INCLUDE += -I$(HEADER_DIR)
57
ifeq ($(USE_SHARED_DIR),1)
58
INCLUDE += -I$(call VMLIB_PATH,backdoor)
62
INCLUDE += $(shell $(CC) $(CC_OPTS) $(INCLUDE) \
63
-E $(AUTOCONF_DIR)/geninclude.c \
64
| sed -n -e 's!^APATH!-I$(HEADER_DIR)/asm!p')
66
CC_OPTS := -g3 -O2 -DMODULE $(GLOBAL_DEFS) $(CC_KFLAGS) $(CC_WARNINGS)
67
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/epoll.c, -DVMW_HAVE_EPOLL, )
68
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/setnice.c, -DVMW_HAVE_SET_USER_NICE, )
73
ifeq ($(MACHINE),x86_64)
74
OBJS += backdoorGcc64.o
76
OBJS += backdoorGcc32.o
79
CFLAGS := $(CC_OPTS) $(INCLUDE)
86
# In open-vm-tools, need to compile the common sources from the lib directory.
89
LIBBACKDOOR_PATH := $(call VMLIB_PATH,backdoor)
91
INCLUDE += -I$(LIBBACKDOOR_PATH)
93
LIBBACKDOOR := backdoorGcc32.o
94
LIBBACKDOOR += backdoorGcc64.o
96
$(LIBBACKDOOR): %.o: $(LIBBACKDOOR_PATH)/%.c
97
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
102
$(DRIVERNAME): $(OBJS)
105
$(DRIVER) $(DRIVER).o ../$(DRIVER).o: $(DRIVERNAME)
108
auto-build: ../$(DRIVER).o
111
rm -f $(DRIVERNAME) ../$(DRIVERNAME) $(DRIVER) $(DRIVER).o ../$(DRIVER).o $(OBJS)