Skip to content

Commit 054bd12

Browse files
committed
#1353 Use extracted include and remove duplicated code
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 9c57332 commit 054bd12

1 file changed

Lines changed: 2 additions & 45 deletions

File tree

common.mk

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# - helm
1919
# - yq
2020

21+
include ./prerequisites.mk
22+
2123
# IMPORTANT: The body of conditionals MUST not be indented! Indentation result in
2224
# errors on macOS/FreeBSD because the line wil be interpreted as command which must
2325
# inside a recipe (target). (see https://github.com/secureCodeBox/secureCodeBox/issues/1353)
@@ -32,51 +34,6 @@ ifeq ($(name),)
3234
$(error name ENV is not set)
3335
endif
3436

35-
# This is an implementation which should work in any shell: It removes spaces from the tested var and compares it with
36-
# the original string. If they're same there are no spaces in string.
37-
PROJECT_DIR_CLEANSED=$(shell printf "%s" $(PROJECT_DIR))
38-
PROJECT_PATH_CONTAINS_WHITESPACES=$(shell if [ "$(PROJECT_DIR)" = "$(PROJECT_DIR_CLEANSED)" ]; then echo 0; else echo 1; fi)
39-
# IMPORTANT: The body of conditionals MUST not be indented! Indentation result in
40-
# errors on macOS/FreeBSD because the line wil be interpreted as command which must
41-
# inside a recipe (target). (see https://github.com/secureCodeBox/secureCodeBox/issues/1353)
42-
ifeq ($(PROJECT_PATH_CONTAINS_WHITESPACES),1)
43-
$(error The path to this repo ($(PROJECT_DIR)) contains white spaces and make can't deal with this! \
44-
Move or checkout this project to a location w/o spaces in the direcotry path)
45-
endif
46-
47-
PYTHON = $(shell which python3)
48-
# IMPORTANT: The body of conditionals MUST not be indented! Indentation result in
49-
# errors on macOS/FreeBSD because the line wil be interpreted as command which must
50-
# inside a recipe (target). (see https://github.com/secureCodeBox/secureCodeBox/issues/1353)
51-
ifeq ($(PYTHON),)
52-
PYTHON = $(shell which python)
53-
ifeq ($(PYTHON),)
54-
$(error PYTHON=$(PYTHON) not found in $(PATH))
55-
endif
56-
endif
57-
58-
PYTHON_VERSION_MIN=3.0
59-
PYTHON_VERSION=$(shell $(PYTHON) -c \
60-
'import sys; print(float(str(sys.version_info[0]) + "." + str(sys.version_info[1])))')
61-
PYTHON_VERSION_OK=$(shell $(PYTHON) -c 'print(int($(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)))' )
62-
63-
# IMPORTANT: The body of conditionals MUST not be indented! Indentation result in
64-
# errors on macOS/FreeBSD because the line wil be interpreted as command which must
65-
# inside a recipe (target). (see https://github.com/secureCodeBox/secureCodeBox/issues/1353)
66-
ifeq ($(PYTHON_VERSION_OK), 0) # True == 1
67-
$(error Need python version >= $(PYTHON_VERSION_MIN) (current: $(PYTHON_VERSION)))
68-
endif
69-
70-
# Thx to https://stackoverflow.com/questions/5618615/check-if-a-program-exists-from-a-makefile
71-
PREREQUISITES = make docker kind git node npm npx kubectl helm yq java
72-
EXECUTABLES = $(PREREQUISITES) $(PYTHON)
73-
ALL_EXECUTABLES_OK := $(foreach exec,\
74-
$(EXECUTABLES),\
75-
$(if $(shell which $(exec)),\
76-
some string,\
77-
$(error "The prerequisites are not met to execute this makefile! No '$(exec)' found in your PATH. Install all these tools: $(PREREQUISITES)"))\
78-
)
79-
8037
# Variables you might want to override:
8138
#
8239
# IMG_NS: Defines the namespace under which the images are build.

0 commit comments

Comments
 (0)