Merge pull request #170 from kylemanna/travis-ci
[apps/agl-service-can-low-level.git] / examples / network_server / Makefile
index 981f2cf..2c7639a 100644 (file)
@@ -1,19 +1,17 @@
-CFLAGS = -ansi -Wall -Werror -g -O0
+# Include the nanopb provided Makefile rules
+include ../../extra/nanopb.mk
 
-# Path to the nanopb root folder
-NANOPB_DIR = ../..
-DEPS = $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_decode.h \
-       $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_encode.h $(NANOPB_DIR)/pb.h
+# Compiler flags to enable all warnings & debug info
+CFLAGS = -ansi -Wall -Werror -g -O0
 CFLAGS += -I$(NANOPB_DIR)
 
 all: server client
 
+.SUFFIXES:
+
 clean:
        rm -f server client fileproto.pb.c fileproto.pb.h
 
-%: %.c $(DEPS) fileproto.pb.h fileproto.pb.c
-       $(CC) $(CFLAGS) -o $@ $< $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_encode.c fileproto.pb.c common.c
+%: %.c common.c fileproto.pb.c
+       $(CC) $(CFLAGS) -o $@ $^ $(NANOPB_CORE)
 
-fileproto.pb.c fileproto.pb.h: fileproto.proto $(NANOPB_DIR)/generator/nanopb_generator.py
-       protoc -ofileproto.pb $<
-       python $(NANOPB_DIR)/generator/nanopb_generator.py fileproto.pb