#!/usr/bin/make -f

package=@CNXTTARGET@modem

build:
	$(checkdir)
	
	$(MAKE) all
	touch build

clean:
	$(checkdir)
	-rm -f build
	-$(MAKE) clean
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars

binary-indep: checkroot build
	$(checkdir)

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp
	$(MAKE) ROOT=`pwd`/debian/tmp install
	rm -rf debian/@CNXTTARGET@modem-doc
	echo "./usr/share/doc/@CNXTTARGET@modem/100498D_RM_HxF_Released.pdf" > debian/@CNXTTARGET@modem-doc.files
	# remove duplicate LICENSE
	rm -f debian/tmp/usr/lib/@CNXTTARGET@modem/LICENSE
# Must have debmake installed for this to work. Otherwise please copy
# /usr/bin/debstd into the debian directory and change debstd to debian/debstd
	debstd BUGS CHANGES CREDITS FAQ INSTALL LICENSE README 100498D_RM_HxF_Released.pdf
	dpkg-gencontrol -p@CNXTTARGET@modem -isp
	chown -R root.root debian/tmp
#	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot
