# Generated automatically from Makefile.in by configure.
#
# Makefile.in for the Tiny COBOL compiler runtime library
#

prefix=/usr/local
exec_prefix=${prefix}

#
# Debug flags are set in htconfig.h
# -DPICTURE_TESTING -DDEBUG_RTS
#
CCX=gcc
ASM=as
INCLUDES=-I/usr/include -I/usr/local/include -I../lib -I../ -I/usr/include/mysql
CCXFLAGS=${INCLUDES} -fcommon -Wall -ggdb 
CCXFLAGS1=${INCLUDES} -fcommon -Wall -fPIC -ggdb 
ACXFLAGS=-as

RANLIB=ranlib
AR=ar

INSTRC=${prefix}/share/htcobol
RCFILE=htrtconf

INSTALL=/usr/bin/install -c
INSTALL_DATA=${INSTALL} -m 644

MV    = mv -f
RM    = rm -f
MKDIR = mkdir -p
LNK   = ln -sf
GREP  = grep -v

MAKEDEPEND=@MAKEDEPEND@
LIBS=-ldl -lm -ldb -lncurses -L/usr/lib/mysql -L/usr/lib

#
# Default install directory is set in htconfig.h
#
lib_dir=${prefix}/lib

lib_version=0.74.0

lib_name1=htcobol
#lib_name2=htcobol2

STATIC_LIB1=lib${lib_name1}.a
#STATIC_LIB2=lib${lib_name2}.a
SHARED_LIB1=lib${lib_name1}.so.${lib_version}
#SHARED_LIB2=lib${lib_name2}.so.${lib_version}

SRC1  = mcmath.c general.c fileio.c \
	pictures.c basicio.c strings.c screenio.c \
	cobmove.c cobmove_f_.c cobmove_x_.c cobmove_e_.c \
	cobmove_9_.c cobmove_b_.c cobmove_c_.c \
	rterrors.c scr_curses.c intrinsic.c \
	dyncall.c flckclient.c config.c screen.c 

#SRC2  = dyncall.c  
#SRC2  = dyncall_ltdl.c ltdl.c 

OBJS1 = $(SRC1:.c=.o)

#OBJS2 = $(SRC2:.c=.o)

OBJD1 = $(SRC1:.c=.lo)

#OBJD2 = $(SRC2:.c=.lo)

#
# Rules for compiling .c .s sources
#
.SUFFIX: .c .o .lo
.c.o:
	$(CCX) $(CCXFLAGS) -c $<

%.lo: %.c
	$(CCX) $(CCXFLAGS1) -c $< -o $@

#
# Notes on building and using the shared htcobol library.
# - The linker will try to use the shared libraries by default. 
#   If not available it will try to use the static libraries.
# - When linking with a shared htcobol library, all other libraries must be 
#   named, whether they are used in the cobol program or not. 
#   (i.e. -lncurses -ldb)
# - To run a cobol program built with a shared htcobol library, and the
#   htcobol library is not installed in one of the standard locations, use 
#   the $LD_LIBRARY_PATH environmental variable to add this path.
#   (i.e. export LD_LIBRARY_PATH=this path:$LD_LIBRARY_PATH )
# - For testing purposes, it is recommended that only a static htcobol library 
#   be used, since gdb will not work properly with shared libraries.
#

all: static-libs shared-libs
#all: shared-libs
#all: static-libs
devel: static-libs

static-libs: ${STATIC_LIB1} # ${STATIC_LIB2}

shared-libs: ${SHARED_LIB1} # ${SHARED_LIB2}

# Rules for building the static library
#
${STATIC_LIB1}: ${OBJS1}
	${AR} cr ${STATIC_LIB1} ${OBJS1}
	${RANLIB} ${STATIC_LIB1}

${STATIC_LIB2}: ${OBJS2}
	${AR} cr ${STATIC_LIB2} ${OBJS2}
	${RANLIB} ${STATIC_LIB2}

# Rules for building the shared library
#
${SHARED_LIB1}: ${OBJD1}
	${CCX} -shared -Wl,-soname,lib${lib_name1}.so.0 -o ${SHARED_LIB1} $(OBJD1) ${LIBS} 
	${LNK} $(SHARED_LIB1) lib$(lib_name1).so.0
	${LNK} $(SHARED_LIB1) lib$(lib_name1).so

${SHARED_LIB2}: ${OBJD2}
	${CCX} -shared -Wl,-soname,lib${lib_name2}.so.0 -o ${SHARED_LIB2} $(OBJD2) ${LIBS}
	${LNK} $(SHARED_LIB2) lib$(lib_name2).so.0
	${LNK} $(SHARED_LIB2) lib$(lib_name2).so

clean:
	@${RM} ${OBJS} ${OBJD} ${STATIC_LIB1} ${STATIC_LIB2} \
	lib$(lib_name1).so* lib$(lib_name2).so* \
	core *.bak *.txt *.o *.lo

install: install-static install-shared

install-rts-config: 
	$(MKDIR)  $(INSTRC)
	${INSTALL_DATA} $(RCFILE) $(INSTRC)/$(RCFILE)

#install-static: ${STATIC_LIB1} # ${STATIC_LIB2}
install-static: ${STATIC_LIB1} install-rts-config
	${INSTALL_DATA} ${STATIC_LIB1} ${lib_dir}/${STATIC_LIB1}
#	${INSTALL_DATA} ${STATIC_LIB2} ${lib_dir}/${STATIC_LIB2}

#install-shared: ${SHARED_LIB1} # ${SHARED_LIB2}
install-shared: ${SHARED_LIB1} install-rts-config
	${INSTALL_DATA} ${SHARED_LIB1} ${lib_dir}/${SHARED_LIB1}
#	${INSTALL_DATA} ${SHARED_LIB2} ${lib_dir}/${SHARED_LIB2}
	${LNK} ${lib_dir}/$(SHARED_LIB1) ${lib_dir}/lib$(lib_name1).so
#	${LNK} ${lib_dir}/$(SHARED_LIB2) ${lib_dir}/lib$(lib_name2).so
	${LNK} ${lib_dir}/$(SHARED_LIB1) ${lib_dir}/lib$(lib_name1).so.0
#	${LNK} ${lib_dir}/$(SHARED_LIB2) ${lib_dir}/lib$(lib_name2).so.0
