# Make file for Scintilla on Windows
# Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
# The License.txt file describes the conditions under which this software may be distributed.
# This makefile assumes the mingw32 version of GCC 2.95.3 is used and changes will
# be needed to use other compilers.
# The -fvtable-thunks option is required for older (2.9*) versions of gcc but can be removed
# safely if using a newer version which may display warning messages.

.SUFFIXES: .cxx
# added by Mitchell
ifdef LINUX
CC = i486-mingw32-g++
DLLWRAP = i486-mingw32-dllwrap
DEL = rm
GCC = i486-mingw32-gcc
RANLIB = i486-mingw32-ranlib
WINDRES = i486-mingw32-windres
else
# end added by Mitchell
CC = g++
DLLWRAP = dllwrap
DEL = del /q
# added by Mitchell
GCC = gcc
RANLIB = ranlib
WINDRES = windres
endif
# end added by Mitchell

COMPONENT = ../bin/Scintilla.dll
LEXCOMPONENT = ../bin/SciLexer.dll
LEXLIB = Lexers.a

ifndef NOTHUNKS
gversion = $(word 1,$(subst ., ,$(shell g++ --version)))
ifeq ($(gversion),2)
THUNKFLAGS=-fvtable-thunks
endif
endif

vpath %.h ../src ../include
vpath %.cxx ../src
vpath %.c ../../scite/lua/src ../../scite/lua/src/lib # added by Mitchell

LDFLAGS=-mwindows -lstdc++ -limm32 -lole32 -luuid -mno-cygwin
# Add -MMD to get dependencies
#CXXFLAGS = -g -pg -pedantic -Os -fno-exceptions -fvtable-thunks -fno-rtti
INCLUDEDIRS=-I ../include -I ../src -I ../../scite/lua/include # modified by Mitchell
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -pedantic $(INCLUDEDIRS) $(THUNKFLAGS) -fno-rtti -mno-cygwin

ifdef DEBUG
CXXFLAGS=-DDEBUG -g $(CXXBASEFLAGS)
else
CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS)
STRIPFLAG=-s
endif

# added by Mitchell
LUA_CORE_OBJS = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
		lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \
		ltable.o ltm.o lundump.o lvm.o lzio.o

LUA_LIB_OBJS =	lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o ltablib.o \
		lstrlib.o loadlib.o loslib.o linit.o lpeg.o

LUA_OBJS = $(LUA_CORE_OBJS) $(LUA_LIB_OBJS)

vpath %.c ../lua/src ../lua/src/lib
# end added by Mitchell

.cxx.o:
	$(CC) $(CXXFLAGS) -c $<

# added by Mitchell
.c.o:
	$(GCC) $(INCLUDEDIRS) $(THUNKFLAGS) -mno-cygwin -c $< -o $@
# end added by Mitchell

ALL:	$(COMPONENT) $(LEXCOMPONENT) $(LEXLIB) ScintillaWinS.o WindowAccessor.o

clean:
	$(DEL) *.exe *.o *.obj *.dll *.res *.map

deps:
	$(CC) -MM $(CXXFLAGS) *.cxx ../src/*.cxx >deps.mak

# modified by Mitchell
#++Autogenerated -- run src/LexGen.py to regenerate
#**LEXOBJS=\\\n\(\*.o \)
LEXOBJS=\
LexLPeg.o
#--Autogenerated -- end of automatically generated section
# end modified by Mitchell

SOBJS	= ScintillaWin.o ScintillaBase.o Editor.o CharClassify.o Decoration.o \
	Document.o ContractionState.o CellBuffer.o CallTip.o \
	ScintRes.o PlatWin.o PositionCache.o KeyMap.o Indicator.o LineMarker.o RESearch.o RunStyles.o \
	Selection.o Style.o ViewStyle.o AutoComplete.o UniConversion.o PropSet.o XPM.o PerLine.o $(LUA_OBJS) # modified by Mitchell
$(COMPONENT): $(SOBJS) Scintilla.def
	$(DLLWRAP) --add-stdcall-alias --target i386-mingw32 -o $@ $(SOBJS) $(LDFLAGS) $(STRIPFLAG) --relocatable

LOBJS	= ScintillaWinL.o ScintillaBaseL.o Editor.o CharClassify.o Decoration.o \
	Document.o ContractionState.o CellBuffer.o CallTip.o \
	ScintRes.o PlatWin.o PositionCache.o KeyMap.o Indicator.o LineMarker.o RESearch.o RunStyles.o \
	Selection.o Style.o ViewStyle.o AutoComplete.o UniConversion.o KeyWords.o \
	DocumentAccessor.o PropSet.o ExternalLexer.o StyleContext.o XPM.o PerLine.o $(LEXOBJS) $(LUA_OBJS) # modified by Mitchell
$(LEXCOMPONENT): $(LOBJS) Scintilla.def
	$(DLLWRAP) --add-stdcall-alias --target i386-mingw32 -o $@ $(LOBJS) $(LDFLAGS) $(STRIPFLAG) --relocatable

$(LEXLIB): $(LEXOBJS)
	$(AR) rc $@ $^
	$(RANLIB) $@ # modified by Mitchell

# Automatically generate dependencies for most files with "make deps"
include deps.mak

# These dependencies are maintained by hand as they do not use the default output name
ScintillaBaseL.o: ScintillaBase.cxx Platform.h Scintilla.h SciLexer.h \
 ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \
 LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \
 ScintillaBase.h PropSet.h Accessor.h DocumentAccessor.h \
 KeyWords.h ExternalLexer.h PerLine.h
ScintillaWinL.o: ScintillaWin.cxx Platform.h Scintilla.h SciLexer.h \
 ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \
 LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \
 ScintillaBase.h PropSet.h Accessor.h KeyWords.h \
 ExternalLexer.h UniConversion.h PerLine.h
ScintillaWinS.o: ScintillaWin.cxx Platform.h Scintilla.h \
 ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \
 LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \
 ScintillaBase.h UniConversion.h PerLine.h

ScintillaBaseL.o:
	$(CC) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@

ScintillaWinS.o:
	$(CC) $(CXXFLAGS) -D STATIC_BUILD -c $< -o $@

ScintillaWinL.o:
	$(CC) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@

ScintRes.o:	ScintRes.rc PlatformRes.h
	$(WINDRES) ScintRes.rc $@ # modified by Mitchell

