1 # This is an include file for Makefiles. It provides rules for building
2 # .pb.c and .pb.h files out of .proto, as well the path to nanopb core.
4 # Path to the nanopb root directory
5 NANOPB_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../)
7 # Files for the nanopb core
8 NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_common.c
10 # Check if we are running on Windows
18 # Check whether to use binary version of nanopb_generator or the
19 # system-supplied python interpreter.
20 ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" ""
22 PROTOC = $(NANOPB_DIR)/generator-bin/protoc
25 # Source only or git checkout
28 PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb.bat
30 PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb
34 # Rule for building .pb.c and .pb.h
35 %.pb.c %.pb.h: %.proto $(wildcard %.options)
36 $(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $<