#/bin/bash

CC=gcc
CFLAGS=-g -Wall -I/usr/include/mariadb
PROGS=raidAgent


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

LINKFLAG=-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 -lz \

TOTAL_OBJ=raid_agent_main.o raid_agent.o raid_agent_task.o
AR_OBJ=raid_agent.o raid_agent_task.o

default: linuxES

all:
	@echo "make clean    -- Delete the target files"
	@echo "make linuxES  -- Generate target files for Redhat Linux ES"
	
linuxES: $(TOTAL_OBJ)
	@$(LINK.c) -o $(PROGS) $(TOTAL_OBJ) $(LINKFLAG) -lm
	ar r libraidAgent.a $(AR_OBJ)
	rm -rf *.o
	rm -rf *bak
	rm -rf *~	
	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

raid_agent_main.o: raid_agent_main.c
	$(LINK.c) -c raid_agent_main.c

raid_agent.o: raid_agent.c
	$(LINK.c) -c raid_agent.c

raid_agent_task.o: raid_agent_task.c
	$(LINK.c) -c raid_agent_task.c

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