#!/usr/pkg/bin/python3.12

import os, sys

def help():
        print("Usage: %s foo_export.h FOO_EXPORT libname" % sys.argv[0])

if len(sys.argv) < 4:
        help()
        sys.exit()

filename=sys.argv[1]
FOO_EXPORT=sys.argv[2]
LIBNAME=sys.argv[3].upper()
HEADER_PROTECTION=filename.upper().replace('.','_')

file=open(filename,'w')
file.write("\
/*  This file is part of the KDE project\n\
    Copyright (C) 2007 David Faure <faure@kde.org>\n\
\n\
    This library is free software; you can redistribute it and/or\n\
    modify it under the terms of the GNU Library General Public\n\
    License as published by the Free Software Foundation; either\n\
    version 2 of the License, or (at your option) any later version.\n\
\n\
    This library is distributed in the hope that it will be useful,\n\
    but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n\
    Library General Public License for more details.\n\
\n\
    You should have received a copy of the GNU Library General Public License\n\
    along with this library; see the file COPYING.LIB.  If not, write to\n\
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n\
    Boston, MA 02110-1301, USA.\n\
*/\n\
\n\
#ifndef %(HEADER_PROTECTION)s\n\
#define %(HEADER_PROTECTION)s\n\
\n\
/* needed for KDE_EXPORT and KDE_IMPORT macros */\n\
#include <kdemacros.h>\n\
\n\
#ifndef %(FOO_EXPORT)s\n\
# if defined(MAKE_%(LIBNAME)s_LIB)\n\
   /* We are building this library */\n\
#  define %(FOO_EXPORT)s KDE_EXPORT\n\
# else\n\
   /* We are using this library */\n\
#  define %(FOO_EXPORT)s KDE_IMPORT\n\
# endif\n\
#endif\n\
\n\
# ifndef %(FOO_EXPORT)s_DEPRECATED\n\
#  define %(FOO_EXPORT)s_DEPRECATED KDE_DEPRECATED %(FOO_EXPORT)s\n\
# endif\n\
\n\
#endif\n" % vars())
file.close()

os.system("svn add "+filename)
