Advertisement
glank

zaddr

Nov 17th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. #!/usr/bin/env sh
  2. set -e
  3.  
  4. if [ "$1" = "-v" ]; then
  5.   shift
  6.   case "$1" in
  7.     10) CPPFLAGS+=" -DZ64_VERSION=Z64_OOT10";;
  8.     11) CPPFLAGS+=" -DZ64_VERSION=Z64_OOT11";;
  9.     12) CPPFLAGS+=" -DZ64_VERSION=Z64_OOT12";;
  10.   esac
  11.   shift
  12. else
  13.   CPPFLAGS+=" -DZ64_VERSION=Z64_OOT10"
  14. fi
  15.  
  16. if [ -z "$1" ]; then
  17.   echo "usage: \`$0 [-v 10|11|12] <expression>\`"
  18.   exit
  19. fi
  20.  
  21. CPPFLAGS+=" -I/opt/n64/mips64/n64-sysroot/usr/include"
  22.  
  23. tmpfile="$(mktemp)"
  24. gcc $CPPFLAGS -x c - -o "$tmpfile" <<EOF
  25.   #include <stdio.h>
  26.   #include <stdint.h>
  27.   #include <inttypes.h>
  28.   #include "src/gz/z64.h"
  29.   int main()
  30.   {
  31.     printf("%08" PRIx32 "\n", (uint32_t)(uintptr_t)&($1));
  32.     return 0;
  33.   }
  34. EOF
  35. chmod a+x "$tmpfile"
  36. "$tmpfile"
  37. rm -f "$tmpfile"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement