# Note: PACKAGE_DATA_DIR and PACKAGE_LOCALE_DIR are no longer used on Windows.

DEFINES = -DHAVE_CONFIG_H \
	-DGEANY_DATADIR=\"data\" \
	-DGEANY_LOCALEDIR=\"share\" \
	-DGEANY_LIBDIR=\"\" \
	-DGEANY_PREFIX=\"\"

.SUFFIXES: .c .o .h .a
WINDRES = windres.exe
CC = gcc
CXX = g++
RES  = ../geany_private.res
TARGET = ../geany.exe
EXECDIR = c:\distrib
PREFIX = C:\libs
RM = del
-include ../localwin32.mk

GTK_INCLUDES= \
	-I$(PREFIX)/include/gtk-2.0 \
	-I$(PREFIX)/lib/gtk-2.0/include \
	-I$(PREFIX)/include/atk-1.0 \
	-I$(PREFIX)/include/pango-1.0 \
	-I$(PREFIX)/include/cairo \
	-I$(PREFIX)/include/glib-2.0 \
	-I$(PREFIX)/lib/glib-2.0/include \
	-I$(PREFIX)/include/gettext \
	-I$(PREFIX)/include

INCLUDEDIRS=  -I.. \
              -I../scintilla/include \
              -I../tagmanager/include \
              $(GTK_INCLUDES)

ALL_GTK_LIBS= \
	-L"$(PREFIX)/lib" \
	-lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 \
	-lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
	# these things are for GTK >= 2.8
	# (should be same as with MSYS: pkg-config --libs gtk+-2.0 gthread-2.0)
	#"$(PREFIX)/lib/libcairo.dll.a" \
	#"$(PREFIX)/lib/asprintf.lib" \
	#"$(PREFIX)/lib/charset.lib" \

ifdef GTK280
ALL_GTK_LIBS +=-liconv
else
ALL_GTK_LIBS +=-lcairo -lpangocairo-1.0 -lgio-2.0
endif

WIN_LIBS=-mwindows -lkernel32 -limm32 -lshfolder -lshell32 \
		 -lole32 -luuid -lcomdlg32 -lcomctl32 -liberty -lwsock32

CBASEFLAGS=-Wall -pipe -mms-bitfields $(DEFINES) $(INCLUDEDIRS)
ifdef DEBUG
CFLAGS=-O0 -g $(CBASEFLAGS)
DEFINES += -DGEANY_DEBUG
else
CFLAGS=-O2 $(CBASEFLAGS)
endif

OBJS =	about.o build.o callbacks.o dialogs.o document.o editor.o encodings.o filetypes.o \
		geanyentryaction.o geanymenubuttonaction.o geanyobject.o geanywraplabel.o highlighting.o \
		interface.o keybindings.o keyfile.o \
		log.o main.o msgwindow.o navqueue.o notebook.o plugins.o prefs.o printing.o project.o \
		queue.o sciwrappers.o search.o socket.o stash.o \
		symbols.o templates.o toolbar.o tools.o treeviews.o \
		ui_utils.o utils.o win32.o

.c.o:
	$(CC) $(CFLAGS) -c $<

# all: binclean $(TARGET) #exec
all: $(TARGET)

$(RES): ../geany_private.rc ../pixmaps/geany.ico
	$(WINDRES) -i $< --input-format=rc -o $@ -O coff

# this calls parent clean-local target because del ../file won't work
clean:
	-$(RM) deps.mak *.o
	cd .. && $(MAKE) -f makefile.win32 clean-local && cd src

exec:
	$(EXECDIR)\geany.exe

binclean:
	$(RM) $(TARGET)

$(TARGET): $(OBJS) $(RES) ../scintilla/scintilla.a ../tagmanager/tagmanager.a
	$(CXX) $(OBJS) $(RES) -o $(TARGET) \
	../scintilla/scintilla.a ../tagmanager/tagmanager.a $(ALL_GTK_LIBS) \
	 $(WIN_LIBS)

deps.mak:
	$(CC) -MM  $(CFLAGS) *.c >deps.mak

# Generate header dependencies with "make deps.mak"
include deps.mak

..\localwin32.mk:
	echo # Set local variables here >$@
