# 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
CFLAGS += -Werror -fstack-protector-strong -D_FORTIFY_SOURCE=2
CFLAGS += -Wformat -Wformat-security -O2
CFLAGS += $(MODEM_CTRL_REMOVE_MODEM_FLAG)
CFLAGS += $(FLAG_DISPLAY_CONFIG)
CFLAGS += $(FLAG_BATTERY_CONFIG)
CFLAGS += $(FLAG_SUSPEND_BLOCKER_CONFIG)
CFLAGS += $(FLAG_PERIODIC_AUTOSUSPEND_CONFIG)
CFLAGS += $(FLAG_PM_UTILS_CONFIG)
CFLAGS += $(FLAG_LED_CONFIG)
CFLAGS += $(FLAG_LED_TWINKLE_CONFIG)
CFLAGS += $(FLAG_POWERSAVE_CONFIG)
CFLAGS += $(FLAG_GPIO_LED_CONFIG)

TARGET = powermanagerservice

LIBS = -lpthread -lrt -ldbus-1 -ldbushelper -liniparser -lled-client
DIR_ROOT = ${SYS_ROOT}/recipe-sysroot

INCLUDES = -I. \
	   -I ./include \
	 $(shell pkg-config --cflags dbus-1)\
	 -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)
SRCS += $(wildcard inputmanager/*.c)
SRCS += $(wildcard powermanager/*.c)
SRCS += $(wildcard displaymanager/*.c)
SRCS += $(wildcard batterymanager/*.c)
SRCS += $(wildcard ledservice/src/*.c)
SRCS += $(wildcard powersave/*.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)
