github.com/sacloud/iaas-api-go@v1.12.0/includes/go/single.mk (about)

     1  #
     2  # Copyright 2022-2023 The sacloud/makefile Authors
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #      http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  #
    16  
    17  GO             ?= go
    18  BIN            ?= TODO_PLEASE_SET_BIN_VARIABLE
    19  GO_ENTRY_FILE  ?= main.go
    20  GO_FILES       ?= $(shell find . -name '*.go')
    21  BUILD_LDFLAGS  ?=
    22  
    23  .PHONY: install
    24  install:
    25  	@echo "running 'go install'..."
    26  	$(GO) install
    27  
    28  .PHONY: build
    29  build: $(BIN)
    30  
    31  $(BIN): $(GO_FILES) go.mod go.sum
    32  	@echo "running 'go build'..."
    33  	@GOOS=$${OS:-"`$(GO) env GOOS`"} GOARCH=$${ARCH:-"`$(GO) env GOARCH`"} CGO_ENABLED=0 $(GO) build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) $(GO_ENTRY_FILE)
    34  
    35  .PHONY: clean
    36  clean:
    37  	@echo "cleaning..."
    38  	rm -rf $(BIN)
    39  
    40  DEFAULT_GOALS += build