#
#   Makefile.fpc for Go32v2 RTL
#

[targets]
loaders=prt0 exceptn fpu
units=$(SYSTEMUNIT) objpas strings \
      go32 dpmiexcp initc ports profile dxeload emu387 \
      dos crt objects printer graph \
      sysutils math typinfo \
      cpu mmx getopts heaptrc lineinfo \
      msmouse
rst=math

[require]
rtl=0

[defaults]
defaulttarget=go32v2
defaultcpu=i386

[install]
unitsubdir=rtl

[dirs]
fpcdir=.
incdir=$(INC) $(PROCINC)
targetdir=.


[presettings]
RTL=..
INC=../inc
PROCINC=../$(CPU_TARGET)

UNITPREFIX=rtl

# Paths
OBJPASDIR=$(RTL)/objpas
GRAPHDIR=$(INC)/graph

# Define Go32v2 Units
SYSTEMUNIT=system

# Insert exception handler in system unit
ifdef EXCEPTIONS_IN_SYSTEM
override FPCOPT+=-dEXCEPTIONS_IN_SYSTEM
endif

# Insert exception handler in system unit
ifdef NO_EXCEPTIONS_IN_SYSTEM
override FPCOPT+=-dNO_EXCEPTIONS_IN_SYSTEM
endif

[postsettings]
SYSTEMPPU=$(addsuffix $(PPUEXT),$(SYSTEMUNIT))

# Get the system independent include file names.
# This will set the following variables :
# SYSINCNAMES
include $(INC)/makefile.inc
SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))

# Get the processor dependent include file names.
# This will set the following variables :
# CPUINCNAMES
include $(PROCINC)/makefile.cpu
SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))

# Put system unit dependencies together.
SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)


[rules]
vpath %$(PASEXT) $(INC) $(PROCINC)

#
# Loaders
#

prt0$(OEXT) : v2prt0.as
        $(AS) -o prt0$(OEXT) v2prt0.as

#
# System Units (System, Objpas, Strings)
#

$(SYSTEMPPU) : system.pp $(SYSDEPS)
        $(COMPILER) -Us -Sg system.pp $(REDIR)

objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMPPU)
        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)

strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
                   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
                   $(SYSTEMPPU)

#
# System Dependent Units
#

go32$(PPUEXT) : go32.pp $(SYSTEMPPU)

dpmiexcp$(PPUEXT) : dpmiexcp.pp exceptn$(OEXT) $(SYSTEMPPU)
        $(COMPILER) -Sg dpmiexcp.pp $(REDIR)

initc$(PPUEXT) : initc.pp $(SYSTEMPPU)

profile$(PPUEXT) : profile.pp dpmiexcp$(PPUEXT) go32$(PPUEXT)

dxeload$(PPUEXT) : dxeload.pp $(SYSTEMPPU)

emu387$(PPUEXT) : emu387.pp fpu$(OEXT) strings$(PPUEXT) dxeload$(PPUEXT) \
                  dpmiexcp$(PPUEXT)

ports$(PPUEXT) : ports.pp objpas$(PPUEXT) $(SYSTEMPPU)

#
# TP7 Compatible RTL Units
#

dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \
               go32$(PPUEXT) strings$(PPUEXT) $(SYSTEMPPU)

crt$(PPUEXT) : crt.pp $(INC)/textrec.inc go32$(PPUEXT) $(SYSTEMPPU)

objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU)

printer$(PPUEXT) : printer.pp $(SYSTEMPPU)

#
# Graph
#

include $(GRAPHDIR)/makefile.inc
GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES))

graph$(PPUEXT) : graph.pp go32$(PPUEXT) ports$(PPUEXT) $(SYSTEMPPU) \
                 $(GRAPHINCDEPS) vesa.inc vesah.inc dpmi.inc
        $(COMPILER) -I$(GRAPHDIR) graph.pp $(REDIR)

#
# Delphi Compatible Units
#

sysutils$(PPUEXT) : $(OBJPASDIR)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
                    filutil.inc disk.inc objpas$(PPUEXT) dos$(PPUEXT) go32$(PPUEXT)
        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/sysutils.pp $(REDIR)

typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
        $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp $(REDIR)

math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/math.pp $(REDIR)

#
# Other system-independent RTL Units
#

cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)

mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)

getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU)

heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMPPU)
        $(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)

lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMPPU)


#
# Other system-dependent RTL Units
#

msmouse$(PPUEXT) : msmouse.pp $(SYSTEMPPU)
