# copyrighted works and confidential proprietary information of
# UNISOC Technology (Shanghai), Inc. They may not be modified, copied, reproduced,
# distributed, or disclosed to third parties in any manner, medium, or form,
# in whole or in part, without the prior written consent of UNISOC Technology (Shanghai), Inc.

CFLAGS = -Wall -g -O -fPIC



TARGET = sensorservice

LIBS = -lpthread -lrt -ldbus-1
ifeq ($(USE_SPRD_SENSOR_HUB),TRUE)
LIBS += -lsensorhubhal
else ifeq ($(USE_SPRD_SENSOR_LIB),TRUE)
LIBS += -lsensorclassic
else
LIBS += -lsensorstub
endif

DIR_ROOT = ${SYS_ROOT}/recipe-sysroot

INCLUDES = -I. \
        $(shell pkg-config --cflags dbus-1)\
        -I./utils \
        -I./../../modules/npi_lib/libsensors/sensorhub/ \
        -I./../../modules/npi_lib/libsensors/sensorhub/include/sensors/ \
        -I./../../modules/npi_lib/libsensors/sensorhub/include/inc/ \
        -I./../../modules/npi_lib/libsensors/sensorclassic/ \
        -I./../../modules/npi_lib/libsensors/sensorclassic/include/ \
        -I$(DIR_ROOT)/usr/include \
        -I$(DIR_ROOT)/usr/include/dbus-1.0 \
        -I$(DIR_ROOT)/usr/lib/dbus-1.0/include \

SRCS := $(wildcard *.c)
SRCS += $(wildcard utils/*.c)


FILES := $(notdir $(SRCS))

OBJS = $(patsubst %c,%o,$(FILES))

$(TARGET): $(OBJS)
	$(CC) -o $(TARGET) $(OBJS) $(LIBS)

$(OBJS):$(SRCS)
	$(CC) $(CFLAGS) $(INCLUDES) -c $^

install:
	cp $(TARGET) /usr/bin
	cp $(TARGET_INC) /usr/include

uninstall:
	rm -f /usr/bin/$(notdir $(TARGET))
	rm -f $(TARGET_INC) /usr/include

clean:
	rm -f *.o
	rm -f $(TARGET)
