include ../Makefile.conf

MODULES=SAwt.o SGPrimitive.o SGEngine.o SWindow.o SColor.o \
 SImage.o SPen.o SCanvas.o SRedrawEvent.o \
 SFont.o SFontImpl.o SFontTTF.o SFontOTF.o SFontBDF.o SUniFont.o \
 SFontFB.o SFontNative.o SPostscript.o \
 SPrinter.o SAccelerator.o SScriptProcessor.o  \
 SSyntaxColors.o

TARGETDIR=
TARGETOBJS=

ifeq ($(SWINDOWS),X11)
TARGETDIR:=$(TARGETDIR) SX11
ifeq ($(USE_X11),-DUSE_X11=1)
TARGETOBJS:=sx11/SX11Impl.o sx11/SX11Window.o \
 sx11/SX11Color.o sx11/SX11Font.o \
 sx11/SXInputMethod.o sx11/SXEventHandler.o 
endif
CPPFLAGS:=$(CPPFLAGS) $(SWINDOW_FLAGS) 
endif

ifeq ($(SWINDOWS),WIN32)
TARGETDIR:=$(TARGETDIR) swin32
TARGETOBJS:=SWin32.o
CPPFLAGS:=$(CPPFLAGS) 
endif


ifeq ($(SPLATFORM),WINDOWS)
OBJS=$(subst .o,.obj,$(MODULES)) $(subst .o,.obj,$(TARGETOBJS))
#OBJS:=$(subst /,\,$(OBJS))
TARGET=swindow.lib
else
OBJS=$(MODULES) $(TARGETOBJS)
TARGET=libswindow.a
endif


all: $(TARGET)

#
# The cl drops its lib here
#
swindow.lib: $(OBJS)
	$(AR)$@ $(subst swin32/,,$(OBJS))

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

sx11/%.o:sx11/%.cpp
	$(CXX) -c -o $@ $(HAVE_LOCALE) $(NEED_SET_IM_VALUES_PROTO) $(HAVE_SET_IM_VALUES) $(CPPFLAGS) $(patsubst %.o,%.cpp,$@)

%.o:%.cpp
	$(CXX) -c $(CPPFLAGS) $(subst .o,.cpp,$@)

%.obj:%.cpp
	$(CXX) -c $(CPPFLAGS) $(subst .obj,.cpp,$@)

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

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

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

install:

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