pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r4017 - in trunk/pingus: . external external/binreloc-2.0 s


From: grumbel at BerliOS
Subject: [Pingus-CVS] r4017 - in trunk/pingus: . external external/binreloc-2.0 src/pingus
Date: Wed, 4 Nov 2009 06:41:29 +0100

Author: grumbel
Date: 2009-11-04 06:41:19 +0100 (Wed, 04 Nov 2009)
New Revision: 4017

Added:
   trunk/pingus/SConscript
   trunk/pingus/external/binreloc-2.0/
   trunk/pingus/external/binreloc-2.0/binreloc.c
   trunk/pingus/external/binreloc-2.0/binreloc.h
Removed:
   trunk/pingus/SConstruct
   trunk/pingus/lib/
Modified:
   trunk/pingus/src/pingus/pingus_main.cpp
Log:
Added BuildDir handling, moved binreloc to external/

Copied: trunk/pingus/SConscript (from rev 4010, trunk/pingus/SConstruct)
===================================================================
--- trunk/pingus/SConstruct     2009-11-04 02:14:11 UTC (rev 4010)
+++ trunk/pingus/SConscript     2009-11-04 05:41:19 UTC (rev 4017)
@@ -0,0 +1,529 @@
+##  -*- python -*-
+##  $Id: pingus_main.hxx,v 1.14 2003/10/18 12:11:30 grumbel Exp $
+##
+##  Pingus - A free Lemmings clone
+##  Copyright (C) 1999 Ingo Ruhnke <address@hidden>,
+##                     Francois Beerten
+##
+##  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 sys, os
+import SCons.Util
+
+pingus_sources = [
+'src/pingus/action_holder.cpp', 
+'src/pingus/addon_menu.cpp', 
+'src/pingus/blitter.cpp',
+'src/pingus/capture_rectangle.cpp', 
+'src/pingus/collider.cpp', 
+'src/pingus/collision_map.cpp', 
+'src/pingus/collision_mask.cpp',
+'src/util/command_line.cpp',
+'src/util/command_line_generic.cpp',
+'src/pingus/config_manager.cpp', 
+'src/pingus/credits.cpp', 
+'src/pingus/debug.cpp', 
+'src/util/debug_stream.cpp', 
+'src/pingus/demo_session.cpp', 
+'src/pingus/direction.cpp', 
+'src/util/file_reader.cpp',
+'src/pingus/font.cpp',
+'src/pingus/font_description.cpp',
+'src/pingus/font_test_screen.cpp',
+'src/pingus/fonts.cpp',
+'src/pingus/fps_counter.cpp', 
+'src/pingus/game_session.cpp', 
+'src/pingus/game_time.cpp', 
+'src/pingus/gettext.cpp', 
+'src/pingus/global_event.cpp', 
+'src/pingus/globals.cpp', 
+'src/pingus/goal_manager.cpp', 
+'src/pingus/graphic_context_state.cpp', 
+'src/pingus/ground_map.cpp', 
+'src/pingus/groundtype.cpp',
+'src/pingus/layer_manager.cpp', 
+'src/pingus/level_menu.cpp',
+'src/pingus/levelset.cpp',
+'src/pingus/line_iterator.cpp',
+'src/math/math.cpp',
+'src/pingus/mover.cpp', 
+'src/pingus/option_menu.cpp',
+'src/pingus/path_manager.cpp',
+'src/util/pathname.cpp', 
+'src/pingus/pingu.cpp', 
+'src/pingus/pingu_action.cpp', 
+'src/pingus/pingu_enums.cpp', 
+'src/pingus/pingu_holder.cpp', 
+'src/pingus/pingus_demo.cpp', 
+'src/pingus/pingus_error.cpp', 
+'src/pingus/pingus_level.cpp', 
+'src/pingus/pingus_main.cpp', 
+'src/pingus/pingus_menu.cpp', 
+'src/pingus/plf_res_mgr.cpp', 
+'src/pingus/res_descriptor.cpp', 
+'src/pingus/resource.cpp',
+'src/pingus/resource_manager.cpp', 
+'src/pingus/resource_modifier.cpp', 
+'src/pingus/result_screen.cpp', 
+'src/pingus/savegame.cpp', 
+'src/pingus/savegame_manager.cpp', 
+'src/pingus/screenshot.cpp', 
+'src/pingus/server.cpp', 
+'src/pingus/server_event.cpp', 
+'src/util/sexpr_file_reader.cpp', 
+'src/util/sexpr_file_writer.cpp', 
+'src/pingus/smallmap_image.cpp', 
+'src/pingus/sprite.cpp',
+'src/pingus/sprite_impl.cpp',
+'src/pingus/start_screen.cpp', 
+'src/pingus/stat_manager.cpp', 
+'src/pingus/state_sprite.cpp', 
+'src/pingus/story_screen.cpp', 
+'src/pingus/string_format.cpp',
+'src/util/string_util.cpp',
+'src/pingus/surface.cpp',
+'src/util/system.cpp', 
+'src/util/utf8.cpp',
+'src/pingus/world.cpp', 
+'src/pingus/worldobj.cpp', 
+'src/pingus/worldobj_factory.cpp', 
+
+'src/actions/angel.cpp', 
+'src/actions/basher.cpp', 
+'src/actions/blocker.cpp', 
+'src/actions/boarder.cpp', 
+'src/actions/bomber.cpp', 
+'src/actions/bridger.cpp', 
+'src/actions/climber.cpp', 
+'src/actions/digger.cpp', 
+'src/actions/drown.cpp', 
+'src/actions/exiter.cpp', 
+'src/actions/faller.cpp', 
+'src/actions/floater.cpp', 
+'src/actions/jumper.cpp', 
+'src/actions/laser_kill.cpp', 
+'src/actions/miner.cpp', 
+'src/actions/rocket_launcher.cpp', 
+'src/actions/slider.cpp', 
+'src/actions/smashed.cpp', 
+'src/actions/splashed.cpp', 
+'src/actions/superman.cpp', 
+'src/actions/waiter.cpp', 
+'src/actions/walker.cpp', 
+
+'src/colliders/pingu_collider.cpp',
+
+'src/components/action_button.cpp', 
+'src/components/button_panel.cpp', 
+'src/components/check_box.cpp', 
+'src/components/choice_box.cpp', 
+'src/components/label.cpp', 
+'src/components/menu_button.cpp', 
+'src/components/pingus_counter.cpp', 
+'src/components/playfield.cpp', 
+'src/components/slider_box.cpp', 
+'src/components/smallmap.cpp', 
+'src/components/time_display.cpp', 
+
+'src/display/delta_framebuffer.cpp', 
+'src/display/display.cpp', 
+'src/display/drawing_context.cpp', 
+'src/display/framebuffer_surface.cpp', 
+'src/display/null_framebuffer.cpp', 
+'src/display/rect_merger.cpp',
+'src/display/scene_context.cpp', 
+'src/display/sdl_framebuffer.cpp', 
+'src/display/sdl_framebuffer_surface_impl.cpp', 
+
+'src/editor/action_properties.cpp', 
+'src/editor/button.cpp',
+'src/editor/checkbox.cpp',
+'src/editor/combobox.cpp', 
+'src/editor/editor_level.cpp', 
+'src/editor/editor_screen.cpp',
+'src/editor/file_dialog.cpp',
+'src/editor/file_list.cpp',
+'src/editor/gui_style.cpp',
+'src/editor/inputbox.cpp',
+'src/editor/label.cpp',
+'src/editor/level_objs.cpp',
+'src/editor/level_properties.cpp',
+'src/editor/minimap.cpp', 
+'src/editor/object_properties.cpp',
+'src/editor/object_selector.cpp',
+'src/editor/object_selector_list.cpp',
+'src/editor/object_selector_set.cpp',
+'src/editor/panel.cpp',
+'src/editor/viewport.cpp', 
+
+'src/gui/component.cpp',
+'src/gui/group_component.cpp', 
+'src/gui/gui_manager.cpp', 
+'src/gui/surface_button.cpp',
+
+'src/input/controller_description.cpp',
+'src/input/controller.cpp',
+'src/input/core_driver.cpp',
+'src/input/sdl_driver.cpp',
+'src/input/manager.cpp',
+
+'src/lisp/getters.cpp',
+'src/lisp/lexer.cpp',
+'src/lisp/lisp.cpp',
+'src/lisp/parser.cpp',
+
+'src/math/origin.cpp',
+'src/math/rect.cpp',
+'src/math/size.cpp',
+'src/math/vector2f.cpp',
+'src/math/vector2i.cpp',
+'src/math/vector3f.cpp',
+
+'src/movers/linear_mover.cpp', 
+
+'src/particles/explosive_particle.cpp', 
+'src/particles/pingu_particle_holder.cpp', 
+'src/particles/rain_particle_holder.cpp', 
+'src/particles/smoke_particle_holder.cpp', 
+'src/particles/snow_particle_holder.cpp', 
+
+'src/screen/gui_screen.cpp', 
+'src/screen/screen.cpp', 
+'src/screen/screen_manager.cpp', 
+
+'src/sound/sound.cpp', 
+'src/sound/sound_dummy.cpp', 
+'src/sound/sound_real.cpp', 
+'src/sound/sound_res_mgr.cpp', 
+
+'external/tinygettext/dictionary.cpp',
+'external/tinygettext/iconv.cpp',
+'external/tinygettext/plural_forms.cpp',
+'external/tinygettext/dictionary_manager.cpp',
+'external/tinygettext/language.cpp',
+'external/tinygettext/po_parser.cpp',
+'external/tinygettext/directory.cpp',
+'external/tinygettext/log.cpp',
+'external/tinygettext/tinygettext.cpp',
+
+'src/worldmap/dot.cpp', 
+'src/worldmap/dot_factory.cpp', 
+'src/worldmap/drawable.cpp', 
+'src/worldmap/drawable_factory.cpp', 
+'src/worldmap/graph.cpp', 
+'src/worldmap/level_dot.cpp', 
+'src/worldmap/path.cpp', 
+'src/worldmap/path_drawable.cpp', 
+'src/worldmap/path_graph.cpp', 
+'src/worldmap/pingus.cpp', 
+'src/worldmap/pingus_worldmap.cpp', 
+'src/worldmap/sprite_drawable.cpp', 
+'src/worldmap/worldmap.cpp', 
+'src/worldmap/worldmap_component.cpp', 
+'src/worldmap/worldmap_screen.cpp', 
+'src/worldmap/worldmap_story.cpp', 
+
+'src/worldobjs/conveyor_belt.cpp', 
+'src/worldobjs/entrance.cpp', 
+'src/worldobjs/exit.cpp', 
+'src/worldobjs/fake_exit.cpp', 
+'src/worldobjs/groundpiece.cpp', 
+'src/worldobjs/guillotine.cpp', 
+'src/worldobjs/hammer.cpp', 
+'src/worldobjs/hotspot.cpp', 
+'src/worldobjs/ice_block.cpp', 
+'src/worldobjs/laser_exit.cpp', 
+'src/worldobjs/liquid.cpp', 
+'src/worldobjs/rain_generator.cpp', 
+'src/worldobjs/smasher.cpp', 
+'src/worldobjs/snow_generator.cpp', 
+'src/worldobjs/solid_color_background.cpp', 
+'src/worldobjs/spike.cpp', 
+'src/worldobjs/starfield_background.cpp', 
+'src/worldobjs/starfield_background_stars.cpp', 
+'src/worldobjs/surface_background.cpp', 
+'src/worldobjs/switch_door.cpp', 
+'src/worldobjs/teleporter.cpp',
+'src/worldobjs/teleporter_target.cpp', 
+'src/worldobjs/thunderstorm_background.cpp', 
+'src/worldobjs/woodthing.cpp',
+
+'external/binreloc-2.0/binreloc.c'
+]
+
+class _SpaceListOptionClass:
+   """An option type for space-separated lists with arbitrary elements."""
+   def CheckDir(self, val):
+      if not os.path.isdir(val):
+         raise SCons.Errors.UserError("No directory at %s" % val)
+
+   def _convert(self, key, val, env):
+      if SCons.Util.is_List(val): # prefer val if it's already a list
+         return val
+      elif len(val) > 0 and val[0] == '[' and val[-1] == ']':
+         # or a repr of a list
+         return eval(val)
+      elif env: # otherwise, use whatever's in env
+         val = env[key]
+         if not SCons.Util.is_List(val):
+            val = val.split(None)
+         return val
+      else: # val was substituted into a string, losing its structure
+         # We'll be called again with env, hopefully that's more useful
+         raise TypeError("try again with the environment")
+
+   def _validate(self, val, env, check, converter):
+      for i in converter(val, env):
+         if check(i):
+            return True
+      return False
+
+   def __call__(self, key, help, check=None, default=[]):
+      def converter(val, env = None):
+         return self._convert(key, val, env)
+ 
+      validator = None
+      if check is not None:
+         validator = lambda k, v, e: self._validate(v, e, check, converter)
+      return (key, help, default, validator, converter)
+ 
+SpaceListOption = _SpaceListOptionClass()
+
+def DefineOptions(filename, args):
+   opts = Variables(filename, args)
+   opts.Add('CC', 'C Compiler', 'gcc')
+   opts.Add('CXX', 'C++ Compiler', 'g++')
+#   opts.Add('debug', 'Build with debugging options', 0)
+#   opts.Add('profile', 'Build with profiling support', 0)
+
+   opts.Add('CPPPATH',    'Additional preprocessor paths', [])
+   opts.Add('LIBPATH',    'Additional library paths',      [])
+   opts.Add('CPPFLAGS',   'Additional preprocessor flags', [])
+   opts.Add('CPPDEFINES', 'defined constants', [])
+   opts.Add('LIBS',       'Additional libraries', [])
+   opts.Add('CCFLAGS',    'C Compiler flags', [])
+   opts.Add('CXXFLAGS',   'C++ Compiler flags', [])
+   opts.Add('LINKFLAGS',  'Linker Compiler flags', [])
+
+   opts.Add(BoolVariable('with_opengl',        'Build with OpenGL support', 
True))
+   opts.Add(BoolVariable('with_xinput',        'Build with Xinput support', 
False))
+   opts.Add(BoolVariable('with_linuxusbmouse', 'Build with Linux USB mouse 
support', True))
+   opts.Add(BoolVariable('with_linuxevdev',    'Build with Linux evdev 
support', True))
+   opts.Add(BoolVariable('with_wiimote',       'Build with Wiimote support', 
False))
+   opts.Add(BoolVariable('ignore_errors',      'Ignore any fatal configuration 
errors', False))
+   opts.Add('optional_sources', 'Additional source files', [])
+   return opts
+
+def CheckSDLLib(context, sdllib):
+   """
+   On some platforms, SDL does this ugly redefine-main thing, that can
+   interact badly with CheckLibWithHeader.
+   """
+   lib = "SDL_%s" % sdllib
+   context.Message('Checking for %s...' % lib)
+   text = """
+#include "SDL.h"
+#include "%s.h"
+int main(int argc, char* argv[]) { return 0; }
+""" % lib
+   context.AppendLIBS(lib)
+   if context.BuildProg(text, ".cpp"):
+      context.Result("failed")
+      return False
+   else:
+      context.Result("ok")
+      return True
+
+def CheckIconv(context):
+   text = """
+#include <iconv.h>
+int main() {
+   %s char *foo;
+   (void)iconv((iconv_t)0, &foo, (size_t*)0, (char**)0, (size_t*)0);
+   return 0;
+}
+"""
+   config.CheckLibWithHeader('iconv', 'iconv.h', 'c++') # Ok to fail
+   context.Message('Check how to call iconv...')
+
+   for i in ['', 'const']:
+      if config.TryCompile(text % i, ".cpp"):
+         context.Result("use '%s'" % i)
+         return i
+   context.Result("failed")
+   return False
+
+def CheckMyProgram(context, prgn):
+   context.Message('Checking for %s...' % prgn)
+   for i in context.env['ENV']['PATH'].split(":"):
+      if os.path.exists(i + "/sdl-config"):
+         context.Result(i + "/sdl-config")
+         return True
+   context.Result("failed")
+   return False
+
+Alias('configure')
+    
+if ('configure' in COMMAND_LINE_TARGETS) or \
+   not (os.path.exists('config.py') and os.path.exists('config.h')) and \
+   not GetOption('clean'):
+    opts = DefineOptions(None, ARGUMENTS)
+    env = Environment(options = opts)
+    Help(opts.GenerateHelpText(env))
+
+    opts.Update(env)
+
+    if os.environ.has_key('PATH'):
+        env['ENV']['PATH'] = os.environ['PATH']
+    if os.environ.has_key('HOME'):
+       env['ENV']['HOME'] = os.environ['HOME']
+
+    if os.environ.has_key('PKG_CONFIG_PATH'):
+        env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
+    
+    env['CPPPATH'] += ['.', 'src/', 'external/']
+
+    config_h_defines = []      
+
+    config = env.Configure(custom_tests = {
+       'CheckMyProgram' : CheckMyProgram,
+       'CheckSDLLib': CheckSDLLib,
+       'CheckIconv': CheckIconv,
+    })
+    fatal_error = ""
+    reports = ""
+
+    # FIXME: Seems to require a rather new version of SCons
+    # ret = config.CheckBuilder(context, None, "C++")
+    # if ret != "":
+    #   reports += "  * C++ Compiler missing: " + ret
+
+    if not env['with_opengl']:
+       reports += "  * OpenGL support: disabled\n"
+    else:
+       reports += "  * OpenGL support: enabled\n"
+       config_h_defines  += [('HAVE_OPENGL', 1)]
+       env['LIBS']       += ['GL']
+       env['optional_sources'] += 
['src/display/opengl_framebuffer_surface_impl.cpp', 
+                                   'src/display/opengl_framebuffer.cpp' ]
+
+    if not env['with_linuxusbmouse']:
+        reports += "  * Linux USB mouse support: disabled\n"
+    else:
+        reports += "  * Linux USB mouse support: enabled\n"
+        config_h_defines  += [('HAVE_LINUXUSBMOUSE', 1)]
+        env['optional_sources'] += ['src/input/usbmouse_driver.cpp']
+    
+    if not env['with_linuxevdev']:
+        reports += "  * Linux evdev support: disabled\n"
+    else:
+        reports += "  * Linux evdev support: ok\n"
+        config_h_defines  += [('HAVE_LINUXEVDEV', 1)]
+        env['optional_sources'] += ['src/input/evdev_driver.cpp',
+                                    'src/input/evdev_device.cpp']
+    
+    if not env['with_wiimote']:
+        reports += "  * Wiimote support: disabled\n"        
+    elif config.CheckLibWithHeader('cwiid', 'cwiid.h', 'c++'):
+        reports += "  * Wiimote support: yes\n"
+        config_h_defines  += [('HAVE_CWIID', 1)]
+        env['LIBS']       += ['cwiid']
+        env['optional_sources'] += ['src/input/wiimote_driver.cpp',
+                                    'src/input/wiimote.cpp']
+    else:
+        reports += "  * Wiimote support: no (libcwiid or cwiid.h not found)\n"
+
+    if not env['with_xinput']:
+        reports += "  * XInput support: disabled\n"
+    elif not config.CheckLibWithHeader('Xi', 'X11/extensions/XInput.h', 'c++'):
+        reports += "  * XInput support: no (library Xi not found)\n" ## FIXME: 
Need to set a define
+    else:
+        reports += "  * XInput support: yes\n"
+        config_h_defines  += [('HAVE_XINPUT', 1)]
+        env['LIBS'] += ['Xi']
+        env['optional_sources'] += ['src/input/xinput_driver.cpp',
+                                    'src/input/xinput_device.cpp']
+        
+    if not config.CheckLibWithHeader('boost_signals', 'boost/signals.hpp', 
'c++'):
+       if not config.CheckLibWithHeader('boost_signals-mt', 
'boost/signals.hpp', 'c++'):
+          fatal_error += "  * library 'boost_signals' not found\n"
+
+    if not config.CheckLibWithHeader('png', 'png.h', 'c++'):
+       fatal_error += "  * library 'png' not found\n"
+
+    if config.CheckMyProgram('sdl-config'):
+       env.ParseConfig('sdl-config  --cflags --libs')
+       for sdllib in ['image', 'mixer']:
+          if not config.CheckSDLLib(sdllib):
+             fatal_error += "  * SDL library '%s' not found\n" % sdllib
+    else:
+       fatal_error += "  * couldn't find sdl-config, SDL missing\n"
+
+    iconv_const = config.CheckIconv()
+    if iconv_const == False:
+       fatal_error += "  * can't call iconv\n"
+
+    env = config.Finish()
+    opts.Save("config.py", env)
+
+    print "Reports:"
+    print reports
+
+    if not fatal_error == "":
+        print "Fatal Errors:"
+        print fatal_error
+        if not env['ignore_errors']:
+           Exit(1)
+        else:
+           print "\nError are being ignored, the build continues"
+
+    config_h = open('config.h', 'w')
+    config_h.write('#define VERSION "0.7.3"\n')
+    config_h.write('#define ENABLE_BINRELOC 1\n')
+    config_h.write('#define ICONV_CONST %s\n' % iconv_const)
+    for (v,k) in config_h_defines:
+        config_h.write('#define %s %s\n' % (v, k))
+    config_h.close()
+    if ('configure' in COMMAND_LINE_TARGETS):
+        print "Configuration written to config.h and config.py, run:"
+        print ""
+        print "  scons"
+        print ""
+        print "To start the compile"
+    else:
+        print "Configuration written to config.h and config.py"
+    ARGUMENTS = {}
+
+if not ('configure' in COMMAND_LINE_TARGETS):
+    if ARGUMENTS != {}:
+        print "Error: You must not supply arguments to the compile step."
+        print "Use:"
+        print ""
+        print "  scons configure [ARGUMENTS]..."
+        print ""
+        print "If you want to change the build configuration."
+        os.sys.exit(1)
+        
+    opts = DefineOptions("config.py", {})
+    env = Environment(options = opts)
+    Help(opts.GenerateHelpText(env))
+
+    opts.Update(env)
+    env['CPPPATH'] += ['.', 'src/']
+    Default(env.Program('pingus', pingus_sources + env['optional_sources']))
+    Clean('pingus', ['config.py', 'config.h'])
+
+    
+## EOF ##

Deleted: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2009-11-04 05:31:52 UTC (rev 4016)
+++ trunk/pingus/SConstruct     2009-11-04 05:41:19 UTC (rev 4017)
@@ -1,529 +0,0 @@
-##  -*- python -*-
-##  $Id: pingus_main.hxx,v 1.14 2003/10/18 12:11:30 grumbel Exp $
-##
-##  Pingus - A free Lemmings clone
-##  Copyright (C) 1999 Ingo Ruhnke <address@hidden>,
-##                     Francois Beerten
-##
-##  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 sys, os
-import SCons.Util
-
-pingus_sources = [
-'src/pingus/action_holder.cpp', 
-'src/pingus/addon_menu.cpp', 
-'src/pingus/blitter.cpp',
-'src/pingus/capture_rectangle.cpp', 
-'src/pingus/collider.cpp', 
-'src/pingus/collision_map.cpp', 
-'src/pingus/collision_mask.cpp',
-'src/util/command_line.cpp',
-'src/util/command_line_generic.cpp',
-'src/pingus/config_manager.cpp', 
-'src/pingus/credits.cpp', 
-'src/pingus/debug.cpp', 
-'src/util/debug_stream.cpp', 
-'src/pingus/demo_session.cpp', 
-'src/pingus/direction.cpp', 
-'src/util/file_reader.cpp',
-'src/pingus/font.cpp',
-'src/pingus/font_description.cpp',
-'src/pingus/font_test_screen.cpp',
-'src/pingus/fonts.cpp',
-'src/pingus/fps_counter.cpp', 
-'src/pingus/game_session.cpp', 
-'src/pingus/game_time.cpp', 
-'src/pingus/gettext.cpp', 
-'src/pingus/global_event.cpp', 
-'src/pingus/globals.cpp', 
-'src/pingus/goal_manager.cpp', 
-'src/pingus/graphic_context_state.cpp', 
-'src/pingus/ground_map.cpp', 
-'src/pingus/groundtype.cpp',
-'src/pingus/layer_manager.cpp', 
-'src/pingus/level_menu.cpp',
-'src/pingus/levelset.cpp',
-'src/pingus/line_iterator.cpp',
-'src/math/math.cpp',
-'src/pingus/mover.cpp', 
-'src/pingus/option_menu.cpp',
-'src/pingus/path_manager.cpp',
-'src/util/pathname.cpp', 
-'src/pingus/pingu.cpp', 
-'src/pingus/pingu_action.cpp', 
-'src/pingus/pingu_enums.cpp', 
-'src/pingus/pingu_holder.cpp', 
-'src/pingus/pingus_demo.cpp', 
-'src/pingus/pingus_error.cpp', 
-'src/pingus/pingus_level.cpp', 
-'src/pingus/pingus_main.cpp', 
-'src/pingus/pingus_menu.cpp', 
-'src/pingus/plf_res_mgr.cpp', 
-'src/pingus/res_descriptor.cpp', 
-'src/pingus/resource.cpp',
-'src/pingus/resource_manager.cpp', 
-'src/pingus/resource_modifier.cpp', 
-'src/pingus/result_screen.cpp', 
-'src/pingus/savegame.cpp', 
-'src/pingus/savegame_manager.cpp', 
-'src/pingus/screenshot.cpp', 
-'src/pingus/server.cpp', 
-'src/pingus/server_event.cpp', 
-'src/util/sexpr_file_reader.cpp', 
-'src/util/sexpr_file_writer.cpp', 
-'src/pingus/smallmap_image.cpp', 
-'src/pingus/sprite.cpp',
-'src/pingus/sprite_impl.cpp',
-'src/pingus/start_screen.cpp', 
-'src/pingus/stat_manager.cpp', 
-'src/pingus/state_sprite.cpp', 
-'src/pingus/story_screen.cpp', 
-'src/pingus/string_format.cpp',
-'src/util/string_util.cpp',
-'src/pingus/surface.cpp',
-'src/util/system.cpp', 
-'src/util/utf8.cpp',
-'src/pingus/world.cpp', 
-'src/pingus/worldobj.cpp', 
-'src/pingus/worldobj_factory.cpp', 
-
-'src/actions/angel.cpp', 
-'src/actions/basher.cpp', 
-'src/actions/blocker.cpp', 
-'src/actions/boarder.cpp', 
-'src/actions/bomber.cpp', 
-'src/actions/bridger.cpp', 
-'src/actions/climber.cpp', 
-'src/actions/digger.cpp', 
-'src/actions/drown.cpp', 
-'src/actions/exiter.cpp', 
-'src/actions/faller.cpp', 
-'src/actions/floater.cpp', 
-'src/actions/jumper.cpp', 
-'src/actions/laser_kill.cpp', 
-'src/actions/miner.cpp', 
-'src/actions/rocket_launcher.cpp', 
-'src/actions/slider.cpp', 
-'src/actions/smashed.cpp', 
-'src/actions/splashed.cpp', 
-'src/actions/superman.cpp', 
-'src/actions/waiter.cpp', 
-'src/actions/walker.cpp', 
-
-'src/colliders/pingu_collider.cpp',
-
-'src/components/action_button.cpp', 
-'src/components/button_panel.cpp', 
-'src/components/check_box.cpp', 
-'src/components/choice_box.cpp', 
-'src/components/label.cpp', 
-'src/components/menu_button.cpp', 
-'src/components/pingus_counter.cpp', 
-'src/components/playfield.cpp', 
-'src/components/slider_box.cpp', 
-'src/components/smallmap.cpp', 
-'src/components/time_display.cpp', 
-
-'src/display/delta_framebuffer.cpp', 
-'src/display/display.cpp', 
-'src/display/drawing_context.cpp', 
-'src/display/framebuffer_surface.cpp', 
-'src/display/null_framebuffer.cpp', 
-'src/display/rect_merger.cpp',
-'src/display/scene_context.cpp', 
-'src/display/sdl_framebuffer.cpp', 
-'src/display/sdl_framebuffer_surface_impl.cpp', 
-
-'src/editor/action_properties.cpp', 
-'src/editor/button.cpp',
-'src/editor/checkbox.cpp',
-'src/editor/combobox.cpp', 
-'src/editor/editor_level.cpp', 
-'src/editor/editor_screen.cpp',
-'src/editor/file_dialog.cpp',
-'src/editor/file_list.cpp',
-'src/editor/gui_style.cpp',
-'src/editor/inputbox.cpp',
-'src/editor/label.cpp',
-'src/editor/level_objs.cpp',
-'src/editor/level_properties.cpp',
-'src/editor/minimap.cpp', 
-'src/editor/object_properties.cpp',
-'src/editor/object_selector.cpp',
-'src/editor/object_selector_list.cpp',
-'src/editor/object_selector_set.cpp',
-'src/editor/panel.cpp',
-'src/editor/viewport.cpp', 
-
-'src/gui/component.cpp',
-'src/gui/group_component.cpp', 
-'src/gui/gui_manager.cpp', 
-'src/gui/surface_button.cpp',
-
-'src/input/controller_description.cpp',
-'src/input/controller.cpp',
-'src/input/core_driver.cpp',
-'src/input/sdl_driver.cpp',
-'src/input/manager.cpp',
-
-'src/lisp/getters.cpp',
-'src/lisp/lexer.cpp',
-'src/lisp/lisp.cpp',
-'src/lisp/parser.cpp',
-
-'src/math/origin.cpp',
-'src/math/rect.cpp',
-'src/math/size.cpp',
-'src/math/vector2f.cpp',
-'src/math/vector2i.cpp',
-'src/math/vector3f.cpp',
-
-'src/movers/linear_mover.cpp', 
-
-'src/particles/explosive_particle.cpp', 
-'src/particles/pingu_particle_holder.cpp', 
-'src/particles/rain_particle_holder.cpp', 
-'src/particles/smoke_particle_holder.cpp', 
-'src/particles/snow_particle_holder.cpp', 
-
-'src/screen/gui_screen.cpp', 
-'src/screen/screen.cpp', 
-'src/screen/screen_manager.cpp', 
-
-'src/sound/sound.cpp', 
-'src/sound/sound_dummy.cpp', 
-'src/sound/sound_real.cpp', 
-'src/sound/sound_res_mgr.cpp', 
-
-'external/tinygettext/dictionary.cpp',
-'external/tinygettext/iconv.cpp',
-'external/tinygettext/plural_forms.cpp',
-'external/tinygettext/dictionary_manager.cpp',
-'external/tinygettext/language.cpp',
-'external/tinygettext/po_parser.cpp',
-'external/tinygettext/directory.cpp',
-'external/tinygettext/log.cpp',
-'external/tinygettext/tinygettext.cpp',
-
-'src/worldmap/dot.cpp', 
-'src/worldmap/dot_factory.cpp', 
-'src/worldmap/drawable.cpp', 
-'src/worldmap/drawable_factory.cpp', 
-'src/worldmap/graph.cpp', 
-'src/worldmap/level_dot.cpp', 
-'src/worldmap/path.cpp', 
-'src/worldmap/path_drawable.cpp', 
-'src/worldmap/path_graph.cpp', 
-'src/worldmap/pingus.cpp', 
-'src/worldmap/pingus_worldmap.cpp', 
-'src/worldmap/sprite_drawable.cpp', 
-'src/worldmap/worldmap.cpp', 
-'src/worldmap/worldmap_component.cpp', 
-'src/worldmap/worldmap_screen.cpp', 
-'src/worldmap/worldmap_story.cpp', 
-
-'src/worldobjs/conveyor_belt.cpp', 
-'src/worldobjs/entrance.cpp', 
-'src/worldobjs/exit.cpp', 
-'src/worldobjs/fake_exit.cpp', 
-'src/worldobjs/groundpiece.cpp', 
-'src/worldobjs/guillotine.cpp', 
-'src/worldobjs/hammer.cpp', 
-'src/worldobjs/hotspot.cpp', 
-'src/worldobjs/ice_block.cpp', 
-'src/worldobjs/laser_exit.cpp', 
-'src/worldobjs/liquid.cpp', 
-'src/worldobjs/rain_generator.cpp', 
-'src/worldobjs/smasher.cpp', 
-'src/worldobjs/snow_generator.cpp', 
-'src/worldobjs/solid_color_background.cpp', 
-'src/worldobjs/spike.cpp', 
-'src/worldobjs/starfield_background.cpp', 
-'src/worldobjs/starfield_background_stars.cpp', 
-'src/worldobjs/surface_background.cpp', 
-'src/worldobjs/switch_door.cpp', 
-'src/worldobjs/teleporter.cpp',
-'src/worldobjs/teleporter_target.cpp', 
-'src/worldobjs/thunderstorm_background.cpp', 
-'src/worldobjs/woodthing.cpp',
-
-'lib/binreloc/binreloc.c'
-]
-
-class _SpaceListOptionClass:
-   """An option type for space-separated lists with arbitrary elements."""
-   def CheckDir(self, val):
-      if not os.path.isdir(val):
-         raise SCons.Errors.UserError("No directory at %s" % val)
-
-   def _convert(self, key, val, env):
-      if SCons.Util.is_List(val): # prefer val if it's already a list
-         return val
-      elif len(val) > 0 and val[0] == '[' and val[-1] == ']':
-         # or a repr of a list
-         return eval(val)
-      elif env: # otherwise, use whatever's in env
-         val = env[key]
-         if not SCons.Util.is_List(val):
-            val = val.split(None)
-         return val
-      else: # val was substituted into a string, losing its structure
-         # We'll be called again with env, hopefully that's more useful
-         raise TypeError("try again with the environment")
-
-   def _validate(self, val, env, check, converter):
-      for i in converter(val, env):
-         if check(i):
-            return True
-      return False
-
-   def __call__(self, key, help, check=None, default=[]):
-      def converter(val, env = None):
-         return self._convert(key, val, env)
- 
-      validator = None
-      if check is not None:
-         validator = lambda k, v, e: self._validate(v, e, check, converter)
-      return (key, help, default, validator, converter)
- 
-SpaceListOption = _SpaceListOptionClass()
-
-def DefineOptions(filename, args):
-   opts = Variables(filename, args)
-   opts.Add('CC', 'C Compiler', 'gcc')
-   opts.Add('CXX', 'C++ Compiler', 'g++')
-#   opts.Add('debug', 'Build with debugging options', 0)
-#   opts.Add('profile', 'Build with profiling support', 0)
-
-   opts.Add('CPPPATH',    'Additional preprocessor paths', [])
-   opts.Add('LIBPATH',    'Additional library paths',      [])
-   opts.Add('CPPFLAGS',   'Additional preprocessor flags', [])
-   opts.Add('CPPDEFINES', 'defined constants', [])
-   opts.Add('LIBS',       'Additional libraries', [])
-   opts.Add('CCFLAGS',    'C Compiler flags', [])
-   opts.Add('CXXFLAGS',   'C++ Compiler flags', [])
-   opts.Add('LINKFLAGS',  'Linker Compiler flags', [])
-
-   opts.Add(BoolVariable('with_opengl',        'Build with OpenGL support', 
True))
-   opts.Add(BoolVariable('with_xinput',        'Build with Xinput support', 
False))
-   opts.Add(BoolVariable('with_linuxusbmouse', 'Build with Linux USB mouse 
support', True))
-   opts.Add(BoolVariable('with_linuxevdev',    'Build with Linux evdev 
support', True))
-   opts.Add(BoolVariable('with_wiimote',       'Build with Wiimote support', 
False))
-   opts.Add(BoolVariable('ignore_errors',      'Ignore any fatal configuration 
errors', False))
-   opts.Add('optional_sources', 'Additional source files', [])
-   return opts
-
-def CheckSDLLib(context, sdllib):
-   """
-   On some platforms, SDL does this ugly redefine-main thing, that can
-   interact badly with CheckLibWithHeader.
-   """
-   lib = "SDL_%s" % sdllib
-   context.Message('Checking for %s...' % lib)
-   text = """
-#include "SDL.h"
-#include "%s.h"
-int main(int argc, char* argv[]) { return 0; }
-""" % lib
-   context.AppendLIBS(lib)
-   if context.BuildProg(text, ".cpp"):
-      context.Result("failed")
-      return False
-   else:
-      context.Result("ok")
-      return True
-
-def CheckIconv(context):
-   text = """
-#include <iconv.h>
-int main() {
-   %s char *foo;
-   (void)iconv((iconv_t)0, &foo, (size_t*)0, (char**)0, (size_t*)0);
-   return 0;
-}
-"""
-   config.CheckLibWithHeader('iconv', 'iconv.h', 'c++') # Ok to fail
-   context.Message('Check how to call iconv...')
-
-   for i in ['', 'const']:
-      if config.TryCompile(text % i, ".cpp"):
-         context.Result("use '%s'" % i)
-         return i
-   context.Result("failed")
-   return False
-
-def CheckMyProgram(context, prgn):
-   context.Message('Checking for %s...' % prgn)
-   for i in context.env['ENV']['PATH'].split(":"):
-      if os.path.exists(i + "/sdl-config"):
-         context.Result(i + "/sdl-config")
-         return True
-   context.Result("failed")
-   return False
-
-Alias('configure')
-    
-if ('configure' in COMMAND_LINE_TARGETS) or \
-   not (os.path.exists('config.py') and os.path.exists('config.h')) and \
-   not GetOption('clean'):
-    opts = DefineOptions(None, ARGUMENTS)
-    env = Environment(options = opts)
-    Help(opts.GenerateHelpText(env))
-
-    opts.Update(env)
-
-    if os.environ.has_key('PATH'):
-        env['ENV']['PATH'] = os.environ['PATH']
-    if os.environ.has_key('HOME'):
-       env['ENV']['HOME'] = os.environ['HOME']
-
-    if os.environ.has_key('PKG_CONFIG_PATH'):
-        env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
-    
-    env['CPPPATH'] += ['.', 'src/', 'external/']
-
-    config_h_defines = []      
-
-    config = env.Configure(custom_tests = {
-       'CheckMyProgram' : CheckMyProgram,
-       'CheckSDLLib': CheckSDLLib,
-       'CheckIconv': CheckIconv,
-    })
-    fatal_error = ""
-    reports = ""
-
-    # FIXME: Seems to require a rather new version of SCons
-    # ret = config.CheckBuilder(context, None, "C++")
-    # if ret != "":
-    #   reports += "  * C++ Compiler missing: " + ret
-
-    if not env['with_opengl']:
-       reports += "  * OpenGL support: disabled\n"
-    else:
-       reports += "  * OpenGL support: enabled\n"
-       config_h_defines  += [('HAVE_OPENGL', 1)]
-       env['LIBS']       += ['GL']
-       env['optional_sources'] += 
['src/display/opengl_framebuffer_surface_impl.cpp', 
-                                   'src/display/opengl_framebuffer.cpp' ]
-
-    if not env['with_linuxusbmouse']:
-        reports += "  * Linux USB mouse support: disabled\n"
-    else:
-        reports += "  * Linux USB mouse support: enabled\n"
-        config_h_defines  += [('HAVE_LINUXUSBMOUSE', 1)]
-        env['optional_sources'] += ['src/input/usbmouse_driver.cpp']
-    
-    if not env['with_linuxevdev']:
-        reports += "  * Linux evdev support: disabled\n"
-    else:
-        reports += "  * Linux evdev support: ok\n"
-        config_h_defines  += [('HAVE_LINUXEVDEV', 1)]
-        env['optional_sources'] += ['src/input/evdev_driver.cpp',
-                                    'src/input/evdev_device.cpp']
-    
-    if not env['with_wiimote']:
-        reports += "  * Wiimote support: disabled\n"        
-    elif config.CheckLibWithHeader('cwiid', 'cwiid.h', 'c++'):
-        reports += "  * Wiimote support: yes\n"
-        config_h_defines  += [('HAVE_CWIID', 1)]
-        env['LIBS']       += ['cwiid']
-        env['optional_sources'] += ['src/input/wiimote_driver.cpp',
-                                    'src/input/wiimote.cpp']
-    else:
-        reports += "  * Wiimote support: no (libcwiid or cwiid.h not found)\n"
-
-    if not env['with_xinput']:
-        reports += "  * XInput support: disabled\n"
-    elif not config.CheckLibWithHeader('Xi', 'X11/extensions/XInput.h', 'c++'):
-        reports += "  * XInput support: no (library Xi not found)\n" ## FIXME: 
Need to set a define
-    else:
-        reports += "  * XInput support: yes\n"
-        config_h_defines  += [('HAVE_XINPUT', 1)]
-        env['LIBS'] += ['Xi']
-        env['optional_sources'] += ['src/input/xinput_driver.cpp',
-                                    'src/input/xinput_device.cpp']
-        
-    if not config.CheckLibWithHeader('boost_signals', 'boost/signals.hpp', 
'c++'):
-       if not config.CheckLibWithHeader('boost_signals-mt', 
'boost/signals.hpp', 'c++'):
-          fatal_error += "  * library 'boost_signals' not found\n"
-
-    if not config.CheckLibWithHeader('png', 'png.h', 'c++'):
-       fatal_error += "  * library 'png' not found\n"
-
-    if config.CheckMyProgram('sdl-config'):
-       env.ParseConfig('sdl-config  --cflags --libs')
-       for sdllib in ['image', 'mixer']:
-          if not config.CheckSDLLib(sdllib):
-             fatal_error += "  * SDL library '%s' not found\n" % sdllib
-    else:
-       fatal_error += "  * couldn't find sdl-config, SDL missing\n"
-
-    iconv_const = config.CheckIconv()
-    if iconv_const == False:
-       fatal_error += "  * can't call iconv\n"
-
-    env = config.Finish()
-    opts.Save("config.py", env)
-
-    print "Reports:"
-    print reports
-
-    if not fatal_error == "":
-        print "Fatal Errors:"
-        print fatal_error
-        if not env['ignore_errors']:
-           Exit(1)
-        else:
-           print "\nError are being ignored, the build continues"
-
-    config_h = open('config.h', 'w')
-    config_h.write('#define VERSION "0.7.3"\n')
-    config_h.write('#define ENABLE_BINRELOC 1\n')
-    config_h.write('#define ICONV_CONST %s\n' % iconv_const)
-    for (v,k) in config_h_defines:
-        config_h.write('#define %s %s\n' % (v, k))
-    config_h.close()
-    if ('configure' in COMMAND_LINE_TARGETS):
-        print "Configuration written to config.h and config.py, run:"
-        print ""
-        print "  scons"
-        print ""
-        print "To start the compile"
-    else:
-        print "Configuration written to config.h and config.py"
-    ARGUMENTS = {}
-
-if not ('configure' in COMMAND_LINE_TARGETS):
-    if ARGUMENTS != {}:
-        print "Error: You must not supply arguments to the compile step."
-        print "Use:"
-        print ""
-        print "  scons configure [ARGUMENTS]..."
-        print ""
-        print "If you want to change the build configuration."
-        os.sys.exit(1)
-        
-    opts = DefineOptions("config.py", {})
-    env = Environment(options = opts)
-    Help(opts.GenerateHelpText(env))
-
-    opts.Update(env)
-    env['CPPPATH'] += ['.', 'src/']
-    Default(env.Program('pingus', pingus_sources + env['optional_sources']))
-    Clean('pingus', ['config.py', 'config.h'])
-
-    
-## EOF ##

Added: trunk/pingus/external/binreloc-2.0/binreloc.c
===================================================================
--- trunk/pingus/external/binreloc-2.0/binreloc.c       2009-11-04 05:31:52 UTC 
(rev 4016)
+++ trunk/pingus/external/binreloc-2.0/binreloc.c       2009-11-04 05:41:19 UTC 
(rev 4017)
@@ -0,0 +1,766 @@
+/*
+ * BinReloc - a library for creating relocatable executables
+ * Written by: Hongli Lai <address@hidden>
+ * http://autopackage.org/
+ *
+ * This source code is public domain. You can relicense this code
+ * under whatever license you want.
+ *
+ * See http://autopackage.org/docs/binreloc/ for
+ * more information and how to use this.
+ */
+
+#ifndef __BINRELOC_C__
+#define __BINRELOC_C__
+
+#ifdef ENABLE_BINRELOC
+       #include <sys/types.h>
+       #include <sys/stat.h>
+       #include <unistd.h>
+#endif /* ENABLE_BINRELOC */
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+#include "binreloc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+/** @internal
+ * Find the canonical filename of the executable. Returns the filename
+ * (which must be freed) or NULL on error. If the parameter 'error' is
+ * not NULL, the error code will be stored there, if an error occured.
+ */
+static char *
+_br_find_exe (BrInitError *error)
+{
+#ifndef ENABLE_BINRELOC
+       if (error)
+               *error = BR_INIT_ERROR_DISABLED;
+       return NULL;
+#else
+       char *path, *path2, *line, *result;
+       size_t buf_size;
+       ssize_t size;
+       struct stat stat_buf;
+       FILE *f;
+
+       /* Read from /proc/self/exe (symlink) */
+       if (sizeof (path) > SSIZE_MAX)
+               buf_size = SSIZE_MAX - 1;
+       else
+               buf_size = PATH_MAX - 1;
+       path = (char *) malloc (buf_size);
+       if (path == NULL) {
+               /* Cannot allocate memory. */
+               if (error)
+                       *error = BR_INIT_ERROR_NOMEM;
+               return NULL;
+       }
+       path2 = (char *) malloc (buf_size);
+       if (path2 == NULL) {
+               /* Cannot allocate memory. */
+               if (error)
+                       *error = BR_INIT_ERROR_NOMEM;
+               free (path);
+               return NULL;
+       }
+
+       strncpy (path2, "/proc/self/exe", buf_size - 1);
+
+       while (1) {
+               int i;
+
+               size = readlink (path2, path, buf_size - 1);
+               if (size == -1) {
+                       /* Error. */
+                       free (path2);
+                       break;
+               }
+
+               /* readlink() success. */
+               path[size] = '\0';
+
+               /* Check whether the symlink's target is also a symlink.
+                * We want to get the final target. */
+               i = stat (path, &stat_buf);
+               if (i == -1) {
+                       /* Error. */
+                       free (path2);
+                       break;
+               }
+
+               /* stat() success. */
+               if (!S_ISLNK (stat_buf.st_mode)) {
+                       /* path is not a symlink. Done. */
+                       free (path2);
+                       return path;
+               }
+
+               /* path is a symlink. Continue loop and resolve this. */
+               strncpy (path, path2, buf_size - 1);
+       }
+
+
+       /* readlink() or stat() failed; this can happen when the program is
+        * running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
+
+       buf_size = PATH_MAX + 128;
+       line = (char *) realloc (path, buf_size);
+       if (line == NULL) {
+               /* Cannot allocate memory. */
+               free (path);
+               if (error)
+                       *error = BR_INIT_ERROR_NOMEM;
+               return NULL;
+       }
+
+       f = fopen ("/proc/self/maps", "r");
+       if (f == NULL) {
+               free (line);
+               if (error)
+                       *error = BR_INIT_ERROR_OPEN_MAPS;
+               return NULL;
+       }
+
+       /* The first entry should be the executable name. */
+       result = fgets (line, (int) buf_size, f);
+       if (result == NULL) {
+               fclose (f);
+               free (line);
+               if (error)
+                       *error = BR_INIT_ERROR_READ_MAPS;
+               return NULL;
+       }
+
+       /* Get rid of newline character. */
+       buf_size = strlen (line);
+       if (buf_size <= 0) {
+               /* Huh? An empty string? */
+               fclose (f);
+               free (line);
+               if (error)
+                       *error = BR_INIT_ERROR_INVALID_MAPS;
+               return NULL;
+       }
+       if (line[buf_size - 1] == 10)
+               line[buf_size - 1] = 0;
+
+       /* Extract the filename; it is always an absolute path. */
+       path = strchr (line, '/');
+
+       /* Sanity check. */
+       if (strstr (line, " r-xp ") == NULL || path == NULL) {
+               fclose (f);
+               free (line);
+               if (error)
+                       *error = BR_INIT_ERROR_INVALID_MAPS;
+               return NULL;
+       }
+
+       path = strdup (path);
+       free (line);
+       fclose (f);
+       return path;
+#endif /* ENABLE_BINRELOC */
+}
+
+
+/** @internal
+ * Find the canonical filename of the executable which owns symbol.
+ * Returns a filename which must be freed, or NULL on error.
+ */
+static char *
+_br_find_exe_for_symbol (const void *symbol, BrInitError *error)
+{
+#ifndef ENABLE_BINRELOC
+       if (error)
+               *error = BR_INIT_ERROR_DISABLED;
+       return (char *) NULL;
+#else
+       #define SIZE PATH_MAX + 100
+       FILE *f;
+       size_t address_string_len;
+       char *address_string, line[SIZE], *found;
+
+       if (symbol == NULL)
+               return (char *) NULL;
+
+       f = fopen ("/proc/self/maps", "r");
+       if (f == NULL)
+               return (char *) NULL;
+
+       address_string_len = 4;
+       address_string = (char *) malloc (address_string_len);
+       found = (char *) NULL;
+
+       while (!feof (f)) {
+               char *start_addr, *end_addr, *end_addr_end, *file;
+               void *start_addr_p, *end_addr_p;
+               size_t len;
+
+               if (fgets (line, SIZE, f) == NULL)
+                       break;
+
+               /* Sanity check. */
+               if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == 
NULL)
+                       continue;
+
+               /* Parse line. */
+               start_addr = line;
+               end_addr = strchr (line, '-');
+               file = strchr (line, '/');
+
+               /* More sanity check. */
+               if (!(file > end_addr && end_addr != NULL && end_addr[0] == 
'-'))
+                       continue;
+
+               end_addr[0] = '\0';
+               end_addr++;
+               end_addr_end = strchr (end_addr, ' ');
+               if (end_addr_end == NULL)
+                       continue;
+
+               end_addr_end[0] = '\0';
+               len = strlen (file);
+               if (len == 0)
+                       continue;
+               if (file[len - 1] == '\n')
+                       file[len - 1] = '\0';
+
+               /* Get rid of "(deleted)" from the filename. */
+               len = strlen (file);
+               if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0)
+                       file[len - 10] = '\0';
+
+               /* I don't know whether this can happen but better safe than 
sorry. */
+               len = strlen (start_addr);
+               if (len != strlen (end_addr))
+                       continue;
+
+
+               /* Transform the addresses into a string in the form of 
0xdeadbeef,
+                * then transform that into a pointer. */
+               if (address_string_len < len + 3) {
+                       address_string_len = len + 3;
+                       address_string = (char *) realloc (address_string, 
address_string_len);
+               }
+
+               memcpy (address_string, "0x", 2);
+               memcpy (address_string + 2, start_addr, len);
+               address_string[2 + len] = '\0';
+               sscanf (address_string, "%p", &start_addr_p);
+
+               memcpy (address_string, "0x", 2);
+               memcpy (address_string + 2, end_addr, len);
+               address_string[2 + len] = '\0';
+               sscanf (address_string, "%p", &end_addr_p);
+
+
+               if (symbol >= start_addr_p && symbol < end_addr_p) {
+                       found = file;
+                       break;
+               }
+       }
+
+       free (address_string);
+       fclose (f);
+
+       if (found == NULL)
+               return (char *) NULL;
+       else
+               return strdup (found);
+#endif /* ENABLE_BINRELOC */
+}
+
+
+#ifndef BINRELOC_RUNNING_DOXYGEN
+       #undef NULL
+       #define NULL ((void *) 0) /* typecasted as char* for C++ type safeness 
*/
+#endif
+
+static char *exe = (char *) NULL;
+
+
+/** Initialize the BinReloc library (for applications).
+ *
+ * This function must be called before using any other BinReloc functions.
+ * It attempts to locate the application's canonical filename.
+ *
+ * @note If you want to use BinReloc for a library, then you should call
+ *       br_init_lib() instead.
+ *
+ * @param error  If BinReloc failed to initialize, then the error code will
+ *               be stored in this variable. Set to NULL if you want to
+ *               ignore this. See #BrInitError for a list of error codes.
+ *
+ * @returns 1 on success, 0 if BinReloc failed to initialize.
+ */
+int
+br_init (BrInitError *error)
+{
+       exe = _br_find_exe (error);
+       return exe != NULL;
+}
+
+
+/** Initialize the BinReloc library (for libraries).
+ *
+ * This function must be called before using any other BinReloc functions.
+ * It attempts to locate the calling library's canonical filename.
+ *
+ * @note The BinReloc source code MUST be included in your library, or this
+ *       function won't work correctly.
+ *
+ * @param error  If BinReloc failed to initialize, then the error code will
+ *               be stored in this variable. Set to NULL if you want to
+ *               ignore this. See #BrInitError for a list of error codes.
+ *
+ * @returns 1 on success, 0 if a filename cannot be found.
+ */
+int
+br_init_lib (BrInitError *error)
+{
+       exe = _br_find_exe_for_symbol ((const void *) "", error);
+       return exe != NULL;
+}
+
+
+/** Find the canonical filename of the current application.
+ *
+ * @param default_exe  A default filename which will be used as fallback.
+ * @returns A string containing the application's canonical filename,
+ *          which must be freed when no longer necessary. If BinReloc is
+ *          not initialized, or if br_init() failed, then a copy of
+ *          default_exe will be returned. If default_exe is NULL, then
+ *          NULL will be returned.
+ */
+char *
+br_find_exe (const char *default_exe)
+{
+       if (exe == (char *) NULL) {
+               /* BinReloc is not initialized. */
+               if (default_exe != (const char *) NULL)
+                       return strdup (default_exe);
+               else
+                       return (char *) NULL;
+       }
+       return strdup (exe);
+}
+
+
+/** Locate the directory in which the current application is installed.
+ *
+ * The prefix is generated by the following pseudo-code evaluation:
+ * \code
+ * dirname(exename)
+ * \endcode
+ *
+ * @param default_dir  A default directory which will used as fallback.
+ * @return A string containing the directory, which must be freed when no
+ *         longer necessary. If BinReloc is not initialized, or if the
+ *         initialization function failed, then a copy of default_dir
+ *         will be returned. If default_dir is NULL, then NULL will be
+ *         returned.
+ */
+char *
+br_find_exe_dir (const char *default_dir)
+{
+       if (exe == NULL) {
+               /* BinReloc not initialized. */
+               if (default_dir != NULL)
+                       return strdup (default_dir);
+               else
+                       return NULL;
+       }
+
+       return br_dirname (exe);
+}
+
+
+/** Locate the prefix in which the current application is installed.
+ *
+ * The prefix is generated by the following pseudo-code evaluation:
+ * \code
+ * dirname(dirname(exename))
+ * \endcode
+ *
+ * @param default_prefix  A default prefix which will used as fallback.
+ * @return A string containing the prefix, which must be freed when no
+ *         longer necessary. If BinReloc is not initialized, or if
+ *         the initialization function failed, then a copy of default_prefix
+ *         will be returned. If default_prefix is NULL, then NULL will be 
returned.
+ */
+char *
+br_find_prefix (const char *default_prefix)
+{
+       char *dir1, *dir2;
+
+       if (exe == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_prefix != (const char *) NULL)
+                       return strdup (default_prefix);
+               else
+                       return (char *) NULL;
+       }
+
+       dir1 = br_dirname (exe);
+       dir2 = br_dirname (dir1);
+       free (dir1);
+       return dir2;
+}
+
+
+/** Locate the application's binary folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/bin"
+ * \endcode
+ *
+ * @param default_bin_dir  A default path which will used as fallback.
+ * @return A string containing the bin folder's path, which must be freed when
+ *         no longer necessary. If BinReloc is not initialized, or if
+ *         the initialization function failed, then a copy of default_bin_dir 
will
+ *         be returned. If default_bin_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_bin_dir (const char *default_bin_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_bin_dir != (const char *) NULL)
+                       return strdup (default_bin_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "bin");
+       free (prefix);
+       return dir;
+}
+
+
+/** Locate the application's superuser binary folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/sbin"
+ * \endcode
+ *
+ * @param default_sbin_dir  A default path which will used as fallback.
+ * @return A string containing the sbin folder's path, which must be freed when
+ *         no longer necessary. If BinReloc is not initialized, or if the
+ *         initialization function failed, then a copy of default_sbin_dir will
+ *         be returned. If default_bin_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_sbin_dir (const char *default_sbin_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_sbin_dir != (const char *) NULL)
+                       return strdup (default_sbin_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "sbin");
+       free (prefix);
+       return dir;
+}
+
+
+/** Locate the application's data folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/share"
+ * \endcode
+ *
+ * @param default_data_dir  A default path which will used as fallback.
+ * @return A string containing the data folder's path, which must be freed when
+ *         no longer necessary. If BinReloc is not initialized, or if the
+ *         initialization function failed, then a copy of default_data_dir
+ *         will be returned. If default_data_dir is NULL, then NULL will be
+ *         returned.
+ */
+char *
+br_find_data_dir (const char *default_data_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_data_dir != (const char *) NULL)
+                       return strdup (default_data_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "share");
+       free (prefix);
+       return dir;
+}
+
+
+/** Locate the application's localization folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/share/locale"
+ * \endcode
+ *
+ * @param default_locale_dir  A default path which will used as fallback.
+ * @return A string containing the localization folder's path, which must be 
freed when
+ *         no longer necessary. If BinReloc is not initialized, or if the
+ *         initialization function failed, then a copy of default_locale_dir 
will be returned.
+ *         If default_locale_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_locale_dir (const char *default_locale_dir)
+{
+       char *data_dir, *dir;
+
+       data_dir = br_find_data_dir ((const char *) NULL);
+       if (data_dir == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_locale_dir != (const char *) NULL)
+                       return strdup (default_locale_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (data_dir, "locale");
+       free (data_dir);
+       return dir;
+}
+
+
+/** Locate the application's library folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/lib"
+ * \endcode
+ *
+ * @param default_lib_dir  A default path which will used as fallback.
+ * @return A string containing the library folder's path, which must be freed 
when
+ *         no longer necessary. If BinReloc is not initialized, or if the 
initialization
+ *         function failed, then a copy of default_lib_dir will be returned.
+ *         If default_lib_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_lib_dir (const char *default_lib_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_lib_dir != (const char *) NULL)
+                       return strdup (default_lib_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "lib");
+       free (prefix);
+       return dir;
+}
+
+
+/** Locate the application's libexec folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/libexec"
+ * \endcode
+ *
+ * @param default_libexec_dir  A default path which will used as fallback.
+ * @return A string containing the libexec folder's path, which must be freed 
when
+ *         no longer necessary. If BinReloc is not initialized, or if the 
initialization
+ *         function failed, then a copy of default_libexec_dir will be 
returned.
+ *         If default_libexec_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_libexec_dir (const char *default_libexec_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_libexec_dir != (const char *) NULL)
+                       return strdup (default_libexec_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "libexec");
+       free (prefix);
+       return dir;
+}
+
+
+/** Locate the application's configuration files folder.
+ *
+ * The path is generated by the following pseudo-code evaluation:
+ * \code
+ * prefix + "/etc"
+ * \endcode
+ *
+ * @param default_etc_dir  A default path which will used as fallback.
+ * @return A string containing the etc folder's path, which must be freed when
+ *         no longer necessary. If BinReloc is not initialized, or if the 
initialization
+ *         function failed, then a copy of default_etc_dir will be returned.
+ *         If default_etc_dir is NULL, then NULL will be returned.
+ */
+char *
+br_find_etc_dir (const char *default_etc_dir)
+{
+       char *prefix, *dir;
+
+       prefix = br_find_prefix ((const char *) NULL);
+       if (prefix == (char *) NULL) {
+               /* BinReloc not initialized. */
+               if (default_etc_dir != (const char *) NULL)
+                       return strdup (default_etc_dir);
+               else
+                       return (char *) NULL;
+       }
+
+       dir = br_build_path (prefix, "etc");
+       free (prefix);
+       return dir;
+}
+
+
+/***********************
+ * Utility functions
+ ***********************/
+
+/** Concatenate str1 and str2 to a newly allocated string.
+ *
+ * @param str1 A string.
+ * @param str2 Another string.
+ * @returns A newly-allocated string. This string should be freed when no 
longer needed.
+ */
+char *
+br_strcat (const char *str1, const char *str2)
+{
+       char *result;
+       size_t len1, len2;
+
+       if (str1 == NULL)
+               str1 = "";
+       if (str2 == NULL)
+               str2 = "";
+
+       len1 = strlen (str1);
+       len2 = strlen (str2);
+
+       result = (char *) malloc (len1 + len2 + 1);
+       memcpy (result, str1, len1);
+       memcpy (result + len1, str2, len2);
+       result[len1 + len2] = '\0';
+
+       return result;
+}
+
+
+char *
+br_build_path (const char *dir, const char *file)
+{
+       char *dir2, *result;
+       size_t len;
+       int must_free = 0;
+
+       len = strlen (dir);
+       if (len > 0 && dir[len - 1] != '/') {
+               dir2 = br_strcat (dir, "/");
+               must_free = 1;
+       } else
+               dir2 = (char *) dir;
+
+       result = br_strcat (dir2, file);
+       if (must_free)
+               free (dir2);
+       return result;
+}
+
+
+/* Emulates glibc's strndup() */
+static char *
+br_strndup (const char *str, size_t size)
+{
+       char *result = (char *) NULL;
+       size_t len;
+
+       if (str == (const char *) NULL)
+               return (char *) NULL;
+
+       len = strlen (str);
+       if (len == 0)
+               return strdup ("");
+       if (size > len)
+               size = len;
+
+       result = (char *) malloc (len + 1);
+       memcpy (result, str, size);
+       result[size] = '\0';
+       return result;
+}
+
+
+/** Extracts the directory component of a path.
+ *
+ * Similar to g_dirname() or the dirname commandline application.
+ *
+ * Example:
+ * \code
+ * br_dirname ("/usr/local/foobar");  --> Returns: "/usr/local"
+ * \endcode
+ *
+ * @param path  A path.
+ * @returns     A directory name. This string should be freed when no longer 
needed.
+ */
+char *
+br_dirname (const char *path)
+{
+       char *end, *result;
+
+       if (path == (const char *) NULL)
+               return (char *) NULL;
+
+       end = strrchr (path, '/');
+       if (end == (const char *) NULL)
+               return strdup (".");
+
+       while (end > path && *end == '/')
+               end--;
+       result = br_strndup (path, end - path + 1);
+       if (result[0] == 0) {
+               free (result);
+               return strdup ("/");
+       } else
+               return result;
+}
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __BINRELOC_C__ */


Property changes on: trunk/pingus/external/binreloc-2.0/binreloc.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/pingus/external/binreloc-2.0/binreloc.h
===================================================================
--- trunk/pingus/external/binreloc-2.0/binreloc.h       2009-11-04 05:31:52 UTC 
(rev 4016)
+++ trunk/pingus/external/binreloc-2.0/binreloc.h       2009-11-04 05:41:19 UTC 
(rev 4017)
@@ -0,0 +1,80 @@
+/*
+ * BinReloc - a library for creating relocatable executables
+ * Written by: Hongli Lai <address@hidden>
+ * http://autopackage.org/
+ *
+ * This source code is public domain. You can relicense this code
+ * under whatever license you want.
+ *
+ * See http://autopackage.org/docs/binreloc/ for
+ * more information and how to use this.
+ */
+
+#ifndef __BINRELOC_H__
+#define __BINRELOC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/** These error codes can be returned by br_init(), br_init_lib(), gbr_init() 
or gbr_init_lib(). */
+typedef enum {
+       /** Cannot allocate memory. */
+       BR_INIT_ERROR_NOMEM,
+       /** Unable to open /proc/self/maps; see errno for details. */
+       BR_INIT_ERROR_OPEN_MAPS,
+       /** Unable to read from /proc/self/maps; see errno for details. */
+       BR_INIT_ERROR_READ_MAPS,
+       /** The file format of /proc/self/maps is invalid; kernel bug? */
+       BR_INIT_ERROR_INVALID_MAPS,
+       /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */
+       BR_INIT_ERROR_DISABLED
+} BrInitError;
+
+
+#ifndef BINRELOC_RUNNING_DOXYGEN
+/* Mangle symbol names to avoid symbol collisions with other ELF objects. */
+       #define br_init             gJdn38894613193140_br_init
+       #define br_init_lib         gJdn38894613193140_br_init_lib
+       #define br_find_exe         gJdn38894613193140_br_find_exe
+       #define br_find_exe_dir     gJdn38894613193140_br_find_exe_dir
+       #define br_find_prefix      gJdn38894613193140_br_find_prefix
+       #define br_find_bin_dir     gJdn38894613193140_br_find_bin_dir
+       #define br_find_sbin_dir    gJdn38894613193140_br_find_sbin_dir
+       #define br_find_data_dir    gJdn38894613193140_br_find_data_dir
+       #define br_find_locale_dir  gJdn38894613193140_br_find_locale_dir
+       #define br_find_lib_dir     gJdn38894613193140_br_find_lib_dir
+       #define br_find_libexec_dir gJdn38894613193140_br_find_libexec_dir
+       #define br_find_etc_dir     gJdn38894613193140_br_find_etc_dir
+       #define br_strcat           gJdn38894613193140_br_strcat
+       #define br_build_path       gJdn38894613193140_br_build_path
+       #define br_dirname          gJdn38894613193140_br_dirname
+
+
+#endif
+int   br_init             (BrInitError *error);
+int   br_init_lib         (BrInitError *error);
+
+char *br_find_exe         (const char *default_exe);
+char *br_find_exe_dir     (const char *default_dir);
+char *br_find_prefix      (const char *default_prefix);
+char *br_find_bin_dir     (const char *default_bin_dir);
+char *br_find_sbin_dir    (const char *default_sbin_dir);
+char *br_find_data_dir    (const char *default_data_dir);
+char *br_find_locale_dir  (const char *default_locale_dir);
+char *br_find_lib_dir     (const char *default_lib_dir);
+char *br_find_libexec_dir (const char *default_libexec_dir);
+char *br_find_etc_dir     (const char *default_etc_dir);
+
+/* Utility functions */
+char *br_strcat  (const char *str1, const char *str2);
+char *br_build_path (const char *dir, const char *file);
+char *br_dirname (const char *path);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __BINRELOC_H__ */


Property changes on: trunk/pingus/external/binreloc-2.0/binreloc.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/pingus/src/pingus/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_main.cpp     2009-11-04 05:31:52 UTC (rev 
4016)
+++ trunk/pingus/src/pingus/pingus_main.cpp     2009-11-04 05:41:19 UTC (rev 
4017)
@@ -49,7 +49,7 @@
 #include "SDL.h"
 
 #ifdef ENABLE_BINRELOC
-#include "../lib/binreloc/binreloc.h"
+#include "../external/binreloc-2.0/binreloc.h"
 #endif 
 
 #include "gettext.h"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]