#------- Comment/uncomment the following line to enable/disable debugging------
DEBUG 		= n
#------------------------------------------------------------------------------


#---------------------- Generic Library variables -----------------------------
# Versions for the library
LIB_VER_MAJOR	= 1
LIB_VER_MINOR	= 0

LIBRARY_NAME	= libami
#------------------------------------------------------------------------------
#---------------------- Compute TOPDIR and include Rules file -----------------
ifndef TOPDIR
TOPDIR  := $(shell cd ../../../../..; pwd)
endif
include $(TOPDIR)/development/rules/Rules.make.libs
-include $(TOPDIR)/development/oem/firmware/IPMI/Configs.make.IPMI
#------------------------------------------------------------------------------


SRC =  exterrno/exterrno.c
SRC += unix/pids.c unix/ipc.c unix/signals.c unix/proc-invok.c unix/security.c unix/semaph.c
SRC += crypt/blowfish.c crypt/md5.c crypt/hashers.c
SRC += vmedia_cfg/vmedia_token.c vmedia_cfg/vmedia_cfg.c
SRC += adviser_cfg/adviser_cfg.c adviser_cfg/adviser_token.c adviser_cfg/capture_screen.c
SRC += crypto/hmac_md5.c crypto/hmac_sha1.c crypto/AES.c crypto/MD5_128.c \
       crypto/HMAC_SHA2/sha2.c crypto/HMAC_SHA2/hmac_sha2.c
SRC += iniparser/iniparser.c iniparser/dictionary.c iniparser/strlib.c
SRC += timezone/timezone.c
SRC += dbgout/dbgout.c
SRC += validate/validate.c
SRC += serverinfo/serverinfo.c
SRC += fwinfo/fwinfo.c
#SRC += segvhandler/sigsegv.c
SRC += hostname/hostname.c
SRC += netports/netports.c netports/tcp.c netports/udp.c netports/protoendpoint.c
SRC	+= ubenv/ubenv.c
SRC += ldapconf/conf_file_api.c ldapconf/ldapconf.c
SRC += ntp/ntp.c
SRC += nwcfg/nwcfg.c nwcfg/userconn.c
SRC += sol/sol.c
SRC += racsessioninfo/racsessioninfo.c
SRC += sshconfig/sshconfig.c

#-------------- CFLAGS from various subdirs -----------------------------------
BOPTS =  -DUNIXTOOLS

# Define HAVE_DEV_URANDOM if /dev/urandom is a cryptographic source of
# pseudo-random numbers
BOPTS += -DHAVE_DEV_URANDOM

# Define these to specify what type of unix behaviour we want, and what
# standards we will be complying with
BOPTS += -D_XOPEN_SOURCE=600 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1 -D_GNU_SOURCE
BOPTS += -fno-strict-aliasing

BOPTS += -I$(TARGETDIR)/usr/include
BOPTS += -I$(TOPDIR)/development/common/include/crypt
BOPTS += -I$(TOPDIR)/development/common/include/crypto
BOPTS += -I$(TOPDIR)/development/common/include/fwinfo
BOPTS += -I$(TOPDIR)/development/common/include/network
BOPTS += -I$(TOPDIR)/development/common/include/timezone
BOPTS += -I$(TOPDIR)/development/common/include/iniparser
BOPTS += -I$(TOPDIR)/development/common/include/adviser
BOPTS += -I$(TOPDIR)/development/common/include/kvm_vm_session
BOPTS += -I$(TOPDIR)/development/common/include/racsessioninfo
BOPTS += -I$(TOPDIR)/development/common/include/usb
BOPTS += -I$(TOPDIR)/development/common/include/gpio
BOPTS += -I$(TOPDIR)/development/common/include/soc
BOPTS += -I$(TOPDIR)/development/common/include/flash
BOPTS += -I$(TOPDIR)/core/linux/drivers/net/pilot2_tulip
BOPTS += -I$(TOPDIR)/development/oem/common/include/ipmi_inc_oem/ $(IPMI_CFLAGS)
BOPTS += -I$(TOPDIR)/development/common/include/ldap
BOPTS += -I$(TOPDIR)/development/common/include/userm
BOPTS += -I$(TOPDIR)/development/common/include/libipmi_inc
BOPTS += -I$(TOPDIR)/development/common/include/sol
BOPTS += -I$(TOPDIR)/development/oem/common/hardware/
BOPTS += -I$(TOPDIR)/development/common/include/sshconfig

# Additional compilation options
CFLAGS		+= $(BOPTS)

#---------------------- Change according to your files ------------------------

##these are unix (linux) standards for naming shared libraries.
#Stick to these conventions for naming
##Linux HOWTO http://www.tldp.org/HOWTO/Program-Library-HOWTO/introduction.html 
#for details
#LIB_LINKERNAME = $(AMIAPPS_COMMON_LIBNAME)
#LIB_SONAME = $(AMIAPPS_COMMON_LIBNAME).$(LIBAMI_VER_MAJOR)    
#LIB_REALNAME = $(AMIAPPS_COMMON_LIBNAME).$(LIBAMI_VER_MAJOR).$(LIBAMI_VER_MINOR)    
#----------------------------------------------------------------------------------

#--------------WARNING : Donot Modify anything below this line ----------------

all: $(LIB_LINKERNAME)

$(LIB_LINKERNAME):$(LIB_REALNAME)
	ln -sf $(LIB_REALNAME) $(LIB_LINKERNAME)


$(LIB_REALNAME): $(OBJ)
	$(AR) $(ARFLAGS) $(LIB_ARCHIVE_NAME) $(OBJ)
	$(CC) -shared   -Wl,-soname,$(LIB_SONAME) -o $(LIB_REALNAME) \
	-Wl,--whole-archive $(LIB_ARCHIVE_NAME) -Wl,--no-whole-archive $(LIBINI) $(LIBCRYPTO)

install: extrainstall

extrainstall:
	$(INSTALL) -D $(ONLY_IF_NEW) $(PRESERVE_SOURCE_TIMESTAMP) vmedia_cfg/vmedia.conf $(target_confdir)/vmedia.conf
	$(INSTALL) -D $(ONLY_IF_NEW) $(PRESERVE_SOURCE_TIMESTAMP) vmedia_cfg/vmedia_KI.conf $(target_confdir)/vmedia_KI.conf
	$(INSTALL) -D $(ONLY_IF_NEW) $(PRESERVE_SOURCE_TIMESTAMP) vmedia_cfg/vmedia.conf $(BINARYDIR)/conf/vmedia.conf
	$(INSTALL) -D $(ONLY_IF_NEW) $(PRESERVE_SOURCE_TIMESTAMP) vmedia_cfg/vmedia_KI.conf $(BINARYDIR)/conf/vmedia_KI.conf

clean:
	rm -f $(LIB_ARCHIVE_NAME)  $(LIB_REALNAME)  $(LIB_LINKERNAME) $(OBJ) $(DFILES)

include $(TOPDIR)/development/rules/Rules.make.libs-install
-include $(DFILES)
