#
# DMakeFile for asyncio library. Both shared library and normal library models.
#
#
# Does not generate all flavors; only the basic ones:
#   Normal arguments, smalldata
#   Registered arguments, smalldata
#
# Should be easy to modify below to generate other flavors, if needed.
#

SRC = Lib.c CloseAsync.c OpenAsync.c OpenAsyncFH.c OpenAsyncFromFH.c ReadAsync.c \
      ReadCharAsync.c RecordAsyncFailure.c RequeuePacket.c SeekAsync.c SendPacket.c \
      WaitPacket.c WriteAsync.c WriteCharAsync.c

OBJ = $(SRC:*.?:*.o)

PRAGMA = /include/pragmas/asyncio_pragmas.h
FD     = /include/fd/asyncio_lib.fd

# Generate all "normal" flavors

All : /libs/asyncio.library $(PRAGMA) /lib/asynciolibs.lib /lib/asynciolibsr.lib /lib/asyncios.lib /lib/asynciosr.lib


# The only difference when making the shared library is that Lib.c is included
# (MUST be first), and that SHARED_LIB is defined. It only affects another define
# in the (private) include file async.h
#
# The only things used in miscsr.lib link library (which I've made, but not
# included here) are a few replacement functions for things available in the
# normal DICE link libraries. Here it is some replacement functions for long
# divide/multiply that uses utility.library instead. Thus, you can use the
# DICE romsr.lib library instead, with the only difference that the linked
# library becomes a tad larger.

/libs/asyncio.library : $(OBJ)
	DLink -o %(left) %(right) miscsr.lib

$(OBJ) : $(SRC)
	Dcc -c -R -mRR -proto -l0 -ms2 -mi -DASIO_SHARED_LIB -o %(left) %(right)


# Does this dependancy look odd to you? Well, it is a bit odd, but it need to
# be written like this, in order to avoid a bug in DMake. If "$(SRC) : async.h"
# was used instead, DMake would recompile the files that _didn't_ need it, and
# ignore the ones that _did_ need it. ;)

$(OBJ) : async.h


# Keep the pragma file up to date

$(PRAGMA) : $(FD)
	FDTOPragma -o%(left) %(right)


# Link libraries for use with the shared version of the library. Only needed if
# the -mi option isn't used, or you use the autoinit stuff.

/lib/asynciolibs.lib : $(FD)
	FDToLib -o%(left) %(right) -auto asyncio.library

/lib/asynciolibsr.lib : $(FD)
	FDToLib -o%(left) %(right) -mr -hasynciolibsr.h -auto asyncio.library

# Large data models of the above two libraries. Not generated per default.

/lib/asynciolibs.lib : $(FD)
	FDToLib -o%(left) %(right) -auto asyncio.library -md

/lib/asynciolibsr.lib : $(FD)
	FDToLib -o%(left) %(right) -mr -hasynciolibsr.h -auto asyncio.library -md


# Here the normal link library versions are generated. See lib.def for more information.

/lib/asyncios.lib :
	LbMake asyncio s

/lib/asynciosr.lib :
	LbMake asyncio s r

# Other flavours, not generated per default

/lib/asynciol.lib :
	LbMake asyncio l

/lib/asynciorl.lib :
	LbMake asyncio l r

/lib/asyncioes.lib :
	LbMake asyncio s e

/lib/asyncioesr.lib :
	LbMake asyncio s r e

/lib/asyncioel.lib :
	LbMake asyncio l e

/lib/asyncioelr.lib :
	LbMake asyncio l r e

/lib/asynciolp.lib :
	LbMake asyncio l p

/lib/asynciolrp.lib :
	LbMake asyncio l r p

/lib/asyncioesp.lib :
	LbMake asyncio s p e

/lib/asyncioesrp.lib :
	LbMake asyncio s r p e

/lib/asyncioelp.lib :
	LbMake asyncio l p e

/lib/asyncioelrp.lib :
	LbMake asyncio l r p e

/lib/asynciosp.lib :
	LbMake asyncio s p

/lib/asynciosrp.lib :
	LbMake asyncio s r p

