
#  N.B. the previous line should be blank.
#+
#  Name:
#     hds_link_adam

#  Purpose:
#     Generate linker (ld) arguments for linking against ADAM HDS.

#  Type of Module:
#     Shell script.

#  Description:
#     This script should be invoked by those building ADAM applications
#     which use HDS in order to generate the correct arguments for the
#     compiler (or ld) command. The arguments generated are written to
#     the standard output.

#  Invocation:
#     The script may be invoked as part of a command such as:
#
#        alink program.f -L/star/lib `hds_link_adam`
#
#     although the ADAM "alink" command will normally link against HDS
#     anyway.

#  Copyright:
#     Copyright (C) 1993 Science & Engineering Research Council

#  Authors:
#     RFWS: R.F. Warren-Smith (STARLINK, RAL)
#     {enter_new_authors_here}

#  History:
#     7-JUL-1993 (RFWS):
#        Original version.
#     {enter_changes_here}

#  Bugs:
#     {note_any_bugs_here}

#-

#.

#  Initialise the special options string.
      special=''

#  Test to see if we are on a system which requires additional
#  "special" ld options for correct linking.

#  DEC Alpha systems running OSF1:
#  ------------------------------
#  Ensure that allocated memory addresses will fit into 32 bits to
#  prevent problems with storing them in Fortran integers.
      if test "`uname -m`" = "alpha" -a "`uname -s`" = "OSF1"; then
         special='-Wl,-D -Wl,40800000 -Wl,-T -Wl,30000000'
      fi

#  Echo any special options, followed by the HDS library reference,
#  followed by the list of options for packages on which HDS depends.
#  Pass the result through an awk script to remove duplicate library
#  references.
      echo "${special}" -lhds `chr_link_adam` `ems_link_adam` `cnf_link_adam` \
           | awk '{for(f=NF;f;f--)if(!w[$f]++)l=$f" "l;print l}'

#  End of script.
