#!/bin/sh

set -e

# Script used to generate the orig source tarball for lame.

LAME_UPSTREAM_VERSION="3.98.4"
LAME_DOWNLOAD_URL="http://downloads.sourceforge.net/project/lame/lame/${LAME_UPSTREAM_VERSION}/lame-${LAME_UPSTREAM_VERSION}.tar.gz"
LAME_VERSION="${LAME_UPSTREAM_VERSION}+repack2"
LAME_TARBALL_CHECKSUM="ac3144c76617223a9be4aaa3e28a66b51bcab28141050c3af04cb06836f772c8"

# Download and verify lame upstream tarball
test -f "lame-${LAME_UPSTREAM_VERSION}.tar.gz" || wget -c "${LAME_DOWNLOAD_URL}"
COMPUTED_CHECKSUM=`sha256sum "lame-${LAME_UPSTREAM_VERSION}.tar.gz" | cut -d ' ' -f 1`
if [ $LAME_TARBALL_CHECKSUM != $COMPUTED_CHECKSUM ] ; then
  echo "Checksum verification failed. Checksum was $COMPUTED_CHECKSUM
Expected checksum $LAME_TARBALL_CHECKSUM."
  exit 1
else
  echo "Checksum verified. Checksum is $COMPUTED_CHECKSUM."
fi
tar -xzf "lame-${LAME_UPSTREAM_VERSION}.tar.gz"
rm -rf "lame-${LAME_VERSION}"
mv "lame-${LAME_UPSTREAM_VERSION}" "lame-${LAME_VERSION}" 
cd "lame-${LAME_VERSION}"

# Modify build system to remove AM_PATH_GTK and debian directory.
# Also insert build fix for arm.
sed -i 's/AM_PATH_GTK/dnl AM_PATH_GTK/g' "configure.in"
sed -i 's/@GTK_CFLAGS@ //g' "frontend/Makefile.am"
sed -i 's/debian //g' "Makefile.am"
sed -i 's/debian\/Makefile //g' "configure.in"
sed -i 's/ -static//g' "frontend/Makefile.am"
rm -rf "debian/"

TMP="$(mktemp)"
cat >"$TMP" <<EOF
--- a/configure.in
+++ b/configure.in
@@ -918,6 +918,13 @@
 				OPTIMIZATION="\${OPTIMIZATION} -march=generic \\
 					-mtune=native"
 				;;
+			arm*-gnueabi)
+				if [ -z "\$(echo \${GCC_version} | awk '/4\.0/')" ]; then
+					# Work round buggy softfloat optimization in ARM EABI compilers
+					# -gnueabi in only gcc-4.1 onwards
+					OPTIMIZATION="\${OPTIMIZATION} -fno-finite-math-only"
+				fi
+				;;
 			esac
 			;;
 		*)
EOF
patch -p1 <"$TMP"

# Patching in all LGPL clarification changes from upstream.
cat >"$TMP" <<EOF
--- a/README
+++ b/README
@@ -1,26 +1,29 @@
-                      LAME 3.xx   
+                      LAME 3.xx
                LAME Ain't an MP3 Encoder
-                 http://www.mp3dev.org
-	             March 2001
+                 http://lame.sf.net
+	             May 2011
 
-Originally developed by Mike Cheng (www.uq.net.au/~zzmcheng).  Now 
-maintained by Mark Taylor (www.mp3dev.org).
+Originally developed by Mike Cheng (www.uq.net.au/~zzmcheng) and was
+latter developed by Mark Taylor (www.mp3dev.org). Currently maintained
+by The LAME Project.
 
-This code is distributed under the GNU LESSER PUBLIC LICENSE
-(LGPL, see www.gnu.org) with the following modification:
+This code is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
+(LGPL, see www.gnu.org), version 2.
 
-1. If you determine that distribution of LAME requires a patent license,
-   and you obtain a patent license, you may distribute LAME even though
-   redistribution of LAME may also require a patent license.  
-
-2. You agree not to enforce any patent claims for any aspect of
-   MPEG audio compression, or any other techniques contained in 
-   the LAME source code. 
+As LAME may contain software for which some companies may claim software
+patents, if you are in a location where software patents are recognized, it is
+suggested that you seek legal advice before deploying and/or redistributing
+LAME.
 
+In particular, it is suggested to visit
+
+    http://www.mp3licensing.com/
+
+if it applies to your jurisdiction.
 
 ============================================================================
 
-see the file "INSTALL" for installation (compiling) instructions.  
+see the file "INSTALL" for installation (compiling) instructions.
 see the file "USAGE" for the most up-to-date guide to the command line options.
 see the file "LICENSE" for details on how to use LAME in non-GPL programs.
 see the file "HACKING" if you are interested in working on LAME
@@ -33,11 +36,9 @@
 LAME uses the MPGLIB decoding engine, from the MPG123 package, written
 by: Michael Hipp (www.mpg123.de) MPGLIB is released under the GPL.
 
-Copyrights (c) 1999-1007 by The LAME Project
-Copyrights (c) 1999,2000,2001 by Mark Taylor
+Copyrights (c) 1999-2011 by The LAME Project
 Copyrights (c) 1999,2000,2001 by Mark Taylor
 Copyrights (c) 1998 by Michael Cheng
 Copyrights (c) 1995,1996,1997 by Michael Hipp: mpglib
 
-As well as additional copyrights as documented in the source code.  
-
+As well as additional copyrights as documented in the source code.
--- a/frontend/brhist.c
+++ b/frontend/brhist.c
@@ -4,7 +4,7 @@
  *	Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/brhist.h
+++ b/frontend/brhist.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/get_audio.c
+++ b/frontend/get_audio.c
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Albert L Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/get_audio.h
+++ b/frontend/get_audio.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Albert L Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/gpkplotting.c
+++ b/frontend/gpkplotting.c
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/gpkplotting.h
+++ b/frontend/gpkplotting.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/gtkanal.c
+++ b/frontend/gtkanal.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/gtkanal.h
+++ b/frontend/gtkanal.h
@@ -1,7 +1,7 @@
 /*
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -10,7 +10,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/lametime.c
+++ b/frontend/lametime.c
@@ -4,7 +4,7 @@
  *	Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/lametime.h
+++ b/frontend/lametime.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -5,7 +5,7 @@
  *                    2000 Takehiro TOMINAGA
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/main.h
+++ b/frontend/main.h
@@ -5,7 +5,7 @@
  *                    2000 Takehiro TOMIANGA
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/parse.c
+++ b/frontend/parse.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/timestatus.c
+++ b/frontend/timestatus.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/timestatus.h
+++ b/frontend/timestatus.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/include/lame.h
+++ b/include/lame.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/VbrTag.c
+++ b/libmp3lame/VbrTag.c
@@ -5,7 +5,7 @@
  *      Copyright (c) 2001 Jonathan Dee
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/VbrTag.h
+++ b/libmp3lame/VbrTag.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 A.L. Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/bitstream.c
+++ b/libmp3lame/bitstream.c
@@ -5,7 +5,7 @@
  *      Copyright (c) 1999-2002 Takehiro Tominaga
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/bitstream.h
+++ b/libmp3lame/bitstream.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Takehiro TOMINAGA
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/encoder.c
+++ b/libmp3lame/encoder.c
@@ -8,7 +8,7 @@
  *      Copyright (c) 2001 John Dahlstrom
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -17,7 +17,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/encoder.h
+++ b/libmp3lame/encoder.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/fft.h
+++ b/libmp3lame/fft.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/id3tag.c
+++ b/libmp3lame/id3tag.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2000 Don Melton.
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
--- a/libmp3lame/l3side.h
+++ b/libmp3lame/l3side.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/lame-analysis.h
+++ b/libmp3lame/lame-analysis.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/lame.c
+++ b/libmp3lame/lame.c
@@ -9,7 +9,7 @@
  *      Copyright (c) 2000-2004 Alexander Leidinger
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -18,7 +18,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/machine.h
+++ b/libmp3lame/machine.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 A.L. Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/mpglib_interface.c
+++ b/libmp3lame/mpglib_interface.c
@@ -7,7 +7,7 @@
  *      Copyright (c) 2008 Robert Hegemann
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -16,7 +16,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/newmdct.c
+++ b/libmp3lame/newmdct.c
@@ -5,7 +5,7 @@
  *
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
--- a/libmp3lame/newmdct.h
+++ b/libmp3lame/newmdct.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Takehiro TOMINAGA
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
--- a/libmp3lame/presets.c
+++ b/libmp3lame/presets.c
@@ -5,7 +5,7 @@
  *	Copyright (c) 2007-2008 Robert Hegemann
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
--- a/libmp3lame/psymodel.c
+++ b/libmp3lame/psymodel.c
@@ -9,7 +9,7 @@
  *      Copyright (c) 2000-2005 Alexander Leidinger
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -18,7 +18,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/psymodel.h
+++ b/libmp3lame/psymodel.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
--- a/libmp3lame/quantize.c
+++ b/libmp3lame/quantize.c
@@ -7,7 +7,7 @@
  *      Copyright (c) 2001-2005 Gabriel Bouvigne
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -16,7 +16,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/quantize.h
+++ b/libmp3lame/quantize.h
@@ -4,7 +4,7 @@
  * Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/quantize_pvt.c
+++ b/libmp3lame/quantize_pvt.c
@@ -7,7 +7,7 @@
  *      Copyright (c) 2002-2005 Gabriel Bouvigne
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -16,7 +16,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/quantize_pvt.h
+++ b/libmp3lame/quantize_pvt.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Takehiro TOMINAGA
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/reservoir.c
+++ b/libmp3lame/reservoir.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999-2000 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/reservoir.h
+++ b/libmp3lame/reservoir.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/set_get.c
+++ b/libmp3lame/set_get.c
@@ -5,7 +5,7 @@
  * Copyright (c) 2001-2005 Alexander Leidinger
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/set_get.h
+++ b/libmp3lame/set_get.h
@@ -4,7 +4,7 @@
  * Copyright (C) 2003 Gabriel Bouvigne / Lame project
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  */
--- a/libmp3lame/tables.c
+++ b/libmp3lame/tables.c
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Albert L Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/tables.h
+++ b/libmp3lame/tables.h
@@ -4,7 +4,7 @@
  *	Copyright (c) 1999 Albert L Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/takehiro.c
+++ b/libmp3lame/takehiro.c
@@ -5,7 +5,7 @@
  *	Copyright (c) 2002-2005 Gabriel Bouvigne
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/util.c
+++ b/libmp3lame/util.c
@@ -5,7 +5,7 @@
  *	Copyright (c) 2000-2005 Alexander Leidinger
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/util.h
+++ b/libmp3lame/util.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 Albert L Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/vbrquantize.c
+++ b/libmp3lame/vbrquantize.c
@@ -5,7 +5,7 @@
  *	Copyright (c) 2000-2007 Robert Hegemann
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -14,7 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/vbrquantize.h
+++ b/libmp3lame/vbrquantize.h
@@ -4,7 +4,7 @@
  * Copyright (c) 1999 Mark Taylor
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/version.c
+++ b/libmp3lame/version.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 A.L. Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/version.h
+++ b/libmp3lame/version.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 1999 A.L. Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/vector/lame_intrin.h
+++ b/libmp3lame/vector/lame_intrin.h
@@ -4,7 +4,7 @@
  *      Copyright (c) 2006 Gabriel Bouvigne
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/libmp3lame/vector/xmm_quantize_sub.c
+++ b/libmp3lame/vector/xmm_quantize_sub.c
@@ -4,7 +4,7 @@
  *      Copyright (c) 2005-2006 Gabriel Bouvigne
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  * Library General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
--- a/frontend/mp3rtp.c
+++ b/frontend/mp3rtp.c
@@ -1,3 +1,27 @@
+/*
+ *      mp3rtp command line frontend program
+ *
+ *      initially contributed by Felix von Leitner
+ *
+ *      Copyright (c) 2000 Mark Taylor
+ *                    2010 Robert Hegemann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 /* \$Id: mp3rtp.c,v 1.25.8.1 2008/08/05 14:16:06 robert Exp $ */

 /* Still under work ..., need a client for test, where can I get one? */
--- a/Dll/BladeMP3EncDLL.c
+++ b/Dll/BladeMP3EncDLL.c
@@ -4,16 +4,16 @@
 *	Copyright (c) 1999 - 2002 A.L. Faber
 *
 * This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
+* modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
+* Library General Public License for more details.
 * 
-* You should have received a copy of the GNU Lesser General Public
+* You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
--- a/Dll/BladeMP3EncDLL.h
+++ b/Dll/BladeMP3EncDLL.h
@@ -5,16 +5,16 @@
  * Based on bladedll.h version 1.0 written by Jukka Poikolainen
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  * 
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * Library General Public License for more details.
  * 
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA  02111-1307, USA.
--- a/Dll/Example.cpp
+++ b/Dll/Example.cpp
@@ -4,16 +4,16 @@
  *	Copyright (c) 2000 A.L. Faber
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
+ * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  * 
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
+ * Library General Public License for more details.
  * 
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA  02111-1307, USA.
--- a/frontend/rtp.c
+++ b/frontend/rtp.c
@@ -1,3 +1,27 @@
+/*
+ *      rtp socket communication functions
+ *
+ *      initially contributed by Felix von Leitner
+ *
+ *      Copyright (c) 2000 Mark Taylor
+ *                    2010 Robert Hegemann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 /* \$Id: rtp.c,v 1.16.8.1 2008/08/05 14:16:06 robert Exp $ */

 #ifdef HAVE_CONFIG_H
--- a/frontend/rtp.h
+++ b/frontend/rtp.h
@@ -1,3 +1,27 @@
+/*
+ *      rtp socket communication include file
+ *
+ *      initially contributed by Felix von Leitner
+ *
+ *      Copyright (c) 2000 Mark Taylor
+ *                    2010 Robert Hegemann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 #ifndef LAME_RTP_H
 #define LAME_RTP_H

EOF
patch -p1 <"$TMP"

# Removing LICENSE file as COPYING file has LGPL-2 text.
rm -f "LICENSE"

# Replace portableio code.
rm -f "frontend/portableio.c"
cat >"$TMP" <<EOF
/* Simple I/O Function header file
 *
 * Copyright (C) 2011 Andres Mejia
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LAME_PORTABLEIO_H
#define LAME_PORTABLEIO_H

#include <stdio.h>
#include <stdint.h>
#include <math.h>

#include "config.h"

static inline int ReadByte(FILE * fp)
{
  int val = (getc(fp)) & 0xFF;
  return (val & 0x80) ? (val - 0x100) & 0xFF : val;
}

static inline int Read16BitsLowHigh(FILE * fp)
{
  int val = ReadByte(fp);
  val |= ReadByte(fp) << 8;
  return (val & 0x8000) ? (val - 0x10000) & 0xFFFF : val;
}

static inline int Read16BitsHighLow(FILE * fp)
{
  int val = (ReadByte(fp) << 8) | ReadByte(fp);
  return (val & 0x8000) ? (val - 0x10000) & 0xFFFF : val;
}

static inline void Write8Bits(FILE * fp, int i)
{
  putc(i & 0xFF, fp);
}

static inline void Write16BitsLowHigh(FILE * fp, int i)
{
  Write8Bits(fp, i & 0xFF);
  Write8Bits(fp, (i >> 8) & 0xFF);
}

static inline void Write16BitsHighLow(FILE * fp, int i)
{
  Write8Bits(fp, (i >> 8) & 0xFF);
  Write8Bits(fp, i & 0xFF);
}

static inline int Read24BitsHighLow(FILE * fp)
{
  int val = (ReadByte(fp) << 16) | (ReadByte(fp) << 8) | ReadByte(fp);
  return (val & 0x800000) ? (val - 0x1000000) & 0xFFFFFF : val;
}

static inline int Read32Bits(FILE * fp)
{
  int val = Read16BitsLowHigh(fp);
  val |= Read16BitsLowHigh(fp) << 16;
  return val;
}

static inline int Read32BitsHighLow(FILE * fp)
{
  return (Read16BitsHighLow(fp) << 16) | Read16BitsHighLow(fp);
}

static inline void Write32Bits(FILE * fp, int i)
{
  Write16BitsLowHigh(fp, i & 0xFFFF);
  Write16BitsLowHigh(fp, (i >> 16) & 0xFFFF);
}

static inline void Write32BitsHighLow(FILE * fp, int i)
{
  Write16BitsHighLow(fp, (i >> 16) & 0xFFFF);
  Write16BitsHighLow(fp, i & 0xFFFF);
}

static inline void ReadBytes(FILE * fp, char *p, int n)
{
  while (!feof(fp) && (n-- > 0))
    *p++ = ReadByte(fp);
  while (n-- > 0)
    *p++ = 0;
}

static inline void ReadBytesSwapped(FILE * fp, char *p, int n)
{
  char *tmp = p;
  while (!feof(fp) && (n-- > 0))
    *tmp++ = ReadByte(fp);
  while (n-- > 0)
    *tmp++ = 0;
  tmp--;
  while (p < tmp)
  {
    n = *p;
    *p++ = *tmp;
    *tmp-- = n;
  }
}

static inline void WriteBytes(FILE * fp, char *p, int n)
{
  while (n-- > 0)
    Write8Bits(fp, *p++);
}

static inline void WriteBytesSwapped(FILE * fp, char *p, int n)
{
  p += n;
  while (n-- > 0)
    Write8Bits(fp, *p--);
}

static inline long double BytesToLongDouble(void *d)
{
  long double val = *((long double *)d);
  return val;
}

static inline double ReadIeeeExtendedHighLow(FILE * fp)
{
  char bytes[10];
#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
#ifdef WORDS_BIGENDIAN
  ReadBytes(fp, bytes, sizeof(bytes));
#else
  ReadBytesSwapped(fp, bytes, sizeof(bytes));
#endif
  /* Take advantage of 80-bit precision of long double from GNU C compiler */
  return BytesToLongDouble(&bytes);
#else
  ReadBytes(fp, &bytes, sizeof(bytes));
  double val;
  uint32_t mantissa_high, mantissa_low;
  int16_t exponent;
  exponent = ((bytes[0] & 0x7F) << 8) | bytes[1];
  mantissa_high = (bytes[2] << 24) |
                  (bytes[3] << 16) |
                  (bytes[4] << 8)  |
                   bytes[5];
  mantissa_low = (bytes[6] << 24) |
                 (bytes[7] << 16) |
                 (bytes[8] << 8)  |
                  bytes[9];
  if (exponent == 0 && mantissa_high == 0 && mantissa_low == 0)
    val = 0;
  else
  {
    /* TODO: Perhaps this should also detect NaN */
    if (exponent == 0x7FFF)
      val = HUGE_VAL;
    else
    {
      exponent -= 0x3FFF; /* Bias for long double precision */
      val = ldexp(mantissa_high, (exponent -= 31));
      val += ldexp(mantissa_low, (exponent -= 32));
    }
  }
  return (bytes[0] & 0x80) ? -val : val;
#endif
}

#define Read32BitsLowHigh(f)  Read32Bits(f)
#define Write32BitsLowHigh(f, i) Write32Bits(f, i)

#endif
EOF
mv -f "$TMP" "frontend/portableio.h"
sed -i 's/^.*portableio.c.*$/\t\\/g' "frontend/Makefile.am"

autoreconf -vif
cd ..

# Remove temp files and other cruft from source tarball
# The find command snippet here was taken from debhelper's dh_clean command
# with some modification to delete more unneeded files.
echo "Removing temp files and other cruft from source tarball"
find lame-${LAME_VERSION} \( \( -type f -a \
  \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
  -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
  -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
  -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
  -o -name config.status -o -name config.cache -o -name config.log \
  \) -exec rm -f "{}" \; \) -o \
  \( -type d -a -name autom4te.cache -prune -exec rm -rf "{}" \; \) \)
rm -rf lame-${LAME_VERSION}/.git
rm -f lame-${LAME_VERSION}/.gitignore

# Remove empty directories
echo "Removing empty directories"
find lame-${LAME_VERSION} -type d -empty -delete

rm -f "lame_${LAME_VERSION}.orig.tar.gz"
tar --exclude-vcs -czf "lame_${LAME_VERSION}.orig.tar.gz" \
  "lame-${LAME_VERSION}/"
