include ../settings.make
include babel.make

# Babel generates this babel.make file to define
# macros for all the files that are generated
ARRAYMODULEOBJS=${ARRAYMODULESRCS:.F90=.lo}
IMPLMODULEOBJS=${IMPLMODULESRCS:.F90=.lo}
IMPLOBJS=${IMPLSRCS:.F90=.lo}
SKELOBJS=${SKELSRCS:.c=.lo}
IOROBJS=${IORSRCS:.c=.lo}
STUBOBJS=${STUBSRCS:.c=.lo}
STUBMODULEOBJS=${STUBMODULESRCS:.F90=.lo}
TYPEMODULEOBJS=${TYPEMODULESRCS:.F90=.lo}

ALLOBJS=$(STUBOBJS) $(TYPEMODULEOBJS) \
                          $(ARRAYMODULEOBJS) \
                          $(STUBMODULEOBJS) $(SKELOBJS) \
                          $(IOROBJS) $(IMPLOBJS) $(IMPLMODULEOBJS)

ifeq ($(BABEL_WITH_F90),1)
all: libf90conway.la
else
all:
endif

# boilerplate dependencies to get things built
# in the correct order
$(ARRAYMODULEOBJS) : $(TYPEMODULEOBJS)
$(STUBMODULEOBJS): $(TYPEMODULEOBJS) $(ARRAYMODULEOBJS)
$(IMPLOBJS) : $(STUBMODULEOBJS) $(IMPLMODULEOBJS)


# make doesn't handle tasks that generate lots of files
# this handy idiom creates touches a bogus file if babel
# executes without errors
babel-stamp: ../life.sidl
	${BABEL} --server=F90  ../life.sidl f90life.sidl && \
	touch babel-stamp
	$(MAKE) all

libf90conway.la: babel-stamp ${ALLOBJS}
	${BABEL_LIBTOOL} --mode=link ${CXX} -module -no-undefined -o libf90conway.la -rpath `pwd`/.libs -release 2.0 ${ALLOBJS} ${FCLIBS} -L${BABEL_LIBDIR}  -lsidl 

clean:
	${RM} babel-stamp ${ALLOBJS} *~ *.o *.lo *.la *.so
	${RM} -rf .libs

new:	clean
	${RM} $(STUBSRCS) $(TYPEMODULESRCS) \
                          $(ARRAYMODULESRCS) \
                          $(STUBMODULESRCS) $(SKELSRCS) \
                          $(IORSRCS) *.mod *.h
