#
# Copyright 2009 Vasilkin Andrey <digi@os2.snc.ru>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#   1. Redistributions of source code must retain the above copyright notice,
#      this list of conditions and the following disclaimer.
#
#   2. Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
#
#   3. The name of the author may not be used to endorse or promote products
#      derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

DLL_NAME = ndplqt

INCPATH = $(%WATCOM)\H\$(PLATFORM);$(%WATCOM)\H;..\h

OBJS = ndlqt.obj resource.obj

CFLAGS = -i=$(INCPATH) -bd -bt=os2 -q -d0 -s -bm -w=2

!ifeq DEBUG 1
CFLAGS += -dDEBUG_CODE -dDEBUG_FILE="ndplqt.log"
LQPIPELIB=lqlibd.lib
BINPATH = ..\..\bin\debug
!else
LQPIPELIB=lqlib.lib
BINPATH = ..\..\bin
!endif

$(DLL_NAME).dll: $(OBJS) $(DLL_NAME).lnk
  wlink @$(DLL_NAME).lnk
  rc16 -n -i h $*.rc $@ >nul
  copy $@ $(BINPATH)

$(DLL_NAME).lnk: $(OBJS)
  @%create $@
  @%append $@ op quiet, maxerrors=100, manyautodata
  @%append $@ form os2 dll initinstance terminstance lx
  @%append $@ libpath $(%WATCOM)\lib386;$(%WATCOM)\lib386\OS2;..\lqlib
  @%append $@ lib $(LQPIPELIB)
  @%append $@ name $(DLL_NAME)
  @for %f in ($(OBJS)) do @%append $@ file %f
  @%append $@ export  NdpTypes			= _NdpTypes
  @%append $@ export  NdpPropertiesInfo		= _NdpPropertiesInfo
  @%append $@ export  NdpAttribute		= _NdpAttribute
  @%append $@ export  NdpPluginLoad
  @%append $@ export  NdpPluginFree
  @%append $@ export  NdpMountResource
  @%append $@ export  NdpFreeResource
  @%append $@ export  NdpCreateConnection
  @%append $@ export  NdpFreeConnection
  @%append $@ export  NdpRsrcCompare
  @%append $@ export  NdpRsrcUpdate
  @%append $@ export  NdpRsrcQueryInfo
  @%append $@ export  NdpRsrcQueryFSAttach
  @%append $@ export  NdpRsrcQueryFSAllocate
  @%append $@ export  NdpQueryPathInfo
  @%append $@ export  NdpDeletePathInfo
  @%append $@ export  NdpDiscardResourceData
  @%append $@ export  NdpRefresh
  @%append $@ export  NdpSetPathInfo
  @%append $@ export  NdpEAQuery
  @%append $@ export  NdpEASet
  @%append $@ export  NdpEASize
  @%append $@ export  NdpSetCurrentDir
  @%append $@ export  NdpCopy
  @%append $@ export  NdpCopy2
  @%append $@ export  NdpForceDelete
  @%append $@ export  NdpCreateDir
  @%append $@ export  NdpFindStart
  @%append $@ export  NdpMove
  @%append $@ export  NdpMove2
  @%append $@ export  NdpChangeCase
  @%append $@ export  NdpRename
  @%append $@ export  NdpOpenExisting
  @%append $@ export  NdpOpenReplaceL
  @%append $@ export  NdpOpenCreateL
  @%append $@ export  NdpDeleteDir
  @%append $@ export  NdpSetFileAttribute
  @%append $@ export  NdpFlush
  @%append $@ export  NdpIOCTL
  @%append $@ export  NdpFileQueryInfo
  @%append $@ export  NdpFileEAQuery
  @%append $@ export  NdpFileEASet
  @%append $@ export  NdpFileEASize
  @%append $@ export  NdpFileSetInfo
  @%append $@ export  NdpFileSetFilePtrL
  @%append $@ export  NdpFileClose
  @%append $@ export  NdpFileCommit
  @%append $@ export  NdpFileNewSizeL
  @%append $@ export  NdpFileRead
  @%append $@ export  NdpFileWrite

.c.obj:
  wcc386 $(CFLAGS) $<


install: .SYMBOLIC
  nd.exe plugin remove $(DLL_NAME).ndp
  nd.exe plugin install $(DLL_NAME).ndp

clean: .SYMBOLIC
  @if exist *.obj del *.obj
  @if exist *.map del *.map
  @if exist *.err del *.err
  @if exist $(DLL_NAME).lnk del $(DLL_NAME).lnk
  @if exist $(DLL_NAME).dll del $(DLL_NAME).dll
  @if exist $(DLL_NAME).res del $(DLL_NAME).res
