#!/bin/sh

# a shell to create the makefile
# the prolog file names are given as argument

cp Makefile Makefile.old
cat >Makefile <<'EOI'
# 
# Makefile to produce ql files from the pl files
#	- made for Sicstus, may work on others.
#

PROLOG =sicstus


EOI

echo -n "SOURCES= ">>Makefile
for i in  $*; do 
 echo "\\" >>Makefile ;  
 echo -n "	$i" >>Makefile ;
done

echo "


" >>Makefile

echo -n "COMPILED =">>Makefile
for i in $*; do 
 echo "\\" >>Makefile ;
 echo -n "	" >>Makefile ;
 echo -n `echo $i | sed -e 's/\.pl$/\.ql/'` >>Makefile
done


cat >>Makefile <<'EOI'


all: $(SOURCES) $(COMPILED)
	@echo "Compiled all predicates"
	

%.ql: %.pl
	@echo "compiling $*"
	@echo "fcompile($*)."|$(PROLOG)


makefile:
	@echo "remaking makefile"
	@exec sh Remake *.pl


EOI
