about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorlatex <latex@disroot.org>2023-01-23 01:14:35 +0100
committerlatex <latex@disroot.org>2023-01-23 01:14:35 +0100
commitfb52c72e80651f76d792b70c552827f3d4f79ca8 (patch)
tree05c2e994aba729036e7484ba20c67725b7b7b32e
parent2499428fb38beb283e45cc620a588135ff536a15 (diff)
downloadlibumumble-fb52c72e80651f76d792b70c552827f3d4f79ca8.tar.gz
Add nanopb to Makefile
-rw-r--r--Makefile12
-rw-r--r--config.mk5
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