include ../Makefile.conf

MODULES=SExcept.o SObject.o SShared.o SHShared.o SBVector.o \
  SBHashtable.o SString.o SUniqueID.o SStringVector.o SProperties.o \
  SEvent.o SEventBSD.o SIO.o SIOStream.o SCharClass.o \
  SConfig.o SBMap.o SUniMap.o SEncoder.o SMatrix.o \
  STextIndex.o SCursorIndex.o SEmbedState.o SGlyph.o SParagraph.o \
  STextData.o SUtil.o SAutogen.o SDimension.o SLocation.o \
  SLineCurve.o SHWConverter.o SCluster.o SBiDi.o SRendClass.o \
  SRectangle.o 


SENC_OBJS= sencoder/SBEncoder.o \
  sencoder/SB_UTF8.o \
  sencoder/SB_Java.o \
  sencoder/SB_UTF7.o \
  sencoder/SB_Generic.o \
  sencoder/SB_ISO2022_JP.o \
  sencoder/SB_ISO2022_JP3.o \
  sencoder/SB_EUC_JP.o \
  sencoder/SB_X11_JP.o \
  sencoder/SB_S_JIS.o  \
  sencoder/SB_X11_HZ.o \
  sencoder/SB_GB2312_8.o \
  sencoder/SB_HZ.o  \
  sencoder/SB_X11_KSC.o \
  sencoder/SB_EUC_KR.o \
  sencoder/SB_UHC.o  \
  sencoder/SB_Johab.o  \
  sencoder/SB_BIG5.o \
  sencoder/SB_UCS2.o \
  sencoder/SB_UInput.o  \
  sencoder/SB_DeShape.o  \
  sencoder/SB_NCR.o  \
  sencoder/SB_GB18030.o  \
  sencoder/SB_S_JIS0213.o  \
  sencoder/SB_EUC_JP0213.o  \
  sencoder/SB_BiDi.o  

SREGEX_OBJS= \
  syntax/SSyntax.o \
  syntax/SSyntaxMarker.o \
  syntax/SMatcher.o \
  syntax/SPattern.o \
  syntax/SHunspellPattern.o

SSEDY_OBJS= \
  sedy/SSedy.o 

# Can not distribute source code for cryptos, they can be added as so
# to binary or compiled from source.
ifeq ($(wildcard ../addon/yudit_sedy/yudit_sedy.h),../addon/yudit_sedy/yudit_sedy.h)
SEDY_CPPFLAGS=-DSEDY_BUILT_IN=1
else
SEDY_CPPFLAGS=-DSEDY_BUILT_IN=0
endif


ifeq ($(SPLATFORM),WINDOWS)
OBJS=$(subst .o,.obj,$(MODULES)) $(patsubst sencoder/%.o,%.obj,$(SENC_OBJS)) $(patsubst syntax/%.o,%.obj,$(SREGEX_OBJS)) $(patsubst sedy/%.o,%.obj,$(SSEDY_OBJS))
TARGET=stoolkit.lib
else
OBJS=$(MODULES) $(SENC_OBJS) $(SREGEX_OBJS) $(SSEDY_OBJS)
TARGET=libstoolkit.a
endif


all: $(TARGET)

stoolkit.lib: $(OBJS)
	$(AR)$@ $(OBJS)

libstoolkit.a: $(OBJS)
	$(AR) $@ $(OBJS)
	$(RANLIB) $@      

sencoder/%.o:sencoder/%.cpp
	$(CXX) -c -o $@ $(CPPFLAGS) $(patsubst %.o,%.cpp,$@)

syntax/%.o:syntax/%.cpp
	$(CXX) -c -o $@ $(CPPFLAGS) $(patsubst %.o,%.cpp,$@)

sedy/%.o:sedy/%.cpp
	$(CXX) -c -o $@ $(SEDY_CPPFLAGS) $(CPPFLAGS) $(patsubst %.o,%.cpp,$@)

%.o:%.cpp
	$(CXX) -c -DYUDIT_DATA=\"$(YUDIT_DATA)\" $(CPPFLAGS) $(subst .o,.cpp,$@)

%.obj:%.cpp
	$(CXX) -c -DYUDIT_DATA=\"$(YUDIT_DATA)\" $(CPPFLAGS) $(subst .obj,.cpp,$@)

%.obj:sencoder/%.cpp
	$(CXX) -c $(CPPFLAGS) $(patsubst %.obj,sencoder/%.cpp,$@)

%.obj:syntax/%.cpp
	$(CXX) -c $(CPPFLAGS) $(patsubst %.obj,syntax/%.cpp,$@)

%.obj:sedy/%.cpp
	$(CXX) -c $(SEDY_CPPFLAGS) $(CPPFLAGS) $(patsubst %.obj,sedy/%.cpp,$@)

depend:
	$(CXX) -M  $(CPPFLAGS)  $(patsubst %.o,%.cpp,$(OBJS)) > .depend

clean: 
	rm -f *.o  *.obj $(TARGET) sencoder/*.o sencoder/*.obj syntax/*.o syntax/*.obj sedy/*.o sedy/*.obj

install:

ifeq (.depend, $(wildcard .depend))
include .depend
endif
