# Make file for Scintilla on Linux or compatible OS
# Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
# The License.txt file describes the conditions under which this software may be distributed.
# This makefile assumes GCC 3.1 is used and changes will be needed to use other compilers.
# GNU make does not like \r\n line endings so should be saved to CVS in binary form.
# Builds for GTK+ 2 if available else GTK+ 1.
# To force GTK+ 2 build, define GTK2 on the make command line.
# To force GTK+ 1 build, define GTK1 on the make command line.

.SUFFIXES: .cxx .c .o .h .a
CC = g++
CCOMP = gcc
AR = ar
RANLIB = touch

ifeq ($(shell uname),Darwin)
RANLIB = ranlib
endif

COMPLIB=../bin/scintilla.a

vpath %.h ../src ../include
vpath %.cxx ../src

INCLUDEDIRS=-I ../include -I ../src -I ../../scite/lua/include # modified by mitchell
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -pedantic -Os -DGTK -DSCI_LEXER $(INCLUDEDIRS)

ifdef NOTHREADS
THREADFLAGS=-DG_THREADS_IMPL_NONE
else
THREADFLAGS=
endif

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

# If explicit setting of GTK1 or GTK2 then use that else look for
# pkg-config which is an OK indication that GTK2 is available
ifdef GTK2
CONFIGFLAGS:=$(shell pkg-config --cflags gtk+-2.0)
MARSHALLER=scintilla-marshal.o
else
ifdef GTK1
CONFIGFLAGS:=$(shell gtk-config --cflags)
else
ifneq (,$(findstring /,$(shell whereis pkg-config)))
CONFIGFLAGS:=$(shell pkg-config --cflags gtk+-2.0)
MARSHALLER=scintilla-marshal.o
else
CONFIGFLAGS:=$(shell gtk-config --cflags)
endif
endif
endif

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

# 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

all: $(COMPLIB)

clean:
	rm -f *.o $(COMPLIB)

deps:
	$(CC) -MM $(CONFIGFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak

$(COMPLIB): DocumentAccessor.o WindowAccessor.o KeyWords.o StyleContext.o \
	CharClassify.o Decoration.o Document.o PerLine.o CallTip.o \
	ScintillaBase.o ContractionState.o Editor.o ExternalLexer.o PropSet.o PlatGTK.o \
	KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o ViewStyle.o \
	RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
	$(MARSHALLER) $(LEXOBJS)
	$(AR) rc $@ $^
	$(RANLIB) $@

# Automatically generate header dependencies with "make deps"
include deps.mak
