#
#   Makefile.fpc for Free Pascal WinCE RTL
#

[package]
main=rtl

[target]
units=$(SYSTEMUNIT) fpintres ctypes objpas macpas iso7185 strings \
      lineinfo heaptrc \
      windows messages dynlibs \
      dos objects \
      rtlconsts sysconst sysutils \
      typinfo types fgl classes \
      strutils convutils math dateutils \
      varutils variants fmtbcd \
      matrix ucomplex \
      charset getopts winsock winsock2 sockets \
      cmem sharemem
#    initc  signals \
#    crt graph \
#    wincrt winmouse winevent  printer \
#    video mouse keyboard \
#    winsysut

# rsts=math varutils typinfo variants classes dateutils sysconst
implicitunits=exeinfo

# fake dll
# programs=fpcmemdll

[require]
nortl=y

[install]
fpcpackage=y

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

[compiler]
includedir=$(INC) $(PROCINC) $(RTL)/win
sourcedir=$(INC) $(PROCINC) $(COMMON)


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

UNITPREFIX=rtl

SYSTEMUNIT=system
PRT0=wprt0

# 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]
.NOTPARALLEL:
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) winres.inc


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

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

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 $(WININC)/messages.inc windows$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
        $(COMPILER) -I$(WININC) messages.pp

#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.pas windows$(PPUEXT) rtlconsts$(PPUEXT) sysconst$(PPUEXT) sysutils$(PPUEXT)

#
# TP7 Compatible RTL Units
#

dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) windows$(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)/sysutils/*.inc) \
                    objpas$(PPUEXT) dos$(PPUEXT) windows$(PPUEXT) sysconst$(PPUEXT)
        $(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp

classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
                   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT) \
		   sysconst$(PPUEXT) fgl$(PPUEXT)
        $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp

fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) sysutils$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/fgl.pp

#winsysut$(PPUEXT) : winsysut.pp sysutils$(PPUEXT)
#        $(COMPILER) winsysut.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) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
                    $(OBJPASDIR)/varutilh.inc varutils.pp sysutils$(PPUEXT)
        $(COMPILER) -Fi$(OBJPASDIR) varutils.pp

variants$(PPUEXT) : $(INC)/variants.pp varutils$(PPUEXT) sysutils$(PPUEXT) sysconst$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT)
        $(COMPILER) -Fi$(INC) $(INC)/variants.pp

fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) variants$(PPUEXT) classes$(PPUEXT) system$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/fmtbcd.pp

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

rtlconsts$(PPUEXT) : objpas$(PPUEXT) $(OBJPASDIR)/rtlconsts.pp
        $(COMPILER) $(OBJPASDIR)/rtlconsts.pp

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

dateutils$(PPUEXT) : $(OBJPASDIR)/dateutils.pp
        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutils.pp

convutils$(PPUEXT) : $(OBJPASDIR)/convutils.pp
        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/convutils.pp

strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp
        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/strutils.pp

#
# Mac Pascal Model
#

macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT)
        $(COMPILER) $(INC)/macpas.pp $(REDIR)

#
# Other system-independent RTL Units
#

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

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

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

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

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

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

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

#
# Other system-dependent RTL Units
#

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

sharemem$(PPUEXT) : $(WINDIR)/sharemem.pp system$(PPUEXT)

fpcmemdll.dll : $(WINDIR)/fpcmemdll.pp system$(PPUEXT)

