bash-masters

dynhacker.org

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