#!/bin/sh # # gcng: general copyright notice generator # Copyright (C) 2001/2002/2003 karsten reincke # # This file is part of of the software-project GTGT. # # GTGT 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. # # GTGT 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. # # file version <#3.0.0#> of project VERSION="<#3.0.0#>" # ============================= # == Usage related functions == # ============================= function usage { cat << EOF Usage: gcng [OPTION] [ PROJECT ] [ FILE ] [ VERSION ] -c echos notice for a C file -cc echos notice for a C++ file -sh echos notice for a shell file (sh, perl, etc) -cS echos short special (LGPL-) notice for a C file -ccS echos short special (LGPL-) notice for a C++ file -shS echos short special (LGPL-) notice for a shell file -cL echos long special (LGPL-) notice for a C file -ccL echos long notice (LGPL-) notice for a C++ file -shL echos long notice (LGPL-) notice for a shell file -m4 echos notice for an m4 file (autoconf macros) -am echos notice for Makefile.am -l echos a copy of the package-relevant license -ecl echos a copyright-line -ech echos a short copyright-hint for project --help --version --license project, file and version are tags used in the main updateline. note: naming a file does not mean that the copyright-notice will be stored in such a file. for that purpose create a pipe. Bug reports to: reincke@fodina.de EOF } function version { cat << EOF gcng $VERSION - The general copyright notice generator Copyright (C) 2000,2001,2002,2003 karsten reincke This file is part of of the software-project GTGT. GTGT 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. GTGT 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. EOF } # ========================================= # == Configure the copyright information == # ========================================= function get_copyright_data { if test -r gcng.conf then AUT_NAME="$(cat gcng.conf | head -1 | tail -1)" AUT_EMAIL="$(cat gcng.conf | head -2 | tail -1)" AUT_YEAR="$(cat gcng.conf | head -3 | tail -1)" COMPANY="$(cat gcng.conf | head -4 | tail -1)" COMP_SHORT_COPYRIGHT_NOTE="$(cat gcng.conf | head -5 | tail -1)" COMP_LONG_COPYRIGHT_NOTE="$(cat gcng.conf | head -6 | tail -1)" else echo "The following information is required for your copyright notices." echo -n "Your name is: " read AUT_NAME echo -n "Your email address is: " read AUT_EMAIL AUT_YEAR=`date +%Y` echo -n "The name of your company is: " read COMPANY if [ -z $COMPANY ]; then COMPANY="GNU" else if [ $COMPANY = "gnu" ]; then COMPANY="GNU" fi fi if [ $COMPANY != "GNU" ] then echo "insert the path of the short copyright-note of your company and" echo "the path of its long copyright-note (don't use relative paths)" echo -n "The filename of its' short copyright-note is: " read COMP_SHORT_COPYRIGHT_NOTE echo -n "The filename of its' long copyright-note is: " read COMP_LONG_COPYRIGHT_NOTE if [ -z ${COMP_SHORT_COPYRIGHT_NOTE} ]; then COMP_SHORT_COPYRIGHT_NOTE="unknown" fi if [ -z $COMP_LONG_COPYRIGHT_NOTE ]; then COMP_LONG_COPYRIGHT_NOTE="unknown" fi else COMP_SHORT_COPYRIGHT_NOTE="function" COMP_LONG_COPYRIGHT_NOTE="function" fi echo ${AUT_NAME} >> gcng.conf echo ${AUT_EMAIL} >> gcng.conf echo ${AUT_YEAR} >> gcng.conf echo ${COMPANY} >> gcng.conf echo ${COMP_SHORT_COPYRIGHT_NOTE} >> gcng.conf echo ${COMP_LONG_COPYRIGHT_NOTE} >> gcng.conf echo "Got it! If you ever need to change any of this, edit the file gcng.conf" echo "findable in your actual working directory" fi export AUT_NAME export AUT_EMAIL export AUT_YEAR export COMPANY export COMP_LONG_COPYRIGHT_NOTE=`eval echo $COMP_LONG_COPYRIGHT_NOTE` export COMP_SHORT_COPYRIGHT_NOTE=`eval echo $COMP_SHORT_COPYRIGHT_NOTE` } function generic_copyright { CR="Copyright (C) ${AUT_YEAR} ${AUT_NAME}" if [ ${COMPANY} != "GNU" ]; then CR="${CR} / ${COMPANY}" fi CR="${CR} <${AUT_EMAIL}>" echo ${CR} } function generic_workline { echo "file <${FILENAME}> version <#${FVERSION}#> of project <${FPRJNAME}>" } # ================================================== # == Print generic header to append to every file == # ================================================== function generic_header { generic_copyright echo " " if [ ${COMPANY} = "GNU" ]; then cat << EOF This file is part of of the software-project ${FPRJNAME}. ${FPRJNAME} 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. ${FPRJNAME} 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. EOF else echo "copyright conditions offered by the company ${COMPANY}" if [ -n ${COMP_SHORT_COPYRIGHT_NOTE} ]; then if [ -f ${COMP_SHORT_COPYRIGHT_NOTE} ]; then cat ${COMP_SHORT_COPYRIGHT_NOTE} fi fi fi echo " " generic_workline } # ================================================== # == Print special header to append to some files == # ================================================== function special_header { generic_copyright echo " " if [ ${COMPANY} = "GNU" ]; then cat << EOF This file is part of of the software-project ${FPRJNAME}. ${FPRJNAME} 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. ${FPRJNAME} 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. EOF else echo "copyright conditions offered by the company ${COMPANY}" if [ -n ${COMP_SHORT_COPYRIGHT_NOTE} ]; then if [ -f ${COMP_SHORT_COPYRIGHT_NOTE} ]; then cat ${COMP_SHORT_COPYRIGHT_NOTE} fi fi fi echo " " generic_workline } # ================================================== # == Print the special header for Autoconf macros == # ================================================== function m4_header_extra_permission { generic_copyright echo " " cat < X Copyright (C) 19yy X X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 2 of the License, or X (at your option) any later version. X X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with this program; if not, write to the Free Software X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X Also add information on how to contact you by electronic and paper mail. X If the program is interactive, make it output a short notice like this when it starts in an interactive mode: X X Gnomovision version 69, Copyright (C) 19yy name of author X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. X This is free software, and you are welcome to redistribute it X under certain conditions; type `show c' for details. X The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. X You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: X X Yoyodyne, Inc., hereby disclaims all copyright interest in the program X `Gnomovision' (which makes passes at compilers) written by James Hacker. X X , 1 April 1989 X Ty Coon, President of Vice X This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. SHAR_EOF } # The comment above is used to fix fontification under emacs # ========================================================================== # ========================================================================== # ========================================= # == Here is the main part of the script == # ========================================= case $1 in --help) usage exit ;; --version) version exit ;; --license) print_gnu_public_license exit ;; *) esac get_copyright_data FILENAME="???" FPRJNAME="???" FVERSION="???" if [ $# -ge 2 ]; then FPRJNAME=$2 if [ $# -ge 3 ]; then FILENAME=$3 if [ $# -ge 4 ]; then FVERSION=$4 fi fi fi # branch out for the various flags case $1 in --help) usage ;; --version) version ;; --license) print_gnu_public_license ;; -c) cc_header ;; -cS) cc_header_special ;; -cL) cc_header_library ;; -cc) cpp_header ;; -ccS) cpp_header_special ;; -ccL) cpp_header_library ;; -sh) sh_header ;; -shS) sh_header_special ;; -shL) sh_header_library ;; -m4) m4_header ;; -am) am_header ;; -l) if [ $COMPANY = "GNU" ]; then print_gnu_public_license else print_company_public_license fi ;; -ecl) generic_copyright ;; -ech) if [ $COMPANY = "GNU" ]; then echo_gnu_license_hint $2 else echo_company_license_hint $2 fi ;; *) usage ;; esac exit