# $Id: src.option.Makefile,v 1.7 1992/06/24 09:14:02 cogito Exp $
# Copyright (c) 1990, University of Paderborn.

SHELL	= /bin/sh
CFLAGS	=

# hack for Sun auto-mounter
PWD	= pwd | sed 's,^/tmp_mnt,,'

# Default master cache location
DESTDIR	= `expr \`$(PWD)\`'/' : '\(.*[^/]\)/[^/]*/[^/]*/'`

CO	= co
COFLAGS	= -q

SPECS	= optcheck.c optcheck.h optcode.c optcode.h optcode.lido \
          optdef.lido optdefs.c optdefs.h optdouble.lido opteval.lido \
          option.abs option.clp option.con option.gla option.head \
          option.ptg option.rel option.specs option.sym optrules.lido
EXE	= ../cola_option.exe
SRCS	= $(SPECS)

TIDY	= *.o core a.out ELI *.dvi *.alw *.ps
CLEAN	= $(TIDY) *.exe frontend.opt table.opt table.2.opt direct.opt option.errors
CLOBBER	= $(CLEAN) COMPILER Makefile

all:	$(EXE)

$(EXE): COMPILER/option.exe
	rm -f $(EXE); ln COMPILER/option.exe $(EXE); chmod 0755 $(EXE)

COMPILER/option.exe:
	cd COMPILER; make CC="$(CC)" option.exe
 
compiler: $(SPECS) CACHE derive
	rm -f option.error compiler
	@if test ! -d COMPILER;\
		then umask 002; mkdir COMPILER; \
		else :; \
		fi         
	$(DESTDIR)/bin/eli -c CACHE < derive
	@if test -s option.error ; \
	then exit 1 ; \
	else \
             echo Dummy dependeny file > compiler;\
	fi

CACHE:
	$(DESTDIR)/bin/eli -c $(DESTDIR) -n CACHE -q
	
	     
gen:	compiler

install: $(EXE) $(SYS) 
	rm -f $(DESTDIR)/cola_option.exe
	cp $(EXE) $(DESTDIR)/cola_option.exe
	chmod 0755 $(DESTDIR)/cola_option.exe

#
# Distribution
#

distrib:	$(SRCS) Makefile COMPILER
	@if test ! -d $(DISTRIB)/option; \
		then umask 002; mkdir $(DISTRIB)/option; \
		else :; \
	fi
	cp Makefile $(DISTRIB)/option
	cd $(DISTRIB)/option; chmod 644 Makefile
	-rm -rf $(DISTRIB)/option/COMPILER
	cd COMPILER; make clean
	cp -r COMPILER $(DISTRIB)/option/COMPILER
	chmod 0644 $(DISTRIB)/option/COMPILER/*

#
# Cleaning Targets
#

tidy:
	rm -rf $(TIDY)
	-cd COMPILER; make tidy

clean:
	rm -rf $(CLEAN)
	-cd COMPILER; make clean

clobber:
	rm -rf $(CLOBBER)

rcsclean:	clean
	-rcsclean $(COFLAGS) $(SRCS) Makefile.cpp
	rm -f Makefile

executable:
	rm -rf $(TIDY) Makefile COMPILER $(AUX) $(SRCS)
	rm Makefile.cpp

#
# Miscellenges
#

checkout:
	$(CO) $(COFLAGS) $(SRCS)

save:
	-mkdir RCS
	-ci -k -t/dev/null -nOriginal -u $(COFLAGS) Makefile.cpp $(SRCS)
	-rcs -bOriginal.1 $(COFLAGS) Makefile.cpp $(SRCS)
	-ci -fOriginal.1 -m/dev/null $(COFLAGS) -u Makefile.cpp
	-ci -fOriginal.1 -m/dev/null $(COFLAGS) $(SRCS)

.PRECIOUS:	$(SRCS)



