Skip to content

Commit 711a5b4

Browse files
authored
Merge pull request #481 from tock/package-name-no-spaces
make: ensure PACKAGE_NAME has no spaces
2 parents 11c37d0 + dfe9ab3 commit 711a5b4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

AppMakefile.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ include $(TOCK_USERLAND_BASE_DIR)/libtock-sync/Makefile
3939
# Include the makefile that has the programming functions for each board.
4040
include $(TOCK_USERLAND_BASE_DIR)/Program.mk
4141

42+
# Remove any leading or trailing spaces from PACKAGE_NAME and then verify there
43+
# are no spaces within the PACKAGE_NAME variable.
44+
override PACKAGE_NAME := $(strip $(PACKAGE_NAME))
45+
$(call check_no_spaces, PACKAGE_NAME)
4246

4347
# Rules to call library makefiles to build required libraries.
4448
#

Helpers.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ __check_defined = \
2323
$(if $(value $1),, \
2424
$(error Undefined $1$(if $2, ($2))))
2525

26+
# Check that the variable has no leading or trailing spaces, or spaces within
27+
# the variable.
28+
#
29+
# Params:
30+
# 1. Variable name to test.
31+
check_no_spaces = \
32+
$(if $(findstring $(strip $($(strip $1))),$($(strip $1))),,$(error Error: Space in variable $(strip $1))) \
33+
$(if $(word 2,$($(strip $1))),$(error Error: Multiple entries in variable $(strip $1)),)
34+
2635
# Check for a ~/ at the beginning of a path variable (TOCK_USERLAND_BASE_DIR).
2736
# Make will not properly expand this.
2837
ifdef TOCK_USERLAND_BASE_DIR

0 commit comments

Comments
 (0)