6 #Proto Module Compile rules
7 PROTOFLAGS
+= $(patsubst %,--proto_path
=%,$(PROTOLIBS
))
9 CLEAN_RULES
+= protoclean
10 SCRUB_RULES
+= protoscrub
11 PROTO_SRC
:= $(wildcard proto
/*.proto
)
12 PROTO_TARG
:= $(PROTO_SRC
:.proto
=.pb-c.c
)
13 PROTO_TARG
:= $(PROTO_TARG
) $(PROTO_TARG
:.c
=.h
)
15 .PHONY
: protoclean protoscrub gen_proto
17 gen_proto
: $(PROTO_TARG
)
19 #download protobuf and move the google proto files.
22 # @git clone git@github.com:google/protobuf.git tmp
23 @curl https
://protobuf.googlecode.com
/files
/protobuf-
$(PBUFV
).
tar.gz |
tar xz
--directory
=tmp
24 @mv tmp
/protobuf-
$(PBUFV
)/src
/google proto
/google
25 @
$(PROTOCC
) --proto_path
=proto
/google
/protobuf
--c_out
=proto
/google
/protobuf proto
/google
/protobuf
/descriptor.proto
26 @echo
"google" > proto
/.gitignore
27 @echo
"*.pb-c.*" >> proto
/.gitignore
30 #default rule for making protobuf-compiled C code
31 %.pb-c.h
%.pb-c.c
: %.proto proto
/google
32 @
$(PROTOCC
) $(PROTOFLAGS
) --c_out
=$(@D
) $<
34 %.pb-c.h
%.pb-c.c
: proto
/%.proto proto
/google
35 @
$(PROTOCC
) $(PROTOFLAGS
) --c_out
=proto
$<
37 %.pb-c.o
%.pb-c.bc
: %.pb-c.h
%.pb-c.c
38 @
$(CC
) -c
-static
$(CPPFLAGS
) $(CFLAGS
) -I
/usr
/include/google
$< -o
$@
45 rm -f proto
/.gitignore