# This Makefile is automatically generated; do not edit
#   Generated on 'builder3' on Wed Sep 12 06:06:53 PDT 2001

LINUX_MODULE=Module-linux
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -D_X86_=1 -Di386=1 -DUNIX -DLINUX -DNV4_HW -DNTRM -DRM20 -D_GNU_SOURCE -DRM_HEAPMGR -D_LOOSE_KERNEL_NAMES   -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=1541
INCLUDES=-I.

OBJECTS=nv.o os-interface.o os-registry.o 
HEADERS=os-interface.h nv-linux.h nv.h nvrm.h nvtypes.h

CFLAGS=-Wall -Wno-unknown-pragmas -Wno-multichar -O $(DEFINES) $(INCLUDES)

RESMAN_KERNEL_MODULE=Module-nvkernel

KERNDIR=/lib/modules/$(shell uname -r)

# check for newer paths. if found, use them, otherwise use old paths
# these wouldn't work with the gnu make included with rh6.2
# KERNINC=$(if -d $(KERNDIR)/build, $(KERNDIR)/build/include, /usr/src/linux/include)
# INSTALLDIR=$(if -d $(KERNDIR)/kernel, $(KERNDIR)/kernel/video, $(KERNDIR)/video)

# this is slightly more brain-dead, but works..
ifeq ($(shell if test -d $(KERNDIR)/build; then echo yes; fi),yes)
KERNINC=$(KERNDIR)/build/include
else
KERNINC=/usr/src/linux/include
endif

ifeq ($(shell if test -d $(KERNDIR)/kernel; then echo yes; fi),yes)
INSTALLDIR=$(KERNDIR)/kernel/video
else
INSTALLDIR=$(KERNDIR)/video
endif

INSTALL=$(shell which install)

# allow specification of alternate include file tree on command line and extra defines
ifdef SYSINCLUDE
INCLUDES += -I$(SYSINCLUDE)
else
INCLUDES += -I$(KERNINC)
endif

DEFINES+=$(EXTRA_DEFINES)

# allow build parameters to be passed in through the environment
ifdef BUILD_PARAMS
    DEFINES+=-D$(BUILD_PARAMS)
endif

all: install

# always 'clean' before build
install: clean package-install

# allow installation without a clean rebuild, for package installation
package-install: NVdriver
	@if [ `id -ur` != 0 ]; then \
		echo Please run \"make install\" as root.; \
	else \
		mkdir -p $(INSTALLDIR) && \
		$(INSTALL) -m 0664 -o root -g root NVdriver $(INSTALLDIR)/NVdriver$(O) && \
		/sbin/depmod -a && \
		/sbin/modprobe NVdriver && \
		./makedevices.sh && \
		echo "NVdriver installed successfully."; \
	fi


NVdriver: $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)
	ld -r -o $@ $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)
	size $@

$(LINUX_MODULE): $(OBJECTS)
	ld -r -o $@ $(OBJECTS)

%.o: %.c $(HEADERS)
	$(CC) -c $(CFLAGS) $<

# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
%.i: %.c
	$(CC) $(CFLAGS) -E $< > $@

%.s: %.c
	$(CC) $(CFLAGS) -S $< > $@


clean:
	$(RM) $(OBJECTS) $(LINUX_MODULE) NVdriver

