# HG changeset patch
# Node ID 6e8a87e8d4c8
# Parent  5407cbf3c5dd
diff --git a/libpurple/Makefile.mingw b/libpurple/Makefile.mingw
--- a/libpurple/Makefile.mingw
+++ b/libpurple/Makefile.mingw
@@ -118,8 +118,11 @@
 			win32/win32dep.c
 
 RC_SRC = win32/libpurplerc.rc
+OBJECTS = $(C_SRC:%.c=%.o) $(RC_SRC:%.rc=%.o)
 
-OBJECTS = $(C_SRC:%.c=%.o) $(RC_SRC:%.rc=%.o)
+PC_SRC = data/purple.pc.in data/purple-uninstalled.pc.in \
+	 data/purple-2.pc.in data/purple-2-uninstalled.pc.in
+PC_FILES = $(PC_SRC:%.pc.in=%.pc)
 
 ##
 ## LIBRARIES
@@ -141,7 +144,7 @@
 ##
 .PHONY: all install install_shallow clean
 
-all: $(TARGET).dll
+all: $(TARGET).dll $(PC_FILES)
 	$(MAKE) -C $(PURPLE_PROTOS_TOP) -f $(MINGW_MAKEFILE)
 	$(MAKE) -C $(PURPLE_PLUGINS_TOP) -f $(MINGW_MAKEFILE)
 
@@ -172,6 +175,8 @@
 clean:
 	rm -f $(OBJECTS) $(RC_SRC) $(PURPLE_VERSION_H) $(PURPLE_PURPLE_H)
 	rm -f $(TARGET).dll $(TARGET).dll.a $(TARGET).def
+	rm -f data/pidgin.pc data/pidgin-uninstalled.pc
+	rm -f data/pidgin-2.pc data/pidgin-2-uninstalled.pc
 	$(MAKE) -C $(PURPLE_PROTOS_TOP) -f $(MINGW_MAKEFILE) clean
 	$(MAKE) -C $(PURPLE_PLUGINS_TOP) -f $(MINGW_MAKEFILE) clean
 
diff --git a/libpurple/data/purple-2-uninstalled.pc.in b/libpurple/data/purple-2-uninstalled.pc.in
--- a/libpurple/data/purple-2-uninstalled.pc.in
+++ b/libpurple/data/purple-2-uninstalled.pc.in
@@ -6,9 +6,6 @@
 datadir=@datadir@
 sysconfdir=@sysconfdir@
 
-abs_srcdir=@abs_srcdir@
-abs_builddir=@abs_builddir@
-
 abs_top_srcdir=@abs_top_srcdir@
 abs_top_builddir=@abs_top_builddir@
 
@@ -18,5 +15,5 @@
 Description: libpurple is a GLib-based instant messenger library.
 Version: @VERSION@
 Requires: glib-2.0
-Cflags: -I${abs_top_srcdir} -I${abs_top_builddir}
-Libs: ${abs_builddir}/libpurple.la
+Cflags: -I${abs_top_srcdir} -I${abs_top_srcdir}/libpurple -I${abs_top_builddir} -I${abs_top_builddir}/libpurple
+Libs: -L${abs_top_builddir}/libpurple -lpurple
diff --git a/libpurple/data/purple-uninstalled.pc.in b/libpurple/data/purple-uninstalled.pc.in
--- a/libpurple/data/purple-uninstalled.pc.in
+++ b/libpurple/data/purple-uninstalled.pc.in
@@ -6,8 +6,8 @@
 datadir=@datadir@
 sysconfdir=@sysconfdir@
 
-abs_srcdir=@abs_srcdir@
-abs_builddir=@abs_builddir@
+abs_top_srcdir=@abs_top_srcdir@
+abs_top_builddir=@abs_top_builddir@
 
 plugindir=${libdir}/purple-@PURPLE_MAJOR_VERSION@
 
@@ -15,5 +15,5 @@
 Description: libpurple is a GLib-based instant messenger library.
 Version: @VERSION@
 Requires: glib-2.0
-Cflags: -I${abs_srcdir} -I${abs_builddir}
-Libs: ${abs_builddir}/libpurple.la
+Cflags: -I${abs_top_srcdir} -I${abs_top_srcdir}/libpurple -I${abs_top_builddir} -I${abs_top_builddir}/libpurple
+Libs: -L${abs_top_builddir}/libpurple -lpurple
diff --git a/libpurple/win32/global.mak b/libpurple/win32/global.mak
--- a/libpurple/win32/global.mak
+++ b/libpurple/win32/global.mak
@@ -8,6 +8,10 @@
 #include optional $(PIDGIN_TREE_TOP)/local.mak to allow overriding of any definitions
 -include $(PIDGIN_TREE_TOP)/local.mak
 
+ABS_TOP_SRCDIR := $(shell realpath $(PIDGIN_TREE_TOP))
+# in case we ever do separate build directories
+ABS_TOP_BUILDDIR := $(ABS_TOP_SRCDIR)
+
 # Locations of our various dependencies
 WIN32_DEV_TOP ?= $(PIDGIN_TREE_TOP)/../win32-dev
 GTKSPELL_TOP ?= $(WIN32_DEV_TOP)/gtkspell-2.0.16
@@ -74,6 +78,8 @@
   cat $(PIDGIN_TREE_TOP)/VERSION \
 )
 PURPLE_VERSION := $(PIDGIN_VERSION)
+PURPLE_MAJOR_VERSION := $(firstword $(subst ., ,$(PURPLE_VERSION)))
+
 ifdef EXTRAVERSION
 DISPLAY_VERSION := $(PIDGIN_VERSION)-$(EXTRAVERSION)
 else
diff --git a/libpurple/win32/rules.mak b/libpurple/win32/rules.mak
--- a/libpurple/win32/rules.mak
+++ b/libpurple/win32/rules.mak
@@ -9,5 +9,20 @@
 %.o: %.rc
 	$(WINDRES) -I$(PURPLE_TOP) -i $< -o $@
 
+%.pc: %.pc.in
+	sed -e 's|@prefix@|/usr/local|g' \
+	    -e 's|@exec_prefix@|$${prefix}|g' \
+	    -e 's|@libdir@|$${exec_prefix}/lib|g' \
+	    -e 's|@includedir@|$${prefix}/include|g' \
+	    -e 's|@datarootdir@|$${prefix}/share|g' \
+	    -e 's|@datadir@|$${datarootdir}|g' \
+	    -e 's|@sysconfdir@|$${prefix}/etc|g' \
+	    -e 's|@VERSION@|$(PIDGIN_VERSION)|g' \
+	    -e 's|@PURPLE_MAJOR_VERSION@|$(PURPLE_MAJOR_VERSION)|g' \
+	    -e 's|@GSTREAMER_VER@|0.10|g' \
+	    -e 's|@abs_top_srcdir@|$(ABS_TOP_SRCDIR)|g' \
+	    -e 's|@abs_top_builddir@|$(ABS_TOP_BUILDDIR)|g' \
+	    $< > $@
+
 %.desktop: %.desktop.in $(wildcard $(PIDGIN_TREE_TOP)/po/*.po)
 	LC_ALL=C $(PERL) $(INTLTOOL_MERGE) -d -u -c $(PIDGIN_TREE_TOP)/po/.intltool-merge-cache $(PIDGIN_TREE_TOP)/po $< $@
diff --git a/pidgin/Makefile.mingw b/pidgin/Makefile.mingw
--- a/pidgin/Makefile.mingw
+++ b/pidgin/Makefile.mingw
@@ -109,6 +109,10 @@
 EXE_C_SRC = win32/winpidgin.c
 EXE_OBJECTS = $(EXE_C_SRC:%.c=%.o) $(EXE_RC_SRC:%.rc=%.o)
 
+PC_SRC = data/pidgin.pc.in data/pidgin-uninstalled.pc.in \
+	 data/pidgin-2.pc.in data/pidgin-2-uninstalled.pc.in
+PC_FILES = $(PC_SRC:%.pc.in=%.pc)
+
 ##
 ## LIBRARIES
 ##
@@ -136,7 +140,7 @@
 ##
 .PHONY: all install install_shallow clean
 
-all: $(EXE_TARGET).exe $(PIDGIN_TARGET).dll
+all: $(EXE_TARGET).exe $(PIDGIN_TARGET).dll $(PC_FILES)
 	$(MAKE) -C $(PIDGIN_PLUGINS_TOP) -f $(MINGW_MAKEFILE)
 
 win32/pidgin_exe_rc.rc: win32/pidgin_exe_rc.rc.in $(PIDGIN_TREE_TOP)/VERSION
@@ -172,5 +176,7 @@
 	rm -f $(PIDGIN_OBJECTS) $(PIDGIN_RC_SRC) $(EXE_OBJECTS) $(EXE_RC_SRC)
 	rm -f $(PIDGIN_TARGET).dll $(PIDGIN_TARGET).dll.a $(PIDGIN_TARGET).def
 	rm -f $(EXE_TARGET).exe
+	rm -f data/pidgin.pc data/pidgin-uninstalled.pc
+	rm -f data/pidgin-2.pc data/pidgin-2-uninstalled.pc
 
 include $(PIDGIN_COMMON_TARGETS)
diff --git a/pidgin/data/pidgin-2-uninstalled.pc.in b/pidgin/data/pidgin-2-uninstalled.pc.in
--- a/pidgin/data/pidgin-2-uninstalled.pc.in
+++ b/pidgin/data/pidgin-2-uninstalled.pc.in
@@ -6,9 +6,6 @@
 datadir=@datadir@
 sysconfdir=@sysconfdir@
 
-abs_srcdir=@abs_srcdir@
-abs_builddir=@abs_builddir@
-
 abs_top_srcdir=@abs_top_srcdir@
 abs_top_builddir=@abs_top_builddir@
 
@@ -18,4 +15,5 @@
 Description: Pidgin is a GTK2-based instant messenger application.
 Version: @VERSION@
 Requires: gtk+-2.0 purple
-Cflags: -I${abs_top_srcdir}
+Cflags: -I${abs_top_srcdir} -I${abs_top_srcdir}/pidgin -I${abs_top_builddir} -I${abs_top_builddir}/pidgin
+Libs: -L${abs_top_builddir}/pidgin -lpidgin
diff --git a/pidgin/data/pidgin-uninstalled.pc.in b/pidgin/data/pidgin-uninstalled.pc.in
--- a/pidgin/data/pidgin-uninstalled.pc.in
+++ b/pidgin/data/pidgin-uninstalled.pc.in
@@ -6,8 +6,8 @@
 datadir=@datadir@
 sysconfdir=@sysconfdir@
 
-abs_srcdir=@abs_srcdir@
-abs_builddir=@abs_builddir@
+abs_top_srcdir=@abs_top_srcdir@
+abs_top_builddir=@abs_top_builddir@
 
 plugindir=${libdir}/pidgin
 
@@ -15,4 +15,5 @@
 Description: Pidgin is a GTK2-based instant messenger application.
 Version: @VERSION@
 Requires: gtk+-2.0 purple
-Cflags: -I${abs_srcdir}
+Cflags: -I${abs_top_srcdir} -I${abs_top_srcdir}/pidgin -I${abs_top_builddir} -I${abs_top_builddir}/pidgin
+Libs: -L${abs_top_builddir}/pidgin -lpidgin
diff --git a/pidgin/pidgin.h b/pidgin/pidgin.h
--- a/pidgin/pidgin.h
+++ b/pidgin/pidgin.h
@@ -34,7 +34,7 @@
 #endif
 
 #ifdef _WIN32
-# include "gtkwin32dep.h"
+# include "win32/gtkwin32dep.h"
 #endif
 
 /**
