#
# $Id: Makefile.in,v 1.1.1.1.2.1 2007/11/22 04:34:12 kish_shen Exp $
#

ARCH = @ARCH@
top_srcdir = @top_srcdir@
PREFIX = @prefix@
MAKEFILE = Makefile.$(ARCH)

PERM = a+r,u+w,go-w
DIRPERM = 2755
DESTDIR = $(PREFIX)/lib_public
ECLIPSE = $(PREFIX)/bin/$(ARCH)/eclipse

PL_ECI_FILES =	applic.pl arrays.pl assoc.pl bags.pl between.pl distfix.pl \
		flat.pl graphs.pl intervals.pl listut.pl \
		logarr.pl map.pl metutl.pl occur.pl order.pl \
		project.pl random.pl rdtok.pl read.pl struct.pl \
		tidy.pl trees.pl

ECL_ECI_FILES =	cardinal.ecl grasper.ecl xml.ecl

PL_FILES =	xml.pl xml_diagnosis.pl xml_pp.pl xml_acquisition.pl \
		xml_generation.pl xml_utilities.pl \
		cardinal_comments.pl cardinal_functions.pl cardinal_minmax.pl \
		cardinal_union.pl cardinal_util.pl

ECL_FILES =

ECI_FILES =

README_FILES =	README
EMACS_FILES =	

ECL_DEST =	$(ECL_ECI_FILES:%.ecl=$(DESTDIR)/%.ecl) \
		$(ECL_FILES:%.ecl=$(DESTDIR)/%.ecl)
PL_DEST =	$(PL_ECI_FILES:%.pl=$(DESTDIR)/%.pl) \
		$(PL_FILES:%.pl=$(DESTDIR)/%.pl)
ECI_DEST =	$(PL_ECI_FILES:%.pl=$(DESTDIR)/%.eci) \
		$(ECL_ECI_FILES:%.ecl=$(DESTDIR)/%.eci) \
		$(ECI_FILES:%.eci=$(DESTDIR)/%.eci)
README_DEST =	$(README_FILES:%=$(DESTDIR)/%)
EMACS_DEST =	$(EMACS_FILES:%=$(DESTDIR)/%)


# This file is needed for the visualisation tools. We put a copy
# in /lib to make it go into the eclipse_basic.tgz package
DESTDIR_EXTRA = $(PREFIX)/lib
EXTRA_DEST = $(DESTDIR_EXTRA)/logarr.pl $(DESTDIR_EXTRA)/logarr.eco


install:	@MAKE_TARGET@
install_cross:	$(ECL_DEST) $(PL_DEST) $(ECI_DEST) $(README_DEST) \
		$(EMACS_DEST)
install_all:	install_cross $(EXTRA_DEST)


clean:
	rm -rf $(ECL_DEST) $(PL_DEST) $(ECI_DEST) $(README_DEST) \
		$(EMACS_DEST) $(EXTRA_DEST)

ecoclean:
	rm -f $(DESTDIR_EXTRA)/logarr.eco

archclean:


%/.stamp:
	mkdir -p $(@D)
	@/bin/chmod $(DIRPERM) $(@D)
	@touch $@; /bin/chmod $(PERM) $@

$(DESTDIR)/%.eci:	%.eci $(DESTDIR)/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

$(DESTDIR)/%.eci:	%.ecl $(DESTDIR)/.stamp
	$(ECLIPSE) -e 'lib(document),icompile("$(*F)","$(@D)")'
	-@/bin/chmod $(PERM) $@

$(DESTDIR)/%.eci:	%.pl $(DESTDIR)/.stamp
	$(ECLIPSE) -e 'lib(document),icompile("$(*F)","$(@D)")'
	-@/bin/chmod $(PERM) $@

$(DESTDIR)/%.ecl:	%.ecl $(DESTDIR)/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

$(DESTDIR)/%.pl:	%.pl $(DESTDIR)/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

$(DESTDIR_EXTRA)/%.pl:	%.pl $(DESTDIR_EXTRA)/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

$(DESTDIR_EXTRA)/%.eco:	%.pl $(DESTDIR_EXTRA)/.stamp
	$(ECLIPSE) -e 'lib(fcompile), set_flag(variable_names,off), set_flag(debug_compile,off), fcompile("$(*F)", [outdir:"$(@D)"])'
	@/bin/chmod $(PERM) $@

$(DESTDIR)/README:	README $(DESTDIR)/.stamp
	/bin/cp README $@
	@/bin/chmod $(PERM) $@

$(DESTDIR)/COPYING:	COPYING $(DESTDIR)/.stamp
	/bin/cp COPYING $@
	@/bin/chmod $(PERM) $@

$(DESTDIR)/%.el:	%.el $(DESTDIR)/.stamp
	/bin/cp $< $@
	@/bin/chmod $(PERM) $@

