Skip to content

Ensure Make behaves like make #3

Description

@squeedee

https://github.com/cf-platform-eng/marman/blob/6452f7f8552f220d34ae146efab2079cfc800c0b/Makefile#L47

Today I learnt (or realised something i knew but haven't been applying):

This is a file target

build/marman-linux: $(SRC) deps
	GOARCH=amd64 GOOS=linux go build -o build/marman-linux -ldflags ${LDFLAGS} ./cmd/marman/main.go

This is a pseudo-target

build-darwin: build/marman-darwin

If you want make to be efficient, try to make sure that file targets always depend on other file targets

In the build/marman-linux target, we're depending on a pseudo-target, deps which means the go build will always be run again, despite there being nothing to do.

the fix is to move deps to the pseudo target:

build/marman-linux: $(SRC)
	GOARCH=amd64 GOOS=linux go build -o build/marman-linux -ldflags ${LDFLAGS} ./cmd/marman/main.go

build-darwin: deps build/marman-darwin

OR we can establish a file target for deps using the temp/tags trick but that's not always feasable.

This isn't an immediate issue, in that building our go apps is pretty fast, but it can balloon out and cause friction when later you decide to add a slower pre-processing action to your builds.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions