2016-11-05 17:09:05 -07:00
|
|
|
# Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
# remove default suffixes as we dont use them
|
|
|
|
|
.SUFFIXES:
|
2016-09-29 15:48:15 -07:00
|
|
|
|
2017-07-21 10:01:14 -07:00
|
|
|
SHELL := /bin/bash
|
2021-02-02 14:15:15 +01:00
|
|
|
ifneq (, $(shell command -v shasum))
|
2019-02-18 16:36:39 -05:00
|
|
|
SHA256CMD := shasum -a 256
|
2021-02-02 14:15:15 +01:00
|
|
|
else ifneq (, $(shell command -v sha256sum))
|
|
|
|
|
SHA256CMD := sha256sum
|
|
|
|
|
else
|
|
|
|
|
$(error "please install 'shasum' or 'sha256sum'")
|
|
|
|
|
endif
|
2017-07-21 10:01:14 -07:00
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
ifeq ($(origin PLATFORM), undefined)
|
2017-07-21 21:17:09 -07:00
|
|
|
ifeq ($(origin GOOS), undefined)
|
2017-06-26 20:04:53 -07:00
|
|
|
GOOS := $(shell go env GOOS)
|
2017-07-21 21:17:09 -07:00
|
|
|
endif
|
|
|
|
|
ifeq ($(origin GOARCH), undefined)
|
2017-06-02 13:46:15 -07:00
|
|
|
GOARCH := $(shell go env GOARCH)
|
2017-07-21 21:17:09 -07:00
|
|
|
endif
|
2017-06-26 20:04:53 -07:00
|
|
|
PLATFORM := $(GOOS)_$(GOARCH)
|
|
|
|
|
else
|
|
|
|
|
GOOS := $(word 1, $(subst _, ,$(PLATFORM)))
|
|
|
|
|
GOARCH := $(word 2, $(subst _, ,$(PLATFORM)))
|
2017-07-21 17:02:50 -07:00
|
|
|
export GOOS GOARCH
|
2017-06-02 13:46:15 -07:00
|
|
|
endif
|
|
|
|
|
|
2018-01-08 20:58:28 -08:00
|
|
|
ALL_PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
|
2017-06-26 20:04:53 -07:00
|
|
|
|
|
|
|
|
ifeq ($(PLATFORM),linux_amd64)
|
2017-06-02 13:46:15 -07:00
|
|
|
CROSS_TRIPLE = x86_64-linux-gnu
|
|
|
|
|
endif
|
2017-06-26 20:04:53 -07:00
|
|
|
ifeq ($(PLATFORM),linux_arm64)
|
2017-06-02 13:46:15 -07:00
|
|
|
CROSS_TRIPLE = aarch64-linux-gnu
|
2016-09-29 15:48:15 -07:00
|
|
|
endif
|
2017-06-26 20:04:53 -07:00
|
|
|
ifeq ($(PLATFORM),darwin_amd64)
|
2016-11-29 21:50:01 -08:00
|
|
|
CROSS_TRIPLE=x86_64-apple-darwin15
|
2016-09-29 15:48:15 -07:00
|
|
|
endif
|
2017-06-26 20:04:53 -07:00
|
|
|
ifeq ($(PLATFORM),windows_amd64)
|
2016-11-29 21:50:01 -08:00
|
|
|
CROSS_TRIPLE=x86_64-w64-mingw32
|
2016-09-29 15:48:15 -07:00
|
|
|
endif
|
2017-08-25 10:22:22 -07:00
|
|
|
export GOARM
|
2016-09-29 15:48:15 -07:00
|
|
|
|
2021-11-02 18:54:58 +01:00
|
|
|
# force the build of a linux binary when running on MacOS
|
|
|
|
|
GOHOSTOS=linux
|
|
|
|
|
GOHOSTARCH := $(shell go env GOHOSTARCH)
|
|
|
|
|
HOST_PLATFORM := $(GOHOSTOS)_$(GOHOSTARCH)
|
|
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
ifneq ($(PLATFORM),$(HOST_PLATFORM))
|
2021-11-02 18:54:58 +01:00
|
|
|
ifeq (,$(shell go env CC))
|
2017-06-02 13:46:15 -07:00
|
|
|
CC := $(CROSS_TRIPLE)-gcc
|
2021-11-02 18:54:58 +01:00
|
|
|
else
|
|
|
|
|
CC := $(shell go env CC)
|
|
|
|
|
endif
|
|
|
|
|
ifeq (,$(shell go env CXX))
|
|
|
|
|
CXX := $(CROSS_TRIPLE)-gcc
|
|
|
|
|
else
|
|
|
|
|
CXX := $(shell go env CXX)
|
|
|
|
|
endif
|
2017-06-02 13:46:15 -07:00
|
|
|
export CC CXX
|
|
|
|
|
endif
|
2017-06-16 10:18:00 -07:00
|
|
|
|
2021-11-02 18:54:58 +01:00
|
|
|
# REAL_HOST_PLATFORM is used to determine the correct url to download the various binary tools from and it does not use
|
|
|
|
|
# HOST_PLATFORM which is used to build the program.
|
|
|
|
|
REAL_HOST_PLATFORM=$(shell go env GOHOSTOS)_$(GOHOSTARCH)
|
|
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
# set the version number. you should not need to do this
|
|
|
|
|
# for the majority of scenarios.
|
|
|
|
|
ifeq ($(origin VERSION), undefined)
|
2018-08-14 23:20:27 -07:00
|
|
|
VERSION := $(shell git describe --dirty --always --tags | sed 's/-/./2' | sed 's/-/./2' )
|
2017-06-26 20:04:53 -07:00
|
|
|
endif
|
2017-08-09 12:57:39 -07:00
|
|
|
export VERSION
|
2017-06-26 20:04:53 -07:00
|
|
|
|
|
|
|
|
# include the common make file
|
|
|
|
|
COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
|
|
|
|
|
2017-07-07 12:45:04 -07:00
|
|
|
ifeq ($(origin ROOT_DIR),undefined)
|
|
|
|
|
ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/../.. && pwd -P))
|
|
|
|
|
endif
|
2017-06-26 21:52:06 -07:00
|
|
|
ifeq ($(origin OUTPUT_DIR),undefined)
|
2017-07-07 12:45:04 -07:00
|
|
|
OUTPUT_DIR := $(ROOT_DIR)/_output
|
2017-06-26 20:04:53 -07:00
|
|
|
endif
|
|
|
|
|
ifeq ($(origin WORK_DIR), undefined)
|
2017-07-07 12:45:04 -07:00
|
|
|
WORK_DIR := $(ROOT_DIR)/.work
|
2017-06-26 20:04:53 -07:00
|
|
|
endif
|
|
|
|
|
ifeq ($(origin CACHE_DIR), undefined)
|
2017-07-07 12:45:04 -07:00
|
|
|
CACHE_DIR := $(ROOT_DIR)/.cache
|
2017-06-26 20:04:53 -07:00
|
|
|
endif
|
2017-07-07 12:45:04 -07:00
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
TOOLS_DIR := $(CACHE_DIR)/tools
|
|
|
|
|
TOOLS_HOST_DIR := $(TOOLS_DIR)/$(HOST_PLATFORM)
|
|
|
|
|
|
2017-07-07 12:45:04 -07:00
|
|
|
ifeq ($(origin HOSTNAME), undefined)
|
|
|
|
|
HOSTNAME := $(shell hostname)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# a registry that is scoped to the current build tree on this host
|
|
|
|
|
ifeq ($(origin BUILD_REGISTRY), undefined)
|
2019-02-18 16:36:39 -05:00
|
|
|
BUILD_REGISTRY := build-$(shell echo $(HOSTNAME)-$(ROOT_DIR) | $(SHA256CMD) | cut -c1-8)
|
|
|
|
|
endif
|
|
|
|
|
ifeq ($(BUILD_REGISTRY),build-)
|
|
|
|
|
$(error Failed to get unique ID for host+dir. Check that '$(SHA256CMD)' functions or override SHA256CMD)
|
2017-07-07 12:45:04 -07:00
|
|
|
endif
|
|
|
|
|
|
2021-07-26 16:40:28 -06:00
|
|
|
SED_IN_PLACE = $(ROOT_DIR)/build/sed-in-place
|
|
|
|
|
export SED_IN_PLACE
|
|
|
|
|
|
2019-06-05 10:23:07 +03:00
|
|
|
# This is a neat little target that prints any variable value from the Makefile
|
|
|
|
|
# Usage: make echo.IMAGES echo.PLATFORM
|
|
|
|
|
echo.%: ; @echo $* = $($*)
|
|
|
|
|
|
2018-07-19 12:36:30 -06:00
|
|
|
# Select which images (backends) to make; default to all possible images
|
2021-08-30 12:26:32 -06:00
|
|
|
IMAGES ?= ceph
|
2018-07-19 12:36:30 -06:00
|
|
|
|
2017-06-26 20:04:53 -07:00
|
|
|
COMMA := ,
|
|
|
|
|
SPACE :=
|
2017-07-07 12:45:04 -07:00
|
|
|
SPACE +=
|
2017-10-24 12:44:18 -07:00
|
|
|
|
|
|
|
|
# define a newline
|
|
|
|
|
define \n
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 11:25:06 -07:00
|
|
|
endef
|