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