#
# Makefile to create shared objects to interface with
# user-defined EXTFH and EXTSM implementations.
#
# libEXTFH.so : to allow to use an external EXTFH file handler
#
# Usage:
# To generate libraries use 'make all'
# To clean up use 'make clean'
#

CFLAGS=-Wall -O3 -fPIC
INCL=-I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux 

#
# EXTFH - EXTSM configurations
#

# Declare here the external library that exports the EXTFH function
LIBEXTFH=

# Declare here  the external library that exports the EXTSM function
LIBEXTSM=

#
# isFileHandledByExtfh configuration
#

# Use the following line for the external definition of isFileHandledByExtfh
EXTFH_FLAGS=-DEXTBYEXTFH

NAME=com_iscobol_extfh_EXTFH
SORT=com_iscobol_extfh_EXTSM

FUNCFH=xfhname
FUNCSM=xsmname

LIBFH=../lib/libEXTFH.so
LIBSM=../lib/libEXTSM.so

#
# Targets
#
ALL: $(LIBFH) $(LIBSM)

$(LIBFH):$(NAME).o $(FUNCFH).o
	$(CC) -shared -o $(LIBFH) -Wl,-soname,$(LIBFH) $(NAME).o $(FUNCFH).o $(LIBEXTFH)

$(FUNCFH).o:$(FUNCFH).c
	$(CC) -c $(EXTFH_FLAGS) $(INCL) $(CFLAGS) $(FUNCFH).c

$(LIBSM):$(SORT).o $(FUNCSM).o
	$(CC) -shared -o $(LIBSM) -Wl,-soname,$(LIBSM) $(SORT).o $(FUNCSM).o $(LIBEXTSM)

$(FUNCSM).o:$(FUNCSM).c
	$(CC) -c $(INCL) $(CFLAGS) $(FUNCSM).c

clean:
	rm -f $(LIBFH) $(FUNCFH).o  
	rm -f $(LIBSM) $(FUNCSM).o

