#
# Main makefile for fpk - pascal under Linux
#

#
# Begin of configurable section. All configurable stuff is set here.
#
# Begin of MANDATORY configuration.
# These things you MUST set, or compilation will not succeed.

# Uncomment this if you want a C-linked system.
# LINK_TO_C=YES

# Uncomment this if you have an AOUT system.
# AOUT = -DAOUT

# Set here the path (no trailing slash) to libgcc.a
# YOU MUST CHECK THIS IF YOU WANT A C-LINKED SYSTEM !!
GCCLIBPATH = /usr/lib/gcc-lib/i486-linux/2.6.3

# end of Mandatory configuration.
####################################################################
# The following can be set to suit your taste.
# Defaults are:
#  - program in /usr/local/bin
#  - libraries and units in /usr/lib/ppc
#  - Version support
#  - No machine support
#  - used units are the ones in the sources. (must be compiled first)
#  - docs compile using latex
#  - html version of docs using latex2html -ascii_mode -no_reuse -split 2

# Where to install the program ?
# This directory will just contain a link to the actual compiler, 
# which will be located in the library directory (see below)
# The default is set to /usr/bin in compiler/Makefile
# PROGINSTALLDIR = /usr/local/bin

# Where to install the rtl libs ?
# The default is set to /usr/lib/ppc in rtl/linux/Makefile 
# LIBINSTALLDIR = /usr/local/lib/ppc

# Uncomment the following if you DON'T want version support 
# version support will create the libraries in a subdirectory which 
# contains the version nr.
# i.e. /usr/lib/ppc/0.9.1/ or the like. (this is the default)
# VERSIONSUPPORT=NO

# Uncomment the following if you want machine support
# This will create the libraries in a subdirectory which contains
# the processor type i.e. /usr/lib/0.9.1/i386 or the like.
# MACHINESUPPORT=YES

# What kind of processor do you have ? (if left empty, defaults to i386)
# PROCESSOR=i386
# PROCESSOR=i486
# PROCESSOR=pentium

# Which libraries to use for the compiler ?
# default are the libraries in rtl/linux
# UNITDIR =../rtl/linux 

# What is the latex program ? (default set to 'latex' in docs subdirectory)
# LATEX = latex

# What is the dvips program ? (default set to 'dvips' in docs subdirectory)
# DVIPS = dvips

# What is the latex2html program ? (default : latex2HTML)
# LATEX2HTML = latex2html

# What options do you want to give it ?
# default : -ascii_mode -split 2 -no_reuse
# LATEX2HTMLOPTS = -ascii_mode -split 0 -no_reuse

#
# End of configurable section. Do not edit after this line.
#
#########################################################################

#define the version
VERSION=0.9.1

# Set the library directory correctly.

# Do we have versionsupport ?
# default is yes
ifndef VERSIONSUPPORT
VERSIONSUPPORT=YES
endif

ifeq ($(VERSIONSUPPORT),YES)
ifndef LIBINSTALLDIR
LIBINSTALLDIR=/usr/lib/ppc
endif
LIBINSTALLDIR:=$(LIBINSTALLDIR)/$(VERSION)
endif

# Do we have machine support ?
ifeq ($(MACHINESUPPORT),YES)
ifndef LIBINSTALLDIR
LIBINSTALLDIR=/usr/lib/ppc
endif
# default we have i386
ifndef PROCESSOR
PROCESSOR=i386
endif
LIBINSTALLDIR:=$(LIBINSTALLDIR)/$(PROCESSOR)
endif

export AOUT INSTALL PROGINSTALLDIR LIBINSTALLDIR UNITDIR GCCLIBPATH LINK_TO_C \
       LATEX LATEX2HTML LATEX2HTMLOPTS

.PHONY : all compiler rtl clean install help units dvi html cleandoc

SUBDIRS= rtl compiler units

help:
	@echo 'Possible targets:'
	@echo ' rtl      : Compile the run-time library.'
	@echo ' compiler : Compile the compiler.'
	@echo ' units    : Compile the units.'
	@echo ' all      : All of the above.'
	@echo ' install  : Install everything in the proper places.'
	@echo ' clean    : clean up the mess.'
	@echo ' dvi      : Make available documentation. (using LaTeX)'
	@echo ' ps       : Make available documentation. (using dvips)'
	@echo ' html     : Make available documentation. (using latex2html)'
	@echo ' cleandoc : Clean documentation directory.'

all: doall
	@echo
	@echo Do a 'Make install' to install everything in the proper places.
	@echo

doall:
	@for f in $(SUBDIRS); do  cd $$f; $(MAKE) all; cd .. ;done

compiler :
	cd compiler; $(MAKE) all

rtl :
	cd rtl; $(MAKE) all

units : 
	cd units; $(MAKE) units

clean :
	@for f in $(SUBDIRS); do  cd $$f; $(MAKE) clean; cd .. ;done

install : doall
	@for f in $(SUBDIRS); do cd $$f; $(MAKE) install; cd ..; done

dvi :
	cd docs; $(MAKE) dvi

html :
	cd docs; $(MAKE) html

ps :
	cd docs; $(MAKE) ps

cleandoc :
	cd docs; $(MAKE) clean