# *************************************************************
#	labra: Ada, code generation
# *************************************************************
#***********************************
# (C) Copyright 1993; dit/upm
#  Distributed under the conditions stated in the
#  TOPO General Public License (see file LICENSE)
#***********************************
# $Id: makefile,v 1.13 1994/11/22 14:23:53 lotos Exp $
#***********************************

TOOL=	labra

#ADACPL=	NONE
#ADARTS=	sequence parallel

CODE=	u_rand.a arena.a mmg.a lbcsz.a kobj.a kspe.a lbc.a k_body.a

all:

install::	$(CODE)
	if test "$(ADACPL)" = ""; then exit 1; fi
	if test "$(ADARTS)" = ""; then exit 1; fi
	for cpl in $(ADACPL); do	\
	  case "$$cpl" in		\
	    "")				\
	      exit 1;;			\
	    *)				\
	      ;;			\
	  esac;				\
	done
	for rts in $(ADARTS); do	\
	  case "$$rts" in		\
	    sequence|parallel)		\
	      ;;			\
	    *)				\
	      exit 1;;			\
	  esac;				\
	done

install::	$(CODE)
	if test ! -d $(TOPOLIB)/labra; then			\
	  (set -x;						\
	   mkdir $(TOPOLIB)/labra;				\
	   chmod a+xr $(TOPOLIB)/labra;				\
	  );							\
	fi
	for rts in $(ADARTS); do				\
	  if test ! -d $(TOPOLIB)/labra/$$rts; then		\
	    (set -x;						\
	     mkdir $(TOPOLIB)/labra/$$rts;			\
	     chmod a+xr $(TOPOLIB)/labra/$$rts;			\
	    );							\
	  fi;							\
	  for src in $(CODE) labra.make; do			\
	    (set -x;						\
	     cp $$src $(TOPOLIB)/labra/$$rts;			\
	     chmod a+r $(TOPOLIB)/labra/$$rts/$$src;		\
	    );							\
	  done;							\
	done

install::	$(CODE)
	for cpl in $(ADACPL); do				\
	  if test "$$cpl" = "NONE"; then continue; fi;		\
	  for rts in $(ADARTS); do				\
	    param="ADARTS=$$rts ADACPL=$$cpl";			\
	    (set -x;						\
	     cd $(TOPOLIB)/labra/$$rts;				\
	     $(MAKE) $(MFLAGS) -f labra.make clean $$param;	\
	     $(MAKE) $(MFLAGS) -f labra.make make $$param;	\
	     $(MAKE) $(MFLAGS) -f labra.make freeze $$param;	\
	    );							\
	    if test $$HOSTTYPE = 'sun'; then			\
	      (set -x;						\
	       chmod -R a+Xr $(TOPOLIB)/labra/$$rts;		\
	      );						\
	    else						\
	      (set -x;						\
	       chmod a+r $(TOPOLIB)/labra/$$rts;		\
	      );						\
	    fi;							\
	  done;							\
	done
	@for cpl in $(ADACPL); do				\
	   if test "$(ADACPL)" != "NONE"; then exit 0; fi;	\
	 done;							\
	 echo "=> no Ada compiler available!!!" 1>&2;		\
	 for rts in $(ADARTS); do				\
	   echo -n "=> $$rts: " 1>&2;				\
	   echo "sources are at $(TOPOLIB)/labra/$$rts" 1>&2;	\
	 done;							\
	 echo -n "=> they must be compiled manually" 1>&2;	\
	 echo " (see labra.make)" 1>&2

install::	$(CODE)
	touch $@

clean::
	-rm -f *~ core

#------------------------------------------------------------------
