#!/usr/bin/make -f
# Sample debian/rules file - for GNU Hello.
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

etcdir =  $(DEBIAN_DIR)/tmp/etc/
afinitd = $(DEBIAN_DIR)/tmp/etc/osso-af-init
initdir = $(DEBIAN_DIR)/tmp/etc/init.d/

build:
	touch build

clean:
	$(checkdir)
	rm -f build
	rm -rf *~ $(DEBIAN_DIR)/tmp $(DEBIAN_DIR)/*~ $(DEBIAN_DIR)/files* $(DEBIAN_DIR)/substvars

binary-indep:	checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:	checkroot build
	$(checkdir)
	rm -rf $(DEBIAN_DIR)/tmp
	install -d $(DEBIAN_DIR)/tmp/ $(afinitd)
	install -d $(DEBIAN_DIR)/tmp/ $(initdir)
	install -d $(DEBIAN_DIR)/tmp/DEBIAN $(DEBIAN_DIR)/tmp/usr/lib/hotplug/firmware/
	install x-server.defs $(afinitd)
	install x-server.sh minircS minishutdown minireboot ttyusb0 $(initdir)
	ln -sf /mnt/initfs/usr/lib/hotplug/firmware/brf6150fw.bin $(DEBIAN_DIR)/tmp/usr/lib/hotplug/firmware/
	ln -sf /mnt/initfs/usr/lib/hotplug/firmware/3825.arm $(DEBIAN_DIR)/tmp/usr/lib/hotplug/firmware/
	install -m 755 $(DEBIAN_DIR)/postinst $(DEBIAN_DIR)/tmp/DEBIAN/
	cp -a fstab inittab network resolv.conf $(etcdir)
	dpkg-gencontrol -isp
	chown -R root:root $(DEBIAN_DIR)/tmp
	chmod -R u+w,go=rX $(DEBIAN_DIR)/tmp
	dpkg --build $(DEBIAN_DIR)/tmp ..

define checkdir
	test -f $(DEBIAN_DIR)/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test $$(id -u) = 0

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