#
# This Makefile was automatically generated; do not edit.
# Generated on 'swio-display-x64-rhel04-12' on Wed Jan 8 18:51:58 PST 2014.
#

#
# KBUILD Makefile for the NVIDIA Linux kernel module.
#
# The motivation for replacing the original Makefile is the hope that this
# version will simplify the build and installation process. In the past,
# many architectural and cosmetic changes to the Linux kernel have made it
# difficult to maintain compatibility or required duplication of logic.
#
# Linux 2.6 introduces numerous such changes, many of which impact modules.
# Relying on KBUILD, some aspects of the build system otherwise difficult
# to support (for example, module versioning) are abstracted away and dealt
# with elsewhere, making life significantly easier here.
#
# The new approach currently has its own share of problems, some of which
# are architectural difficulties with KBUILD, others minor annoyances. For
# this reason, an improved version of the NVIDIA Makefile is available to
# those experiencing difficulties.
#
# kbuild Makefile originally developed by:
#
# Alistair J Strachan (alistair@devzero.co.uk) (first pass, enhancements)
# Christian Zander (zander@mail.minion.de) (enhancements)
#

#
# The NVIDIA kernel module base name.
#

MODULE_BASENAME := nvidia

# 
# This suffix is used to construct the name of the NVIDIA kernel module
# in case of multiple kernel module builds. This suffix can either take the 
# numeric value 0-7 or the string "frontend". For normal NVIDIA kernel module 
# builds, this variable is empty and hence the module name is identical to 
# the base names.
#

NV_MODULE_SUFFIX ?=

#
# The NVIDIA kernel module name and static file names. In case of multiple 
# NVIDIA kernel module builds, $(NV_MODULE_SUFFIX) is appended to the 
# module basename to construct the module name of the concerned module. 
# KBUILD will go ahead and append ".o" or ".ko" to form the module file name. 
#

ifeq ($(NV_MODULE_SUFFIX),frontend)
 MODULE_NAME := $(MODULE_BASENAME)-$(NV_MODULE_SUFFIX)
else
 MODULE_NAME := $(MODULE_BASENAME)$(NV_MODULE_SUFFIX)
endif
VERSION_HEADER := nv_compiler.h

#
# List of object files to link into NVIDIA kernel module; this list
# is assigned depending on the value of $(NV_MODULE_SUFFIX) being passed.
# Make sure KBUILD understands that we want a module.
#

CORE_OBJS := nv-kernel.o

ifdef NV_BUILD_MODULE_INSTANCES
 ifeq ($(NV_MODULE_SUFFIX),frontend)
 MODULE_GLUE_OBJS := $(patsubst %.c,%.o,nv-frontend.c)
 $(MODULE_NAME)-objs := $(MODULE_GLUE_OBJS)
 else
 MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mlock.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-pci.c os-registry.c os-smp.c os-usermap.c nv_uvm_interface.c)
 $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
 endif
else
 MODULE_GLUE_OBJS := $(patsubst %.c,%.o, nv.c nv-acpi.c nv-chrdev.c nv-cray.c nv-drm.c nv-gvi.c nv-i2c.c nv-mempool.c nv-mlock.c nv-mmap.c nv-p2p.c nv-pat.c nv-procfs.c nv-usermap.c nv-vm.c nv-vtophys.c os-interface.c os-pci.c os-registry.c os-smp.c os-usermap.c nv_uvm_interface.c) $(patsubst %.c,%.o,nv-frontend.c)
 $(MODULE_NAME)-objs := $(CORE_OBJS) $(MODULE_GLUE_OBJS)
endif

#
# List of targets to build in case of multiple NVIDIA kernel module builds. 
# The actual target is constructed by prefixing nvidia/nvidia- to every
# item in the list $(BUILD_MODULES_LIST)/$(BUILD_MODULE_FRONTEND).
#

ifdef NV_BUILD_MODULE_INSTANCES
 BUILD_MODULES_LIST := $(shell seq 0 `expr $(NV_BUILD_MODULE_INSTANCES) - 1`)
 BUILD_MODULE_FRONTEND := frontend
endif

COMPILE_TESTS = \
	remap_page_range \
	remap_pfn_range \
	vmap \
	set_pages_uc \
	set_memory_uc \
	set_memory_array_uc \
	change_page_attr \
	i2c_adapter \
	pci_get_class \
	pm_message_t \
	irq_handler_t \
	pci_choose_state \
	vm_insert_page \
	acpi_device_ops \
	acpi_device_id \
	acquire_console_sem \
	kmem_cache_create \
	outer_flush_all \
	on_each_cpu \
	smp_call_function \
	vmm_support \
	nvmap_support \
	acpi_evaluate_integer \
	ioremap_cache \
	ioremap_wc \
	proc_dir_entry \
	INIT_WORK \
	acpi_walk_namespace \
	acpi_os_wait_events_complete \
	scatterlist \
	pci_domain_nr \
	pci_dma_mapping_error \
	file_operations \
	sg_init_table \
	pci_get_domain_bus_and_slot \
	get_num_physpages \
	efi_enabled \
	dom0_kernel_present \
	drm_available \
	proc_create_data \
	pde_data \
	proc_remove

#
# CFLAGS dependent on the type of builds (e.g. single/muliple module, debug)
#

ifdef NV_BUILD_MODULE_INSTANCES
 EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=1
 ifneq ($(NV_MODULE_SUFFIX),frontend)
 EXTRA_CFLAGS += -DNV_MODULE_INSTANCE=$(NV_MODULE_SUFFIX)
 endif
else
 EXTRA_CFLAGS += -DNV_MODULE_INSTANCE=0
 EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=0
endif

EXTRA_CFLAGS += -UDEBUG -U_DEBUG -DNDEBUG

#
# Include common definitions; we rely on the definition of the source path to
# find the file; set to a reasonable default if unset (e.g. for top-level
# passes). The source path is also used in the common file.
#

src ?= .
include $(src)/nvidia-modules-common.mk

#
# Expands into multiple targets on runtime depending on the items present in
# the lists $(BUILD_MODULES_LIST) and $(BUILD_MODULE_FRONTEND) for multiple
# NVIDIA kernel module builds.
# For normal builds, expands to the target $(MODULE_OBJECT).
#

ifdef NV_BUILD_MODULE_INSTANCES
 $(foreach obj_file, $(BUILD_MODULES_LIST), $(eval $(call BUILD_MODULE_RULE,$(MODULE_BASENAME)$(obj_file).ko,$(obj_file),$(MODULE_BASENAME)-$(BUILD_MODULE_FRONTEND).ko)))
 $(foreach obj_file, $(BUILD_MODULE_FRONTEND), $(eval $(call BUILD_MODULE_RULE,$(MODULE_BASENAME)-$(obj_file).ko,$(obj_file),)))
else
 $(eval $(call BUILD_MODULE_RULE, $(MODULE_OBJECT),,))
endif
