#/bin/bash

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


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 \

NRTRDE_OBJ=nrtrde.o decodeASN.o encodeASN.o conv_prefix.o seq_num_mng.o

default: linuxES

all:
	@echo "make clean    -- Delete the target files"
	@echo "make linuxES  -- Generate target files for Redhat Linux ES"
	
linuxES: $(NRTRDE_OBJ)
	@$(LINK.c) -o $(PROGS) $(NRTRDE_OBJ) $(LINKFLAG) -lm
	ar r libnrtrde.a nrtrde.o decodeASN.o encodeASN.o conv_prefix.o seq_num_mng.o

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

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

installall: installbin installomc

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

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

encodeASN.o: encodeASN.c
	${LINK.c} -c encodeASN.c
	
conv_prefix.o: conv_prefix.c
	${LINK.c} -c conv_prefix.c

seq_num_mng.o: seq_num_mng.c
	${LINK.c} -c seq_num_mng.c

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