SCPILIB = scpilib.a
SCPILIB_CSRC = \
	scpilib.c \
	vxi11_clnt.c \
	vxi11_xdr.c
SCPILIB_OBJS = $(patsubst %.c, %.o, $(SCPILIB_CSRC))

SCPITEST_CSRC = \
	test.c
SCPITEST_OBJS = $(patsubst %.c,%.o, $(SCPITEST_CSRC))

ALL_OBJS = $(SCPILIB_OBJS) $(SCPITEST_OBJS)

# define variables for building RPCL (.x) files
RPCGEN=rpcgen -N -M

CFLAGS += -Wno-unused

all:	$(SCPILIB) scpitest

# EX1629 auto-dependency generation
-include $(EX1629_ROOT)/AutoDep
-include $(ALL_OBJS:.o=.P)

$(SCPILIB_OBJS): vxi11.h

scpitest: $(SCPITEST_OBJS) $(SCPILIB) Makefile
	$(CC) $(CFLAGS) $(LDFLAGS) $(SCPITEST_OBJS) -o $@ $(SCPILIB) $(LDLIBS) -lm

$(SCPILIB): $(SCPILIB_OBJS) Makefile
	$(AR) $(ARFLAGS) $@ $^

# RPC files
# these need to be generated one at a time to control the server
# creation properly
vxi11_clnt.c vxi11.h vxi11_xdr.c: vxi11.x Makefile
	$(RM) -f $@
	$(RPCGEN) $(RPCFLAGS)  vxi11.x

clean:
	rm -f *.o *.gdb scpitest 
	rm -f vxi11_clnt.c vxi11_clnt.c vxi11.h vxi11_xdr.c vxi11_svc.c
	rm -f scpilib.a
	rm -f *.P
