#
#   Makefile.fpc for Free Pascal Win32 RTL
#

[package]
main=rtl

[target]
loaders=wprt0 wdllprt0 gprt0
units=$(SYSTEMUNIT) systhrds objpas strings \
      lineinfo heaptrc \
      windows ole2 activex winsock initc \
      dos crt objects graph messages \
      sysutils typinfo math varutils variants \
      cpu mmx charset ucomplex getopts \
      wincrt winmouse winevent sockets printer dynlibs \
      video mouse keyboard types comobj
rsts=math varutils typinfo

[require]
nortl=y

[install]
fpcpackage=y

[default]
fpcdir=../..
target=win32

[compiler]
includedir=$(INC) $(PROCINC)
sourcedir=$(INC) $(PROCINC)
targetdir=.


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

UNITPREFIX=rtl

ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
SYSTEMUNIT=system
PRT0=wprt0
override FPCOPT+=-dMT
else
SYSTEMUNIT=syswin32
PRT0=wprt0_10
endif

# Use new feature from 1.0.5 version
# that generates release PPU files
# which will not be recompiled
ifdef RELEASE
override FPCOPT+=-Ur
endif

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

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

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


[rules]
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)


#
# Loaders
#

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

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


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

$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp win32.inc $(SYSDEPS)
        $(COMPILER) -Us -Sg $(SYSTEMUNIT).pp

systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT)

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

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

#
# System Dependent Units
#

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

messages$(PPUEXT): messages.pp $(SYSTEMUNIT)$(PPUEXT)
        $(COMPILER) -I$(WININC) messages.pp

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

activex$(PPUEXT) : activex.pp $(WININC)/objbase.inc windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

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

winsock$(PPUEXT) : winsock.pp windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

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

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

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

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

dynlibs$(PPUEXT) : $(INC)/dynlibs.pp windows$(PPUEXT)

#
# TP7 Compatible RTL Units
#

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

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

objects$(PPUEXT) : $(INC)/objects.pp $(SYSTEMUNIT)$(PPUEXT)

#
# Graph
#

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

graph$(PPUEXT) : graph.pp strings$(PPUEXT) windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
                 $(GRAPHINCDEPS)
        $(COMPILER) -I$(GRAPHDIR) graph.pp


#
# Delphi Compatible Units
#

sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
                    objpas$(PPUEXT) dos$(PPUEXT) windows$(PPUEXT)
        $(COMPILER) -I$(OBJPASDIR) sysutils.pp

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

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

varutils$(PPUEXT) : varutils.pp $(OBJPASDIR)/cvarutil.inc \
                    objpas$(PPUEXT) $(OBJPASDIR)/varutilh.inc
        $(COMPILER) -I$(OBJPASDIR) varutils.pp

types$(PPUEXT) : $(OBJPASDIR/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/types.pp

comobj$(PPUEXT) : comobj.pp activex$(PPUEXT) sysutils$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(OBJPASDIR)/comobjh.inc $(OBJPASDIR)/comobj.inc
        $(COMPILER) -I$(OBJPASDIR) comobj.pp

#
# Other system-independent RTL Units
#

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

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

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

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

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

charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)

ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

#
# Other system-dependent RTL Units
#

callspec$(PPUEXT) : $(INC)/callspec.pp $(SYSTEMUNIT)$(PPUEXT)