# 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 3.2 is used and changes will
# be needed to use other compilers.

ifdef TERM
# Assume that any defined TERM implies cygwin.
CYGWIN = 1
endif

.SUFFIXES: .cxx
CC = g++
DLLWRAP = dllwrap
ifndef CYGWIN
DEL = del /q
COPY = copy
else
DEL = rm
COPY = cp
endif

PROG	= ../../../bin/sdlB.exe
PROGSTATIC = ../../../bin/sdlBasic.exe

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

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


INCLUDEDIRS=-I ../scintilla/include -I ../scintilla/win32 -I ../src
RCINCLUDEDIRS=--include-dir ../scintilla/win32 --include-dir ../src

CBASEFLAGS = -W -Wall $(INCLUDEDIRS) -mno-cygwin

ifdef DEBUG
CFLAGS=-DDEBUG -g $(CBASEFLAGS)
else
CFLAGS=-DNDEBUG -Os $(CBASEFLAGS)
STRIPFLAG="-Wl,-s"
endif

CXXFLAGS = $(CFLAGS) -pedantic -fno-exceptions $(THUNKFLAGS) -fno-rtti -mno-cygwin

LDFLAGS=-mwindows -lcomctl32 -limm32 -lole32 -luuid -mno-cygwin

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

.c.o:
	gcc $(CFLAGS) -c $< -o $@

OTHER_OBJS	= SciTEBuffers.o SciTEIO.o Exporters.o SciTEProps.o \
SciTEWin.o SciTEWinBar.o SciTEWinDlg.o MultiplexExtension.o \
UniqueInstance.o WindowAccessor.o \
PropSet.o PlatWin.o UniConversion.o Utf8_16.o SciTERes.o \
DirectorExtension.o XPM.o

OBJS = SciTEBase.o $(OTHER_OBJS)

#++Autogenerated -- run scintilla/src/LexGen.py to regenerate
#**1:LEXPROPS=\\\n\(..\\bin\\\* \)
LEXPROPS=..\bin\others.properties ..\bin\vb.properties ..\bin\sdlbasic.properties

#--Autogenerated -- end of automatically generated section
PROPS=..\share\sdlBasic\SciTEGlobal.properties ..\share\sdlBasic\vb.properties ..\share\sdlBasic\sdlbasic.properties

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

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

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


$(PROG): $(OBJS)
	$(CC) $(STRIPFLAG) -Xlinker --subsystem -Xlinker windows -o  $@ $^ $(LDFLAGS)

OBJSSTATIC = Sc1.o SciTEWinBar.o SciTEWinDlg.o MultiplexExtension.o \
	UniqueInstance.o SciTEBase.o SciTEBuffers.o \
	SciTEIO.o Exporters.o SciTEProps.o  Editor.o \
	DocumentAccessor.o KeyWords.o ExternalLexer.o \
	ContractionState.o CellBuffer.o CallTip.o Sc1Res.o PlatWin.o \
	Utf8_16.o KeyMap.o Indicator.o LineMarker.o RESearch.o \
	AutoComplete.o DirectorExtension.o MultiplexExtension.o  \
	Lexers.a Document.o DocumentAccessor.o ScintillaWinL.o ScintillaBaseL.o PropSet.o Style.o StyleContext.o UniConversion.o ViewStyle.o WindowAccessor.o XPM.o

$(PROGSTATIC): $(OBJSSTATIC)
	$(CC) $(STRIPFLAG) -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 $@

# Make sure SciTEBase gets rebuilt (so its about box gets a new
# date stamp) when any of the other objects are updated.
SciTEBase.o: $(OTHER_OBJS)
