From fb52c72e80651f76d792b70c552827f3d4f79ca8 Mon Sep 17 00:00:00 2001 From: latex Date: Mon, 23 Jan 2023 01:14:35 +0100 Subject: Add nanopb to Makefile --- Makefile | 12 ++++++------ config.mk | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 143ffa7..cb04172 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ +include deps/nanopb/extra/nanopb.mk include config.mk SRC += $(shell find src/ -type f -name '*.c') +PROTO = $(shell find src/ -type f -name '*.proto') OBJ = $(SRC:%=$(BUILD_DIR)/%.o) +OBJ += $(PROTO:%.proto=$(BUILD_DIR)/%.pb.c.o) H = include/libumumble.h .PHONY: all static shared clean install-static install-shared install @@ -12,7 +15,7 @@ static: $(SNAME) shared: $(DNAME) -$(OBJ): config.h config.mk +$(OBJ): config.mk $(PROTO) $(SNAME): $(OBJ) ar -rcs $@ $^ @@ -21,15 +24,12 @@ $(DNAME): LDFLAGS += -shared $(DNAME): $(OBJ) $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ -config.h: - cp config.def.h $@ - $(BUILD_DIR)/%.c.o: %.c mkdir -p '$(@D)' - $(CC) -c -o $@ $(INCLUDES) $(CFLAGS) $*.c + $(CC) -c -o $@ $(INCLUDES) $(CFLAGS) $< clean: - rm -rf $(SNAME) $(DNAME) $(BUILD_DIR) + rm -rf $(SNAME) $(DNAME) $(BUILD_DIR) src/*.pb.h src/*.pb.c install-header: install -m 644 $(H) diff --git a/config.mk b/config.mk index f5df9ef..2ccc175 100644 --- a/config.mk +++ b/config.mk @@ -7,7 +7,8 @@ DNAME = $(NAME).so CC = gcc CFLAGS = -W -Wall -Wvla -std=gnu99 -g CFLAGS += $(shell pkg-config --cflags libuv) - LDLIBS = $(shell pkg-config --libs libuv) +NANOPB_DIR = deps/nanopb + +INCLUDES = -I$(NANOPB_DIR) -I. -Iinclude -Isrc -INCLUDES = -Iinclude -Isrc -- cgit 1.4.1-2-gfad0