all: rusersd
include ../MCONFIG

CFLAGS=-O2 -D__USE_BSD_SIGNAL

#  .if exists(/usr/include/X11/extensions/xidle.h)
#CFLAGS+= -DXIDLE
#LDADD+= -L/usr/X386/lib -lXext -lX11
#  .endif

RPCGEN=../rpcgen/rpcgen

# Warning, do not put this in the current directory without updating
# the clean target.
RUSERSX=/usr/include/rpcsvc/rusers.x

rusersd: rusersd.o rusers_proc.o rusers_xdr.o
	$(CC) $(LDFLAGS) $^ $(LIBS) -lbsd -o $@

install: rusersd
	install -s -m755 rusersd $(BASEDIR)/usr/sbin/rpc.rusersd
	install -m644 rusersd.8 $(BASEDIR)/usr/man/man8
	install -m644 rpc.rusersd.8 $(BASEDIR)/usr/man/man8

clean:
	rm -f *.o rusersd rusers.h rusers_xdr.c rusers.x

rusersd.o rusers_proc.o: rusers.h
rusers_xdr.o: rusers_xdr.c rusers.h

# see rusers makefile for an explanation of why this is necessary
rusers.x: 
	ln -s $(RUSERSX) rusers.x

rusers.h: $(RUSERSX) rusers.x
	$(RPCGEN) -h -o rusers.h rusers.x

rusers_xdr.c: $(RUSERSX)
	$(RPCGEN) -c -C -o rusers_xdr.c rusers.x
