prefix=@prefix@
prgdir=@PRGDIR@
imdir=@IMDIR@

CFLAGS = @CFLAGS@
DLIB_PROG = libimm_server.so

DLIB_OBJS = TLS_HzInput.o TLS_ImmOp.o TLS_MemFile.o \
       TLS_Debug.o TLS_LibMain.o TLS_DoubleByteConvertor.o \
       TLS_AsciiConvertor.o


# CFLAGS = -g -D__IMM_DEBUG__ -Wall -I. -I/usr/local/include -I../include 
CFLAGS = -g -Wall -I. -I/usr/include -I../../include 
CC=g++

all: $(DLIB_PROG)

libimm_server.so: $(DLIB_OBJS)
	$(CC) $(DLIB_OBJS) -shared -o $(DLIB_PROG)

TLS_LibMain.o : TLS_LibMain.cpp
	$(CC) $(CFLAGS) -DUNICON_LIB=\"$(prefix)$(imdir)\" -c TLS_LibMain.cpp -o TLS_LibMain.o

TLS_HzInput.o: TLS_HzInput.cpp TLS_HzInput.hpp
	$(CC) $(CFLAGS) -c TLS_HzInput.cpp -o TLS_HzInput.o
TLS_ImmOp.o : TLS_ImmOp.cpp TLS_ImmOp.hpp
	$(CC) $(CFLAGS) -c TLS_ImmOp.cpp -o TLS_ImmOp.o
TLS_MemFile.o : TLS_MemFile.cpp TLS_MemFile.hpp
	$(CC) $(CFLAGS) -c TLS_MemFile.cpp -o TLS_MemFile.o
TLS_Debug.o : TLS_Debug.cpp TLS_Debug.hpp
	$(CC) $(CFLAGS) -c TLS_Debug.cpp -o TLS_Debug.o
TLS_DoubleByteConvertor.o : TLS_DoubleByteConvertor.cpp TLS_DoubleByteConvertor.hpp
	$(CC) $(CFLAGS) -c TLS_DoubleByteConvertor.cpp -o TLS_DoubleByteConvertor.o
TLS_AsciiConvertor.o : TLS_AsciiConvertor.cpp
	$(CC) $(CFLAGS) -c TLS_AsciiConvertor.cpp -o TLS_AsciiConvertor.o

install: all
	mkdir -p $(prefix)/bin
	mkdir -p $(prefix)$(imdir)
	if [ -f $(DLIB_PROG) ]; then  cp -f $(DLIB_PROG) $(prefix)$(imdir); fi

clean:
	if test -e $(PROG); then rm -f $(PROG); fi
	if test -e $(PROG_LIB); then rm -f $(PROG_LIB); fi
	if test -e $(DLIB_PROG); then rm -f $(DLIB_PROG); fi
	rm -f *.o *.bak 
distclean: clean
	rm -f Makefile
	if test -e $(PROG); then rm -f $(PROG); fi

