##  Flexlay - A Generic 2D Game Editor
##  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
##
##  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.

import os
import glob

Import('clanLib_env')

opts = Variables('custom.py')
opts.Add('CXX', 'The C++ compiler.', 'g++')
opts.Add('CXXFLAGS', 'The C++ compiler flags.', ['-g3', '-O0', '-Wall', '-fPIC', '-std=c++11'])
opts.Add('CPPPATH', 'additional header path', '')
opts.Add('LIBPATH', 'additional library path', '')

opts.Add('DESTDIR', 'destination directory which gets appended to PREFIX', '')
opts.Add('PREFIX',  'PREFIX, ie. /usr/local', '/usr/local')

env = Environment(SHLIBPREFIX='',
                  ENV = os.environ,
                  options=opts)
Help(opts.GenerateHelpText(env))

#env.Program('sharedptrtest', 'sharedptrtest.cpp',
#            CPPPATH=['/home/ingo/run/ClanLib-0.8-current/include/ClanLib-0.8/'])

# env.Program('simpleed',
#             ['simpleed.cpp'],
#             CPPPATH=['.', 
#                     '/home/ingo/run/ClanLib-0.8-current//include/ClanLib-0.8/'],
#            LIBPATH=['.', '/home/ingo/run/ClanLib-0.8-current//lib/'],
#            LIBS=['flexlay'])

libflexlay_env = env.Clone()
flexlay_lib = libflexlay_env.StaticLibrary(
    target = 'libflexlay.a',
    source = Glob('*.cpp') + Glob('*/*.cpp'),
    CPPPATH = ['.', '..'] + clanLib_env['CPPPATH'],
    CXXFLAGS  = env['CXXFLAGS'] + clanLib_env['CCFLAGS'],
    LINKFLAGS = clanLib_env['LINKFLAGS'],
    LIBPATH=['$USER_LIBPATH'] + clanLib_env['LIBPATH'],
    LIBS = clanLib_env['LIBS'])

flexlay_data = \
             glob.glob('../data/images/files/*.png') + \
             glob.glob('../data/images/fonts/*.png') + \
             glob.glob('../data/images/icons16/*.png') + \
             glob.glob('../data/images/icons24/*.png') + \
             glob.glob('../data/gui/gui.xml')    + \
             glob.glob('../data/gui/*/*.tga')    + \
             glob.glob('../data/gui/*/*.png')    + \
             glob.glob('../data/*.xml')

flexlay_headers = glob.glob('*.hxx')

flexlay_datadir = env['DESTDIR'] + env['PREFIX'] + '/share/flexlay'

install_lib     = env.Alias('install_lib', Install(env['DESTDIR'] + env['PREFIX'] + '/lib', flexlay_lib))
install_headers = env.Alias('install_headers', Install(env['DESTDIR'] + env['PREFIX'] + '/include/flexlay', flexlay_headers))
install_data    = env.Alias('install_data', InstallAs([os.path.join(flexlay_datadir, i[8:]) for i in flexlay_data],
                                                      flexlay_data))
env.Alias('install', [install_data, install_lib, install_headers])

# EOF #
