# debug, e.g.:    nmake /f Makefile32 clean && nmake /f Makefile32
# release, e.g.:  nmake /f Makefile32 clean && nmake /f Makefile32 RELEASE=1
# 32-bit version, rgf, 2009-09-07, adapted for dbus on 2011-08-17
#                 rgf, 2014-08-06


# rgf, 2011-09-20
# DBUS_HOME       = e:\programme\dbus

# rgf, 2014-08-07
# DBUS_HOME       = e:\programme\dbus-20140807
DBUS_HOME       = e:\programme\dbus-20150418
DBUS_INCLUDE    = $(DBUS_HOME)\include
DBUS_LIB_HOME   = $(DBUS_HOME)\lib

LIB = $(LIB);$(DBUS_LIB_HOME)

INC_PATH        = .;$(DBUS_INCLUDE)
INCLUDE = $(INCLUDE);$(INC_PATH)
OP_SYS          = -DWINDOWS
# <--- rgf


# What we are going to build
all: dbusoorexx-32.dll

!IF DEFINED(REXX_HOME)
INCLUDE = $(INCLUDE);$(REXX_HOME)\api
LIB = $(LIB);$(REXX_HOME)\api
!ENDIF

REXX_LIBS = rexx.lib rexxapi.lib
DBUS_LIB  = dbus-1.lib WS2_32.lib

WARNINGFLAGS = /W3       /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE

DEF_FILE = /def:dbusoorexx-32.def

!IF DEFINED(RELEASE)
# Set the compile and link flags for a release build
# OOREXX_CFLAGS = /nologo /EHsc /O2 /Gs /FAcs /MT /showIncludes $(WARNINGFLAGS) -DWINDOWS -DDBUSOOREXX_32 /c
OOREXX_CFLAGS = /nologo /EHsc /O2 /Gs /FAcs /MT $(WARNINGFLAGS) -DWINDOWS -DDBUSOOREXX_32 /c
DLL_LFLAGS = /nologo /SUBSYSTEM:Windows $(REXX_LIBS) $(DBUS_LIB) $(DEF_FILE) /DLL
!ELSE # release not defined
# Set the compile and link flags for a debug build
OOREXX_CFLAGS =  /nologo /EHsc /Zi /Od /MTd $(WARNINGFLAGS) -DWINDOWS -DDBUSOOREXX_32 /c
DLL_LFLAGS = /nologo /DEBUG -debugtype:cv /SUBSYSTEM:Windows $(REXX_LIBS) $(DBUS_LIB) $(DEF_FILE) /DLL
!ENDIF


dbusoorexx-32.dll: dbusoorexx-32.obj
    @echo "DLL_LFLAGS :" $(DLL_LFLAGS)
    @echo begin-LIB---
    @echo $(LIB)
    @echo begin-LINK---
    @echo link $(DLL_LFLAGS) $(@B).obj -out:$(@B).dll
    @echo start---
    link $(DLL_LFLAGS) $(@B).obj -out:$(@B).dll
    @echo end---
    copy $(@B).dll ..
    copy $(@B).dll dbusoorexx.dll
    copy $(@B).dll ..\install\libs
    @if exist $(@B).exp copy $(@B).exp dbusoorexx.exp > nul
    @if exist $(@B).ilk copy $(@B).ilk dbusoorexx.ilk > nul
    @if exist $(@B).lib copy $(@B).lib dbusoorexx.lib > nul
    @if exist $(@B).obj copy $(@B).obj dbusoorexx.obj > nul
    @if exist $(@B).pdb copy $(@B).pdb dbusoorexx.pdb > nul



dbusoorexx-32.obj: dbusoorexx.cc
  @echo "OOREXX_CFLAGS:" $(OOREXX_CFLAGS)
  @echo --begin--compile
  @echo cl $(OOREXX_CFLAGS) /Fo$(@B).obj dbusoorexx.cc
  @echo --start--compile
  cl $(OOREXX_CFLAGS) /Fo$(@B).obj dbusoorexx.cc
  @echo --end--compile

mostlyclean:
	del *.obj *.ilk *.lib *.exp  *.cod *.res *.map 1>nul 2>&1

clean:
  attrib -h *.suo 1>nul 2>&1
	del *.exe *.dll *.obj *.ilk *.pdb *.lib *.exp *.suo *.cod *.res *.sln *.map 1>nul 2>&1

