PROGS = quotacheck quotaon quota repquota warnquota edquota rpc.rquotad 
CC = gcc
CFLAGS = -O6 -fexpensive-optimizations -fstrength-reduce
LDFLAGS = -N -s
LLIBS = -lbsd
INSTALL = install
RPCSRC = rquota.h rquota_xdr.c rquota_clnt.c
RPCGEN = rpcgen

BINDIR = /usr/bin
SUPERBIN = /usr/sbin
MANDIR = /usr/man

all: $(PROGS)

clean:
	-rm -f core *.o

clobber:
	-rm -f core *.o $(RPCSRC) $(PROGS)

install: all 
	-$(INSTALL) -o bin -g staff -m 500 quotacheck edquota \
	quotaon repquota warnquota rpc.rquotad $(ROOTDIR)$(SUPERBIN)
	-rm -f $(ROOTDIR)$(SUPERBIN)/quotaoff
	-ln $(ROOTDIR)$(SUPERBIN)/quotaon $(ROOTDIR)$(SUPERBIN)/quotaoff
	-$(INSTALL) -o bin -g bin -m 644 rquota.h rquota.x $(ROOTDIR)usr/include/rpcsvc
	-$(INSTALL) -o root -g staff -m 4555 quota $(ROOTDIR)$(BINDIR)
	-$(INSTALL) -o bin -g bin -m 444 *.1 $(ROOTDIR)$(MANDIR)/man1
	-$(INSTALL) -o bin -g bin -m 444 *.2 $(ROOTDIR)$(MANDIR)/man2
	-$(INSTALL) -o bin -g bin -m 444 *.3 $(ROOTDIR)$(MANDIR)/man3
	-$(INSTALL) -o bin -g bin -m 444 *.8 $(ROOTDIR)$(MANDIR)/man8

quotaon: quotaon.o quotactl.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ quotaon.o quotactl.o hasquota.o

quotacheck: quotacheck.o quotactl.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ quotacheck.o quotactl.o hasquota.o

quota: rquota.h quota.o quotactl.o rquota_clnt.o rquota_xdr.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ quota.o quotactl.o rquota_clnt.o \
	rquota_xdr.o hasquota.o

repquota: repquota.o quotactl.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ repquota.o quotactl.o hasquota.o

warnquota: warnquota.o quotactl.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ warnquota.o quotactl.o hasquota.o

edquota: pathnames.h edquota.o quotactl.o  hasquota.o
	$(CC) $(LDFLAGS) -o $@ edquota.o quotactl.o hasquota.o

rpc.rquotad: rquota.h rquota_server.o rquota_svc.o rquota_xdr.o quotactl.o hasquota.o
	$(CC) $(LDFLAGS) -o $@ rquota_server.o rquota_svc.o rquota_xdr.o \
	quotactl.o hasquota.o $(LLIBS)

quota.o: quota.c
	$(CC) $(CFLAGS) -DRPC -c quota.c -o $@

rquota.h:
	$(RPCGEN) -h -o $@ rquota.x

rquota_xdr.c:
	$(RPCGEN) -c -o $@ rquota.x

rquota_clnt.c:
	$(RPCGEN) -l -o $@ rquota.x

