#
# A "simple" Makefile to compile a C driver for the Conway Life Example
#
#

# this Makefiles uses GNU make extensions
include ../settings.make	# get config settings
include babel.make		# get files generated by Babel
STUBOBJS=$(STUBSRCS:.c=.lo)	# libtool objects
ALLOBJS=$(STUBOBJS)		# all libtool objects
ALLSTATICS=$(STUBSRCS:.c=.lo)	# .lo is used for statically linked objects
ifeq ($(BABEL_WITH_F90),1)
SIDLFILES=../life.sidl ../libC/clife.sidl ../libCxx/cxxlife.sidl \
	../libF90/f90life.sidl
ALLLIBS= -L../libC -lcconway -L../libCxx -lcxxconvery -L../libF90 -lf90conway
else
SIDLFILES=../life.sidl ../libC/clife.sidl ../libCxx/cxxlife.sidl
ALLLIBS= -L../libC -lcconway -L../libCxx -lcxxconvery
endif


all : my_driver			#statically linked executable

babel-stamp: $(SIDLFILES)
	$(BABEL) --client=C $(SIDLFILES) && \
	touch babel-stamp
	$(MAKE) all

# Note: we use GNU libtool in a peculiar way, actually installing it
# with the rest of Babel as ... babel-libtool

my_driver: babel-stamp $(ALLOBJS) my_driver.lo
	$(BABEL_LIBTOOL) --mode=link $(CXX) \
	-all-static -no-install -no-undefined \
	-o my_driver my_driver.lo $(ALLOBJS) \
	$(ALLLIBS) -L$(BABEL_LIBDIR) -lsidl $(CLIBS)

clean:
	$(RM) *.o *.lo

# source files are generated, so its okay to remove most
# but not IMPLs!

new:
	$(RM) my_driver babel-stamp $(STUBHDRS) $(STUBSRCS) \
	$(IORHDRS) $(IORSRCS) $(SKELHDRS) $(SKELSRCS)
