# Makefile for shutdown / halt / reboot.

CFLAGS=$(OPT) -D_MINIX
LDFLAGS=-fnone

PROGRAMS=	shutdown halt tinyhalt
MANUALS=	shutdown.8 halt.8 reboot.8
MANDIR=		/usr/man

all:	$(PROGRAMS)

shutdown:	shutdown.o sh_wall.o log.o
	$(CC) $(LDFLAGS) -o shutdown shutdown.o sh_wall.o log.o

halt:	halt.o log.o
	$(CC) $(LDFLAGS) -o halt halt.o log.o

tinyhalt:	tinyhalt.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $?

install:	/usr/sbin/halt /usr/sbin/reboot /usr/sbin/shutdown \
		/sbin/halt /sbin/reboot \
		$(MANDIR)/man8/halt.8 $(MANDIR)/man8/reboot.8 \
		$(MANDIR)/man8/shutdown.8

/usr/sbin/halt:	halt
	install -c -o root -g operator -m 744 $? $@

/usr/sbin/reboot:	/usr/sbin/halt
	install -l $? $@

/usr/sbin/shutdown:	shutdown
	install -c -o root -g operator -m 4754 $? $@

/sbin/halt:	tinyhalt
	install -cs -o root -g operator -m 744 $? $@

/sbin/reboot:	/sbin/halt
	install -l $? $@

$(MANDIR)/man8/halt.8:	halt.8
	install -lc $? $@

$(MANDIR)/man8/reboot.8:	reboot.8
	install -lc $? $@

$(MANDIR)/man8/shutdown.8:	shutdown.8
	install -lc $? $@

clean:
	rm -f *.o a.out core $(PROGRAMS)
