Chameleon: Fix Makefile
The $() in the shell command will be run no matter the if is true or
false. Using "Makefile ifeq" instead of "shell if" to fix this issue.
Move CHAMELEON_HOSTNAME out of the target to make sure it will be
parsed before ifeq.
BUG=b:185973512
TEST=make remote-install to Chameleon fpga successfully
Change-Id: Iaa68e0e2fe10aa29750f89cdd919b0e20dcf6ab5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/chameleon/+/2841995
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
diff --git a/Makefile b/Makefile
index 2ce993e..d200854 100644
--- a/Makefile
+++ b/Makefile
@@ -152,25 +152,28 @@
"cat /etc/hostname")
endef
+ifdef CHAMELEON_HOST
+ CHAMELEON_HOSTNAME := $(call get_chameleon_hostname)
+endif
+
.PHONY: check_pi_make
check_pi_make:
- $(eval CHAMELEON_HOSTNAME := $(call get_chameleon_hostname))
- @if [ $(CHAMELEON_HOSTNAME) == raspberrypi ]; then \
- $(eval PY_VERSION := python3) \
- if [ $(shell cat $(PY_VERSION_FILE)) != $(PY_VERSION) ]; then \
- echo "Raspberry Pi has switched to python3."; \
- echo "You need to explicitly make with python3 for Raspberry" \
- "Pi now until all other platforms have switched to python3" \
- "as well."; \
- echo; \
- echo "Please make with python3 and then install as"; \
- echo "(cr) $$ make PY_VERSION=python3"; \
- echo '(cr) $$ make remote-install' \
- 'CHAMELEON_HOST=$$RASPBERRY_IP'; \
- echo; \
- exit 1; \
- fi; \
- fi
+ifeq ($(CHAMELEON_HOSTNAME), raspberrypi)
+ $(eval PY_VERSION := python3)
+ @if [ $(shell cat $(PY_VERSION_FILE)) != $(PY_VERSION) ]; then \
+ echo "Raspberry Pi has switched to python3."; \
+ echo "You need to explicitly make with python3 for Raspberry" \
+ "Pi now until all other platforms have switched to python3" \
+ "as well."; \
+ echo; \
+ echo "Please make with python3 and then install as"; \
+ echo "(cr) $$ make PY_VERSION=python3"; \
+ echo '(cr) $$ make remote-install' \
+ 'CHAMELEON_HOST=$$RASPBERRY_IP'; \
+ echo; \
+ exit 1; \
+ fi;
+endif
.PHONY: remote-install
remote-install: check_git_tree_clean check_git_commit_HEAD check_pi_make