# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../nvidia/postlinux.conf
# Copyright (C) 2008 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# 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 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

# this builds the matching nvidia kernel modules for the building kernel

nvidia_main() {
	f=
	case $arch in
	  x86) f="`match_source_file -p -x86-`" ;;
	  x86-64) f="`match_source_file -p -x86_64-`" ;;
	  ia64) f="`match_source_file -p -ia64-`" ;;
	esac
	[ "$f" ] || abort "No binary for this architecture detected!"

	sh $f --extract-only
	cd N*-Linux-*-pkg*

	apply_patchfiles

	cd usr/src/nv
	var_append makeopt " " "CC=$KCC"

	var_append makeopt " " "SYSSRC=$kerneldir KERNEL_MODLIB=$moduledir"
	var_append makeopt " " "KERNEL_UNAME=$lx_kernelrelease"
	var_append makeopt " " "MODULE_ROOT=$moduledir"

	echo $MAKE $makeopt module
	eval $MAKE $makeopt module
	if [[ $treever = 24* ]] ; then
		echo $MAKE $makeopt package-install
		eval $MAKE $makeopt package-install
	else
		echo $MAKE $makeopt module-install
		eval $MAKE $makeopt module-install
	fi
}

autoextract=0
custmain="nvidia_main"

var_append KCC_WRAPPER_REMOVE ' ' '-Werror'