#
#   Makefile.fpc for Free Pascal Linux RTL
#

[targets]
loaders=prt0 cprt0 gprt0 cprt21 gprt21
units=$(SYSTEMUNIT) objpas strings \
      linux ports initc \
      dos crt objects printer graph ggigraph \
      sysutils typinfo math \
      cpu mmx getopts heaptrc lineinfo \
      errors sockets gpm ipc serial
rst=math

[require]
rtl=0

[defaults]
defaulttarget=linux
defaultcpu=i386

[install]
unitsubdir=rtl

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

[libs]
libname=libfprtl.so
libversion=1.0
libunits=$(SYSTEMUNIT) objpas strings \
      linux ports \
      dos crt objects printer \
      sysutils typinfo math \
      cpu mmx getopts heaptrc \
      errors sockets ipc


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

UNITPREFIX=rtl

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

# Define Go32v2 Units
SYSTEMUNIT=syslinux

# Use new graph unit ?
# NEWGRAPH=YES
# Use LibGGI ?
# Use
#
ifndef USELIBGGI
USELIBGGI=NO
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) : $(CPU_TARGET)/prt0.as
        $(AS) -o prt0$(OEXT) $(CPU_TARGET)/prt0.as

gprt0$(OEXT) : $(CPU_TARGET)/gprt0.as
        $(AS) -o gprt0$(OEXT) $(CPU_TARGET)/gprt0.as

cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
        $(AS) -o cprt0$(OEXT) $(CPU_TARGET)/cprt0.as

cprt21$(OEXT) : $(CPU_TARGET)/cprt21.as
        $(AS) -o cprt21$(OEXT) $(CPU_TARGET)/cprt21.as

# still need to use gprt1, because gprt21 crashes
gprt21$(OEXT) : $(CPU_TARGET)/gprt0.as
        $(AS) -o gprt21$(OEXT) $(CPU_TARGET)/gprt0.as


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

$(SYSTEMPPU) : syslinux.pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
        $(COMPILER) -Us -Sg syslinux.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
#

linux$(PPUEXT) : linux.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
                 syscalls.inc systypes.inc sysconst.inc timezone.inc $(SYSTEMPPU) \
                 linsysca.inc

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

#
# TP7 Compatible RTL Units
#

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

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

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

printer$(PPUEXT) : printer.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)

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

graph$(PPUEXT) : graph.pp linux$(PPUEXT) $(SYSTEMPPU) \
                 $(GRAPHINCDEPS) vgagraph16.inc
        $(COMPILER) -I$(GRAPHDIR) graph.pp $(REDIR)

ggigraph$(PPUEXT) : ggigraph.pp linux$(PPUEXT) $(SYSTEMPPU) \
                 $(GRAPHINCDEPS)
        $(COMPILER) -I$(GRAPHDIR) ggigraph.pp $(REDIR)

#
# Delphi Compatible Units
#

sysutils$(PPUEXT) : $(OBJPASDIR)/sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
                    filutil.inc disk.inc objpas$(PPUEXT) linux$(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)

gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/gettext.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
#

sockets$(PPUEXT) : sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
                   linux$(PPUEXT) $(SYSTEMPPU)

errors$(PPUEXT) : errors.pp strings$(PPUEXT) $(SYSTEMPPU)

ipc$(PPUEXT) : ipc.pp linux$(PPUEXT) $(SYSTEMPPU)
