#  Makefile for utilities library
#
include    ../Make.defs
MAJOR      = 1
MINOR      = 0
REVISION   = 0
VERSION    = ${MAJOR}.${MINOR}.${REVISION}

HEADERS     = ${INCDIR}/utils.h ${INCDIR}/errormsg.h ${INCDIR}/errorlog.h

ifeq (${ISELF},yes)
    TARGET_LIB  = ../lib/${STDLIB_R}.so.${VERSION}
    LINK        = ../lib/${STDLIB_R}.so.1
else
    TARGET_LIB  = ../lib/${STDLIB_R}.a
endif

LIB_OBJECTS = ${OBJDIR}/c_r.o ${OBJDIR}/errorlog.o ${OBJDIR}/errormsg.o

all: install ${TARGET_LIB}

${TARGET_LIB}: ${LIB_OBJECTS}
ifeq (${ISELF},yes)
	@echo + building ${TARGET_LIB}
	@rm -f ${TARGET_LIB} ${LINK}
	@${CC} -shared -Wl,-soname,${LINK} -o ${TARGET_LIB} ${LIB_OBJECTS}
	@ln -s ${TARGET_LIB} ${LINK}
else
	@ar r ${TARGET_LIB} ${LIB_OBJECTS}
endif


${OBJDIR}/c_r.o:         c_r.c utils.h
${OBJDIR}/errorlog.o:    errorlog.c errorlog.h
${OBJDIR}/errormsg.o:    errormsg.c errormsg.h

install:
	@cp -f *.h ${INCDIR}

clobber: clean
	@rm -f ${TARGET_LIB} ${LINK} ${HEADERS} ${LIB_OBJECTS}

clean:
	@rm -f *.bak *.rem *~


