Makefile tuning
[apps/agl-service-can-low-level.git] / extra / nanopb.mk
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
5 NANOPB_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../)
6
7 # Files for the nanopb core
8 NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c
9
10 # Check whether to use binary version of nanopb_generator or the
11 # system-supplied python interpreter.
12 ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" ""
13         # Binary package
14         PROTOC = $(NANOPB_DIR)/generator-bin/protoc
15         PROTOC_OPTS = 
16 else
17         # Source only or git checkout
18         PROTOC = protoc
19         ifdef windir
20                 PROTOC_OPTS = --plugin=nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb.bat
21         else
22                 PROTOC_OPTS = --plugin=nanopb=$(NANOPB_DIR)/generator/protoc-gen-nanopb
23         endif
24 endif
25
26 # Rule for building .pb.c and .pb.h
27 %.pb.c %.pb.h: %.proto $(wildcard %.options)
28         $(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $<
29