# Makefile for Scintilla in Pythonwin
#
# Simply recursively calls the real scintilla makefile
# (but with special macros) and generates the .py
# from the .h's

!IFDEF DEBUG
DIR_O = ..\Build\Temp\Scintilla\Debug
!ELSE
DIR_O = ..\Build\Temp\Scintilla\Release
!ENDIF

DIR_BIN = ..\Build

PYTHON = python

# Relative to the subdirectory for the sub-makefile
!ifndef SUB_DIR_BIN
SUB_DIR_BIN = ..\$(DIR_BIN)
!endif
!ifndef SUB_DIR_O
SUB_DIR_O=..\$(DIR_O)
!endif

!IFDEF DEBUG
SCINTILLA_DLL = $(SUB_DIR_BIN)\Scintilla_d.dll
!ELSE
SCINTILLA_DLL = $(SUB_DIR_BIN)\Scintilla.dll
!ENDIF

all: Scintilla

clean:
  cd win32 && $(MAKE) /$(MAKEFLAGS) -f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) clean && cd ..

Scintilla:
  @if not exist $(DIR_O) md $(DIR_O)
  @if not exist $(DIR_BIN) md $(DIR_BIN)
  @set DEBUG=$(DEBUG)
  @set CL=$(CL) /nologo
  @set LINK=$(LINK) /nologo
  where cl
  set INCLUDE
  @cd win32 && $(MAKE) /$(MAKEFLAGS) /f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) LEXCOMPONENT=$(SCINTILLA_DLL) COMPONENT=dummy $(SCINTILLA_DLL) && cd ..

scintillacon.py: Include\Scintilla.h Include\SciLexer.h
  $(PYTHON) ..\..\Win32\scripts\h2py.py Include\scintilla.h
  $(PYTHON) ..\..\Win32\scripts\h2py.py Include\scilexer.h
  type scintilla.py > ..\pywin\scintilla\scintillacon.py
  type scilexer.py >> ..\pywin\scintilla\scintillacon.py
  del scintilla.py scilexer.py
