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

# Generate all "normal" flavors

All : /libs/asyncio.library $(PRAGMA) /lib/asynciolibs.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

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

$(OBJ) : $(SRC)
	Dcc -c -DASIO_SHARED_LIB -o %(left) %(right)


# Keep the pragma file up to date

$(PRAGMA) : asyncio_lib.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 : asyncio_lib.fd
	Resident Dcc:Bin/Das
	fdtolib -o%(left) %(right) -auto asyncio.library
	Resident Das REMOVE

# This only generates autoinitcode for some odd reason. Thus, you can use the
# above library if you need it.
/lib/asynciolibsr.lib : asyncio_lib.fd
	Resident Dcc:Bin/Das
	fdtolib -o%(left) %(right) -mr -hasynciolibsr.h -auto asyncio.library
	Resident Das REMOVE


# 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
