From: Andrew Udvare <audvare@gmail.com>
Subject: [PATCH] makefile: do not fight the package manager

Avoids needing LDFLAGS= and MAKEOPTS=-j1 overrides in the ebuild.
---
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,9 @@
   NOOP := @:
 endif
 
-# set LDFLAGS environment variable to any extra ldflags required
-LDFLAGS := $(LDFLAGS)
+# LDFLAGS is deliberately not taken from the environment: the value used by
+# the C toolchain is not valid for go's -ldflags.
+LDFLAGS :=
 
 # set OUTPUT environment variable to generate a specific binary name
 # this will apply to both `stash` and `phasher`, so build them separately
@@ -53,6 +54,10 @@
   COMPILER_IMAGE := ghcr.io/stashapp/compiler:latest
 endif
 
+# The flags-* targets set variables with $(eval ...) from their recipes, so a
+# parallel make can start building before the flags are applied.
+.NOTPARALLEL:
+
 .PHONY: release
 release: generate build-release
 
@@ -66,7 +71,6 @@
 .PHONY: flags-release
 flags-release:
 	$(NOOP)
-	$(eval LDFLAGS += -s -w)
 	$(eval GO_BUILD_FLAGS += -trimpath)
 
 .PHONY: flags-pie
