axiom_c_runtime_extra = @axiom_c_runtime_extra@

subdir = src/sman/

# this is where to put the various commands
OUT=	$(axiom_target_bindir)
OUTLIB=	$(axiom_target_libdir)

# this is where the include files live
INC=    $(axiom_src_srcdir)/include

build_libdir = $(abs_top_builddir)/src/lib

bin_PROGRAMS = session$(EXEEXT) \
		spadclient$(EXEEXT) \
		sman$(EXEEXT)

session_sources = session.c
session_objects = $(session_sources:.c=.$(OBJEXT))
session_LDADD = -L$(build_libdir) -lspad $(axiom_c_runtime_extra)
session_DEPENDENCIES = $(build_libdir)/libspad.a

spadclient_sources = spadclient.c
spadclient_objects = $(spadclient_sources:.c=.$(OBJEXT))
spadclient_LDADD = -L$(build_libdir) -lspad $(axiom_c_runtime_extra)
spadclient_DEPENDENCIES = $(build_libdir)/libspad.a

sman_sources = sman.c
sman_objects = $(sman_sources:.c=.$(OBJEXT))
sman_LDADD = -L$(build_libdir) -lspad $(axiom_c_runtime_extra)
sman_DEPENDENCIES = $(build_libdir)/libspad.a



.PHONY: all all-sman

all: all-ax

all-ax all-sman: stamp

stamp:	$(OUTLIB)/session$(EXEEXT) \
		$(OUTLIB)/spadclient$(EXEEXT) \
		$(OUT)/sman$(EXEEXT)
	-rm -f stamp
	$(STAMP) stamp

.PRECIOUS: %.$(OBJEXT)

%.$(OBJEXT): $(srcdir)/%.c 
	$(CC) -c ${CCF} $(axiom_includes) -I$(srcdir) -o $@ $<

${OUTLIB}/session$(EXEEXT): $(session_objects) $(session_DEPENDENCIES)
	$(CC) $(session_objects) -o $@ $(session_LDADD) ${LDF} -o $@

${OUTLIB}/spadclient$(EXEEXT): $(spadclient_objects) $(spadclient_DEPENDENCIES)
	$(CC) $(spadclient_objects) $(spadclient_LDADD) ${LDF} -o $@

spadclient.$(OBJEXT): $(axiom_configdir)/axiom-c-macros.h

${OUT}/sman$(EXEEXT): $(sman_objects) $(sman_DEPENDENCIES)
	$(CC) $(sman_objects) $(sman_LDADD) ${LDF} -o $@

$(sman_objects): $(srcdir)/sman.h $(axiom_c_macros_h)

mostlyclean-local:
	-rm -f $(session_objects) $(sman_objects) $(spadclient_objects)
	-rm -f stamp

clean-local: mostlyclean-local
	-rm -f $(OUTLIB)/session$(EXEEXT)
	-rm -f $(OUTLIB)/spadclient$(EXEEXT)
	-rm -f $(OUT)/sman$(EXEEXT)

distclean-local: clean-local

