# Make file for SciTE on Windows
# Copyright 1998-2002 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.

.SUFFIXES: .cxx
CC = g++
DLLWRAP = dllwrap

PROG	= ../bin/SciTE.exe
PROGSTATIC = ../bin/Sc1.exe

vpath %.h ../src ../../scintilla/include ../../scintilla/win32
vpath %.cxx ../src
vpath %.o ../../scintilla/win32

LDFLAGS=-mwindows -lcomctl32 -limm32 -lole32 -luuid
#CXXFLAGS = -W -Wall
#CXXFLAGS = -g -pg -pedantic -Os -fno-exceptions -fvtable-thunks -fno-rtti
INCLUDEDIRS=-I ../../scintilla/include -I ../../scintilla/win32 -I ../src
RCINCLUDEDIRS=--include-dir ../../scintilla/win32 --include-dir ../src
CXXBASEFLAGS = -W -Wall -pedantic $(INCLUDEDIRS) -Os -fno-exceptions -fvtable-thunks -fno-rtti

ifdef DEBUG
CXXFLAGS=-DDEBUG $(CXXBASEFLAGS)
else
CXXFLAGS=-DNDEBUG $(CXXBASEFLAGS)
endif

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

LEXOBJS	= LexAda.o LexAVE.o LexBaan.o LexBullant.o LexConf.o LexCPP.o \
 LexCrontab.o LexEiffel.o LexHTML.o LexLisp.o LexLua.o LexOthers.o \
 LexPascal.o LexPerl.o LexPython.o LexRuby.o LexSQL.o LexVB.o
OBJS	= SciTEBase.o SciTEBuffers.o SciTEIO.o Exporters.o SciTEProps.o \
SciTEWin.o SciTEWinBar.o SciTEWinDlg.o WindowAccessor.o \
PropSet.o PlatWin.o UniConversion.o SciTERes.o DirectorExtension.o

DLLS=..\bin\Scintilla.dll ..\bin\SciLexer.dll

PROPS=..\bin\SciTEGlobal.properties ..\bin\abbrev.properties \
..\bin\ada.properties ..\bin\ave.properties ..\bin\baan.properties \
..\bin\bullant.properties ..\bin\conf.properties \
..\bin\cpp.properties ..\bin\eiffel.properties ..\bin\html.properties \
..\bin\latex.properties ..\bin\lisp.properties ..\bin\lua.properties \
..\bin\nncrontab.properties ..\bin\others.properties \
..\bin\ruby.properties ..\bin\pascal.properties ..\bin\perl.properties ..\bin\python.properties \
..\bin\sql.properties ..\bin\tcl.properties ..\bin\vb.properties

LEXPROPS=\
..\bin\ada.properties ..\bin\ave.properties ..\bin\ave.properties \
..\bin\bullant.properties ..\bin\conf.properties \
..\bin\cpp.properties ..\bin\eiffel.properties ..\bin\html.properties \
..\bin\latex.properties ..\bin\lisp.properties ..\bin\lua.properties \
..\bin\nncrontab.properties ..\bin\others.properties \
..\bin\ruby.properties ..\bin\pascal.properties ..\bin\perl.properties \
..\bin\python.properties ..\bin\sql.properties ..\bin\tcl.properties \
..\bin\vb.properties

ALL:	$(PROG) $(PROGSTATIC) $(DLLS) $(PROPS)

clean:
	del /q *.exe *.o *.obj *.dll *.res *.map

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

..\bin\Scintilla.dll:	..\..\scintilla\bin\Scintilla.dll
	copy ..\..\scintilla\bin\Scintilla.dll $@

..\bin\SciLexer.dll:	..\..\scintilla\bin\SciLexer.dll
	copy ..\..\scintilla\bin\SciLexer.dll $@

..\bin\SciTEGlobal.properties:	..\src\SciTEGlobal.properties
	copy $^ $@
..\bin\abbrev.properties:	..\src\abbrev.properties
	copy $^ $@
..\bin\ada.properties:	..\src\ada.properties
	copy $^ $@
..\bin\ave.properties:	..\src\ave.properties
	copy $^ $@
..\bin\baan.properties:	..\src\baan.properties
	copy $^ $@
..\bin\bullant.properties:	..\src\bullant.properties
	copy $^ $@
..\bin\conf.properties:	..\src\conf.properties
	copy $^ $@
..\bin\cpp.properties:	..\src\cpp.properties
	copy $^ $@
..\bin\eiffel.properties:	..\src\eiffel.properties
	copy $^ $@
..\bin\html.properties:	..\src\html.properties
	copy $^ $@
..\bin\latex.properties:	..\src\latex.properties
	copy $^ $@
..\bin\lisp.properties:	..\src\lisp.properties
	copy $^ $@
..\bin\lua.properties:	..\src\lua.properties
	copy $^ $@
..\bin\nncrontab.properties:	..\src\nncrontab.properties
	copy $^ $@
..\bin\others.properties:	..\src\others.properties
	copy $^ $@
..\bin\ruby.properties:	..\src\ruby.properties
	copy $^ $@	
..\bin\pascal.properties:	..\src\pascal.properties
	copy $^ $@
..\bin\perl.properties:	..\src\perl.properties
	copy $^ $@
..\bin\python.properties:	..\src\python.properties
	copy $^ $@
..\bin\sql.properties:	..\src\sql.properties
	copy $^ $@
..\bin\tcl.properties:	..\src\tcl.properties
	copy $^ $@
..\bin\vb.properties:	..\src\vb.properties
	copy $^ $@

# Normally distributed rather than built as may not have grep on all machines
# Copy all non-comment lines from all the properties files into one combined file
..\src\Embedded.properties: $(PROPS)
	fgrep -G -v -h "^#" $(PROPS) >..\src\Embedded.properties

$(PROG): $(OBJS)
	$(CC) "-Wl,-s" -Xlinker --subsystem -Xlinker windows -o  $@ $^ $(LDFLAGS)

OBJSSTATIC = Sc1.o SciTEWinBar.o SciTEWinDlg.o SciTEBase.o SciTEBuffers.o \
	SciTEIO.o Exporters.o SciTEProps.o ScintillaWinL.o ScintillaBaseL.o Editor.o \
	WindowAccessor.o DocumentAccessor.o KeyWords.o ExternalLexer.o StyleContext.o\
	$(LEXOBJS) PropSet.o \
	ContractionState.o Document.o CellBuffer.o CallTip.o Sc1Res.o PlatWin.o \
	UniConversion.o KeyMap.o Indicator.o LineMarker.o RESearch.o Style.o \
	ViewStyle.o AutoComplete.o DirectorExtension.o

$(PROGSTATIC): $(OBJSSTATIC)
	$(CC) "-Wl,-s" -Xlinker --subsystem -Xlinker windows -o $@ $^ $(LDFLAGS)

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

Sc1.o: SciTEWin.cxx SciTEWin.h SciTE.h Accessor.h WindowAccessor.h KeyWords.h PropSet.h \
 SString.h Scintilla.h Extender.h SciTEBase.h
	$(CC) $(CXXFLAGS) -D STATIC_BUILD -c $< -o $@

SciTERes.o:	SciTERes.rc SciTE.h PlatformRes.h
	windres $(RCINCLUDEDIRS) SciTERes.rc $@

# Also depends on ../src/Embedded.properties but may not want to build everywhere
# so must explicitly ask to build it.
Sc1Res.o:	SciTERes.rc SciTE.h PlatformRes.h
	windres $(RCINCLUDEDIRS) SciTERes.rc --define STATIC_BUILD $@

