package require emu::autobuild
proc AutoBuildInit {template} {}
proc AutoBuild {template h} {

# get the segment numbers at level TB
set tbsegs [$h segments TB]

# get the first of these
set tbfirst [lindex $tbsegs 0]

# get the second of these
set tbsecond [lindex $tbsegs 1]

# get the segment numbers at tier TT
set ttsegs [$h segments TT]

# get the first of these
set ttfirst [lindex $ttsegs 0]

# get the second of these
set ttsecond [lindex $ttsegs 1]

# Link first segment at TB with the first segment at TT
$h seginfo $ttfirst children TB $tbfirst

# Link the 2nd segment at TB with the 2nd segment at TT
$h seginfo $ttsecond children TB $tbsecond

# Get the segment number at the Word tier
set wordseg [$h segments Word]

# Get the segments at the Segment tier that are children at the Word tier
set phonsegs [$h seginfo $wordseg children Segment]

# Get the first of these
set phonfirst [lindex $phonsegs 0]

# Link this first segment at the Segment tier to all segments at tier TT
$h seginfo $phonfirst children TT $ttsegs

# Link this first segment at the Segment tier to all segments at tier TB
$h seginfo $phonfirst children TB $ttsegs

# Make links for all segments between the first and last segments at
# the Segment tier dominated by Word
LinkSpans $h Word Segment

}
