#!/usr/bin/make -sf

.PHONY: build binary install clean stage control

BINARY_PACKAGES=uschedule

# The Debian package builder targets this in order to make the package contents.
build:
	MAKEFLAGS= package/compile

# The Debian package builder targets this in order to clean the build areas.
clean:
	${RM} debian/files debian/substvars
	for i in ${BINARY_PACKAGES} ; \
	do \
		${RM} -r debian/"$$i"/ || exit 1 ; \
	done
	${RM} -r debian/tmp/

# The Debian package builder targets this in order to make the .deb files.
binary: stage control
	for i in ${BINARY_PACKAGES} ; \
	do \
		dpkg -b debian/"$$i" ../ || exit 1 ; \
	done

stage:
	echo 1>&2 "Copying slashpackage image."
	install -d -m 0755 debian/tmp
	pax -r -w -l command doc debian/tmp/
	echo 1>&2 "Staging from debian/tmp/"
	package/stage debian/tmp debian

control:
	${RM} debian/files
	for i in ${BINARY_PACKAGES} ; \
	do \
		echo 1>&2 "Building control file for $$i." ; \
		debian/gencontrol "$$i" debian/"$$i" || exit 1 ; \
	done
