nanopb.mk: Make NANOPB_DIR relative if nanopb.mk is included with relative path.
This simplifies handling of space characters in paths.
diff --git a/examples/simple/Makefile b/examples/simple/Makefile
index 970a865..b503f1b 100644
--- a/examples/simple/Makefile
+++ b/examples/simple/Makefile
@@ -3,7 +3,7 @@
# Compiler flags to enable all warnings & debug info
CFLAGS = -Wall -Werror -g -O0
-CFLAGS += -I$(NANOPB_DIR)
+CFLAGS += "-I$(NANOPB_DIR)"
# C source code files that are required
CSRC = simple.c # The main program
diff --git a/extra/nanopb.mk b/extra/nanopb.mk
index 8be2929..279515f 100644
--- a/extra/nanopb.mk
+++ b/extra/nanopb.mk
@@ -2,7 +2,7 @@
# .pb.c and .pb.h files out of .proto, as well the path to nanopb core.
# Path to the nanopb root directory
-NANOPB_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../)
+NANOPB_DIR := $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))))
# Files for the nanopb core
NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_common.c
@@ -25,9 +25,9 @@
# Source only or git checkout
PROTOC_OPTS =
ifdef WINDOWS
- PROTOC = python "$(NANOPB_DIR)/generator/protoc"
+ PROTOC = python $(NANOPB_DIR)/generator/protoc
else
- PROTOC = "$(NANOPB_DIR)/generator/protoc"
+ PROTOC = $(NANOPB_DIR)/generator/protoc
endif
endif