#! /usr/bin/env python
#    This file is part of pysdl_mixer.
#
#    pysdl_mixer 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.
#
#    pysdl_mixer 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 pysdl_mixer; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

INCDIR = [
  "/usr/include",
  "/usr/local/include",
  "/sw/include", # For Mac OS X
  ]
LIBDIR = [
  "/usr/lib",
  "/usr/local/lib",
  "/sw/lib/", # For Mac OS X
  ]


import os.path, sys, glob, distutils.core, distutils.sysconfig
from distutils.core import setup, Extension

try:  
  from Pyrex.Distutils import build_ext
  HAVE_PYREX = 1
except:
  HAVE_PYREX = 0

HERE = os.path.dirname(sys.argv[0])

endian = sys.byteorder
if endian == "big":
  DEFINES = [("SOYA_BIG_ENDIAN", endian)]
else:
  DEFINES = []

if sys.platform[:3] == "win":
  LIBS = ["SDL", "SDL_mixer" ]
else:
  LIBS = ["SDL", "SDL_mixer" ]

SOYA_PYREX_SOURCES  = ["sdl_mixer.pyx"]
SOYA_C_SOURCES      = ["sdl_mixer.c"]

# Taken from Twisted ; thanks to Christopher Armstrong :
#   make sure data files are installed in twisted package
#   this is evil.
import distutils.command.install_data
class install_data_twisted(distutils.command.install_data.install_data):
  def finalize_options(self):
    self.set_undefined_options('install', ('install_lib', 'install_dir'))
    distutils.command.install_data.install_data.finalize_options(self)
    
if HAVE_PYREX:
  KARGS = {
    "ext_modules" : [
    Extension("pysdl_mixer.sdl_mixer", SOYA_PYREX_SOURCES,
    #Extension("pysdl_mixer", SOYA_PYREX_SOURCES,
              include_dirs=INCDIR, library_dirs=LIBDIR,
              libraries=LIBS, define_macros=DEFINES,
              extra_compile_args = ["-w"], # with GCC ; disable (Pyrex-dependant) warning
              ),
    ],
    "cmdclass" : {
        'build_ext'   : build_ext,            # Pyrex magic stuff
        'install_data': install_data_twisted, # Put data with the lib
        },
    }

else:
  print
  print "WARNING ! PYREX NOT FOUND"
  sys.exit(1)
 
setup(
  name         = "pysdl_mixer",
  version      = "0.0.3",
  license      = "LGPL",
  description  = "A pyrex interface to SDL_mixer for python",
  long_description  = """A pyrex interface SDL_mixer for python""",
  keywords     = "python pyrex SDL mixer audio",
  author       = "dunk fordyce",
  author_email = "dunk@dunkfordyce.co.uk",
  url          = "http://30bentham.homelinux.org/~dunk/pysdl_mixer",
  classifiers  = [
  "Topic :: Software Development :: Libraries :: Python Modules",
  "Programming Language :: Python",
  "Intended Audience :: Developers",
  ],
  
  #scripts      = ["soya_editor"],
  package_dir  = {"pysdl_mixer" : ""},
  packages     = ["pysdl_mixer"],
  
  data_files   = [],
  **KARGS)

