Skip to content

Building from source

Martin Hebnes Pedersen edited this page Dec 8, 2023 · 28 revisions

Introduction

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

Requirements

  • Git
  • Latest stable Go (>=1.19)

With certain build configurations, Pat is dependent on some C libraries. Having a C compiler (gcc/clang) available in addition to the Go toolchain is recommended to ensure you'll get the full feature set in your build.

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.

Replace latest with a tag, commit sha or branch name to get a specific version.

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: The static web resources (./web/dist/) are bundled by the Go compiler at build time using the embed package.

github.com/la5nta/wl2k-go

Core functionality is implemented as a set of Go packages in the neighboring repository https://github.com/la5nta/wl2k-go.

To build Pat against local changes in wl2k-go, you'll have to add a replace directive in Pat's go.mod file. Clone both repositories into two adjacent folders and run the following command:

echo 'replace github.com/la5nta/wl2k-go => ../wl2k-go' >> go.mod && go mod tidy

The resulting modifications to go.mod and go.sum should not be committed. When submitting PRs, please submit the wl2k-go changes first.

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 install:

go install -tags 'libax25 libhamlib' github.com/la5nta/pat@latest

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.