Skip to content

Building from source

Chris Keller edited this page Apr 9, 2020 · 28 revisions

Introduction

This document describes how to build the source code using the Go toolchain.

Pat is dependent on some C libraries, so a C compiler (gcc/clang) must be available in addition to the Go toolchain.

Requirements

  • Git
  • Latest stable Go (>=1.10) with cgo enabled
  • A configured GOPATH

The fast route

If you're building with Go 1.5, be sure to export GO15VENDOREXPERIMENT=1 before running go get. This is not needed with Go 1.6 or later.

$ go get -u github.com/la5nta/pat

go get will download the latest release of Pat (including dependencies), build and install the binary at $GOPATH/bin/pat.

The long route

The source code must live inside your Go workspace ($GOPATH). Clone the repository to $GOPATH/src/github.com/la5nta/pat:

git clone https://github.com/la5nta/pat $GOPATH/src/github.com/la5nta/pat
cd $GOPATH/src/github.com/la5nta/pat

The master branch is the stable branch for Pat, this is where you'll find the latest released Pat version.

Linux only: download and build libax25

$ ./make.bash libax25

Re-generate the HTTP resources (updates static HTML/JS/CSS files):

$ go generate

Build using the make.bash-script:

$ ./make.bash

The build output is ./pat which is a self-contained binary.

Faster web development

The bindata_assetfs.go file contains all of the web resources (HTML, JavaScript and CSS). In production builds, it contains a binary string of the original files.

When only making web client changes, you can make that file a shim which loads files off of your local disk instead. That means you don't need to recompile the pat binary, just reload the browser to pull in web resource changes.

In http.go, find the line:

//go:generate go-bindata-assetfs res/...

and change to:

//go:generate go-bindata-assetfs -debug res/...

Then re-run go generate && make.

Build tags

Build tags can be used to enable additional features for the build:

  • libhamlib: Link against libhamlib for serial/usb rig control (no rigctld required).
  • libax25: Link against libax25 to enable Linux's AX.25 implementation.

To enable both features when using go get:

$ go get -tags 'libax25 libhamlib' github.com/la5nta/pat

make.bash uses the $TAGS environment variable for this purpose:

$ TAGS="libax25 libhamlib" ./make.bash

Debian packaging

dpkg-buildpackage -d -us -uc