#!/bin/sh

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

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=alarmGenerator

OBJ  =	alarmGen.o
OBJ.ES  =	alarmGen.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: $(OBJ) alarmMain.o
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) alarmMain.o $(OBJ) $(LINKFLAG) -lm
	ar r libalarmGen.a $(OBJ)
	rm -rf *.o *bak *~
	#cp -f $(PROGS) ../../../../bin/
	#cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(OBJ.ES) alarmMain.o.ES
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) alarmMain.o $(OBJ) $(LINKFLAG.ES) -lm
	ar r libalarmGen.a $(OBJ)
	rm -rf *.o *bak *~
	#cp -f $(PROGS) ../../../../bin/
	#cp -f $(PROGS) /usr/local/omc/bin/

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

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

installall: installbin installomc

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

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

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

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

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