Skip to content

Enforce custom LDFLAGS within makefile #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2017
Merged

Enforce custom LDFLAGS within makefile #684

merged 1 commit into from
Jan 17, 2017

Conversation

tboerger
Copy link
Member

Fixes #540

@appleboy
Copy link
Member

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jan 17, 2017
@lunny
Copy link
Member

lunny commented Jan 17, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 17, 2017
@lunny lunny merged commit d0ad792 into go-gitea:master Jan 17, 2017
Copy link
Member

@bkcsoft bkcsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little late to the game, but anyhow 🙂

@@ -11,7 +11,7 @@ BINDATA := modules/{options,public,templates}/bindata.go
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
JAVASCRIPTS :=

LDFLAGS += -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
LDFLAGS ?= -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only makes it set LDFLAGS if it's is not set already

If you’d like a variable to be set to a value only if it’s not already set, then you can use the shorthand operator ‘?=’ instead of ‘=’

https://www.gnu.org/software/make/manual/html_node/Setting.html#Setting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make with LDFLAGS

$ LDFLAGS="-X 'main.Version=1'" make clean build
go clean -i ./...
rm -rf gitea dist modules/{options,public,templates}/bindata.go
go build -v -tags '' -ldflags '-s -w -X 'main.Version=1'' -o gitea

missing LDFLAGS

$ make clean build
go clean -i ./...
rm -rf gitea dist modules/{options,public,templates}/bindata.go
go build -v -tags '' -ldflags '-s -w -X "main.Version=1.0.0+138-g68f7246"' -o gitea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, it needs to be changed to LDFLAGS = :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LDFLAGS := and this is solved in another PR, #709

@tboerger tboerger deleted the makefile-fix branch January 24, 2017 21:50
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/deployment type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using make: flag provided but not defined
4 participants