################################################################
# This Makefile is created from Makefile.in by the main Prolog
# configuration in .../pl/src/configure.
#
# It can be used to configure and make the add-on packages.  
################################################################
.EXPORT_ALL_VARIABLES:

# Define the packages you wish to build.  Please note that xpce requires
# libXPM and libjpeg to compile

PKG=	clib \
	table \
	sgml \
	sgml/RDF \
	xpce

# Define additional config options.  If you wish to build the multi-threaded
# version of SWI-Prolog and pl-mt to the same install-base, you must provide
# --enable-mt here.

#CNFG=	--enable-mt

################################################################
# Normally, all should be fine below here
################################################################

# Values filled from the main SWI-Prolog configure

prefix=@prefix@
PL=@PL@@RT@
PLVERSION=@PLVERSION@
PLBASE=$(prefix)/lib/@PL@-$(PLVERSION)
PKGDOC=$(PLBASE)/doc/packages
PLLIBS=@LIBS@
PLARCH=@ARCH@
PLLDFLAGS=@LDFLAGS@
PLINCL=$(shell dirname `pwd`)/include
PLSHARED=@PLSHARED@
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@

# How to run configure.  We pass the information required from SWI-Prolog
# in the environment.  All configure scripts in the packages are designed
# to trust the environment if they find $PLINCL.  Otherwise they run Prolog
# to find the required parameters.

CONFIG=	env PL="$(PL)" PLBASE="$(PLBASE)" PLARCH="$(PLARCH)" \
	    PLLIBS="$(PLLIBS)" PLLDFLAGS="$(PLLDFLAGS)" \
	    PLINCL="$(PLINCL)" PLSHARED="$(PLSHARED)" \
	    ./configure $(CNFG) --prefix=$(prefix)

all:	objects
	
objects::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) ); fi; \
        done
	
install::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done

rpm-install: html-install
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done
	
pdf-install::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done
	
html-install::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done
	$(INSTALL_DATA) index.html $(PKGDOC)
	
configure::
	@echo "**********************"
	@echo "* Configuring packages $(PKG)"
	@echo "**********************"
	@for p in $(PKG); do \
	    if [ -r $$p/configure ]; then \
	        echo "**********************"; \
		echo "* Package $$p"; \
		echo "**********************"; \
	        ( cd $$p && $(CONFIG) ); \
	    fi; \
        done
	
distclean::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done

clean::
	for p in $(PKG); do \
	    if [ -r $$p/Makefile ]; then ( cd $$p && $(MAKE) $@ ); fi; \
        done

