# start to compile shared library file 
#-----------------------------------------------------
TOPDIR  :=  $(shell /bin/pwd)
TOPDIR  :=  $(TOPDIR)/..

include $(TOPDIR)/prerules.mk
#-----------------------------------------------------
CCFLAGS=-fPIC -Wall -c
ARFLAGS=rc

OBJS=smart_common.o smart_daemon.o smart_command.o 

all: libsmart SMT_smart_act
libsmart:$(OBJS)
	$(CC) -g -shared -L $(COMM_LIB_PATH) -Wl,-soname,libsmart.so.0 -s \
		-o libsmart.so.0.0 smart_common.o smart_daemon.o smart_command.o -llog -lprofile -lutility
	$(STRIP) libsmart.so.0.0
	ln -sf libsmart.so.0.0 libsmart.so.0
	ln -sf libsmart.so.0 libsmart.so
	cp -afv libsmart* $(COMM_LIB_PATH)
	cp -f *.h $(COMM_INC_PATH)
	
smart_common.o:smart_all.h smart_common.c
	$(CC) $(CFLAGS) -fPIC -I $(COMM_INC_PATH) -O2 -DLINUX  -g -c  smart_common.c

smart_daemon.o:smart_all.h smart_daemon.c
	$(CC) $(CFLAGS) -fPIC -I $(COMM_INC_PATH) -O2 -DLINUX  -g -c smart_daemon.c

smart_command.o:smart_all.h smart_command.c
	$(CC) $(CFLAGS) -fPIC -I $(COMM_INC_PATH) -O2 -DLINUX  -g -c  smart_command.c

SMT_smart_act:
	$(CC) $(CFLAGS) -g -c smartd.c -o smartd.o
	$(CC) $(CFLAGS) -s -g -o SMT_smart_act smartd.o -L $(COMM_LIB_PATH) -lsmart -lprofile -llog -lutility 
	
clean:
	@echo Cleaning up
	rm -f *.[do]
	rm -f libsmart*
	rm -f $(COMM_LIB_PATH)/libsmart*
	rm -f $(COMM_INC_PATH)/smart.h
	rm -f SMT_smart_act
		
install:
	mkdir -p $(T_LIB)
	cp -pdR $(COMM_LIB_PATH)/libsmart* $(T_LIB)
	mkdir -p $(T_SBIN)
	cp -pdR SMT_smart_act $(T_SBIN)

#-----------------------------------------------------
include $(TOPDIR)/rules.mk
#-----------------------------------------------------
