mysqlInclude=/usr/local/mysql/include
mysqlInclude.ES=/usr/include/mysql

mysqlLib=/usr/local/mysql/lib
mysqlLib.ES=/usr/lib/mysql

OBJ		=bsscomm.o  bss_hb.o nmimp.o nmtypes.o
OBJ.ES	=bsscomm.o.ES  bss_hb.o.ES nmimp.o.ES nmtypes.o.ES

PROGS1=bsscomm
PROGS2=alive

default: linuxES

all: 
	@echo " **** Compiling $(PROGS1) and $(PROGS2) ****"
	@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: bsscomm alive
	make alive
	make bsscomm

linuxES: bsscomm.ES alive
	make alive
	make bsscomm.ES

bsscomm:${OBJ}
	@echo Linking $(PROGS1)
	@gcc -g -W -Wall -o $(PROGS1) ${OBJ} -L$(mysqlLib) -lmariadbclient -lz
	ar r libimp.a ${OBJ}
	# cp -f bsscomm ../../../omc83_bin/
	#cp -f bsscomm /usr/local/omc/bin/

bsscomm.ES:${OBJ.ES}
	@echo Linking $(PROGS1)
	@gcc -g -W -Wall -o $(PROGS1) ${OBJ} -L$(mysqlLib.ES) -lmariadbclient -lz -lm
	ar r libimp.a ${OBJ}

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

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

installall: installbin installomc

#imptest.o: imptest.c 
#	gcc -g -O2 -W -Wall -c imptest.c \
#		-I/usr/local/mysql/include \
	

bsscomm.o: bsscomm.c nmimp.h nmtypes.h nmstatus.h iwtypes.h
	gcc -g -W -Wall -c bsscomm.c -I$(mysqlInclude)

bss_hb.o: bss_hb.c bss_hb.h iwtypes.h bsscomm.h
	gcc -g -W -Wall -c bss_hb.c	-I$(mysqlInclude)

nmimp.o: nmimp.c nmimp.h iwtypes.h nmstatus.h
	gcc -g -W -Wall -c nmimp.c

nmtypes.o: nmtypes.c nmtypes.h iwtypes.h
	gcc -g -W -Wall -c nmtypes.c 

bsscomm.o.ES: bsscomm.c nmimp.h nmtypes.h nmstatus.h iwtypes.h
	gcc -g -W -Wall -c bsscomm.c -I$(mysqlInclude.ES)

bss_hb.o.ES: bss_hb.c bss_hb.h iwtypes.h bsscomm.h
	gcc -g -W -Wall -c bss_hb.c	-I$(mysqlInclude.ES)

nmimp.o.ES: nmimp.c nmimp.h iwtypes.h nmstatus.h
	gcc -g -W -Wall -c nmimp.c

nmtypes.o.ES: nmtypes.c nmtypes.h iwtypes.h
	gcc -g -W -Wall -c nmtypes.c 

alive: alive.c
	gcc -g -W -Wall -o alive alive.c
	#cp -f alive ../../../omc83_bin/
	#cp -f alive ../../../../bin/
	# cp -f alive /usr/local/omc/bin/

clean:
	rm -rf *.a *.o bsscomm alive 

tags:
	ctags -R .
 
