#**************************************************************************
#
#	Copyright (c) 2001  ICP Electronics Inc.  All Rights Reserved.
#
#	FILE:
#		Makefile
#
#	Abstract: 
#		Makefile for storage library
#
#	Commnet : N/A
#
#	HISTORY:
#		2001/8/21	release beta version
#		2001/5/18	Louis Tsai created
#**************************************************************************
TARGET = libuLinux_Storage
CC = $(CROSS_COMPILE)gcc
STRIP = $(CROSS_COMPILE)strip
CFLAG = -fPIC -Wall -c 
INCLUDE = -I../include -I../uLinux -I../common
PHASE_ONE_DST_DIR = $(shell pwd)/../.build/usr/lib
#LIB = -L${PHASE_ONE_DST_DIR} -luLinux_config -luLinux_NAS -luLinux_Util -luLinux_quota -luLinux_PDC
LIB = -L${TARGET_PREFIX}/usr/lib -luLinux_config -luLinux_Util -luLinux_NAS -luLinux_Storage -luLinux_PDC -luLinux_quota

# To enable debug message dump, un-comment the following flag
#DEBUG_FLAG = -g -DDEBUG

OBJS = disk.o interface.o raid.o nasdisk.o volume.o lvm.o lvm_config.o sata.o sg_err.o sg_cap.o mount.o
MORE_OBJS = disk.o interface.o raid.o nasdisk.o volume.o lvm.o lvm_config.o sata.o sg_err.o sg_cap.o mount.o ../config/cfg_system.o ../config/eventlog.o ../config/cfg_samba.o ../config/cfg_netware.o ../quota/quota.o ../config/msg.o ../config/cfg_rtrr.o ../config/cfg_printer.o ../config/cfg_nfs.o ../config/cfg_misc.o ../config/cfg_appletalk.o ../config/cfg_display.o ../config/cfg_ftp.o ../config/cfg_nic.o ../config/cfg_webfs.o ../config/cfg_fw.o ../config/cfg_snmp.o ../config/cfg_network.o ../config/sem.o ../config/cfg_alert.o ../config/ifcfg.o ../config/gw.o

all: 	$(OBJS)
	$(CC) $(DEBUG_FLAG) -shared -Wl,-soname,${TARGET}.so.0 -o ${TARGET}.so.0.0 ${OBJS} -lc ${LIB}

phase_one:	$(MORE_OBJS)
	$(CC) $(LFS) $(DEBUG_FLAG) -shared -Wl,-soname,$(TARGET).so.0 -o $(TARGET).so.0.0 $(OBJS) -lc -lcrypt
	[ -d $(PHASE_ONE_DST_DIR) ] || mkdir -p $(PHASE_ONE_DST_DIR)
	mv $(TARGET).so.0.0 $(PHASE_ONE_DST_DIR)
	ln -sf $(TARGET).so.0.0  $(PHASE_ONE_DST_DIR)/$(TARGET).so.0
	ln -sf $(TARGET).so.0  $(PHASE_ONE_DST_DIR)/$(TARGET).so

%.o : %.c 
	$(CC) $(CFLAG) $(INCLUDE) $(DEBUG_FLAG) $< -o $@ 

t:	t.o
	$(CC) $(INCLUDE) $(LIB) $(DEBUG_FLAG) t.o -o t
tt:	tt.o
	$(CC) $(INCLUDE) $(LIB) $(DEBUG_FLAG) tt.o -o tt
disktest:	disktest.c 
	rm -f disktest
	$(CC) $(INCLUDE) $(DEBUG_FLAG) disktest.c -o disktest -luLinux_Storage -lc
intest:	
	rm -f intest
	$(CC) $(INCLUDE) $(DEBUG_FLAG) intest.c -o intest -luLinux_Storage -lc

testvol:
	
	rm -f testvol
	$(CC) $(INCLUDE) $(DEBUG_FLAG) testvol.c -o testvol -luLinux_Storage -lc
	
install:
	$(STRIP) $(TARGET).so.0.0
	install -m 644 $(TARGET).so.0.0  $(TARGET_PREFIX)/usr/lib
	ln -sf $(TARGET).so.0.0  $(TARGET_PREFIX)/usr/lib/$(TARGET).so.0
	ln -sf $(TARGET).so.0  $(TARGET_PREFIX)/usr/lib/$(TARGET).so 
	
clean:
	rm -f intest
	rm -f disktest
	rm -f *.o 
	rm -f $(TARGET).so.0.0
	rm -f *~
