#
# Makefile for the Linux Philips USB Webcam driver
#
# NOTE: This make file can serve as both an external Makefile (launched
#       directly by the user), or as the sub-dir Makefile used by the kernel
#       build system.

# Debianizando...
DESTDIR=

# If CONFIG_USB_PWC isn't set, we'll assume the user want to build this driver has a module

ifndef CONFIG_USB_PWC
CONFIG_USB_PWC=m
endif

ifneq ($(KERNELRELEASE),)

pwc-objs	:= pwc-if.o pwc-misc.o pwc-ctrl.o pwc-v4l.o pwc-uncompress.o
pwc-objs	+= pwc-dec1.o pwc-dec23.o pwc-kiara.o pwc-timon.o

obj-$(CONFIG_USB_PWC) += pwc.o

else
ifndef KVER
KVER  := $(shell uname -r)
endif
KLINK := $(shell test -e /lib/modules/${KVER}/source/ && echo source || echo build)
KSRC  := /lib/modules/$(KVER)/$(KLINK)
KMISC := /lib/modules/$(KVER)/kernel/drivers/usb/media
PWD := $(shell pwd)
EXTRA_CFLAGS=-Wall

# Fix some problem with suse < 9.2 and suse >= 9.2
is_suse := $(shell test -e /etc/SuSE-release && echo 1 || echo 0)
ifeq ($(is_suse),1)
  is_suse_92 := $(shell grep -q "SuSE Linux 9.[23]" /etc/SuSE-release && echo 1 || echo 0)
  ifeq ($(is_suse_92),1)
    KSRC := /lib/modules/$(KVER)/build
  endif
endif



default:
	$(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules

install: default
	install -d $(DESTDIR)/$(KMISC)
	install -m 644 -c pwc.ko $(DESTDIR)/$(KMISC)

uninstall:
	-rm -rf $(KMISC)/pwc.ko

endif

clean:
	rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
	rm -rf .tmp_versions

