#!/usr/bin/perl

use strict;
use warnings;

my %license_texts;

push @{$license_texts{LGPL_1}},<<'EOF';
 * 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.
EOF

push @{$license_texts{LGPL_2}},<<'EOF';
;This program 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 program 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, write to the Free Software Foundation, Inc.
;59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
EOF

push @{$license_texts{LGPL_3}},<<'EOF';
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 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.
   
   You should have received a copy of the GNU Lesser 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
EOF

push @{$license_texts{LGPL_3}},<<'EOF';
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
EOF

push @{$license_texts{LGPL_4}},<<'EOF';
    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., 675 Mass Ave, Cambridge, MA 02139, USA.
EOF

push @{$license_texts{LGPL_5}},<<'EOF';
 * 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.
EOF

push @{$license_texts{LGPL_6}},<<'EOF';
* This program 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 program 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, write to the Free Software Foundation, Inc.                                     *
* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                        *
EOF

push @{$license_texts{LGPL_7}},<<'EOF';
; This program 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 program 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, write to the Free Software Foundation, Inc.
; 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
EOF

push @{$license_texts{LGPL_8}},<<'EOF';
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser 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.
 *
 * You should have received a copy of the GNU Lesser 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
EOF

push @{$license_texts{LGPL_9}},<<'EOF';
 * EffecTV is free software. * 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.
EOF

push @{$license_texts{LGPL_10}},<<'EOF';
 * EffecTV is free software. 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.
EOF

push @{$license_texts{LGPL_11}},<<'EOF';
   This program 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, or (at your option)
   any later version.

   This program 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, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   USA.  */
EOF

push @{$license_texts{LGPL_12}},<<'EOF';
 * 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,
 e Boston, MA 02111-1307, USA.
EOF

push @{$license_texts{GPL_1}},<<'EOF';
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_2}},<<'EOF';
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU 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
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
EOF

push @{$license_texts{GPL_3}},<<'EOF';
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_4}},<<'EOF';
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program 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
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#   As a special exception to the GNU General Public License, if you
#   distribute this file as part of a program that contains a
#   configuration script generated by Autoconf, you may include it under
#   the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_5}},<<'EOF';
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_6}},<<'EOF';
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program 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 General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_7}},<<'EOF';
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
EOF

push @{$license_texts{GPL_8}},<<'EOF';
 * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
 * PLEASE READ THESE TERMS DISTRIBUTING.                            *
EOF

push @{$license_texts{GPL_9}},<<'EOF';
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
EOF

push @{$license_texts{PUBLIC_DOMAIN_1}},<<'EOF';
 *
 * This code is in the public domain 
 *
EOF

push @{$license_texts{PUBLIC_DOMAIN_2}},<<'EOF';
/* This code is in the public domain */
EOF

push @{$license_texts{PUBLIC_DOMAIN_3}},<<'EOF';
   Free software by Richard W.E. Furse. Do with as you will. No
   warranty. */
EOF

push @{$license_texts{PUBLIC_DOMAIN_4}},<<'EOF';
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
EOF

push @{$license_texts{PUBLIC_DOMAIN_5}},<<'EOF';
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
EOF

push @{$license_texts{PUBLIC_DOMAIN_6}},<<'EOF';
# Copyright (C) 2004 Free Software Foundation, Inc.
# This file is put in the public domain.
EOF

push @{$license_texts{PUBLIC_DOMAIN_7}},<<'EOF';
/*
 * This source code is public domain.
 *
EOF

push @{$license_texts{PUBLIC_DOMAIN_8}},<<'EOF';
# Copyright © 2004 Free Software Foundation, Inc.
# This file is put in the public domain.
EOF

push @{$license_texts{PUBLIC_DOMAIN_9}},<<'EOF';
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL SCOTT LAIRD BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
EOF

push @{$license_texts{BSD_1}},<<'EOF';
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
 * by the XIPHOPHORUS Company http://www.xiph.org/                  *
EOF

push @{$license_texts{BSD_2}},<<'EOF';
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice and the following
 * two paragraphs appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
EOF

push @{$license_texts{BSD_3}},<<'EOF';
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
EOF

push @{$license_texts{BSD_4}},<<'EOF';
 * This file is under what is known as the BSD license:
 *
 * Redistribution and use in source and binary forms, with or without modification, i
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products derived from 
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 
 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOF

push @{$license_texts{XFREE_AND_PUBLIC_DOMAIN_1}},<<'EOF';
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
EOF


my %skip_patterns;

push @{$skip_patterns{"skip (SCM)"}}, qw(
        CVS(/|$)
);

push @{$skip_patterns{"skip (generated)"}}, qw(
        Makefile\.(am|in)$
        config\.h\.in$
);

push @{$skip_patterns{"skip (distribution information or probably no license needed)"}}, qw(
        .*\.txt$
        README\b
        NOTES$
        TODO$
        ABOUT-NLS$
        AUTHORS$
        COPYING$
        COPYING-DOCS$
        INSTALL$
        NEWS$
        RELEASE$
        REQUIREMENTS$
        ChangeLog$
        MAINTAINERS$
        LICENSE_readme$
        PORTED_09$
        CHANGES-0\.9$
        DEVEL$
        DOCBUILDING$
        HACKING$
        LICENSE$
        WHAT_THE_HECK_IS_THIS_CODE_DOING$
);

push @{$skip_patterns{"skip (license can't be embedded in comments or probably no license needed)"}}, qw(
        gst-launch\.desktop\.in$
        gst-inspect\.desktop\.in$
        gst-editor\.desktop\.in$
        gst-editor-libs\.pc\.in$
        gst-editor-libs-uninstalled\.pc\.in$
        gconf/gstreamer\.schemas\.in$
        gst/.*\.vcproj$
        tools/gst-launch-ext\.1\.in$
        tools/gst-launch-ext-m\.m$
        tools/gst-visualise\.1\.in$
        tools/gst-visualise-m\.m$
);

my %category_patterns;

push @{$category_patterns{"GStreamer, should have a license header (Makefiles)"}}, qw(
        common/as-libtool\.mak$
        common/glib-gen\.mak$
        common/gtk-doc\.mak$
        common/po\.mak$
        common/release\.mak$
        omf\.make$
        xmldocs\.make$
        idiottest\.mak$
        docs/upload\.mak$
);
push @{$category_patterns{"GStreamer, should have a license header (m4 macros)"}}, qw(
        common/m4/.*\.m4$
        gst-element-check\.m4(\.in)?$
);
push @{$category_patterns{"GStreamer, should have a license header (spec files)"}}, qw(
        cupid\.spec(\.in)?$
        gst-plugins\.spec(\.in)?$
        gstreamer\.spec(\.in)?$
        gst-editor\.spec(\.in)?$
);
push @{$category_patterns{"GStreamer, should have a license header (testsuite)"}}, qw(
        testsuite(/|$)
);
push @{$category_patterns{"GStreamer, should have a license header"}}, qw(
        common/gst-autogen\.sh$
        configure\.ac(\.orig)?$
        mkinstalldirs$
        ext/arts/gst_artsio_impl\.cc$
        ext/flac/flac_compat\.h$
        ext/libmms/gstmms\.h$
        ext/mikmod/drv_gst\.c$
        ext/mikmod/mikmod_reader\.c$
        ext/pango/gsttextoverlay\.h$
        ext/polyp/plugin\.c$
        ext/polyp/polypsink\.[ch]$
        ext/smoothwave/demo-osssrc\.c$
        ext/wavpack/gstwavpackcommon\.[ch]$
        ext/dv/demo-play\.c$
        ext/lame/test-lame\.c$
        ext/mpeg2dec/perftest\.c$
        examples/capsfilter/capsfilter1\.c$
        examples/dynparams/filter\.c$
        examples/seeking/.*\.c$
        autogen\.sh$
        gst/debug/efence\.h$
        gst/effectv/gstdice\.c$
        gst/law/alaw\.c$
        gst/law/mulaw\.c$
        gst/law/mulaw-conversion\.[ch]$
        gst/librfb/rfbbuffer\.[ch]
        gst/librfb/rfbbytestream\.[ch]$
        gst/librfb/rfb\.[ch]$
        gst/librfb/rfbdecoder\.[ch]$
        gst/librfb/rfbcontext\.h$
        gst/librfb/rfbutil\.h$
);

push @{$category_patterns{"GStreamer, should have a license header (trivial files)"}}, qw(
        ext/arts/gst_artsio\.idl$
        ext/arts/gst_artsio_impl\.h$
        ext/cairo/gsttextoverlay\.h$
        ext/dvdread/demo-play$
        ext/flac/gstflactag\.h$
        ext/musicbrainz/blank-file\.cpp$
        ext/spc/gstspc\.h$
        ext/dvdnav/gst-dvd$
        stamp\.h\.in$
);

push @{$category_patterns{"Upstream, should have a license header"}}, qw(
        ext/spc/APU\.Asm$
        ext/spc/DSP\.Asm$
        ext/spc/Macro\.Inc$
        ext/spc/SPC700\.Asm$
        ext/tarkin/bitcoder\.h$
        ext/tarkin/golomb\.h$
        ext/tarkin/mem\.[ch]$
        ext/tarkin/rle\.h$
        ext/tarkin/tarkin\.[ch]$
        ext/tarkin/wavelet\.[ch]$
        ext/tarkin/wavelet_coeff.c$
        ext/tarkin/wavelet_xform.c$
        ext/tarkin/yuv.[ch]$
        gst/goom/filters.[ch]$
        gst/goom/filters_mmx\.s$
        gst/goom/goom_core\.[ch]$
        gst/goom/goom_tools\.h$
        gst/goom/graphic.[ch]$
        gst/goom/lines.[ch]$
        gst/modplug/libmodplug/it_defs\.h$
);

push @{$category_patterns{"Upstream, should have a license header (trivial files)"}}, qw(
        ext/spc/SNESAPU\.h$
        ext/spc/spc\.h$
        ext/spc/Types\.h$
);

push @{$category_patterns{"Help, could not categorize"}}, qw(
        .*\.func$
        .*\.gob$
        .*\.patch$
        win32/gst\.sln$
);

# returns the license of the file as 'LGPL', or 'UNKNOWN'
sub license {
    my $file = shift;

    my $licenses = "";
    while (my ($name, $texts) = each %license_texts) {
        foreach (@{$texts}) {
            if ($file =~ /\Q$_\E/) {
                $licenses .= $name . " ";
            }
        }
    }
    $licenses =~ s/ $//;
    return $licenses unless ($licenses eq "");

    return "UNKNOWN";
}

local $/;

FILE: while (<>) {
    my $file = $ARGV;
    print $file . ": ";

    foreach my $desc (keys %skip_patterns) {
        foreach (@{$skip_patterns{$desc}}) {
            if ($file =~ m#(^|/)$_#) {
                print $desc . "\n";
                next FILE;
            }
        }
    }

    my $license;
    $license = license($_);

    if ($license ne "UNKNOWN") {
        print $license . "\n";
        next FILE;
    }

    foreach my $desc (keys %category_patterns) {
        foreach (@{$category_patterns{$desc}}) {
            if ($file =~ m#(^|/)$_#) {
                print $desc . "\n";
                next FILE;
            }
        }
    }

    print "NOT FOUND\n";
}

