Home | History | Annotate | Download | only in extra
      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 if we are running on Windows
     11 ifdef windir
     12 WINDOWS = 1
     13 endif
     14 ifdef WINDIR
     15 WINDOWS = 1
     16 endif
     17 
     18 # Check whether to use binary version of nanopb_generator or the
     19 # system-supplied python interpreter.
     20 ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" ""
     21 	# Binary package
     22 	PROTOC = $(NANOPB_DIR)/generator-bin/protoc
     23 	PROTOC_OPTS = 
     24 else
     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
     32 endif
     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