#!/bin/sh

export TOPSRCDIR=`pwd`
export MOZSDKDIR=/usr/ports/www/firefox3/work/mozilla/dist
export WEAVE_BUILDID=`basename ${TOPSRCDIR} | sed 's/weave-//'`

cd /usr/ports/www/firefox3 && make
cd ${TOPSRCDIR}

echo Building Weave ${WEAVE_BUILDID}

patch < $0
gmake clean
gmake xpi

exit

############################

--- src/Makefile.orig	2008-07-18 06:39:51.000000000 +0200
+++ src/Makefile	2008-07-21 17:59:36.000000000 +0200
@@ -67,11 +67,20 @@
   cxx = cl
   so = dll
 else
+ifeq ($(sys), FreeBSD)
+  os = Linux
+  compiler = gcc3
+  cxx = c++
+  so = so
+  cppflags += -DDEBUG -I/usr/ports/www/firefox3/work/mozilla/config/system_wrappers -I/usr/ports/www/firefox3/work/mozilla/dist/include/xpcom -I/usr/local/include/nspr -shared 
+  ldflags += -L/usr/local/lib -L/usr/local/lib/firefox3/sdk -L/usr/local/lib/firefox3
+else
   $(error Sorry, your os is unknown/unsupported: $(sys))
 endif
 endif
 endif
 endif
+endif
 
 # Arch detection
 
@@ -108,8 +117,12 @@
 ifeq ($(sys), Darwin)
   platform = $(os)
 else
+ifeq ($(sys), FreeBSD)
+  platform = $(sys)_$(arch)-$(compiler)
+else
   platform = $(os)_$(arch)-$(compiler)
 endif
+endif
 
 ###################################################################
 # Target and objects
--- install.rdf.orig	2008-07-26 15:57:45.000000000 +0200
+++ install.rdf	2008-07-26 15:58:02.000000000 +0200
@@ -8,11 +8,7 @@
     <em:version>0.2.5</em:version>
     <em:type>2</em:type>
 
-    <em:targetPlatform>Darwin_x86-gcc3</em:targetPlatform>
-    <em:targetPlatform>Darwin_ppc-gcc3</em:targetPlatform>
-    <em:targetPlatform>Linux_x86-gcc3</em:targetPlatform>
-    <em:targetPlatform>Linux_x86_64-gcc3</em:targetPlatform>
-    <em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
+    <em:targetPlatform>FreeBSD_x86-gcc3</em:targetPlatform>
    
     <!-- Target Application this extension can install into, 
          with minimum and maximum supported versions. --> 
