Newer
Older
dub_jkp / build.sh
@Martin Nowak Martin Nowak on 13 Apr 2015 1 KB use DMD to refer to dmd/gdmd/ldmd2
  1. #!/bin/sh
  2. set -e
  3.  
  4. if [ "$DMD" = "" ]; then
  5. if [ ! "$DC" = "" ]; then # backwards compatibility with DC
  6. DMD=$DC
  7. else
  8. command -v gdmd >/dev/null 2>&1 && DMD=gdmd || true
  9. command -v ldmd2 >/dev/null 2>&1 && DMD=ldmd2 || true
  10. command -v dmd >/dev/null 2>&1 && DMD=dmd || true
  11. fi
  12. fi
  13.  
  14. if [ "$DMD" = "" ]; then
  15. echo >&2 "Failed to detect D compiler. Use DMD=... to set a dmd compatible binary manually."
  16. exit 1
  17. fi
  18.  
  19. # link against libcurl
  20. LIBS=`pkg-config --libs libcurl 2>/dev/null || echo "-lcurl"`
  21.  
  22. # fix for modern GCC versions with --as-needed by default
  23. if [ "$DMD" = "dmd" ]; then
  24. if [ `uname` = "Linux" ]; then
  25. LIBS="-l:libphobos2.a $LIBS"
  26. else
  27. LIBS="-lphobos2 $LIBS"
  28. fi
  29. elif [ "$DMD" = "ldmd2" ]; then
  30. LIBS="-lphobos2-ldc $LIBS"
  31. fi
  32.  
  33. # adjust linker flags for dmd command line
  34. LIBS=`echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g'`
  35.  
  36. echo Generating version file...
  37. GITVER=$(git describe) || GITVER=unknown
  38. echo "module dub.version_;" > source/dub/version_.d
  39. echo "enum dubVersion = \"$GITVER\";" >> source/dub/version_.d
  40. echo "enum initialCompilerBinary = \"$DMD\";" >> source/dub/version_.d
  41.  
  42.  
  43. echo Running $DMD...
  44. $DMD -ofbin/dub -w -version=DubUseCurl -Isource $* $LIBS @build-files.txt
  45. echo DUB has been built as bin/dub.
  46. echo
  47. echo You may want to run
  48. echo sudo ln -s $(pwd)/bin/dub /usr/local/bin
  49. echo now.