Skip to content

Commit 508b74e

Browse files
committed
Makefile: improve check for TARGET
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.
1 parent e951feb commit 508b74e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,26 @@ FW_TARGET_DIR=$(FW_DIR)/firmwares/$(MAINTARGET)-$(SUBTARGET)
1616
VERSION_FILE=$(FW_TARGET_DIR)/VERSION.txt
1717
UMASK=umask 022
1818

19+
define newline
20+
21+
22+
endef
23+
24+
25+
define listtargets
26+
$(error $(1) TARGET defined ! $(newline) \
27+
$(addprefix $(newline) * ,$(VALID_TARGETS)) \
28+
$(newline)Please specify one from the list above via 'TARGET' environment or in config.mk)
29+
endef
30+
1931
# test for existing $TARGET-config or abort
32+
VALID_TARGETS=$(sort $(notdir $(basename $(wildcard $(FW_DIR)/profiles/*.profiles))))
33+
ifdef TARGET
2034
ifeq ($(wildcard $(FW_DIR)/configs/$(TARGET).config),)
21-
$(error config for $(TARGET) not defined)
35+
$(call listtargets,Invalid)
36+
endif
37+
else
38+
$(call listtargets,No)
2239
endif
2340

2441
# if any of the following files have been changed: clean up openwrt dir

config.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# default parameters for Makefile
22
SHELL:=$(shell which bash)
3-
TARGET=ar71xx-generic
3+
#TARGET=ar71xx-generic
44
PACKAGES_LIST_DEFAULT=notunnel tunnel-berlin-tunneldigger manual
55
MAKE_ARGS=

0 commit comments

Comments
 (0)