
OSSORELEASE = $(shell cat ../osso-release)

DEBIAN_DIR := debian

KSRC = ../linux-g

KSRCVER = $(shell dpkg-parsechangelog -l$(KSRC)/$(DEBIAN_DIR)/changelog  | awk '/^Version/{print $$2}')
KMAJORVER = $(word 1, $(subst -, ,$(KSRCVER)))
WEEK = $(word 1, $(OSSORELEASE))
BUILD = $(word 2, $(OSSORELEASE))

USER = $(shell whoami)

all: deb

deb: control-stamp changelog-stamp
	dpkg-buildpackage -i'.git/' -I'.git' -rfakeroot -S 

modules:
	fakeroot debian/rules modules-deb

control-stamp: control
	touch control-stamp

control:
	sed -i 's/^Build-Depends-Indep: kernel-source-rx-34 (=[^)]*)/Build-Depends-Indep: kernel-source-rx-34 (=$(KSRCVER))/' $(DEBIAN_DIR)/control

changelog-stamp: changelog
	touch changelog-stamp

changelog:
	dch -v $(KMAJORVER)-$(WEEK)osso$(BUILD) "Updated kernel version ($(KSRCVER))"

version:
	dch -i "Custom $(USER) kernel modules version" 

clean:
	rm -f control-stamp changelog-stamp
