#
# Makefile.tmpl
#
PROGRAM=	xntpd
#
# xntpd - NTP daemon
#
COMPILER= gcc -DUSE_PROTOTYPES -Wall
COPTS= -O2 -m486 -finline-functions -fomit-frame-pointer
BINDIR=	/usr/sbin
INSTALL= install
DEFS=       -DSYS_LINUX -DHAVE_TERMIOS
DEFS_OPT=
DEFS_LOCAL= $(DEFS_OPT)  -DREFCLOCK #TEST -DPPSPPS -DKERNEL_PLL
DEFS_INCLUDE= -DHAVE_SYS_TIMEX_H -DNTP_SYSCALLS_LIBC
CLOCKDEFS=  -DLOCAL_CLOCK #TEST -DAS2201 -DCHU -DDATUM -DGOES -DGPSTM -DIRIG -DLEITCH -DLOCAL_CLOCK -DOMEGA -DPARSE -DATOM -DCLOCK_MEINBERG -DCLOCK_SCHMID -DCLOCK_DCF7000 -DCLOCK_TRIMTAIP -DCLOCK_RAWDCF -DCLOCK_RCC8000 -DPST -DTPRO -DTRAK -DWWVB -DTRUETIME -DACTS -DPTBACTS
DAEMONLIBS=
RESLIB=
ADJLIB=
COMPAT=
#
INCL=	    -I../include -I/usr/include/bsd
CFLAGS=		$(COPTS) $(DEFS_INCLUDE) $(DEFS) $(DEFS_LOCAL) $(INCL)
CC=		$(COMPILER)
LIB=		../lib/libntp.a ../parse/libparse.a
LINTLIB=	../lib/llib-llibntp.ln
MAKE=		make
TOP=../
#
SOURCE=	ntp_config.c ntp_control.c ntp_io.c ntp_leap.c \
	ntp_loopfilter.c ntp_monitor.c ntp_peer.c ntp_proto.c \
	ntp_refclock.c ntp_request.c ntp_restrict.c ntp_timer.c \
	ntp_unixclock.c ntp_util.c ntp_intres.c ntp_filegen.c ntpd.c \
	refclock_conf.c refclock_chu.c refclock_local.c \
	refclock_pst.c refclock_wwvb.c refclock_goes.c \
	refclock_mx4200.c refclock_parse.c refclock_as2201.c \
	refclock_omega.c refclock_tpro.c refclock_leitch.c \
	refclock_irig.c refclock_msfees.c refclock_gpstm.c \
	refclock_trak.c refclock_datum.c refclock_acts.c \
	refclock_heath.c refclock_nmea.c refclock_moto.c \
	refclock_atom.c refclock_ptbacts.c refclock_usno.c \
	refclock_true.c refclock_hpgps.c

OBJS=	ntp_config.o ntp_control.o ntp_io.o ntp_leap.o \
	ntp_loopfilter.o ntp_monitor.o ntp_peer.o ntp_proto.o \
	ntp_refclock.o ntp_request.o ntp_restrict.o ntp_timer.o \
	ntp_unixclock.o ntp_util.o ntp_intres.o ntp_filegen.o ntpd.o \
	refclock_conf.o refclock_chu.o refclock_local.o \
	refclock_pst.o refclock_wwvb.o refclock_goes.o \
	refclock_mx4200.o refclock_parse.o refclock_as2201.o \
	refclock_omega.o refclock_tpro.o refclock_leitch.o \
	refclock_irig.o refclock_msfees.o refclock_gpstm.o \
	refclock_trak.o refclock_datum.o refclock_acts.o \
	refclock_heath.o refclock_nmea.o refclock_moto.o \
	refclock_atom.o refclock_ptbacts.o refclock_usno.o \
	refclock_true.o refclock_hpgps.o

all:	$(PROGRAM)

$(PROGRAM): $(OBJS) $(LIB) version.o 
	-rm -f $(PROGRAM)
	$(CC) $(COPTS) -o $@ $(OBJS) version.o $(LIB) $(DAEMONLIBS) \
		$(RESLIB) $(ADJLIB) $(COMPAT)

install:	$(BINDIR)/$(PROGRAM)

$(BINDIR)/$(PROGRAM): $(PROGRAM)
	$(INSTALL) -c -m 0755 $(PROGRAM) $(BINDIR)

tags:
	ctags *.c *.h

depend:
	mkdep $(CFLAGS) $(SOURCE)

clean:
	-@rm -f $(PROGRAM) *.o *.out tags oxntpd make.log Makefile.bak lint.errs
	-@rm -f .depend *~ .version

distclean:	clean
	-@rm -f *.orig *.rej .version Makefile

lint:	$(LINTLIB)
	lint -x -u $(DEFS) $(INCL) $(LINTLIB) $(SOURCE) >lint.errs

../lib/llib-llibntp.ln:
	cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" lintlib

../lib/libntp.a:
	cd ../lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)"

../parse/libparse.a:
	cd ../parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)"

#
# we want to build the current version string here
#
version.o: ../VERSION
	../scripts/mkversion $(PROGRAM)
	$(CC) $(COPTS) $(INCL) -c version.c

../VERSION:
	-@rm -f .version
#
# These guys require knowledge of our clock configuration
#
refclock_chu.o:		refclock_chu.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_conf.o:	refclock_conf.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_local.o:	refclock_local.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL)  $(CLOCKDEFS) $(INCL) -c $*.c

refclock_pst.o:		refclock_pst.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_goes.o:	refclock_goes.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_wwvb.o:	refclock_wwvb.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_parse.o:	refclock_parse.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_mx4200.o:	refclock_mx4200.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_as2201.o:	refclock_as2201.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_omega.o:	refclock_omega.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_tpro.o:	refclock_tpro.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_leitch.o:	refclock_leitch.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_irig.o:	refclock_irig.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_msfees.o:	refclock_msfees.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_trak.o:	refclock_trak.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_gpstm.o:	refclock_gpstm.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_datum.o:	refclock_datum.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_acts.o:	refclock_acts.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_ptbacts.o:	refclock_ptbacts.c refclock_acts.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c refclock_ptbacts.c

refclock_heath.o:	refclock_heath.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_nmea.o:	refclock_nmea.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_moto.o:	refclock_moto.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_atom.o:	refclock_atom.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_true.o:	refclock_true.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_usno.o:	refclock_usno.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c

refclock_hpgps.o:	refclock_hpgps.c
	$(CC) $(COPTS) $(DEFS) $(DEFS_LOCAL) $(CLOCKDEFS) $(INCL) -c $*.c
