CC=gcc2
CFLAGS=-DPOSIX

SRCS=rootlinks.c util.c file.c services.c environment.c os.c cmds.c
OBJS=rootlinks.o util.o file.o services.o environment.o os.o cmds.o

test: test.o $(OBJS)
	$(CC) -o test test.o $(OBJS)

saber_test:
	#load $(CFLAGS) test.c $(SRCS)

tests: test test_walk test_find test_vno test_header test_get_service \
		test_set_env test_parse

test_walk:
	./test 1 | sort > test_walk.1
	find / -xdev -print | sort > test_walk.2
	@echo "May fail if items in root cannot be searched"
	-diff test_walk.1 test_walk.2
	./test 2 | sort > test_walk.3
	find / -xdev -type l -print | sort > test_walk.4
	@echo "May fail if items in root cannot be searched"
	-diff test_walk.3 test_walk.4
	rm -f test_walk.{1,2,3,4}

test_find:
	./test 4

test_vno:
	./test 5

test_header:
	./test 6

test_get_service:
	rm -rf /tmp/test_mkserv
	./test 7

test_set_env:
	@echo "Environment tests.................."
	@echo "Check the following for proper values"
	./test 8 | egrep "No|RVDROOT|SRVDIR|^PATH|LOGFILE|VERS|MACH=|SERVERD""
	@echo
	@echo "Check RVDROOT and SRVDIR"
	RVDROOT=/foo ./test 8 | egrep "SRVDIR|RVDROOT|^PATH"
	@echo
	SRVDIR=/foo ./test 8 | egrep "SRVDIR|RVDROOT|^PATH"
	@echo
	@echo "The following should not change"
	LOGFILE=/foo ./test 8 | egrep "LOGFILE"
	@echo "Environment tests end...."

test_parse:
	./test 9

clean:
	rm -f test_walk.1 test_walk.2 test_walk.3 test_walk.4 test *.o

$(OBJS): mkserv.h
os.c: os.h
