--- configure.orig	2011-12-15 15:01:05.000000000 +0100
+++ configure	2011-12-29 02:08:51.963305635 +0100
@@ -635,7 +635,7 @@
 _iwmmxt=auto
 _mtrr=auto
 _altivec=auto
-_install=install
+_install=@${BSD_INSTALL_PROGRAM}
 _ranlib=ranlib
 _windres=windres
 _cc=cc
@@ -1447,7 +1447,6 @@
 
   *)
     echo "Unknown parameter: $ac_option"
-    exit 1
     ;;
 
   esac
@@ -3565,7 +3564,7 @@
 if linux ; then
   THREAD_CFLAGS=-D_REENTRANT
 elif freebsd || netbsd || openbsd || bsdos ; then
-  THREAD_CFLAGS=-D_THREAD_SAFE
+  THREAD_CFLAGS=${PTHREAD_CFLAGS}
 fi
 if test "$_pthreads" = auto ; then
 cat > $TMPC << EOF
@@ -3575,7 +3574,7 @@
 EOF
 _pthreads=no
 if ! hpux ; then
-  for ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do
+  for ld_tmp in ${PTHREAD_LIBS} ; do
     # for crosscompilation, we cannot execute the program, be happy if we can link statically
     cc_check $THREAD_CFLAGS $ld_tmp && (tmp_run || test "$ld_static") && ld_pthread="$ld_tmp" && _pthreads=yes && break
   done
@@ -6216,7 +6215,7 @@
 echocheck "libgsm"
 if test "$_libgsm" = auto ; then
   _libgsm=no
-  statement_check gsm/gsm.h 'gsm_create()' -lgsm && _libgsm=yes
+  statement_check gsm.h 'gsm_create()' -lgsm && _libgsm=yes
 fi
 if test "$_libgsm" = yes ; then
   def_libgsm='#define CONFIG_LIBGSM 1'
@@ -6716,6 +6715,16 @@
   nolibrtmp=no
   def_librtmp='#define CONFIG_LIBRTMP 1'
   inputmodules="librtmp $inputmodules"
+
+  if $_pkg_config --exists librtmp; then
+	_inc_tmp=$($_pkg_config --cflags librtmp)
+	_ld_tmp=$($_pkg_config --libs librtmp)
+  else
+	_inc_tmp="-I${LOCALBASE}/include"
+	_ld_tmp="-L${LOCALBASE}/lib -lrtmp -lz -lssl -lcrypto"
+  fi
+  extra_ldflags="$extra_ldflags $_ld_tmp"
+  extra_cflags="$extra_cflags $_inc_tmp"
 else
   nolibrtmp=yes
   _librtmp=no
@@ -7085,7 +7094,7 @@
 echocheck "mencoder"
 if test "$_mencoder" = no ; then
   # mpeg1video for vf_lavc, snow for vf_uspp / vf_mcdeint,
-  libavencoders="$mplayer_encoders MPEG1VIDEO_ENCODER SNOW_ENCODER"
+  libavencoders="$mplayer_encoders MPEG1VIDEO_ENCODER H263_ENCODER SNOW_ENCODER"
   # needed for codec id -> tag conversion
   libavmuxers="AVI_MUXER"
 fi
@@ -7425,8 +7434,11 @@
 if test "$_gui" = yes ; then
 
   # Required libraries
-  if test "$ffmpeg" != yes ||
-      ! echo $libavdecoders | grep -q PNG_DECODER ; then
+  # Work around a sh bug in FreeBSD < 8
+  if test "$ffmpeg" != yes ; then
+    die "The GUI requires libavcodec with PNG support (needs zlib)."
+  fi
+  if ! echo $libavdecoders | grep -q PNG_DECODER ; then
     die "The GUI requires libavcodec with PNG support (needs zlib)."
   fi
   test "$_freetype" = no && test "$_bitmap_font" = no &&
@@ -7991,7 +8003,7 @@
 EXESUF      = $_exesuf
 EXESUFS_ALL = .exe
 
-ARCH = $arch
+MPLAYER_ARCH = $arch
 $(mak_enable "$arch_all"    "$arch"    ARCH)
 $(mak_enable "$subarch_all" "$subarch" ARCH)
 $(mak_enable "$cpuexts_all" "$cpuexts" HAVE)
