Build system: Use ifndef X in makefiles instead of ifeq("$(X)","")

This commit is contained in:
Angus Gratton 2016-11-10 16:19:59 +11:00
parent 25db1effd6
commit 07f36a9437
2 changed files with 8 additions and 9 deletions

View file

@ -8,7 +8,7 @@
#
# CWD is the build directory of the component.
ifeq ("$(PROJECT_PATH)","")
ifndef PROJECT_PATH
$(error Make was invoked from $(CURDIR). However please do not run make from the sdk or a component directory; invoke make from the project directory. See the ESP-IDF README for details.)
endif
@ -60,7 +60,7 @@ include $(COMPONENT_MAKEFILE)
# Object files which need to be linked into the library
# By default we take all .c, .cpp & .S files in COMPONENT_SRCDIRS.
ifeq ("$(COMPONENT_OBJS)", "")
ifndef COMPONENT_OBJS
# Find all source files in all COMPONENT_SRCDIRS
COMPONENT_OBJS := $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.c,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.c)))
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.cpp,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.cpp)))
@ -120,7 +120,7 @@ component_project_vars.mk::
# If COMPONENT_OWNBUILDTARGET is not set, define a phony build target and
# a COMPONENT_LIBRARY link target.
ifeq ("$(COMPONENT_OWNBUILDTARGET)", "")
ifndef COMPONENT_OWNBUILDTARGET
.PHONY: build
build: $(COMPONENT_LIBRARY)
@mkdir -p $(COMPONENT_SRCDIRS)
@ -134,7 +134,7 @@ $(COMPONENT_LIBRARY): $(COMPONENT_OBJS)
endif
# If COMPONENT_OWNCLEANTARGET is not set, define a phony clean target
ifeq ("$(COMPONENT_OWNCLEANTARGET)", "")
ifndef COMPONENT_OWNCLEANTARGET
CLEAN_FILES = $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EXTRA_CLEAN) component_project_vars.mk
.PHONY: clean
clean:

View file

@ -40,10 +40,9 @@ help:
MAKEFLAGS_OLD := $(MAKEFLAGS)
MAKEFLAGS +=-rR
# Figure out PROJECT_PATH if not set
ifeq ("$(PROJECT_PATH)","")
#The path to the project: we assume the Makefile including this file resides
#in the root of that directory.
# Default path to the project: we assume the Makefile including this file
# is in the project directory
ifndef PROJECT_PATH
PROJECT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
export PROJECT_PATH
endif
@ -67,7 +66,7 @@ SRCDIRS ?= main
# The project Makefile can define a list of components, but if it does not do this we just take
# all available components in the component dirs.
ifeq ("$(COMPONENTS)","")
ifndef COMPONENTS
# Find all component names. The component names are the same as the
# directories they're in, so /bla/components/mycomponent/ -> mycomponent. We then use
# COMPONENT_DIRS to build COMPONENT_PATHS with the full path to each component.