Last revision:  09-Aug-1993

Included in this distribution of XNTP V3 is a configuration file suitable
for use under Apple's A/UX Version 3.0.x  While it may work with
other versions, it has not been tested.  To make the executables follow
the steps outlined below.

*** NOTE:  You must have gcc installed to successfully compile the current
distribution; the native cc supplied with A/UX will NOT correctly compile
this source.  See the FAQ in comp.unix.aux for places to obtain gcc from
and how to install it.

First of all, you need to edit Config.local to make sure that BINDIR is
correct for where you wish the programs to be "installed". The default
(and what I use) is /usr/local/etc. Make sure that DEFS_LOCAL and
CLOCKDEFS are commented out!

Now, you need to create the makefiles:

    % make makefiles

After this is done (you should be told that your system is A/UX 3), make
xntpd (the options to 'gcc' are held in compilers/aux3.gcc):

    % make

I do not normally use the `make install' option and so have not verified its
compatibility with A/UX.  Rather, I pull out each of the executables and
place them in the locally appropriate locations.

At this point you need to set things up so that 'xntpd' is started upon
boot-up. You can do this in 1 of 2 ways: either add entries in /etc/inittab
or create and use an /etc/rc.local file.

By default, A/UX doesn't have one, so you'll need to add the following to
/etc/inittab:

    net6:2:wait:/etc/syslogd		# set to "wait" to run a syslog daemon
+   jmj0:2:wait:/etc/rc.local 1>/dev/syscon 2>&1	# Local stuff
    dbg2::wait:/etc/telinit v	# turn off init's verbose mode

Now, the look of /etc/rc.local is as follows:

    #!/bin/sh
    :
    : rc.local
    :
    #	@(#)Copyright Apple Computer 1987	Version 1.17 of rc.sh on 91/11/08 15:56:21 (ATT 1.12)
    
    
    #	Push line discipline/set the device so it will print
    /etc/line_sane 1
    echo " "
    echo "Entering rc.local..."
    
    set `/bin/who -r`
    if [ "$7" = 2 ]
    then
        /bin/echo " now setting the time..."
        /usr/local/etc/ntpdate -s -b <host.domain>
        sleep 5
    #
    # start up xntpd if we want
    #
        if [ -f /etc/ntp.conf ]
        then
    	/bin/echo " setting tick and tickadj..."
    	/usr/local/etc/tickadj -t 16672 -a 54
    	sleep 5
    	/bin/echo " starting xntpd..."
    	/usr/local/etc/xntpd <&- > /dev/null 2>&1
    	sleep 5
        fi
    #
    fi
    
    echo "Leaving rc.local..."

There are a few things to notice about the above:

    o When run, 'ntpdate' forces your clock to the time returned by the
      host(s) specified by <host.domain> (you'll need to replace this
      be the IP address(es) of your timehosts. This is good since it gets
      things close to start off with.

    o 'tickadj' is also called. This does two things: changes the
      default value of 'tick' (which the the amount of time, in ms, that
      is added to the clock every 1/60 seconds) and changes the value
      of 'tickadj' which the the amount that is added or subtracted
      from 'tickadj' when adjtime() is called.

      Now Mac clocks are pretty bad and tend to be slow. Sooo, instead of
      having A/UX add the default of 16666ms every 1/60th of a second,
      you want it to add more so that it keeps better time. The above
      value works for me but your "best" value may be different and will
      likely require some fooling around to find the best value.

      A/UX's default value of 'tickadj' is 1666 which is too big for
      'xntpd'... so it also needs to be adjusted.


Finally, before A/UX and 'xntpd' will work happily together, you need to
patch the kernel. This is due to the fact that A/UX attempts to keep the
UNIX-software clock and the Mac-hardware clock in sync. Now both of these
are too good. Also, 'xntpd' will be attempting to adjust the software
clock as well, so having A/UX muck around with it is asking for headaches.
What you therefore need to do is tell the kernel _not_ to sync the s/w clock
with the h/w one. This is done using 'adb'. The following is a shell script
that will do the patch for you:

    #! /bin/sh
    adb -w /unix <<!
    init_time_fix_timeout?4i
    init_time_fix_timeout?w 0x4e75
    init_time_fix_timeout?4i
    $q
    !

This must be done _every_ time you create a new kernel (via newconfig or
newunix) or else 'xntpd' will go crazy.

John Dundas was the original porter of xntpd and a lot of the additions
and A/UX-ports are from him. I got involved when I wanted to run 'xntpd'
on jagubox. It was also around this time that the base-patchlevel of
'xntpd' changed relatively significantly so John may not be up on this
version (called the "jones" version).

The original kernel patch (which patched 'time_fix_timeout') was from
Richard Todd. I suggest patching 'init_time_fix_timeout' which prevents
'time_fix_timeout' from even being called.

TECHNICAL NOTES:

    o As configured (see machines/aux3), 'xntpd' will log messages via syslogd
      using the LOC_LOCAL1 facility. I would suggest the following in
      /etc/syslog.conf:

	local1.notice					/usr/adm/ntpd-syslog

    o As mentioned above, the clocks on A/UX and Macs are kinda bad. Not
      only that, but logging in and out of the MacOS mode as well as
      extensive floppy use causes A/UX to drop and lose clock interupts
      (these are sent every 1/60th of a second). So, if you do these
      activities a lot, you find out that you lose about 300ms of time
      (i.e., you become 300ms slow). 'xntpd' default way of handling this
      is to called 'settimeofday()' and step the clock to the correct
      time. I prefer having 'xntpd' slew the clock back into line by
      making gradual adjustments to the clock over a coupla minutes
      or so. It's for this reason that SLEWALWAYS is defined in
      include/ntp_machine.h for SYS_AUX3. 

Good luck!  If you have problems under A/UX feel free to contact me (e-mail
is preferred).
--
    Jim Jagielski               |  "That is no ordinary rabbit... 'tis the
    jim@jagubox.gsfc.nasa.gov   |   most foul, cruel and bad-tempered
    NASA/GSFC, Code 734.4       |   rodent you ever set eyes on"
    Greenbelt, MD 20771         |                   Tim the Enchanter
