#!/bin/sh

#Author: 		Cui Ticun
#Version:		9.00.00 
#Date:  		2007-7-1
#Description:	Makefile for subsComm module.

CC = gcc
CFLAGS=-D_REENTRANT -g -Wall

dbINCLUDEFLAG		= -I/usr/local/mysql/include
dbLINKFLAG			= -L/usr/local/mysql/lib -lmariadbclient -lz 

dbINCLUDEFLAG.ES	= -I/usr/include/mariadb
dbLINKFLAG.ES		= -L/usr/lib/mysql -lmariadbclient -lz 

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/x86_64-linux-gnu -lpthread \

LINK_SUFFIX	 	= $(dbINCLUDEFLAG)		$(dbLINKFLAG) 	$(LINKFLAG) 	
LINK_SUFFIX.ES	= $(dbINCLUDEFLAG.ES)	$(dbLINKFLAG.ES)$(LINKFLAG) 

PROGS = subsComm

SUBSCOMM_OBJ 	=	subsCommMain.o subsComm.o 
SUBSCOMM_OBJ.ES =	subsCommMain.o.ES subsComm.o.ES

LIB_OBJ 	= subsComm.o 
LIB_OBJ.ES 	= subsComm.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: $(SUBSCOMM_OBJ)
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(SUBSCOMM_OBJ) $(LINK_SUFFIX) -lm
	ar r libsubsComm.a $(LIB_OBJ)
	rm -f *.o core *~
	#cp -f $(PROGS) ../../../../bin
	#cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(SUBSCOMM_OBJ.ES)
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(SUBSCOMM_OBJ) $(LINK_SUFFIX.ES) -lm
	ar r libsubsComm.a $(LIB_OBJ)

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

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

installall: installbin installomc

subsCommMain.o: subsCommMain.c 
	$(CC) $(CFLAGS) -c subsCommMain.c $(dbINCLUDEFLAG)

subsComm.o: subsComm.c
	$(CC) $(CFLAGS) -c subsComm.c $(dbINCLUDEFLAG)

subsCommMain.o.ES: subsCommMain.c 
	$(CC) $(CFLAGS) -c subsCommMain.c $(dbINCLUDEFLAG.ES)

subsComm.o.ES: subsComm.c
	$(CC) $(CFLAGS) -c subsComm.c $(dbINCLUDEFLAG.ES)

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