#==============================================================================
# Makefile
#
# OS/2 Makefile to build the ODBC driver for PostGreSQL
#
# written 1997 by Dirk Ohme
#==============================================================================
# includes
#==============================================================================
include ..\..\Config.mk
include ..\..\Version.mk
#==============================================================================
# Site specific configuration (OS/2) -> normally set by autoconf (Config.mk)
#==============================================================================
## [BEGIN]
#
# option switches
# (do not remove the lines starting with "##" !!!)
#
# debug mode: select this to enable debugging of the software
##-DEBUG_MODE=Y
#
# list mode: select this (and DEBUG_MODE) to create a list file of each *.c
##-LIST_MODE=Y
#
## [END]
#==============================================================================

#---| definitions |------------------------------------------------------------
NAME     = libpgres
OBJECTS  = connect.obj errclass.obj connectp.obj execute.obj transact.obj\
 prepare.obj wraper.obj dll.obj tuple.obj pgtypes.obj setup.obj options.obj\
 globals.obj results.obj info.obj sockio.obj postodbc.obj

#---| compiler |---------------------------------------------------------------
CC       = icc
!ifndef BCPP
!  ifdef VACPP
CFLAGS   = /c /DOS2 /DVACPP /D$(ODBC) /G5 /Gd- /Ge- /Gf /Gi /Gm /Gs- /I.\
/I..\..\include /O /Ol /Q /Se /Ss+ /W1
!  else
CFLAGS   = /c /DOS2 /D$(ODBC) /G4 /Gd- /Ge- /Gf /Gi /Gm /Gs- /I.\
/I..\..\include /Q /Se /Ss+
!  endif
!else
CFLAGS   = /c /DOS2 /DBCPP /D$(ODBC) /I. /I..\..\include
!endif

CEXTRA   = /DVERSION="\"$(VERSION)$(EXTVER)\""

RC       = rc
RC_1st   = rc -r

#---| linker |-----------------------------------------------------------------
!ifdef VACPP
LN       = ilink
LFLAGS   = /nofree /dll /e /noi /nol /packc /packd /pm:PM /se:1024 /st:32768
LN_END   =
!else
LN       = link386
LFLAGS   = /noi /nol /pm:PM /se:1024 /st:32768
LN_END   = ;
!endif

#---| libraries |--------------------------------------------------------------
!ifdef mSQL
LIBS     = mSQL-1.x\mSQL.lib so32dll.lib tcp32dll.lib
!else
LIBS     = mSQL-2.x\mSQL.lib so32dll.lib tcp32dll.lib
!endif

#---| debugging |--------------------------------------------------------------
!ifdef DEBUG_MODE
!  ifdef LIST_MODE
DEBUG    = /DDEBUG /Le /Ls /Ti+
LDEBUG   = /deb
!  else
DEBUG    = /DDEBUG /Ti+
LDEBUG   = /deb
!  endif
!else
DEBUG    =
LDEBUG   =
!endif

#---| library tool |-----------------------------------------------------------
!ifdef VACPP
AR       = ilib
!else
AR       = lib
!endif
ARFLAGS  = /noe /noi /nol
IMPLIB   = implib
IFLAGS   = /nol

#---| dependencies |-----------------------------------------------------------
.c.obj:
         $(CC) $(DEBUG) $(CFLAGS) $(CEXTRA) $*.c

#---| global dependencies |----------------------------------------------------
all:     $(NAME).DLL
clean:
         @if exist *.lst       del *.lst
         @if exist *.obj       del *.obj
         @if exist *.res       del *.res
delete:  clean
         @if exist *.def       del *.def
         @if exist *.dll       del *.dll
delete_all: delete

#---| local dependencies |-----------------------------------------------------
$(NAME).def: ..\..\lib\odbc.def
        @echo ; $(NAME).def                      >  $(NAME).def
        @echo LIBRARY LIBPGRES                   >> $(NAME).def
        @echo DESCRIPTION 'PostGreSQL iODBC driver' >> $(NAME).def
        @type ..\..\lib\odbc.def | find " POSTGRES " >> $(NAME).def

dll.res: dll.rc dll.h
         $(RC_1st) dll

$(NAME).DLL: $(OBJECTS) $(NAME).def dll.res
         $(LN) $(LFLAGS) $(LDEBUG) $(OBJECTS), $(NAME).dll, nul,\
$(LIBS), $(NAME).def $(LN_END)
         $(RC) dll.res $(NAME).dll
         @if exist ..\..\lib\$(NAME).dll del ..\..\lib\$(NAME).dll
         @copy $(NAME).dll ..\..\lib /b
#         $(IMPLIB) $(IFLAGS) ..\..\LIB\$(NAME).lib $(NAME).def

#==============================================================================
