
PROCEDURE qcp$link_generated_qcu (
  nosve_link_input_catalog, nlic: file = $required
  site_link_input_catalog, slic: file = $required
  deadstart_catalog, dc: file = $required
  link_output_catalog, loc: file = $required
  output, o: file = $output
  status)



VAR
 qcv$system: file = $SYSTEM
 ignore: status
VAREND

  "$FORMAT=OFF
  VAR
    directives_file: file = $LOCAL//$name($unique)
    qcu_log: file = qcv$system.field_maintenance.qcu_log
    qcu_state: file = qcv$system.field_maintenance.site_modifications
    ignore_status: status
    job_file: file = $LOCAL//$name($unique)
    jt_virtual_memory_string: string
    jt_link_map: string
    link_errors: file = $unique(:$local)
    link_input_catalog: string
    local_job_template_223: string = '$LOCAL.'//$unique
    local_job_template_23d: string = '$LOCAL.'//$unique
    local_status: status
    monitor_debug_table: string = '$LOCAL.'//$unique
    monitor_symbols_string: string = '$LOCAL.'//$unique
    monitor_virtual_memory_string: string = '$LOCAL.'//$unique
    new_deadstart_catalog: string
    new_link_output_catalog: string
    ol_job_template_223: string
    ol_job_template_236: string
    ol_job_template_23d: string
    ol_job_template_2dd: string
    ol_system_core_113: string
    ol_system_core_133: string
    ol_system_core_13d: string
    ol_system_core_1dd: string
    ol_monitor: string
    ol_message_templates: string
    os_version: string
    pageable_segment: integer = 2
    sc_link_map: string
    site_bound_job_template_223: string
    site_bound_job_template_23d: string
    site_os_maintenance: string
    system_core_debug_table: string = '$LOCAL.'//$unique
    system_debug_table: string
    system_symbols_string: string = '$LOCAL.'//$unique
    system_virtual_memory_string: string = '$LOCAL.'//$unique
    wired_segment: integer = 1
  VAREND
  "$FORMAT=ON"

        ofile = $string($value(output))


putl '         link input catalog ='                 o=qcu_log.$eoi
putl '                  '//nosve_link_input_catalog  o=qcu_log.$eoi
putl '         site input catalog ='                 o=qcu_log.$eoi
putl '                  '//site_link_input_catalog   o=qcu_log.$eoi
putl '         deadstart catalog  ='                 o=qcu_log.$eoi
putl '                  '//deadstart_catalog         o=qcu_log.$eoi
putl '         link output catalog ='                o=qcu_log.$eoi
putl '                  '//link_output_catalog       o=qcu_log.$eoi

  link_input_catalog = $string(nosve_link_input_catalog)

  site_os_maintenance = $string(site_link_input_catalog)
  site_bound_job_template_223 = site_os_maintenance // '.OSF$BOUND_JOB_TEMPLATE_223'
  site_bound_job_template_23d = site_os_maintenance // '.OSF$BOUND_JOB_TEMPLATE_23D'

  new_deadstart_catalog = $string(deadstart_catalog)
  new_link_output_catalog = $string(link_output_catalog)



link_block: ..
  BLOCK




    jt_virtual_memory_string = new_deadstart_catalog // '.job_image'
    monitor_virtual_memory_string = new_deadstart_catalog // '.monitor_image'
    system_virtual_memory_string = new_deadstart_catalog // '.system_core_image'
    jt_link_map = new_link_output_catalog // '.job_template_link_map'
    sc_link_map = new_link_output_catalog // '.system_core_link_map'
    system_debug_table = new_link_output_catalog // '.system_debug_table'






    ol_monitor = link_input_catalog // '.osf$bound_monitor'




    ol_system_core_113 = link_input_catalog // '.osf$bound_system_core_113'
    ol_system_core_133 = link_input_catalog // '.osf$bound_system_core_133'
    ol_system_core_13d = link_input_catalog // '.osf$bound_system_core_13d'
    ol_system_core_1dd = link_input_catalog // '.osf$bound_system_core_1dd'





    ol_job_template_223 = link_input_catalog // '.osf$bound_job_template_223'
    ol_job_template_236 = link_input_catalog // '.osf$bound_job_template_236'
    ol_job_template_23d = link_input_catalog // '.osf$bound_job_template_23d'
    ol_job_template_2dd = link_input_catalog // '.osf$bound_job_template_2dd'
    ol_message_templates = link_input_catalog // '.osf$message_templates'





    os_version = link_input_catalog // '.os_version'
    $system.include_file f=$fname(os_version) status=local_status
    $system.detach_file f=$fname(os_version) status=ignore_status
    EXIT link_block WHEN NOT local_status.normal





    IF $file($fname(site_bound_job_template_223) permanent) THEN

      $system.put_line ' ' o=$fname(ofile//'.$eoi')
      $system.put_line '      Combining the  sites JOB_TEMPLATE_223 library'  o=$fname(ofile//'.$eoi')
      $system.put_line '                                with'      o=$fname(ofile//'.$eoi')
      $system.put_line '               the systems JOB_TEMPLATE_223 library'  o=$fname(ofile//'.$eoi')

      $system.put_line 'OSF$JOB_TEMPLATE_223'    o= qcu_state.$eoi

COLLECT_TEXT o=job_file until='**'
  $system.CREATE_OBJECT_LIBRARY
    add_modules l=$fname(ol_job_template_223)
    replace_modules l=$fname(site_bound_job_template_223)
    generate_library l=$fname(local_job_template_223)
  QUIT
  ol_job_template_223 = local_job_template_223
**
      $system.include_file f=job_file status=local_status
      $system.delete_file f=job_file status=ignore_status
      EXIT link_block WHEN NOT local_status.normal
    IFEND


    IF $file($fname(site_bound_job_template_23d) permanent) THEN
      $system.put_line ' ' o=$fname(ofile//'.$eoi')
      $system.put_line '      Combining the sites JOB_TEMPLATE_23D library'  o=$fname(ofile//'.$eoi')
      $system.put_line '                                with'      o=$fname(ofile//'.$eoi')
      $system.put_line '              the systems JOB_TEMPLATE_23D library'  o=$fname(ofile//'.$eoi')

      $system.put_line 'OSF$JOB_TEMPLATE_23D'   o= qcu_state.$eoi

COLLECT_TEXT o=job_file until='**'
  $system.CREATE_OBJECT_LIBRARY
    add_modules l=$fname(ol_job_template_23d)
    replace_modules l=$fname(site_bound_job_template_23d)
    generate_library l=$fname(local_job_template_23d)
  QUIT
  ol_job_template_23d = local_job_template_23d
**
      $system.include_file job_file status=local_status
      $system.delete_file job_file status=ignore_status
      EXIT link_block WHEN NOT local_status.normal
    IFEND




    map_file_string = $trim(sc_link_map)


    $system.put_line '   Linking monitor.' o=qcu_log.$eoi

COLLECT_TEXT directives_file until='**' status=ignore_status
  $system.LINK_VIRTUAL_ENVIRONMENT
*copy raf$monitor_linker_commands
  QUIT
**

    $system.include_file f=directives_file status=local_status
    $system.delete_file f=directives_file status=ignore_status
    EXIT link_block WHEN NOT local_status.normal




    input_debug_table = monitor_debug_table

    $system.put_line '   Linking system core.' o=qcu_log.$eoi

COLLECT_TEXT directives_file until='**' status=ignore_status
  $system.LINK_VIRTUAL_ENVIRONMENT
*copy raf$system_core_linker_commands
  QUIT
**

    $system.include_file f=directives_file status=local_status
    $system.delete_file f=directives_file status=ignore_status
    EXIT link_block WHEN NOT local_status.normal




    map_file_string = jt_link_map
    input_debug_table = system_core_debug_table

    $system.put_line '   Linking job template.' o=qcu_log.$eoi

COLLECT_TEXT directives_file until='**' status=ignore_status
  $system.LINK_VIRTUAL_ENVIRONMENT
    use_object_library $system.cybil.cyf$run_time_library ring_brackets=(3 13 13)
*copy raf$job_template_linker_comnds
  QUIT
**

    $system.include_file f=directives_file status=local_status
    $system.delete_file f=directives_file status=ignore_status
    EXIT link_block WHEN NOT local_status.normal

    search_link_map link_map=$fname(jt_link_map) output=link_errors status=local_status
    EXIT link_block WHEN NOT local_status.normal

    IF $file_attributes(link_errors, size) <> 0 THEN
      $system.put_line '   Linker errors found.  See file: ' o=$fname(ofile//'.$eoi')
      $system.put_line '      '//jt_link_map o=$fname(ofile//'.$eoi')
      EXIT link_block
    IFEND

    $system.put_line '' o=$fname(ofile//'.$eoi')
    $system.change_file_attribute $fname(monitor_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '        Monitor Virtual Memory Image is installed' o=$fname(ofile//'.$eoi')
    $system.put_line '                      and' o=$fname(ofile//'.$eoi')
    $system.change_file_attribute $fname(system_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '        System Core Virtual Memory Image is installed ' o=$fname(ofile//'.$eoi')
    $system.put_line '                      and' o=$fname(ofile//'.$eoi')
    $system.change_file_attribute $fname(jt_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '        Job Template Virtual Memory Image is installed ' o=$fname(ofile//'.$eoi')
    $system.put_line '                      and' o=$fname(ofile//'.$eoi')
    $system.change_file_attribute $fname(sc_link_map) ui=build_id status=ignore_status

    $system.change_file_attribute $fname(jt_link_map) ui=build_id status=ignore_status

    $system.change_file_attribute $fname(system_debug_table) ui=build_id status=ignore_status
    $system.put_line '        System Debug Table is installed ' o=$fname(ofile//'.$eoi')
    $system.put_line ' ' o=$fname(ofile//'.$eoi')

  BLOCKEND link_block

  $system.detach_file f=$fname(ol_system_core_113) status=ignore_status
  $system.detach_file f=$fname(ol_system_core_133) status=ignore_status
  $system.detach_file f=$fname(ol_system_core_13d) status=ignore_status
  $system.detach_file f=$fname(ol_system_core_1dd) status=ignore_status
  $system.detach_file f=$fname(ol_monitor) status=ignore_status
  $system.detach_file f=$fname(ol_job_template_223) status=ignore_status
  $system.detach_file f=$fname(ol_job_template_236) status=ignore_status
  $system.detach_file f=$fname(ol_job_template_23d) status=ignore_status
  $system.detach_file f=$fname(ol_job_template_2dd) status=ignore_status
  $system.detach_file f=$fname(ol_message_templates) status=ignore_status
  $system.detach_file f=$fname(sc_link_map) status=ignore_status
  $system.detach_file f=$fname(system_core_debug_table) status=ignore_status
  $system.detach_file f=$fname(system_debug_table) status=ignore_status
  $system.detach_file f=$fname(system_symbols_string) status=ignore_status
  $system.detach_file f=$fname(system_virtual_memory_string) status=ignore_status
  $system.detach_file f=$fname(monitor_debug_table) status=ignore_status
  $system.detach_file f=$fname(monitor_symbols_string) status=ignore_status
  $system.detach_file f=$fname(monitor_virtual_memory_string) status=ignore_status
  $system.detach_file f=$fname(jt_virtual_memory_string) status=ignore_status
  $system.detach_file f=$fname(jt_link_map) status=ignore_status
  $system.detach_file f=link_errors status=ignore_status

  EXIT procedure WITH local_status WHEN NOT local_status.normal

PROCEND qcp$link_generated_qcu
