anchor.diff:          copy nyagos.lua "%INSTALLDIR%\."
           copy /-Y _nyagos "%INSTALLDIR%\."
           copy nyagos.exe "%INSTALLDIR%\."
  -        if errorlevel 1 (start %~0 install_ & exit /b)
  -        goto end
  +        if errorlevel 1 (start "" "%~dpfx0" install_ & exit /b)
  +        exit /b
   
  -:install_
  +:"install_"
           taskkill /F /im nyagos.exe
           copy nyagos.exe "%INSTALLDIR%\."
           timeout /T 3
           exit %ERRORLEVEL%
   
  -:icon
  +:"icon"
           makeicon.cmd
  -        goto end
  +        exit /b
   
  -:help
  +:"help"
           echo Usage for make.cmd
           echo  %0          : Equals to '%0 build'
           echo  %0 build    : Build nyagos.exe as snapshot (ignore version.txt)
  
positive.code: if exist goarch.txt for /F %%I in (goarch.txt) do set "GOARCH=%%I"
  if "%GOARCH%" == "" for /F "delims=/ tokens=2" %%I in ('go version') do set "GOARCH=%%I"
  
  if not "%1" == "" goto %1
          for /F %%I in ('git describe --tags') do set "X_VERSION=-X main.version=%%I"
  
  goto build
  
  :debug
          set "TAGS=-tags=debug"
          goto build
  
  :release
          for /F %%I in (%~dp0Misc\version.txt) do set "VERSION=%%I"
          set "X_VERSION=-X main.version=%VERSION%"
  
  :build
          call :fmt
          pushd "%~dp0main"
          powershell -ExecutionPolicy RemoteSigned -File makesyso.ps1
          popd
          for /F %%I in ('dir /b /s /aa nyagos.d') do attrib -A "%%I" & if exist main\bindata.go del main\bindata.go
          if not exist main\bindata.go call :bindata
          for /F "delims=" %%V in ('git log -1 --date^=short --pretty^=format:"-X main.stamp=%%ad -X main.commit=%%H"') do go build -o nyagos.exe -ldflags "%%V %X_VERSION%" %TAGS% .\main
          goto end
  
  :fmt
          for /F %%I IN ('dir /s /b /aa *.go') do go fmt "%%I" & attrib -A "%%I"
          exit /b
  
  :status
          nyagos -e "print(nyagos.version or 'Snapshot on '..nyagos.stamp)"
          goto end
  
  :clean
          for %%I in (nyagos.exe main\nyagos.syso version.now main\bindata.go) do if exist %%I del %%I
          powershell "ls -R | ?{ $_ -match '\.go$' } | %%{ [System.IO.Path]::GetDirectoryName($_.FullName)} | Sort-Object | Get-Unique | %%{ Write-Host 'go clean on',$_ ;  pushd $_ ; go clean ; popd }"
  
  :sweep
          for /R %%I in (*~ *.bak) do if exist %%I del %%I
          if exist main\main.exe del main\main.exe
          goto end
  
  :get
          powershell "Get-ChildItem . -Recurse | ?{ $_.Extension -eq '.go' } | %%{  Get-Content $_.FullName | %%{ ($_ -replace '\s*//.*$','').Split()[-1] } | ?{ $_ -match 'github.com/' } } | Sort-Object | Get-Unique | %%{ Write-Host $_ ; go get -u $_ }"
          goto end
  
  :getbindata
          go get "github.com/jteeuwen/go-bindata"
  
negative.code:         echo     : Copy binaries to INSTALLDIR
          echo  %0 install  
          echo     : Copy binaries to last INSTALLDIR
          exit /b
  