PROCEDURE rap$link_operating_system_ii (
  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
  status)


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'

"    The purpose of this request is to link the OS files
"previously installed into the catalog specified by the
"SITE_LINK_INPUT_CATALOG parameter with the released versions.
"The path names to the files are hardcoded
"using this parameter as the base.  The bi-products of this procedure,
"files which are classified as OS_SUPPORT files (JOB_IMAGE, MONITOR_IMAGE,
"and SYSTEM_CORE_IMAGE) are placed in the catalog specified by the
"DEADSTART_CATALOG parameter.  All output from the link is stored in
"the catalog specified by the LINK_OUTPUT_CATALOG parameter.
"
"   This routine has been converted to SCL new types as much as it
"possibly can.  The three (3) common decks (*CALL) have not been
"converted to new types (Integration owns them).  Because of this,
"this procedure must interface to these common decks in the old SCL.
"
*IFEND


  "$FORMAT=OFF
  VAR
    directives_file: file = $LOCAL//$name($unique)
    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"

  IF NOT $variable(rav$linker_errors_found, defined) THEN
    VAR
      rav$linker_errors_found: (JOB) boolean
    VAREND
  IFEND

  rav$linker_errors_found = FALSE
  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


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Setup the variables with the paths for the linker output
"files.
*IFEND


    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'



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Setup the variable with the path for the input file for the
"monitor.
*IFEND



    ol_monitor = link_input_catalog // '.osf$bound_monitor'


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Setup the variables with the paths for the input files for
"the system core.
*IFEND


    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'



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Setup the variables with the paths for the input files for
"the job template.
*IFEND


    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'



*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Obtain the VERSION_ID and the BUILD_ID for the OS files from
"the specified SYSTEM_CATALOG.  By doing an include file on the
"OSF$VERSION file the two variables are automatically created.
*IFEND


    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 $variable(wev$proc_doc,declared)<>'UNKNOWN'

"Any site modification to the load modules in OSF$BOUND_JOB_TEMPLATE_223 or
"OSF$BOUND_JOB_TEMPLATE_23D must first be merged onto the released versions
"found in the NOSVE_MAINTENANCE catalog.  A site modification exists when either
"OSF$BOUND_JOB_TEMPLATE_223 or OSF$BOUND_JOB_TEMPLATE_23D are found in the
"SITE_OS_MAINTENANCE catalog.
*IFEND


    IF $file($fname(site_bound_job_template_223) permanent) THEN
      $system.put_line (' Merging '//site_bound_job_template_223//' ..' '       with '//ol_job_template_223) ..
            o=$response

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 (' Merging '//site_bound_job_template_23d//' ..' '       with '//ol_job_template_23d) ..
            o=$response

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


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
" Link the monitor.
*IFEND


    map_file_string = $trim(sc_link_map)

    $system.put_line '   Linking monitor.' o=$response

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


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
" Link the system core.
*IFEND


    input_debug_table = monitor_debug_table

    $system.put_line '   Linking system core.' o=$response

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


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"  Link the job template.
"  Supplement the standard linker directives with a directive specifying where to get
"  cyf$run_time_library, in case the site analyst has added code that needs it.
*IFEND


    map_file_string = jt_link_map
    input_debug_table = system_core_debug_table

    $system.put_line '   Linking job template.' o=$response

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


*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Search the job template link map for errors.
*IFEND

    $system.software_maintenance.raf$library.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=$response
      $system.put_line '      '//jt_link_map o=$response
      rav$linker_errors_found = TRUE
      EXIT link_block
    IFEND

*IF $variable(wev$proc_doc,declared)<>'UNKNOWN'
"    Add the BUILD_ID to the output files created by this command.
*IFEND


    $system.change_file_attribute $fname(monitor_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '   Linker output MONITOR VIRTUAL MEMORY IMAGE is installed as:' o=$response
    $system.put_line '      '//monitor_virtual_memory_string o=$response

    $system.change_file_attribute $fname(system_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '   Linker output SYSTEM CORE VIRTUAL MEMORY IMAGE is installed as:' o=$response
    $system.put_line '      '//system_virtual_memory_string o=$response

    $system.change_file_attribute $fname(jt_virtual_memory_string) ui=build_id status=ignore_status
    $system.put_line '   Linker output JOB TEMPLATE VIRTUAL MEMORY IMAGE is installed as:' o=$response
    $system.put_line '      '//jt_virtual_memory_string o=$response

    $system.change_file_attribute $fname(sc_link_map) ui=build_id status=ignore_status
    $system.put_line '   Linker output SYSTEM CORE LINK MAP is installed as:' o=$response
    $system.put_line '      '//sc_link_map o=$response

    $system.change_file_attribute $fname(jt_link_map) ui=build_id status=ignore_status
    $system.put_line '   Linker output JOB TEMPLATE LINK MAP is installed as:' o=$response
    $system.put_line '      '//jt_link_map o=$response

    $system.change_file_attribute $fname(system_debug_table) ui=build_id status=ignore_status
    $system.put_line '   Linker output SYSTEM DEBUG TABLE is installed as:' o=$response
    $system.put_line '      '//system_debug_table o=$response


  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 rap$link_operating_system_ii
