#
#   Makefile.fpc for Free Pascal Win32 RTL
#

[targets]
loaders=wprt0 wdllprt0
units=$(SYSTEMUNIT) objpas strings \
      windows ole2 opengl32 os_types winsock initc \
      dos crt objects graph \
      sysutils typinfo math \
      cpu mmx getopts heaptrc lineinfo \
      wincrt winmouse sockets printer
rst=math

[require]
rtl=0

[defaults]
defaulttarget=win32
defaultcpu=i386

[install]
unitsubdir=rtl

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


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

UNITPREFIX=rtl

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

SYSTEMUNIT=syswin32

# Files used by windows.pp
include $(WININC)/makefile.inc

WINDOWS_SOURCE_FILES=$(addprefix $(WININC)/,$(addsuffix .inc,$(WINDOWS_FILES)))


[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
#

override AS=asw

wprt0$(OEXT) : wprt0.as
        $(AS) -o wprt0$(OEXT) wprt0.as

wdllprt0$(OEXT) : wdllprt0.as
        $(AS) -o wdllprt0$(OEXT) wdllprt0.as


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

$(SYSTEMPPU) : syswin32.pp win32.inc $(SYSDEPS)
        $(COMPILER) -Us -Sg syswin32.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
#

windows$(PPUEXT) : windows.pp $(WINDOWS_SOURCE_FILES) $(SYSTEMPPU)
        $(COMPILER) -I$(WININC) windows.pp $(REDIR)

ole2$(PPUEXT) : ole2.pp windows$(PPUEXT) $(SYSTEMPPU)

opengl32$(PPUEXT) : opengl32.pp windows$(PPUEXT) $(SYSTEMPPU)

os_types$(PPUEXT) : $(INC)/os_types.pp

winsock$(PPUEXT) : winsock.pp windows$(PPUEXT) $(SYSTEMPPU) os_types$(PPUEXT)

sockets$(PPUEXT) : sockets.pp windows$(PPUEXT) winsock$(PPUEXT) $(SYSTEMPPU) \
                   $(INC)/sockets.inc $(INC)/socketsh.inc

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

wincrt$(PPUEXT) : wincrt.pp $(SYSTEMPPU) windows$(PPUEXT) graph$(PPUEXT)

winmouse$(PPUEXT) : winmouse.pp $(SYSTEMPPU) windows$(PPUEXT) graph$(PPUEXT)

#
# TP7 Compatible RTL Units
#

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

crt$(PPUEXT) : crt.pp $(INC)/textrec.inc $(SYSTEMPPU) objpas$(PPUEXT) dos$(PPUEXT) windows$(PPUEXT)

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

#
# Graph
#

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

graph$(PPUEXT) : graph.pp strings$(PPUEXT) windows$(PPUEXT) $(SYSTEMPPU) \
                 $(GRAPHINCDEPS)
        $(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) windows$(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
#
