# Variables substituted by the autoconf configure script:

SHELL = @SHELL@

CC = @CC@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
RANLIB = @RANLIB@
@SET_MAKE@
prefix = @prefix@

package = libctl
distdir = $(package)-@LIBCTL_VERSION@

# Subdirectories to make in:

LIBSUBDIRS = base utils
SUBDIRS = $(LIBSUBDIRS) examples

all: all-recursive

install: libs install-recursive

libs: libs-recursive

dist:
	cvs export -D now -d $(distdir) $(package)
	cp config.guess config.sub $(distdir)
	cp install-sh $(distdir)
	pushd $(distdir) && autoconf && popd
	rm -f $(distdir).tar.gz
	GZIP="--best" tar chozf $(distdir).tar.gz $(distdir)
	rm -rf $(distdir)

snapshot:
	ss_vers=`date +"%Y%m%d"` && \
	ss_dir=$(package)-$$ss_vers && \
	cvs export -D now -d $$ss_dir $(package) && \
	cp config.guess config.sub $$ss_dir && \
	cp install-sh $$ss_dir && \
	(sed "s/VERSION=@LIBCTL_VERSION@/VERSION=$$ss_vers/" $$ss_dir/configure.ac > $$ss_dir/configure.ac.ss) && \
	mv -f $$ss_dir/configure.ac.ss $$ss_dir/configure.ac && \
	pushd $$ss_dir && autoconf && popd && \
	rm -f $$ss_dir".tar.gz" && \
	GZIP="--best" tar chozf $$ss_dir".tar.gz" $$ss_dir && \
	rm -rf $$ss_dir

clean: clean-recursive
	rm -f core

distclean: clean
	@list='$(SUBDIRS)'; for subdir in $$list; do \
	  echo "rm -f $$subdir/Makefile"; rm -f $$subdir/Makefile; done
	rm -f config.cache Makefile config.log config.status
	rm -f base/ctl.h utils/gen-ctl-io
	rm -f base/Makefile utils/Makefile examples/Makefile

maintainer-clean: distclean
	rm -f configure

# Recursive makes in subdirectories:
# (borrowed from automake)

all-recursive clean-recursive:
	@set fnord $(MAKEFLAGS); amf=$$2; \
	list='$(SUBDIRS)'; for subdir in $$list; do \
          target=`echo $@ | sed s/-recursive//`; \
          echo "Making $$target in $$subdir"; \
          (cd $$subdir && $(MAKE) $$target) \
           || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
        done && test -z "$$fail"

libs-recursive install-recursive:
	@set fnord $(MAKEFLAGS); amf=$$2; \
	list='$(LIBSUBDIRS)'; for subdir in $$list; do \
          target=`echo $@ | sed s/-recursive//`; \
          echo "Making $$target in $$subdir"; \
          (cd $$subdir && $(MAKE) $$target) \
           || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
        done && test -z "$$fail"
