#!/usr/bin/make -f

# debug
#export DH_VERBOSE=y
#export TO_NULL=&>/dev/null
#TO_NULL=&>/dev/null
#MAKEFLAGS+=-s --no-print-directory

#export DH_OPTIONS

TARGET_DIR=debian/tmp/etc/wlan/
TARGET_DIR_COPYRIGHT=debian/tmp/usr/share/doc/linux-wlan-ng-firmware-files/

# install stuff that is arch dependent
install-stamp:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# firmware files	
	mkdir -p $(TARGET_DIR)
	for x in src/prism2/*.hex ; do \
		if [ -f "$$x" ]; then \
			SUFFIX=`echo $$x |  cut -c12-13`;\
			cp $$x $(TARGET_DIR)prism2_$$SUFFIX.hex ; \
		fi; \
	done

	# copyright
	mkdir -p $(TARGET_DIR_COPYRIGHT)
	cp src/prism2/README.firmware $(TARGET_DIR_COPYRIGHT)/copyright 
	touch install-stamp

# package all arch dependent stuff
binary-indep: DH_OPTIONS=-i
binary-indep: install-stamp
	dh_installdirs $(DH_OPTIONS)
	dh_install $(DH_OPTIONS)
	dh_installchangelogs $(DH_OPTIONS)
	dh_strip  $(DH_OPTIONS) 
	dh_fixperms  $(DH_OPTIONS) 
	dh_shlibdeps  $(DH_OPTIONS)   
	dh_installdeb  $(DH_OPTIONS)  
	dh_gencontrol  $(DH_OPTIONS)
	dh_compress    $(DH_OPTIONS) 
	dh_md5sums     $(DH_OPTIONS) 
	dh_builddeb    $(DH_OPTIONS)  

build-stamp:
	touch build-stamp

build: build-stamp

############################ CLEAN ################################

clean:
	dh_clean debian/postinst

# stamps
	$(RM) build-stamp install-stamp 
	
########################## MAIN ##################################

binary-arch:
	
binary: binary-indep 

.PHONY: build clean binary-arch binary
