# Edit the following to match your environment
# Common path to installation directories
INSTALLDIR = `pwd`/Install/$$PLATFORM

LIBDIRS = \
  libjs \
  libquad \
  libdelaunay \
  libflt \
  libps \
  libia \
  libaa
  
PROGDIRS = \
  bool \
  dusort
  
TESTDIRS = \
  tests-delaunay/random \
  tests-ia/timing \
  tests-ia/zerofind \
  tests-aa/timing \
  tests-aa/validation \
  tests-aa/curve-tests \
  tests-aa/plot-tests

.PHONY: components tests cleanup

all: components

components: ;\
  inst=$(INSTALLDIR) ;\
  pkgdir=`pwd`; \
  echo "building the exported libraries, programs, and manpages" ;\
  echo "exported components will be installed in $$inst" ;\
  for f in $(LIBDIRS) $(PROGDIRS) ;\
    do\
      cd $$pkgdir/$$f && nice make all INSTALLDIR=$$inst;\
    done

tests: ;\
  inst=$(INSTALLDIR) ;\
  pkgdir=`pwd`; \
  echo "running tests" ;\
  echo "headers and libraries are imported from $$inst" ;\
  for f in $(TESTDIRS) ;\
    do\
      cd $$pkgdir/$$f && nice make all INSTALLDIR=$$inst;\
    done

cleanup: ;\
  pkgdir=`pwd`; \
  echo "deleting derived files" ;\
  for f in $(LIBDIRS) $(PROGDIRS) $(TESTDIRS) ;\
    do\
      cd $$pkgdir/$$f && make cleanup;\
    done