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. 3 4# Path to the nanopb root directory 5NANOPB_DIR := $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))))) 6 7# Files for the nanopb core 8NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_common.c 9 10# Check if we are running on Windows 11ifdef windir 12WINDOWS = 1 13endif 14ifdef WINDIR 15WINDOWS = 1 16endif 17 18# Check whether to use binary version of nanopb_generator or the 19# system-supplied python interpreter. 20ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" "" 21 # Binary package 22 PROTOC = $(NANOPB_DIR)/generator-bin/protoc 23 PROTOC_OPTS = 24else 25 # Source only or git checkout 26 PROTOC_OPTS = 27 ifdef WINDOWS 28 PROTOC = python $(NANOPB_DIR)/generator/protoc 29 else 30 PROTOC = $(NANOPB_DIR)/generator/protoc 31 endif 32endif 33 34# Rule for building .pb.c and .pb.h 35%.pb.c %.pb.h: %.proto $(wildcard %.options) 36 $(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $< 37 38