Commit d701221e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

make: protobuf -- Generate protofiles deps

Some protobuf files do import another files so
we should generate dependencies and rebuild
the program when needed.

For example core.proto imports core-x86.proto
and core-arm.proto, thus if any of them are
changed the final core.pb-c.c should be regenerated.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2e7982ce
......@@ -42,13 +42,22 @@ PROTO_FILES += tty.proto
PROTO_FILES += file-lock.proto
PROTO_FILES += rlimit.proto
PROTO_DEPS := $(patsubst %.proto,%.proto.d,$(PROTO_FILES))
PROTO_HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
PROTO_SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
PROTO_OBJS := $(patsubst %.c,%.o,$(PROTO_SRCS))
.DEFAULT_GOAL := protobuf
%.pb-c.c %.pb-c.h: %.proto
%.proto.d: %.proto
$(E) " PROTOBUF DEPS "$@
$(Q) grep "import" $^ | \
sed -e 's/^import//' | \
sed -e 's/[\";]//g' | \
sed -e 's/.*/$^:&/' | \
uniq > $@
%.pb-c.c %.pb-c.h: %.proto %.proto.d
$(E) " PROTOBUF "$@
$(Q) protoc-c --c_out=./ $<
ifeq ($(ARCH),arm)
......@@ -72,3 +81,8 @@ protobuf: $(PROTO_LIBRARY) $(PROTO_SRCS) $(PROTO_HDRS)
clean:
$(E) " CLEAN PROTOBUF"
$(Q) rm -f $(PROTO_SRCS) $(PROTO_HDRS) $(PROTO_OBJS) $(PROTO_LIBRARY)
$(Q) rm -f $(PROTO_DEPS)
ifneq ($(MAKECMDGOALS),clean)
-include $(PROTO_DEPS)
endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment