#!/bin/sh

CC = gcc
CFLAGS=-D_REENTRANT -g -Wall -D_TEST_

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

LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
-L/usr/local/mysql/lib -lmariadbclient -lz \
-L../../../../plat/snmp/lib -lsnmp \
-L../../../../plat/iptrans/lib -liptrans \
-L../../../../plat/debug/lib -ldebug \
-L../../../../plat/public/lib -lpublic \

LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
-L/usr/lib/mysql -lmariadbclient -lz \
-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 \

LINK_SUFFIX = $(dbINCLUDE_FLAGS) $(LINKFLAG)
LINK_SUFFIX.ES = $(dbINCLUDE_FLAGS.ES) $(LINKFLAG.ES)

PROGS=alarmAgent

ALL_OBJ  =	alarmSnmp.o alarmAgent.o
ALL_OBJ.ES  =	alarmSnmp.o.ES alarmAgent.o.ES

LIB_OBJ  =	alarmSnmp.o 
LIB_OBJ.ES  =	alarmSnmp.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)
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX) -lm
	ar r libalarmAgent.a $(LIB_OBJ)
	rm -rf *.o *~
	cp -f $(PROGS) ../../../../bin/
	cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(ALL_OBJ.ES)
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX.ES) -lm 
	ar r libalarmAgent.a $(LIB_OBJ)
	# rm -rf *.o *~

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

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

installall: installbin installomc

alarmSnmp.o: alarmSnmp.c alarmAgent.h 
	$(CC) $(CFLAGS) -c alarmSnmp.c $(dbINCLUDE_FLAGS)

alarmAgent.o: alarmAgent.c alarmAgent.h 
	$(CC) $(CFLAGS) -c alarmAgent.c $(dbINCLUDE_FLAGS)

alarmSnmp.o.ES: alarmSnmp.c alarmAgent.h 
	$(CC) $(CFLAGS) -c alarmSnmp.c $(dbINCLUDE_FLAGS.ES)

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

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

