From 2facf9662a94854239ef3d185289ca79e7ee2146 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Wed, 22 May 2024 03:43:12 +0400 Subject: [PATCH] Updated Makefile. Fixed DESTDIR, PREFIX and VERSION vars. FLAGS -> GOFLAGS. Added -linkmode and -extldflags. Also perform a build when invoke a run target if there are changes. --- Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3571bcd..354f334 100755 --- a/Makefile +++ b/Makefile @@ -1,20 +1,20 @@ -TARGET:=dwelling-radio +TARGET := dwelling-radio -SYSDDIR_:=${shell pkg-config systemd --variable=systemdsystemunitdir} -SYSDDIR:=${SYSDDIR_:/%=%} +SYSDDIR_ := ${shell pkg-config systemd --variable=systemdsystemunitdir} +SYSDDIR := ${SYSDDIR_:/%=%} -DESTDIR:= -PREFIX:=/usr/local +DESTDIR ?= +PREFIX ?= /usr/local -VERSION=24.20.0 +VERSION ?= 24.20.0 -FLAGS:=-buildmode=pie -modcacherw -mod=readonly -trimpath -LDFLAGS:= -ldflags "-s -w -X main.version=${VERSION}" -tags osusergo,netgo +GOFLAGS := -buildmode=pie -modcacherw -mod=readonly -trimpath +LDFLAGS := -ldflags "-linkmode=external -extldflags \"${LDFLAGS}\" -s -w -X main.version=${VERSION}" -tags osusergo,netgo .PHONY: run install uninstall clean ${TARGET}: web/*_templ.go - go build -o bin/$@ ${LDFLAGS} ${FLAGS} cmd/$@/main.go + go build -o bin/$@ ${LDFLAGS} ${GOFLAGS} cmd/$@/main.go web/*_templ.go: web/*.templ ifeq (,$(wildcard $(shell go env GOPATH)/bin/templ)) @@ -22,7 +22,7 @@ ifeq (,$(wildcard $(shell go env GOPATH)/bin/templ)) endif $(shell go env GOPATH)/bin/templ generate -run: +run: | ${TARGET} bin/dwelling-radio -listen 127.0.0.1:18322 \ -playlist /mnt/data/appdata/radio/playlists/all-rand \ -fallback-song /mnt/data/appdata/radio/fallback.ogg \