# Makefile for admutils

CC	=	gcc

# where to put certain binaries, in this case mount/umount and shutdown
# change it to /sbin in certain cases
#SBINDIR	=	/etc
SBINDIR	=	/sbin

# see pathnames.h for details
#LOGDIR	=	/etc
LOGDIR	=	/var/log

# Add -DNO_PATHS_H if you don't have <paths.h> (old libs & includes...)
CFLAGS	=	-Wall -O2 -I. -DSBINDIR=\"$(SBINDIR)\" -DLOGDIR=\"$(LOGDIR)\"
LDFLAGS	=	-s -N
USRBIN	=	last chsh passwd newgrp shutdown su ctrlaltdel
PRGS	=	${USRBIN}
OBJS	=	last.o chsh.o passwd.o newgrp.o shutdown.o su.o ctrlaltdel.o \
		islocal.o
LIBS	=

all:	${PRGS}

install: ${USRBIN}
	cp -f last chsh passwd newgrp ctrlaltdel /usr/bin
	(cd /usr/bin; \
	  chown 0:0 passwd newgrp chsh; \
	  chmod a=x,u+s passwd newgrp chsh)
	cp -f shutdown $(SBINDIR)
	chown 0:0 $(SBINDIR)/shutdown
	chmod 110 $(SBINDIR)/shutdown
	-ln -fs $(SBINDIR)/shutdown /usr/bin/reboot
	-ln -fs $(SBINDIR)/shutdown /usr/bin/halt
	-ln -fs $(SBINDIR)/shutdown /usr/bin/fastboot
	-ln -fs $(SBINDIR)/shutdown /usr/bin/fasthalt
	cp -f su /bin/su
	chown 0:0 /bin/su
	chmod 4110 /bin/su
	-if [ ! -e /etc/shells ]; then cp shells /etc; fi
	-chmod a+r shells

chsh:	chsh.o islocal.o

passwd:	passwd.o islocal.o

clean:	
	rm -f *.o core

real-clean: clean
	rm -f ${PRGS}
