54 lines
1.2 KiB
Makefile
54 lines
1.2 KiB
Makefile
include deps/nanopb/extra/nanopb.mk
|
|
include config.mk
|
|
|
|
SRC += $(shell find src/ -type f -name '*.c')
|
|
SRC += $(NANOPB_DIR)/pb_encode.c
|
|
SRC += $(NANOPB_DIR)/pb_decode.c
|
|
SRC += $(NANOPB_DIR)/pb_common.c
|
|
PROTO = $(shell find src/ -type f -name '*.proto')
|
|
OBJ = $(PROTO:%.proto=$(BUILD_DIR)/%.pb.c.o)
|
|
OBJ += $(SRC:%=$(BUILD_DIR)/%.o)
|
|
INCLUDE = $(shell find include/)
|
|
|
|
.PHONY: all static shared tests clean install-static install-shared install
|
|
|
|
all: static shared
|
|
|
|
static: $(SNAME)
|
|
|
|
shared: $(DNAME)
|
|
|
|
$(OBJ): config.mk $(PROTO)
|
|
|
|
$(SNAME): $(OBJ)
|
|
ar rcs $@ $?
|
|
|
|
$(DNAME): LDFLAGS += -shared
|
|
$(DNAME): $(OBJ)
|
|
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
|
|
|
$(BUILD_DIR)/%.c.o: %.c
|
|
mkdir -p '$(@D)'
|
|
$(CC) -c -o $@ $(INCLUDES) $(CFLAGS) $<
|
|
|
|
tests: $(SNAME)
|
|
$(MAKE) -C tests
|
|
|
|
clean:
|
|
rm -rf $(SNAME) $(DNAME) $(BUILD_DIR) src/*.pb.h src/*.pb.c
|
|
$(MAKE) -C tests clean
|
|
|
|
install-header: $(INCLUDE)
|
|
install -d $(DESTDIR)$(INCLUDEDIR)
|
|
cp -Rv include/. $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
install-static: $(SNAME)
|
|
install -d $(DESTDIR)$(LIBDIR)
|
|
install -m 755 $^ $(DESTDIR)$(LIBDIR)
|
|
|
|
install-shared: $(DNAME)
|
|
install -d $(DESTDIR)$(LIBDIR)
|
|
install -m 755 $^ $(DESTDIR)$(LIBDIR)
|
|
|
|
install: install-header install-static install-shared
|