Skip to content

Building from source

Martin Hebnes Pedersen edited this page Aug 20, 2022 · 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.16) with cgo enabled
  • A configured GOPATH

The fast route

go install github.com/la5nta/pat@latest

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

The proper route

Clone the repository:

git clone https://github.com/la5nta/pat
cd pat

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

Linux only: download and build libax25

$ ./make.bash libax25

Build using the make.bash-script:

$ ./make.bash

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

Faster web development

# Start webpack-dev-server
cd web
npm start

# Run pat http pointing to the dev server
PAT_WEB_DEV_ADDR="http://localhost:8081" go run . http

Note: As of commit 37f73134, this is no longer applicable. The static web resources are now bundled by the Go compiler at build time using the embed package.

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.bash.

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

MacOS packaging

Install Packages, then run ./make.bash. Along with the pat executable, make.bash will generate another file pat_$VERSION_darwin_amd64_unsigned.pkg.