#
# very simple makefile
#
# Possible defines:
# LINEMON:	include support for monitoring CD transitions (sun zs driver only)
# KERNEL:	must define
# VDDRV:	loadable driver support - recommended
# DEBUG_DCF:	include debug code (STREAMS mechanism and parsing)
# DEBUG_CD:	include signal propagation to sun4c LED (sun4c only)
# `arch -k`:	must define for correct kernel module
#
KARCH:sh=arch -k
DEFS=-DSTREAM -DLINEMON -DKERNEL -DVDDRV -D$(KARCH)
MICROTIME=../ppsclock/sys/$(KARCH)/microtime.s

all: parsestreams.o dcftest testdcf

mparsestreams.o: parsestreams.c microtime.o ../lib/libntp.a ../include/parse.h ../include/sys/parsestreams.h
	cc -c -DMICROTIME $(DEFS) -I../include parsestreams.c
	ld -r -o $@ .parsestreams.o ../lib/libntp.a microtime.o
	rm -f parsestreams.o

parsestreams.o: parsestreams.c ../lib/libntp.a ../include/parse.h ../include/sys/parsestreams.h
	cc -c $(DEFS) -I../include parsestreams.c
	ld -r -o $@ $@ ../lib/libntp.a

dcftest: dcftest.c ../include/parse.h
	cc -o $@ -I../include dcftest.c

testdcf: testdcf.c
	cc -o $@ testdcf.c

microtime.o: $(MICROTIME) assym.s
	cc -E -I. $(MICROTIME) | sed -e '/\.global _uniqtime/d' > $@.i
	as -o $@ $@.i
	rm -f $@.i assym.s

assym.s: genassym
	./genassym > $@

genassym: ../ppsclock/sys/genassym/genassym.c
	cc -o $@ $?

lint: parsestreams.c ../include/parse.h ../include/sys/parsestreams.h ../lib/llib-llibntp.ln
	lint -u -I../include $(DEFS) parsestreams.c ../lib/llib-llibntp.ln

../lib/llib-llibntp.ln:
	cd ../lib ; make lintlib

clean:
	rm -f *.o genassym assym.s parsestreams testdcf dcftest

distclean: clean
