.SUFFIXES: .c .o

COMPILE = $(CC) $(CFLAGS)
INC_PATH = -I. -Itrunk_mgr -I../common -I../tracker -I../client -Ifdht_client -I/usr/include/fastcommon
LIB_PATH = $(LIBS)  -lfastcommon -lserverframe
TARGET_PATH = $(TARGET_PREFIX)/bin
CONFIG_PATH = $(TARGET_CONF_PATH)

SHARED_OBJS = ../common/fdfs_global.o ../tracker/fdfs_shared_func.o \
              ../tracker/fdfs_server_id_func.o ../tracker/tracker_proto.o \
              tracker_client_thread.o storage_global.o storage_func.o \
              storage_sync_func.o storage_service.o storage_sync.o \
              storage_dio.o storage_ip_changed_dealer.o \
              storage_param_getter.o storage_disk_recovery.o \
              file_id_hashtable.o  \
              trunk_mgr/trunk_mem.o trunk_mgr/trunk_shared.o \
              trunk_mgr/trunk_sync.o trunk_mgr/trunk_client.o \
              trunk_mgr/trunk_free_block_checker.o \
              ../client/client_global.o ../client/tracker_client.o \
              ../client/storage_client.o ../client/client_func.o \
              fdht_client/fdht_proto.o fdht_client/fdht_client.o \
              fdht_client/fdht_func.o fdht_client/fdht_global.o \
              $(STORAGE_EXTRA_OBJS)

ALL_OBJS = $(SHARED_OBJS)

ALL_PRGS = fdfs_storaged 

all: $(ALL_OBJS) $(ALL_PRGS)

$(ALL_PRGS): $(ALL_OBJS)

.o:
	$(COMPILE) -o $@ $<  $(SHARED_OBJS) $(LIB_PATH) $(INC_PATH)
.c:
	$(COMPILE) -o $@ $<  $(ALL_OBJS) $(LIB_PATH) $(INC_PATH)
.c.o:
	$(COMPILE) -c -o $@ $<  $(INC_PATH)
install:
	mkdir -p $(TARGET_PATH)
	mkdir -p $(CONFIG_PATH)
	cp -f $(ALL_PRGS) $(TARGET_PATH)
	if [ ! -f $(CONFIG_PATH)/storage.conf ]; then cp -f ../conf/storage.conf $(CONFIG_PATH)/storage.conf; fi
clean:
	rm -f $(ALL_OBJS) $(ALL_PRGS)
