2019-08-20 21:14:45 +00:00
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
|
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
SHELL := bash # the shell used internally by "make"
|
|
|
|
|
2022-10-12 15:28:34 +00:00
|
|
|
# Windows does not symlink cc to gcc
|
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
CC := gcc
|
|
|
|
else
|
2022-10-04 16:18:45 +00:00
|
|
|
CC ?= gcc
|
2022-10-12 15:28:34 +00:00
|
|
|
endif
|
2019-08-20 21:14:45 +00:00
|
|
|
LD := $(CC)
|
|
|
|
|
2022-11-24 16:07:01 +00:00
|
|
|
NIMC ?= nim
|
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
#- extra parameters for the Nim compiler
|
|
|
|
#- NIMFLAGS should come from the environment or make's command line
|
|
|
|
NIM_PARAMS := $(NIMFLAGS)
|
|
|
|
|
|
|
|
# verbosity level
|
|
|
|
V := 0
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) --verbosity:$(V)
|
|
|
|
HANDLE_OUTPUT :=
|
|
|
|
SILENT_TARGET_PREFIX := disabled
|
|
|
|
ifeq ($(V), 0)
|
2020-04-18 16:28:38 +00:00
|
|
|
NIM_PARAMS := $(NIM_PARAMS) --hints:off
|
2021-11-04 23:18:36 +00:00
|
|
|
# don't swallow stderr, in case it's important
|
|
|
|
HANDLE_OUTPUT := >/dev/null
|
2019-08-20 21:14:45 +00:00
|
|
|
SILENT_TARGET_PREFIX :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Chronicles log level
|
2021-02-19 18:43:14 +00:00
|
|
|
ifdef LOG_LEVEL
|
2020-05-28 01:31:08 +00:00
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:chronicles_log_level="$(LOG_LEVEL)"
|
2019-08-20 21:14:45 +00:00
|
|
|
endif
|
|
|
|
|
2020-10-08 19:39:40 +00:00
|
|
|
# statically link everything but libc
|
|
|
|
PARTIAL_STATIC_LINKING := 0
|
|
|
|
ifeq ($(PARTIAL_STATIC_LINKING), 1)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) --passL:-static-libgcc
|
|
|
|
endif
|
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# avoid a "libpcre.so.3: cannot open shared object file: No such file or directory" message, where possible
|
2020-11-13 12:44:27 +00:00
|
|
|
LINK_PCRE ?= 1
|
2020-08-22 02:44:10 +00:00
|
|
|
ifeq ($(LINK_PCRE), 1)
|
|
|
|
ifneq ($(OS), Windows_NT)
|
2020-10-08 19:39:40 +00:00
|
|
|
ifneq ($(strip $(shell uname)), Darwin)
|
|
|
|
ifeq ($(PARTIAL_STATIC_LINKING), 1)
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:usePcreHeader --passL:-l:libpcre.a
|
|
|
|
else
|
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -d:usePcreHeader --passL:-lpcre
|
|
|
|
endif
|
|
|
|
endif
|
2020-06-16 23:34:34 +00:00
|
|
|
endif
|
2019-08-20 21:14:45 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# guess who does parsing before variable expansion
|
|
|
|
COMMA := ,
|
|
|
|
EMPTY :=
|
|
|
|
SPACE := $(EMPTY) $(EMPTY)
|
|
|
|
|
|
|
|
# coloured messages
|
2021-09-09 12:12:17 +00:00
|
|
|
BUILD_MSG := "\\x1B[92mBuilding:\\x1B[39m"
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
GIT_CLONE := git clone --quiet --recurse-submodules
|
|
|
|
GIT_PULL := git pull --recurse-submodules
|
|
|
|
GIT_STATUS := git status
|
|
|
|
#- the Nimble dir can't be "[...]/vendor", or Nimble will start looking for
|
|
|
|
# version numbers in repo dirs (because those would be in its subdirectories)
|
|
|
|
#- duplicated in "env.sh" for the env var with the same name
|
|
|
|
NIMBLE_DIR := vendor/.nimble
|
|
|
|
REPOS_DIR := vendor
|
2020-12-02 21:35:05 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
PWD := pwd -W
|
2020-12-02 21:35:05 +00:00
|
|
|
EXE_SUFFIX := .exe
|
|
|
|
# available since Git 2.9.4
|
|
|
|
GIT_TIMESTAMP_ARG := --date=unix
|
2019-08-20 21:14:45 +00:00
|
|
|
else
|
|
|
|
PWD := pwd
|
2020-12-02 21:35:05 +00:00
|
|
|
EXE_SUFFIX :=
|
|
|
|
# available since Git 2.7.0
|
|
|
|
GIT_TIMESTAMP_ARG := --date=format-local:%s
|
2019-08-20 21:14:45 +00:00
|
|
|
endif
|
2020-12-02 21:35:05 +00:00
|
|
|
|
|
|
|
ifeq ($(shell uname), Darwin)
|
|
|
|
# md5sum - macOS is a special case
|
|
|
|
MD5SUM := md5 -r
|
|
|
|
NPROC_CMD := sysctl -n hw.logicalcpu
|
|
|
|
else
|
|
|
|
MD5SUM := md5sum
|
|
|
|
NPROC_CMD := nproc
|
|
|
|
endif
|
|
|
|
|
|
|
|
GET_CURRENT_COMMIT_TIMESTAMP := git log --pretty=format:%cd -n 1 $(GIT_TIMESTAMP_ARG)
|
|
|
|
UPDATE_TIMESTAMP := .update.timestamp
|
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
ifeq ($(BUILD_SYSTEM_DIR),)
|
|
|
|
$(error You need to define BUILD_SYSTEM_DIR before including this file)
|
|
|
|
endif
|
2020-12-02 21:35:05 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# we want a "recursively expanded" (delayed interpolation) variable here, so we can set CMD in rule recipes
|
2021-09-09 12:12:17 +00:00
|
|
|
RUN_CMD_IN_ALL_REPOS = git submodule foreach --recursive --quiet 'echo -e "\n\x1B[32m$$name:\x1B[39m"; $(CMD)'; echo -e "\n\x1B[32m$$($(PWD)):\x1B[39m"; $(CMD)
|
2020-12-02 21:35:05 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# absolute path, since it will be run at various subdirectory depths
|
2020-01-30 00:09:52 +00:00
|
|
|
ENV_SCRIPT := "$(CURDIR)/$(BUILD_SYSTEM_DIR)/scripts/env.sh"
|
2020-12-02 21:35:05 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# duplicated in "env.sh" to prepend NIM_DIR/bin to PATH
|
2019-08-28 12:44:42 +00:00
|
|
|
NIM_DIR := $(BUILD_SYSTEM_DIR)/vendor/Nim
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
NIM_BINARY := $(NIM_DIR)/bin/nim$(EXE_SUFFIX)
|
2020-12-02 21:35:05 +00:00
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# AppVeyor/Travis cache of $(NIM_DIR)/bin
|
|
|
|
CI_CACHE :=
|
|
|
|
|
2020-04-15 15:25:03 +00:00
|
|
|
# bypassing the shipped Nim, usually for testing new Nim devel versions
|
|
|
|
USE_SYSTEM_NIM := 0
|
|
|
|
|
2020-12-26 15:04:58 +00:00
|
|
|
# Skip multiple bootstrap iterations and tool building.
|
|
|
|
QUICK_AND_DIRTY_COMPILER := 0
|
|
|
|
|
2022-01-26 14:20:55 +00:00
|
|
|
# Override local submodule changes during `make update`. On by default. Turned off in `make update-dev`.
|
|
|
|
OVERRIDE := 1
|