SHELL=/bin/sh

OS=$(OSTYPE)

all::
	-@if test "x$(OS)" = x; then \
          echo "please set the environment variable OSTYPE ";\
	  echo "to a value appropriate for your system.";\
	  echo "to do so type: setenv OSTYPE `uname`   for the csh, tcsh";\
          echo "               export OSTYPE=`uname`   for other shells";\
        else \
	  if test -f Makefile.in ; then \
	    if test -f $(OS)/Makefile ; then \
	      NEEDED=`(cd $(OS); ${MAKE} checkneeds;) | grep "needed to compile" `;\
	      if test "x$$NEEDED" = x; then \
	        (cd $(OS); ${MAKE} $@); \
	      else \
                (cd $(OS); ${MAKE} checkneeds); \
	      fi ; \
	    else \
	      echo "Did you configure your system?";\
	    fi; \
	  fi; \
	fi;

distrib::
	@if test ! -d ../../distrib ; then mkdir ../../distrib; fi;
	@if test ! -f ../../system.list ; then \
	 echo "dummy" > ../../system.list;\
	fi
	@(curr=`pwd`; direc=`basename $$curr`;\
	 basedir=`dirname $$curr`;\
         basedirname=`basename $$basedir`;\
	 if test ! -d ../../distrib/$$basedirname ; then \
	   mkdir ../../distrib/$$basedirname;\
	 fi;\
	 if test -d doc; then (cd doc; make clean;); fi;\
	 (cd ..; \
	  echo creating $$direc.tar from the current directory;\
	  files="`\
	       find $$direc -type f \
	       | fgrep -vf ../system.list \
	       | grep -v "~" \
	       | grep -v "#" \
	      ` $(DISTRIBUTE_ADDITIONAL)";\
	  tar -cf /tmp/$$direc.tar $$files;\
	  echo compressing $$direc.tar to $$direc.tgz;\
	  gzip -c /tmp/$$direc.tar > ../distrib/$$basedirname/$$direc.tgz;\
	  rm /tmp/$$direc.tar;\
	 )\
	)

.DEFAULT:
	-@if test "x$(OS)" = x; then \
          echo "please set the environment variable OSTYPE ";\
	  echo "to a value appropriate for your system.";\
	  echo "to do so type: setenv OSTYPE `uname`   for the csh, tcsh";\
          echo "               export OSTYPE=`uname`   for other shells";\
        else \
	  if test -f Makefile.in ; then \
	    if test -f $(OS)/Makefile ; then \
	      NEEDED=`(cd $(OS); ${MAKE} checkneeds) | grep "needed to compile" `;\
	      if test "x$$NEEDED" = x; then \
	        (cd $(OS); ${MAKE} $@); \
	      else \
                (cd $(OS); ${MAKE} checkneeds); \
	      fi ; \
	    else \
	      echo "Did you configure your system?";\
	    fi \
	  fi \
	fi

