Skip to content

Commit

Permalink
Makefile: improve check for TARGET
Browse files Browse the repository at this point in the history
Make defining a TARGET in config.mk optinonal, by testing for it. Improve the test by a more
verbose message, which includes the valid choices.
This avoids problems for people forgetting to override the default on commandline.
  • Loading branch information
SvenRoederer committed Oct 26, 2020
1 parent e951feb commit 508b74e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,26 @@ FW_TARGET_DIR=$(FW_DIR)/firmwares/$(MAINTARGET)-$(SUBTARGET)
VERSION_FILE=$(FW_TARGET_DIR)/VERSION.txt
UMASK=umask 022

define newline


endef


define listtargets
$(error $(1) TARGET defined ! $(newline) \
$(addprefix $(newline) * ,$(VALID_TARGETS)) \
$(newline)Please specify one from the list above via 'TARGET' environment or in config.mk)
endef

# test for existing $TARGET-config or abort
VALID_TARGETS=$(sort $(notdir $(basename $(wildcard $(FW_DIR)/profiles/*.profiles))))
ifdef TARGET
ifeq ($(wildcard $(FW_DIR)/configs/$(TARGET).config),)
$(error config for $(TARGET) not defined)
$(call listtargets,Invalid)
endif
else
$(call listtargets,No)
endif

# if any of the following files have been changed: clean up openwrt dir
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# default parameters for Makefile
SHELL:=$(shell which bash)
TARGET=ar71xx-generic
#TARGET=ar71xx-generic
PACKAGES_LIST_DEFAULT=notunnel tunnel-berlin-tunneldigger manual
MAKE_ARGS=

0 comments on commit 508b74e

Please sign in to comment.