Add nanopb to Makefile

This commit is contained in:
latex 2023-01-23 01:14:35 +01:00
parent 2499428fb3
commit fb52c72e80
2 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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