152 lines
4.7 KiB
Makefile
152 lines
4.7 KiB
Makefile
#!/usr/bin/make -f
|
|
##########################################################
|
|
# Copyright (C) 1998,2015 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)
|
|
|
|
####
|
|
#### 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,)
|
|
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 -DVMMON -DVMCORE $(GLOBAL_DEFS) $(CC_KFLAGS) $(CC_WARNINGS)
|
|
|
|
INCLUDE := -I$(SRCROOT)/include -I$(SRCROOT)/common -I$(SRCROOT)/linux \
|
|
-I$(SRCROOT)/vmcore -I$(HEADER_DIR)
|
|
|
|
INCLUDE += $(shell $(CC) $(INCLUDE) -E $(SRCROOT)/autoconf/geninclude.c \
|
|
| sed -n -e 's!^APATH!-I$(HEADER_DIR)/asm!p')
|
|
|
|
C_TARGETS_LINUX := driver.o hostif.o driverLog.o
|
|
C_TARGETS_COMMON := vmx86.o memtrack.o phystrack.o cpuid.o task.o hashFunc.o
|
|
C_TARGETS_VMCORE := moduleloop.o
|
|
C_TARGETS_BOOTSTRAP := bootstrap.o
|
|
C_TARGETS_LINUX_D := ${C_TARGETS_LINUX:.o=.d}
|
|
C_TARGETS_COMMON_D := ${C_TARGETS_COMMON:.o=.d}
|
|
C_TARGETS_VMCORE_D := ${C_TARGETS_VMCORE:.o=.d}
|
|
C_TARGETS_BOOTSTRAP_D := ${C_TARGETS_BOOTSTRAP:.o=.d}
|
|
C_TARGETS := $(C_TARGETS_LINUX) $(C_TARGETS_COMMON) $(C_TARGETS_VMCORE) \
|
|
$(C_TARGETS_BOOTSTRAP)
|
|
|
|
####
|
|
#### Make Targets are beneath here.
|
|
####
|
|
|
|
driver: setup deps
|
|
$(MAKE) -C $(DESTDIR) -f ../Makefile SRCROOT=../$(SRCROOT) $(DRIVER).o \
|
|
INCLUDE_DEPS=1
|
|
|
|
setup:
|
|
@if [ -d $(DESTDIR) ] ; then true ; else mkdir $(DESTDIR); chmod 755 $(DESTDIR) ; fi
|
|
|
|
$(DRIVER) $(DRIVER).o: $(DRIVERNAME)
|
|
cp -f $< $@
|
|
|
|
$(DRIVERNAME): $(C_TARGETS)
|
|
$(ECHO) "Building $(DRIVERNAME)"
|
|
ld -r -o $(DRIVERNAME) $(C_TARGETS)
|
|
|
|
auto-build:
|
|
$(MAKE) driver QUIET=1
|
|
cp -f $(DESTDIR)/$(DRIVERNAME) $(SRCROOT)/../$(DRIVER).o
|
|
|
|
$(C_TARGETS_LINUX): %.o: $(SRCROOT)/linux/%.c
|
|
$(ECHO) "Compiling linux/$(<F)"
|
|
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
|
|
|
|
$(C_TARGETS_COMMON): %.o: $(SRCROOT)/common/%.c
|
|
$(ECHO) "Compiling common/$(<F)"
|
|
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
|
|
|
|
$(C_TARGETS_VMCORE): %.o: $(SRCROOT)/vmcore/%.c
|
|
$(ECHO) "Compiling vmcore/$(<F)"
|
|
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
|
|
|
|
$(C_TARGETS_BOOTSTRAP): %.o: $(SRCROOT)/bootstrap/%.c
|
|
$(ECHO) "Compiling bootstrap/$(<F)"
|
|
$(CC) $(CC_OPTS) $(INCLUDE) -c $<
|
|
|
|
clean:
|
|
rm -rf $(DESTDIR)/
|
|
|
|
$(C_TARGETS_COMMON_D): %.d: $(SRCROOT)/common/%.c
|
|
$(ECHO) "Dependencies for $(<F)"
|
|
$(CC) -MM $(CC_OPTS) $(INCLUDE) $< > $@
|
|
|
|
$(C_TARGETS_LINUX_D): %.d: $(SRCROOT)/linux/%.c
|
|
$(ECHO) "Dependencies for $(<F)"
|
|
$(CC) -MM $(CC_OPTS) $(INCLUDE) $< > $@
|
|
|
|
$(C_TARGETS_VMCORE_D): %.d: $(SRCROOT)/vmcore/%.c
|
|
$(ECHO) "Dependencies for $(<F)"
|
|
$(CC) -MM $(CC_OPTS) $(INCLUDE) $< > $@
|
|
|
|
$(C_TARGETS_BOOTSTRAP_D): %.d: $(SRCROOT)/bootstrap/%.c
|
|
$(ECHO) "Dependencies for $(<F)"
|
|
$(CC) -MM $(CC_OPTS) $(INCLUDE) $< > $@
|
|
|
|
deps: setup
|
|
$(MAKE) -C $(DESTDIR) -f ../Makefile SRCROOT=../$(SRCROOT) driver_deps
|
|
|
|
driver_deps: ${C_TARGETS:.o=.d}
|
|
|
|
ifdef INCLUDE_DEPS
|
|
include ${C_TARGETS:.o=.d}
|
|
endif
|
|
|
|
.SILENT:
|