make.bash 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -e
  3. #set -xv # verbose output for testing
  4. if [ ! -f make.bash ]; then
  5. echo 'make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient'
  6. exit 1
  7. fi
  8. CGO_ENABLED=1
  9. # Make sure we have our dependencies
  10. echo -e "go-getting dependencies...\n"
  11. go get -d -v ./...
  12. LDFLAGS="\
  13. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate `date --iso-8601=seconds` \
  14. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo `git config --get remote.origin.url` \
  15. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev `git rev-parse HEAD` \
  16. "
  17. echo -e "LDFLAGS=$LDFLAGS\n"
  18. echo -e "\nBuilding windows-386..."
  19. CC=/usr/bin/i686-w64-mingw32-gcc \
  20. gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output windows_386_psiphon-tunnel-core
  21. # We are finding that UPXing the full Windows Psiphon client produces better results
  22. # if psiphon-tunnel-core.exe is not already UPX'd.
  23. #upx --best windows_386_psiphon-tunnel-core.exe
  24. echo -e "\nBuilding windows-amd64..."
  25. CC=/usr/bin/x86_64-w64-mingw32-gcc \
  26. gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output windows_amd64_psiphon-tunnel-core
  27. upx --best windows_amd64_psiphon-tunnel-core.exe
  28. echo -e "\nBuilding linux-amd64..."
  29. gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output linux_amd64_psiphon-tunnel-core
  30. upx --best linux_amd64_psiphon-tunnel-core
  31. echo -e "\nBuilding linux-386..."
  32. CFLAGS=-m32 \
  33. gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output linux_386_psiphon-tunnel-core
  34. upx --best linux_386_psiphon-tunnel-core