mindist.in 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. #
  3. # mindist: create minimum distribution for running cputil
  4. #
  5. # Copyright (C) 2016,2021 Matthew R. Wette
  6. #
  7. # Copying and distribution of this file, with or without modification,
  8. # are permitted in any medium without royalty provided the copyright
  9. # notice and this notice are preserved. This file is offered as-is,
  10. # without any warranty.
  11. prefix=@prefix@
  12. exec_prefix=@exec_prefix@
  13. libexecdir=@libexecdir@
  14. libdir=@libdir@
  15. includedir=@includedir@
  16. fail () {
  17. echo "usage: mindist DESTDIR=<dir>"
  18. echo "example:"
  19. echo " mindist DESTDIR=/var/tmp/mindist"
  20. exit 1
  21. }
  22. if [ $# -ne 1 ]; then fail; fi
  23. case $1 in
  24. DESTDIR=*) destdir=`echo $1 | sed -e 's/DESTDIR=//'` ;;
  25. *) fail ;;
  26. esac
  27. if echo $destdir | grep '.*\/$'; then
  28. true
  29. else
  30. destdir=$destdir/
  31. fi
  32. cu_execdir=$libexecdir/cputil
  33. top=$destdir$prefix
  34. exe=$destdir$libexecdir/valgrind
  35. lib=$destdir$libdir
  36. inc=$destdir$includedir
  37. cu_exe=$destdir$cu_execdir
  38. if [ ! -f $top/bin/valgrind ]; then
  39. echo "do not see $top/bin/valgrind -- quitting"
  40. exit 1
  41. fi
  42. mv $top/bin/valgrind $exe
  43. rm $top/bin/*
  44. if [ -f $top/include/valgrind/libvex_ir.h ]; then
  45. cp $top/include/valgrind/libvex_ir.h $exe
  46. fi
  47. if [ -f $top/include/valgrind/cputil.h ]; then
  48. cp $top/include/valgrind/cputil.h $inc
  49. cp $top/include/valgrind/cputil.h $exe
  50. fi
  51. rm -rf $top/include/valgrind
  52. rm -rf $top/share
  53. rm -rf $top/lib/pkgconfig
  54. rm -f $exe/vgpreload_dhat*
  55. rm -f $exe/vgpreload_drd*
  56. rm -f $exe/vgpreload_exp*
  57. rm -f $exe/vgpreload_helgrind*
  58. rm -f $exe/vgpreload_massif*
  59. rm -f $exe/vgpreload_memcheck*
  60. rm -f $exe/s390*
  61. rm -f $exe/power*
  62. rm -f $exe/mips*
  63. rm -f $exe/arm*
  64. rm -f $exe/none*
  65. rm -f $exe/memcheck*
  66. rm -f $exe/massif*
  67. rm -f $exe/getoff*
  68. rm -f $exe/helgrind*
  69. rm -f $exe/lackey*
  70. rm -f $exe/exp*
  71. rm -f $exe/drd*
  72. rm -f $exe/cachegrind*
  73. rm -f $exe/callgrind*
  74. rm -f $lib/*.a
  75. rm -f $lib/libmpiwrap*.so
  76. rm -f $exe/dh*
  77. rm -f $exe/*.xml
  78. rm -f $exe/valgrind-monitor-def.py
  79. rm -f $exe/valgrind-monitor.py
  80. if [ ! -d $cu_exe ]; then mv $exe $cu_exe; fi
  81. # cleanup
  82. rm -rf $exe $lib
  83. # generate driver script
  84. echo '#!/bin/sh' >$top/bin/cputil
  85. echo 'top=$(realpath $(dirname $0)/..)' >>$top/bin/cputil
  86. echo 'VALGRIND_LIB=$top/libexec/cputil' >>$top/bin/cputil
  87. echo 'VALGRIND_LAUNCHER=$VALGRIND_LIB' >>$top/bin/cputil
  88. echo 'export VALGRIND_LIB VALGRIND_LAUNCHER' >>$top/bin/cputil
  89. echo '$VALGRIND_LIB/valgrind -q --tool=cputil "$@"' >>$top/bin/cputil
  90. chmod +x $top/bin/cputil
  91. # --- last line ---