PREFIX			= /usr/local
TARGET_SERVER		= b25-server
TARGET_CLIENT		= b25-client.so
OBJ_SERVER		= BCasCard.o CasClient.o CasServer.o SmartSock.o TsUtilClass.o b25-server.o
HEADER_SERVER		= BCasCard.h CasClient.h CasServer.h SmartSock.h TsUtilClass.h
OBJ_CLIENT		= CasProxy.o SmartSock.o b25-client.o
HEADER_CLIENT		= CasProxy.h SmartSock.h
PCSC_CFLAGS		= `pkg-config libpcsclite --cflags`
PCSC_LDLIBS		= `pkg-config libpcsclite --libs`

CC			= g++
CFLAGS			= -fPIC -O2 -Wall -g ${PCSC_CFLAGS}
CFLAGS_FOR_LIB	= -fPIC -shared
LDFLAGS		= -pthread ${PCSC_LDLIBS}
LIBS			= 

.cpp.o:
			${CC} $(CFLAGS) -c $<

.c.o:
			${CC} $(CFLAGS) -c $<

all:			${TARGET_SERVER} ${TARGET_CLIENT}

${TARGET_SERVER}:	${OBJ_SERVER}
			${CC} ${CFLAGS} ${OBJ_SERVER} -o $@ ${LDFLAGS} ${LIBS}

${TARGET_CLIENT}:	${OBJ_CLIENT}
			${CC} ${CFLAGS_FOR_LIB} ${OBJ_CLIENT} -o $@ ${LDFLAGS} ${LIBS}

${OBJ_SERVER}:	${HEADER_SERVER}

${OBJ_CLIENT}:	${HEADER_CLIENT}

install:		${TARGET_SERVER} ${TARGET_CLIENT}
			install -m755 ${TARGET_SERVER} ${PREFIX}/bin
			install -m755 ${TARGET_CLIENT} ${PREFIX}/lib

uninstall:
			rm ${PREFIX}/bin/${TARGET_SERVER}
			rm ${PREFIX}/lib/${TARGET_CLIENT}

clean:
			rm -f core ${TARGET_SERVER} *.o *.so

