#!/bin/sh

#Author: 		Cui Ticun
#Version:		9.00.00 
#Date:  		2007-8-1
#Description:	Makefile for omcMain.

CC = gcc
CFLAGS=-D_REENTRANT -g -Wall

dbINCLUDE_FLAGS = -I/usr/local/mysql/include
dbINCLUDE_FLAGS.ES = -I/usr/include/mariadb

dbLib		= -L/usr/local/mysql/lib -lmariadbclient -lz
dbLib.ES	= -L/usr/lib/mysql -lmariadbclient -lpthread -lz

#plat
publicLib		= -L../../../../plat/public/lib	-lpublic
iptransLib		= -L../../../../plat/iptrans/lib -liptrans
snmpLib			= -L../../../../plat/snmp/lib	-lsnmp
mtp3Lib			= -L../../../../plat/mtp3/lib	-lmtp3
m2uaLib			= -L../../../../plat/m2ua/lib   -lm2ua
sccpLib			= -L../../../../plat/sccp/lib	-lsccp 
debugLib		= -L../../../../plat/debug/lib	-ldebug
smppLib			= -L../../../../plat/smpp/lib	-lsmpp

#myOMC
omcLib			= -L../../../omcLib/c_program/omcLib	-lomcLib
beatProcLib		= -L../../../faultMgr/c_program/beatProc	-lbeatProc
sysStatLib		= -L../../../faultMgr/c_program/sysStat	-lsysStat
beatSendLib		= -L../../../faultMgr/c_program/beatSend -lbeatSend
dualsrvLib		= -L../../../faultMgr/c_program/dualsrv -ldualsrv
raidAgentLib		= -L../../../faultMgr/c_program/raidAgent -lraidAgent
cstalib			= -L../../../performanceMgr/c_program/cstaCollector -lcsta
smeglib			= -L../../../smeg/lib -lsmeg #-liconv
wsmslib			= -L../../../accountMgr/c_program/wsms -lwsms
LIB_FLAGS	= $(beatProcLib) $(beatSendLib)	$(sysStatLib) $(dualsrvLib) $(smeglib)\
			  $(cstalib) $(smppLib) $(snmpLib) $(sccpLib) $(mtp3Lib) $(m2uaLib) \
			  $(iptransLib)  $(debugLib) $(publicLib) $(omcLib) $(wsmslib) $(raidAgentLib)

LINK_SUFFIX		= $(LIB_FLAGS) $(dbLib)
LINK_SUFFIX.ES	= $(LIB_FLAGS) $(dbLib.ES)

PROGS = omcMain

ALL_OBJ = omcMain.o
ALL_OBJ.ES = omcMain.o.ES

default: linuxES

all:
	@echo " **** Compiling $(PROGS) ****"
	@echo "make clean    -- Delete the target files"
	@echo "make linux72  -- Generate target files for Redhat Linux 72"
	@echo "make linuxES  -- Generate target files for Redhat Linux ES"

linux72: $(ALL_OBJ)
	@cd ../../../omcLib/c_program/omcLib;		make linux72;cd ..
	@cd ../../../faultMgr/c_program/beatProc;	make linux72;cd ..
	@cd ../../../faultMgr/c_program/sysStat;	make;		 cd ..
	@cd ../../../faultMgr/c_program/beatSend;	make linux72;cd ..
	@cd ../../../faultMgr/c_program/dualsrv;	make linux72;cd ..
	@cd ../../../performanceMgr/c_program/cstaCollector; make linux72;cd ..   
	@cd ../../../omcMain/c_program/omcMain
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX) -lm
	rm -rf *.o *~ core
	cp -f $(PROGS) ../../../bin/
	cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(ALL_OBJ.ES)
	@cd ../../../omcLib/c_program/omcLib;		make linuxES;cd ..
	@cd ../../../faultMgr/c_program/beatProc;	make linuxES;cd ..
	@cd ../../../faultMgr/c_program/sysStat;	make;		 cd ..
	@cd ../../../faultMgr/c_program/beatSend;	make linuxES;cd ..
	@cd ../../../faultMgr/c_program/dualsrv;	make linuxES;cd ..
	@cd ../../../performanceMgr/c_program/cstaCollector; make linuxES;cd ..
	@cd ../../../omcMain/c_program/omcMain
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX.ES) -lm

installbin: linuxES
	cp -f $(PROGS) ../../../../bin/

installomc: linuxES
	cp -f $(PROGS) /usr/local/omc/bin/

installall: installbin installomc

omcMain.o: omcMain.c 
	$(CC) $(CFLAGS) -c omcMain.c $(dbINCLUDE_FLAGS)

omcMain.o.ES: omcMain.c 
	$(CC) $(CFLAGS) -c omcMain.c $(dbINCLUDE_FLAGS.ES)

clean:
	rm -f *.o *.a $(PROGS)
	@cd ../../../omcLib/c_program/omcLib;		rm -f *.o *.a; cd ..
	@cd ../../../faultMgr/c_program/beatProc;	rm -f *.o *.a; cd ..
	@cd ../../../faultMgr/c_program/sysStat;	rm -f *.o *.a; cd ..
	@cd ../../../faultMgr/c_program/beatSend;	rm -f *.o *.a; cd ..
	@cd ../../../faultMgr/c_program/dualsrv;	rm -f *.o *.a; cd ..
	@cd ../../../performanceMgr/c_program/cstaCollector; rm -f *.o *.a; cd ..
	@cd ../../../omcMain/c_program/omcMain;		rm -f *.o *.a; cd ..

