#
#   Makefile.fpc for Free Pascal Netware RTL
#

[package]
main=rtl

[target]
loaders=nwpre prelude
units=$(SYSTEMUNIT) objpas strings \
      netware os_types winsock2 \
      dos crt objects \
      sysutils typinfo math \
      cpu mmx getopts heaptrc lineinfo \
      sockets aio varutils \
      video mouse keyboard types
rsts=math typinfo varutils

[require]
nortl=y

[install]
fpcpackage=y

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

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


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

UNITPREFIX=rtl

ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
SYSTEMUNIT=system
else
SYSTEMUNIT=sysnetwa
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

# for netware always use multithread
override FPCOPT+=-dMT

# and alway use smartlinking
CREATESMART=1

# Paths
OBJPASDIR=$(RTL)/objpas


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

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

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

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

$(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp nwsys.inc $(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
#

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

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

winsock2$(PPUEXT) : winsock2.pp qos.inc netware$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) os_types$(PPUEXT)

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

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

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

#
# Delphi Compatible Units
#

sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
                    objpas$(PPUEXT) dos$(PPUEXT) nwsys.inc
        $(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
        
gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
        $(COMPILER) $(OBJPASDIR)/gettext.pp

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

types$(PPUEXT) : $(OBJPASDIR/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
	$(COMPILER) $(OBJPASDIR)/types.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)

#
# Other system-dependent RTL Units
#

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

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

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

#
# Netware-.imp files need to be installed in the unit-dir
#
override INSTALLPPUFILES+=nwimp/aio.imp nwimp/aio.imp nwimp/audnlm32.imp \
nwimp/calnlm32.imp nwimp/ccs.imp nwimp/ccs-os.imp nwimp/clibaux.imp \
nwimp/clibctx.imp nwimp/clib.imp nwimp/clxnlm32.imp nwimp/dplsv386.imp \
nwimp/dsapi.imp nwimp/dsevent.imp nwimp/fpsm.imp nwimp/lib0.imp \
nwimp/locnlm32.imp nwimp/ndpsrpc.imp nwimp/netnlm32.imp nwimp/nit.imp \
nwimp/nlmlib.imp nwimp/nwpsrv3x.imp nwimp/nwpsrv.imp nwimp/nwsnut.imp \
nwimp/requestr.imp nwimp/socklib.imp nwimp/streams.imp nwimp/threads.imp \
nwimp/tli.imp nwimp/vollib.imp nwimp/ws2_32.imp nwimp/ws2nlm.imp

# the smartlinked objects will not be installed by the
# standard makefile ????

#override UNITPPUFILES+=cpu.a crt.a dos.a getopts.a heaptrc.a keyboard.a \
#lineinfo.a math.a mmx.a mouse.a netware.a objects.a objpas.a sockets.a \
#strings.a system.a sysutils.a typinfo.a varutils.a video.a winsock2.a