• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../)
6
7# Files for the nanopb core
8NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.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 = protoc
27	ifdef WINDOWS
28		PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb.bat
29	else
30		PROTOC_OPTS = --plugin=protoc-gen-nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb
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