#!/bin/sh

#Author: 		Cui Ticun
#Version:		9.00.00 
#Date:  		2007-7-1
#Description:	Makefile for paraComm 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 \

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

PROGS = paraComm

PARACOMM_OBJ 	=	paraCommMain.o paraComm.o initParaConf.o
PARACOMM_OBJ.ES =	paraCommMain.o.ES paraComm.o.ES initParaConf.o.ES

LIB_OBJ 	= paraComm.o initParaConf.o
LIB_OBJ.ES 	= paraComm.o.ES initParaConf.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: $(PARACOMM_OBJ)
	@echo Linking $(PROGS)
	@$(CC) $(CFLAGS) -o $(PROGS) $(PARACOMM_OBJ) $(LINK_SUFFIX) -lm
	ar r libparaComm.a $(LIB_OBJ)

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

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

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

installall: installbin installomc

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

paraComm.o: paraComm.c
	$(CC) $(CFLAGS) -c paraComm.c $(dbINCLUDEFLAG)
	
initParaConf.o: initParaConf.c
	$(CC) $(CFLAGS) -c initParaConf.c $(dbINCLUDEFLAG)

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

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

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

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