bash-masters

dynhacker.org

Jan 1st, 2013
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. # UPDATE: Sat, Jan, 5 2013: silenced over-talkative make, +removed 'echo' debug line
  5.  
  6. # OMG its the borg...
  7. # They are back and they are assimilating...
  8. # Resistance is futile..
  9.  
  10. # This script does some shit (whether you like that statement or not).
  11. #
  12. # 1.  download a source tarball of dyncall (if needed)
  13. # 2.  set up some destination paths for resulting build files (libs & headers)
  14. # 3.  extract the tarball
  15. # 4.  build the package
  16. # 5.  request the general directory name the resulting binaries (differs for each platform)
  17. # 6.  locates the development binaries
  18. # 8.  locates the development headers
  19. # 9.  puts the binary files into BINARYDEST directory (default relative: ./bin)
  20. # 10. puts the development headers into HEADERDEST (default relative: ./src/dyncall)
  21. # 11. Removes completely the extracted tarball directory
  22. #
  23. #
  24. # A program may then use the dyncall libraries as such in a c file located in .src/
  25. #
  26. #   #include "dyncall/dyncall.h"
  27. #   ...
  28. #
  29. # compiling is fairly simple: gcc [paths] [files] bin/lib* [options] [sharedlibs]
  30. #
  31. # This script is smart enough to run properly from a makefile.
  32. #
  33. # The question is: are you smart enough to use it or dyncall? -lol
  34. #
  35.  
  36. DYNCALLPKG=http://dyncall.org/r0.7/dyncall-0.7.tar.gz
  37. DYNCALLARC=src/dyncall-0.7.tar.gz
  38.  
  39. BINARYDEST=bin
  40. HEADERDEST=src/dyncall;
  41.  
  42. # HACK ROOT
  43. dynRoot=src/dyncall-0.7;
  44.  
  45. # only download missing files
  46. urlHamper() {
  47.     [[ -e "$1" ]] && return;
  48.     type -p curl > /dev/null || {
  49.         # teach the user how to be a supporting advocate of this script's operation
  50.         echo please install curl or download: $DYNCALLPKG --\> ./src directory;
  51.         exit 1;
  52.     } >&2;
  53.     curl -\# -o "$1" "${2}";
  54. }
  55.  
  56. set -e; # exit on unhandled errors
  57.  
  58. mkdir -vp ${BINARYDEST} ${HEADERDEST};
  59.  
  60. urlHamper ${DYNCALLARC} ${DYNCALLPKG};
  61.  
  62. tar --directory src -xvf ${DYNCALLARC};
  63.  
  64. ( cd ${dynRoot}; ./configure && make; );
  65.  
  66. echo Hacking dyncall resources...
  67.  
  68. MARVEL=$(
  69.     cd $dynRoot;
  70.     make -s --eval 'Hackologist:
  71.     @echo ${BUILD_DIR}
  72. ')
  73.  
  74. echo Destination descriptor acquired...
  75. UNIVERSE=($(printf '%s\n' $dynRoot/{dyncall,dynload,dyncallback}/${MARVEL}));
  76.  
  77. echo Locating objects...
  78. LIBS="$(
  79.     for superHero in "${UNIVERSE[@]}"; do
  80.         echo $superHero/lib*;
  81.     done
  82. )"
  83.  
  84. echo Discovering headers...
  85. HEADERS=$(echo $dynRoot/{dyncall/*.h,dynload/*.h,dyncallback/*.h})
  86.  
  87. cp -vt ${HEADERDEST} ${HEADERS} &
  88. cp -vt ${BINARYDEST} ${LIBS};
  89.  
  90. wait $!;
  91.  
  92. # get rid of junk
  93. rm -vrf $dynRoot;
  94.  
  95. echo Dyncall Assimilation Complete
Add Comment
Please, Sign In to add comment