PageRenderTime 68ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tet3/bin/w32_shlib_build.ksh

#
Korn Shell | 120 lines | 62 code | 15 blank | 43 comment | 4 complexity | e13060e6db499caed27981dbe2be44fa MD5 | raw file
  1. #
  2. # SCCS: @(#)w32_shlib_build.ksh 1.1 (98/09/01)
  3. #
  4. # UniSoft Ltd., London, England
  5. #
  6. # Copyright (c) 1998 The Open Group
  7. # All rights reserved.
  8. #
  9. # No part of this source code may be reproduced, stored in a retrieval
  10. # system, or transmitted, in any form or by any means, electronic,
  11. # mechanical, photocopying, recording or otherwise, except as stated in
  12. # the end-user licence agreement, without the prior permission of the
  13. # copyright owners.
  14. # A copy of the end-user licence agreement is contained in the file
  15. # Licence which accompanies this distribution.
  16. #
  17. # Motif, OSF/1, UNIX and the "X" device are registered trademarks and
  18. # IT DialTone and The Open Group are trademarks of The Open Group in
  19. # the US and other countries.
  20. #
  21. # X/Open is a trademark of X/Open Company Limited in the UK and other
  22. # countries.
  23. #
  24. # ************************************************************************
  25. #
  26. # SCCS: @(#)w32_shlib_build.ksh 1.1 98/09/01 TETware release 3.3
  27. # NAME: w32_shlib_build.ksh
  28. # PRODUCT: TETware
  29. # AUTHOR: Andrew Dingwall, UniSoft Ltd.
  30. # DATE CREATED: July 1998
  31. #
  32. # DESCRIPTION:
  33. # shell script to build the shared API libraries on Win32 systems
  34. #
  35. # MODIFICATIONS:
  36. #
  37. # ************************************************************************
  38. tmp=tmp$$
  39. trap 's=$?; rm -f $tmp; exit $s' 0
  40. trap 'exit $?' 1 2 3 13 15
  41. badusage()
  42. {
  43. echo "usage: $0 [cc-options ...] -o output ofiles ..." 1>&2
  44. exit 2
  45. }
  46. # parse the command line
  47. output=
  48. ofiles=
  49. cflags=
  50. libs=
  51. while test $# -gt 0
  52. do
  53. case $1 in
  54. -o)
  55. # note that patterns are case-insensitive in the MKS shell
  56. if test X$1 = X-o
  57. then
  58. output=$2
  59. shift
  60. else
  61. cflags="$cflags${cflags:+ }$1"
  62. fi
  63. ;;
  64. -*)
  65. cflags="$cflags${cflags:+ }$1"
  66. ;;
  67. *.obj)
  68. ofiles="$ofiles${ofiles:+ }$1"
  69. ;;
  70. *.lib)
  71. libs="$libs${libs:+ }$1"
  72. ;;
  73. *)
  74. echo "$0: unknown file $1 ignored" 1>&2
  75. ;;
  76. esac
  77. shift
  78. done
  79. if test -z "$ofiles" -o -z "$output"
  80. then
  81. badusage
  82. fi
  83. # generate the list of symbol files
  84. for ofile in $ofiles
  85. do
  86. symfiles="$symfiles${symfiles:+ }${ofile%.obj}.sym"
  87. done
  88. set -e
  89. sort -u -o $tmp $symfiles
  90. # generate the dynlink.gen file for use by tcm/dynlink.c
  91. awk '$1 == "EXPORT" {
  92. if ($2 == "DATA" || $2 == "FUNCPTR" || $2 == "ARRAY")
  93. printf("\ttet_dll_%s = &%s;\n", $3, $3);
  94. else if ($2 == "FUNC")
  95. printf("\ttet_dll_%s = %s;\n", $3, $3);
  96. }' $tmp > dynlink.gen
  97. # generate the dlcheck.gen file for use by tcm/dynlink.c
  98. awk '$1 == "EXPORT" {
  99. printf("\tif (!tet_dll_%s)\n\t\treport_nullptr(\"%s\");\n", $3, $3);
  100. }' $tmp > dlcheck.gen
  101. # build the shared API library
  102. CC=cc ../bin/w32_symbuild -I. $cflags -c ../tcm/dynlink.c
  103. mv dynlink.obj dlcheck.obj
  104. set -x
  105. cc -LD -o $output $ofiles dlcheck.obj $libs