#/bin/sh

# Makefile for dualSrv Module.

CC = gcc
CFLAGS=-g -Wall -I/usr/local/mysql/include
CFLAGS.ES=-g -Wall -D_LINUX_ES -I/usr/include/mariadb

COMPILE.c=$(CC) $(CFLAGS) 
COMPILE.c.ES=$(CC) $(CFLAGS.ES)

LINK.c=$(CC) $(CFLAGS)
LINK.c.ES=$(CC) $(CFLAGS.ES) 

LINKFLAG=\
-L../../../faultMgr/c_program/beatProc -lbeatProc \
-L../../../faultMgr/c_program/beatSend -lbeatSend \
-L../../../faultMgr/c_program/sysStat -lsysStat \
-L../../../omcLib/c_program/omcLib -lomcLib \
-L/usr/local/mysql/lib -lmariadbclient -lz \
-L../../../../plat/debug/lib -ldebug \
-L../../../../plat/snmp/lib -lsnmp \
-L../../../../plat/iptrans/lib -liptrans \
-L../../../../plat/public/lib -lpublic \

LINKFLAG.ES=\
-L../../../faultMgr/c_program/beatProc -lbeatProc \
-L../../../faultMgr/c_program/beatSend -lbeatSend \
-L../../../faultMgr/c_program/sysStat -lsysStat \
-L../../../omcLib/c_program/omcLib -lomcLib \
-L/usr/lib/mysql -lmariadbclient -lz \
-L../../../../plat/debug/lib -ldebug \
-L../../../../plat/snmp/lib -lsnmp \
-L../../../../plat/iptrans/lib -liptrans \
-L../../../../plat/public/lib -lpublic \

PROGS=dualsrv

OMC_OBJ  =	dualsrv.o dualsrv_debug.o dualsrv_func.o dualsrv_main.o
OMC_OBJ.ES  =	dualsrv.o.ES dualsrv_debug.o.ES dualsrv_func.o.ES dualsrv_main.o.ES

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"

link: 
	@echo Linking $@
	@$(LINK.c) -o $(PROGS) $(OMC_OBJ) $(LINKFLAG)

linux72: $(OMC_OBJ) omcmain.o
	@echo Linking $(PROGS)
	#@cd ../../../omc83_faultMgr/c_program/beatProc; make clean; make linuxES; cd -
	#@cd ../../../omc83_faultMgr/c_program/beatSend; make clean; make linuxES; cd -
	#@cd ../../../omc83_faultMgr/c_program/sysStat; make clean; make; cd -
	#@cd ../../../omc83_omcLib/c_program/omcLib; make clean; make linuxES; cd -
	#@cd ../../../omc83_omcLib/c_program/snmpRT; make clean; make; cd -
	ar -r libdualsrv.a $(OMC_OBJ)
	#@$(LINK.c) -o $(PROGS) dualsrv_main.o $(OMC_OBJ) $(LINKFLAG)
	rm -rf *.o *~ *bak
	#cp -f $(PROGS) ../../../../bin/
	#cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(OMC_OBJ.ES) dualsrv_main.o.ES
	@echo Linking $(PROGS)
	#@cd ../../../omc83_faultMgr/c_program/beatProc; make clean; make linuxES; cd -
	#@cd ../../../omc83_faultMgr/c_program/beatSend; make clean; make linuxES; cd -
	#@cd ../../../omc83_faultMgr/c_program/sysStat; make clean; make; cd -
	#@cd ../../../omc83_omcLib/c_program/omcLib; make clean; make linuxES; cd -
	#@cd ../../../omc83_omcLib/c_program/snmpRT; make clean; make; cd -
	ar -r libdualsrv.a $(OMC_OBJ)
	#@$(LINK.c.ES) -o $(PROGS) dualsrv_main.o $(OMC_OBJ) $(LINKFLAG.ES)
	rm -rf *.o *~ *bak
	#cp -f $(PROGS) ../../../../bin/
	#cp -f $(PROGS) /usr/local/omc/bin/

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

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

installall: installbin installomc

dualsrv_main.o: dualsrv_main.c 
	$(COMPILE.c) -c dualsrv_main.c

dualsrv.o: dualsrv.c
	$(COMPILE.c) -c dualsrv.c

dualsrv_debug.o: dualsrv_debug.c
	$(COMPILE.c) -c dualsrv_debug.c

dualsrv_func.o: dualsrv_func.c
	$(COMPILE.c) -c dualsrv_func.c




dualsrv_main.o.ES: dualsrv_main.c
	$(COMPILE.c.ES) -c dualsrv_main.c

dualsrv.o.ES: dualsrv.c
	$(COMPILE.c.ES) -c dualsrv.c

dualsrv_debug.o.ES: dualsrv_debug.c
	$(COMPILE.c.ES) -c dualsrv_debug.c

dualsrv_func.o.ES: dualsrv_func.c
	$(COMPILE.c.ES) -c dualsrv_func.c

dualsrv_pub.o.ES: dualsrv_pub.c
	$(COMPILE.c.ES) -c dualsrv_pub.c

clean:
	rm -f $(PROGS) *.o *.a
