1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#!/usr/bin/make -f
##########################################################
# Copyright (C) 2007 VMware, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation version 2 and no later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
##########################################################
vm_check_build = $(shell if $(CC) $(CC_OPTS) $(INCLUDE) -Werror -S -o /dev/null -xc $(1) \
> /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi)
vm_product_defines = $(if $(findstring tools,$(1)), -DVMX86_TOOLS,)
####
#### DESTDIR is where the module, object files, and dependencies are built
####
DESTDIR := driver-$(VM_UNAME)
####
#### DRIVERNAME should be untouched unless you have a good reason to change
#### it. The form below is how the scripts expect it.
####
DRIVERNAME := $(DRIVER)-xxx-$(VM_UNAME)
ifneq (,$(filter x86_64%, $(shell $(CC) -dumpmachine)))
MACHINE := x86_64
else
MACHINE := x386
endif
ifdef QUIET
ECHO := @true
else
ECHO := @echo
endif
####
#### You must compile with at least -O level of optimization
#### or the module won't load.
#### If desparate, I think that bringing in <linux/bitops.h> might
#### suffice.
####
CC_WARNINGS := -Wall -Wstrict-prototypes
# Don't use -pipe or egcs-2.91.66 (shipped with RedHat) will die
CC_KFLAGS := -D__KERNEL__ -fno-strength-reduce -fno-omit-frame-pointer \
-fno-common -DKBUILD_MODNAME=$(DRIVER)
CC_KFLAGS += $(call vm_check_gcc,-falign-loops=2 -falign-jumps=2 -falign-functions=2, \
-malign-loops=2 -malign-jumps=2 -malign-functions=2)
CC_KFLAGS += $(call vm_check_gcc,-fno-strict-aliasing,)
CC_KFLAGS += $(call vm_product_defines, $(PRODUCT))
ifeq ($(MACHINE),x86_64)
CC_KFLAGS += -mno-red-zone -mcmodel=kernel
else
# Gcc 3.0 deprecates -m486 --hpreg
CC_KFLAGS += -DCPU=586 $(call check_gcc,-march=i586,-m486)
endif
CC_OPTS := -O2 -DMODULE $(GLOBAL_DEFS) $(CC_KFLAGS) $(CC_WARNINGS)
INCLUDE += -I$(SRCROOT)/include
INCLUDE += -I$(SRCROOT)/linux
INCLUDE += -I$(SRCROOT)/common
INCLUDE += -I$(HEADER_DIR)
INCLUDE += $(shell $(CC) $(INCLUDE) -E $(AUTOCONF_DIR)/geninclude.c \
| sed -n -e 's!^APATH!-I$(HEADER_DIR)/asm!p')
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/skas1.c, -DVMW_SKAS_MMAP, )
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/epoll.c, -DVMW_HAVE_EPOLL, )
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/setnice.c, -DVMW_HAVE_SET_USER_NICE, )
# This test is inverted.
CC_OPTS += $(call vm_check_build, $(AUTOCONF_DIR)/sk_filter.c,, -DVMW_HAVE_NEW_SKFILTER )
CC_OPTS += -DVMW_KMEMCR_HAS_DTOR
LINUX_OBJS := af_vsock.o
LINUX_OBJS += vsockAddr.o
LINUX_OBJS += util.o
LINUX_OBJS += driverLog.o
LINUX_DEPS := ${LINUX_OBJS:.o=.d}
OBJS := $(LINUX_OBJS)
ifdef OVT_SOURCE_PATH
driverLog.o: $(OVT_SOURCE_DIR)/modules/linux/shared/driverLog.c
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
else
driverLog.o: shared/driverLog.c
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
endif
####
#### Make Targets are beneath here.
####
driver: setup deps
$(MAKE) -C $(DESTDIR) -f ../Makefile SRCROOT=../$(SRCROOT) $(DRIVERNAME) \
INCLUDE_DEPS=1
setup:
@if [ -d $(DESTDIR) ] ; then true ; else mkdir $(DESTDIR); chmod 755 $(DESTDIR) ; fi
$(DRIVER): $(DRIVERNAME)
cp -f $< $@
$(DRIVERNAME): $(OBJS)
$(ECHO) "Building $(DRIVERNAME)"
ld -r -o $(DRIVERNAME) $^
auto-build:
$(MAKE) driver QUIET=1
cp -f $(DESTDIR)/$(DRIVERNAME) $(SRCROOT)/../$(DRIVER).o
$(LINUX_OBJS): %.o: $(SRCROOT)/linux/%.c
$(ECHO) "Compiling $<"
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
clean:
rm -rf $(DESTDIR)/
$(LINUX_DEPS): %.d: $(SRCROOT)/linux/%.c
$(ECHO) "Dependencies for $<"
$(CC) -MM $(CC_OPTS) $(INCLUDE) $< > $@
deps: setup
$(MAKE) -C $(DESTDIR) -f ../Makefile SRCROOT=../$(SRCROOT) driver_deps
driver_deps: ${OBJS:.o=.d}
ifdef INCLUDE_DEPS
include ${OBJS:.o=.d}
endif
.SILENT:
|