#!/usr/bin/make -sf

# This is modelled on the Debian dpkg build ruleset.

.PHONY: build binary stage control clean

BINARY_PACKAGES=uschedule

# Target this in order to make the package contents.
build:
	MAKEFLAGS= package/compile

# Target this in order to clean the build areas.
clean:
	for i in ${BINARY_PACKAGES} ; \
	do \
		rm -r -f bsd/"$$i"/ || exit 1 ; \
	done
	rm -r -f bsd/tmp/

# Target this in order to make the package files.
binary: stage control
	for i in ${BINARY_PACKAGES} ; \
	do \
		echo 1>&2 "Building package $$i." ; \
		bsd/pkgcreate bsd/"$$i"/ bsd/"$$i"/ "$$i" || exit 1 ; \
	done

stage:
	echo 1>&2 "Copying slashpackage image."
	install -d -m 0755 bsd/tmp
	pax -r -w -l command doc bsd/tmp/
	echo 1>&2 "Building staging areas."
	package/stage bsd/tmp bsd

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