#
# make compatibility
#
SHELL = /bin/sh

.SUFFIXES:
.SUFFIXES: .c .cc .cpp .o

@SET_MAKE@
# 
# Source and installation paths
#
prefix  =       @prefix@
exec_prefix =   @exec_prefix@
srcdir =        @srcdir@
VPATH =         @srcdir@
#
# Installation directories for binaries and manual pages
#
BINDIR  =       @bindir@
MANDIR  =       @mandir@
#
# install program
#
INSTALL =               @INSTALL@
INSTALL_PROGRAM =       ${INSTALL} -c
INSTALL_DATA =          ${INSTALL} -c -m 644
#
# compiler and library stuff
#
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ 
LDFLAGS = @LDFLAGS@
AR = ar
RANLIB = @RANLIB@
#
# Version and distribution stuff
#
VERSION = @cdrdao_version@
DISTDIR = cdrdao-$(VERSION)
#
#
#
SUBDIRS = @scsilib_dir@ edc_ecc trackdb paranoia dao utils @xdao@
SUBDIRSINST = trackdb dao utils @xdao@

all:
	for d in $(SUBDIRS) ; do  \
  $(MAKE) -C $$d all || exit 1 ; \
  done

install: all
	for d in $(SUBDIRSINST) ; do  \
  $(MAKE) -C $$d install || exit 1 ; \
  done

clean:
	for d in $(SUBDIRS) ; do  \
  $(MAKE) -C $$d clean || exit 1 ; \
  done

distclean:
	for d in $(SUBDIRS) ; do  \
  $(MAKE) -C $$d distclean || exit 1 ; \
  done
	rm -f Makefile config.cache config.h config.log config.status

dist:
	mkdir $(DISTDIR)
	mkdir $(DISTDIR)/edc_ecc
	mkdir $(DISTDIR)/trackdb
	mkdir $(DISTDIR)/dao
	mkdir $(DISTDIR)/xdao
	mkdir $(DISTDIR)/testtocs
	mkdir $(DISTDIR)/paranoia
	mkdir $(DISTDIR)/utils
	chmod 777 $(DISTDIR) $(DISTDIR)/trackdb $(DISTDIR)/dao $(DISTDIR)/xdao
	chmod 777 $(DISTDIR)/paranoia
	cp Makefile.in CREDITS README* cdrdao.lsm config.guess config.sub \
           configure.in configure config.h.in aclocal.m4 install-sh       \
           mkinstalldirs INSTALL COPYING aclocal.m4 Release-* $(DISTDIR)
	cp edc_ecc/Makefile.in edc_ecc/*.c edc_ecc/*.h $(DISTDIR)/edc_ecc
	cp edc_ecc/*.ecc edc_ecc/README edc_ecc/crc.txt $(DISTDIR)/edc_ecc
	rm -f $(DISTDIR)/edc_ecc/Makefile
	cp trackdb/Makefile.in trackdb/*.h trackdb/*.cc trackdb/*.g \
           $(DISTDIR)/trackdb
	cp paranoia/Makefile.in paranoia/README paranoia/overlapdef.txt \
           paranoia/config.guess paranoia/config.sub paranoia/configure \
           paranoia/configure.in paranoia/*.c paranoia/*.h $(DISTDIR)/paranoia
	cp dao/Makefile.in dao/*.h dao/*.cc dao/cdrdao.man dao/cdrdao.drivers $(DISTDIR)/dao
	cp xdao/Makefile.in xdao/*.h xdao/*.cc xdao/xcdrdao.man xdao/gcdmaster.* xdao/*.png $(DISTDIR)/xdao
	cp utils/Makefile.in utils/*.cc $(DISTDIR)/utils
	cp testtocs/*.toc $(DISTDIR)/testtocs
	tar cf - contrib | ( cd $(DISTDIR) ; tar xf - )
	tar cf - scsilib | ( cd $(DISTDIR) ; tar xf - )
	find $(DISTDIR) -depth -name "CVS" -type d -exec rm -r {} \;
	chmod -R ugo+r $(DISTDIR)
	chmod -R u+w $(DISTDIR)
	tar cvzf cdrdao-$(VERSION).src.tar.gz $(DISTDIR)
	rm -rf $(DISTDIR)
