60 lines
1.2 KiB
Makefile
60 lines
1.2 KiB
Makefile
CC ?= $(CROSS_COMPILE)gcc
|
|
RM := rm
|
|
|
|
PREFIX ?= /usr
|
|
|
|
CFLAGS := -O2 -Wall -c -fPIC
|
|
|
|
OUT_DIR := bin
|
|
OBJ_DIR := obj
|
|
API_DIR := Api
|
|
|
|
TARGET_LIB := $(PWD)/$(OUT_DIR)/libvl53l0x.so
|
|
|
|
INCLUDES = \
|
|
-I$(PWD)/$(API_DIR)/core/inc \
|
|
-I$(PWD)/platform/inc
|
|
|
|
VPATH = \
|
|
$(PWD)/$(API_DIR)/core/src \
|
|
$(PWD)/platform/src/
|
|
|
|
LIB_SRCS = \
|
|
vl53l0x_api_calibration.c \
|
|
vl53l0x_api_core.c \
|
|
vl53l0x_api_ranging.c \
|
|
vl53l0x_api_strings.c \
|
|
vl53l0x_api.c \
|
|
vl53l0x_platform.c
|
|
|
|
LIB_OBJS = $(LIB_SRCS:%.c=$(OBJ_DIR)/%.o)
|
|
|
|
.PHONY: all
|
|
all: ${TARGET_LIB}
|
|
|
|
$(TARGET_LIB): $(LIB_OBJS)
|
|
mkdir -p $(dir $@)
|
|
$(CC) -shared $^ $(INCLUDES) -lpthread -o $@
|
|
|
|
$(OBJ_DIR)/%.o:%.c
|
|
mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) $(PYTHON_INCLUDES) $(INCLUDES) $< -o $@
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
-${RM} -rf $(TARGET_LIB) $(LIB_OBJS)
|
|
|
|
.PHONY: install
|
|
install:
|
|
install --directory $(PREFIX)/lib
|
|
install $(TARGET_LIB) $(PREFIX)/lib
|
|
install $(PWD)/$(API_DIR)/core/inc/vl53l0x_api.h $(PREFIX)/include/
|
|
install $(PWD)/platform/inc/vl53l0x_platform.h $(PREFIX)/include/
|
|
ldconfig -n $(PREFIX)/lib
|
|
|
|
.PHONY: uninstall
|
|
uninstall:
|
|
$(RM) $(PREFIX)/lib/$(TARGET_LIB) \
|
|
$(PREFIX)/include/vl53l0x_api.h \
|
|
$(PREFIX)/include/vl53l0x_platform.h
|