#!/bin/sh

# Makefile for test snmpComm module.

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 -lm

omcLib		= -L../../../omcLib/c_program/omcLib    -lomcLib

LIB_FLAGS	= $(omcLib) $(dbLib)
#LIB_FLAGS.ES	= $(omcLib) $(dbLib.ES)

LIB_FLAGS.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
-L../../../../plat/snmp/lib -lsnmp \
-L../../../../plat/sccp/lib -lsccp \
-L../../../../plat/iptrans/lib -liptrans \
-L../../../../plat/debug/lib -ldebug \
-L../../../../plat/public/lib -lpublic \
-L/usr/lib/mysql -lmariadbclient -lm


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

PROGS = subsDataBackup

SNMPCOMM_OBJ	=	subsDataBackupMain.o subsDataBackup.o
SNMPCOMM_OBJ.ES =	subsDataBackupMain.o.ES subsDataBackup.o.ES

LIB_OBJ		= subsDataBackup.o
LIB_OBJ.ES	= subsDataBackup.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: $(SNMPCOMM_OBJ)
	@cd ../../../omcLib/c_program/omcLib; make clean; make linux72; cd -
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(SNMPCOMM_OBJ) $(LINK_SUFFIX)
	ar r libsubsDataBackup.a $(LIB_OBJ)
	rm -f *.o core *~
	cp -f $(PROGS) ../../../bin/
	cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(SNMPCOMM_OBJ.ES)
	@cd ../../../omcLib/c_program/omcLib; make clean; make linuxES; cd -
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(SNMPCOMM_OBJ) $(LINK_SUFFIX.ES)
	ar r libsubsDataBackup.a $(LIB_OBJ)

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

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

installall: installbin installomc

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

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

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

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

clean:
	rm -f *.o *.a $(PROGS)
	@cd ../../../accountMgr/c_program/subsDataBackup;	rm -f *.o *.a; cd ..
