#/bin/sh

CC = gcc
CFLAGS=-g -Wall -I/usr/local/mysql/include
CFLAGS.ES=-g -Wall -I/usr/include/mariadb

COMPILE.c=$(CC) $(CFLAGS)
COMPILE.c.ES=$(CC) $(CFLAGS.ES)

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

LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
-L../../../omcLib/c_program/ftp -lftp \
-L/usr/local/mysql/lib -lmariadbclient -lz


LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
-L../../../omcLib/c_program/ftp -lftp \
-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 \

PROGS=ftpSend
FTPSEND_OBJ  =  ftpsend.o
FTPSEND_OBJ.ES  =  ftpsend.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: $(FTPSEND_OBJ)
	@cd ../../../omcLib/c_program/ftp; make linux72;      cd ..
	@cd ../../../accountMgr/c_program/ftpsend;
	@echo Linking $(PROGS)
	@$(LINK.c) -o $(PROGS) $(FTPSEND_OBJ) $(LINKFLAG) -lm
	ar r libftpsend.a $(FTPSEND_OBJ)
	# rm -rf *.o
	# rm -rf *bak
	# rm -rf *~
	# cp -f $(PROGS) ../../../bin
	# cp -f $(PROGS) /usr/local/omc/bin/

linuxES: $(FTPSEND_OBJ.ES)
	@cd ../../../omcLib/c_program/ftp; make linuxES;      cd ..
	@cd ../../../accountMgr/c_program/ftpsend;
	@echo Linking $(PROGS)
	@$(LINK.c.ES) -o $(PROGS) $(FTPSEND_OBJ) $(LINKFLAG.ES) -lm
	ar r libftpsend.a $(FTPSEND_OBJ)

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

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

installall: installbin installomc

ftpsend.o:ftpsend.c
	$(COMPILE.c) -c ftpsend.c

ftpsend.o.ES:ftpsend.c
	$(COMPILE.c.ES) -c ftpsend.c

clean:
	rm -f *.o *.a $(PROGS)
	@cd ../../../omcLib/c_program/ftp;            rm -f *.o *.a; cd ..
	@cd ../../../accountMgr/c_program/ftpsend;        rm -f *.o *.a; cd ..


