Allow full-length Unix pathnames.

Move bits of HAVE_OPENCL/HAVE_WX for OS X from SConstruct to header files.

Use /usr/lib/libz on OS X now that we no longer have -L/opt/local/lib in
the library path. It is still possible that we could pick up a libz in
/usr/local/lib that would make the application non-redistributable, but
the danger is much less than previously.

Also bits of minor portability cleanup.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5868 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-07-10 21:17:08 +00:00
parent 379706b25a
commit addb89fecc
8 changed files with 79 additions and 87 deletions

View File

@ -1,7 +1,13 @@
# -*- python -*-
import sys
Import('env')
luaenv = env.Clone()
if not sys.platform == 'win32':
luaenv['CPPDEFINES'].append('LUA_USE_LINUX') # Also works for OS X
files = [
'lapi.c',
'lauxlib.c',
@ -35,4 +41,4 @@ files = [
'print.c',
]
env.StaticLibrary(env['local_libs'] + "lua", files)
luaenv.StaticLibrary(env['local_libs'] + "lua", files)

View File

@ -204,7 +204,6 @@ env['CCFLAGS'] = compileFlags
env['CPPDEFINES'] = cppDefines
if not sys.platform == 'win32':
env['CXXFLAGS'] = ['-fvisibility-inlines-hidden']
cppDefines.append('LUA_USE_LINUX')
# Configuration tests section
tests = {'CheckWXConfig' : wxconfig.CheckWXConfig,
@ -258,21 +257,16 @@ env['HAVE_WX'] = 0
if sys.platform == 'darwin':
compileFlags.append('-mmacosx-version-min=10.5')
if not env['nowx']:
cppDefines.append('HAVE_WX=1')
conf = env.Configure(custom_tests = tests)
# wxWidgets 2.9 has Cocoa support
env['HAVE_WX'] = conf.CheckWXConfig(2.9, wxmods, 0)
wxconfig.ParseWXConfig(env)
# Make sure that the libraries claimed by wx-config are valid
if not conf.CheckLib('wx_baseu-2.9'):
print "WX libraries not found - see config.log"
Exit(1)
conf.Finish()
# wx-config wants us to link with the OS X QuickTime framework
# which is not available for x86_64 and we don't use it anyway.
# Strip it out to silence some harmless linker warnings.
if env['FRAMEWORKS'].count('QuickTime'):
env['FRAMEWORKS'].remove('QuickTime')
if env['CPPDEFINES'].count('WXUSINGDLL'):
if env['FRAMEWORKS'].count('QuickTime'):
env['FRAMEWORKS'].remove('QuickTime')
env['CC'] = "gcc-4.2"
env['CFLAGS'] = ['-x', 'objective-c']
env['CXX'] = "g++-4.2"
@ -287,6 +281,7 @@ if sys.platform == 'darwin':
env['HAVE_OPENCL'] = 1
env['LINKFLAGS'] += ['-weak_framework', 'OpenCL']
env['FRAMEWORKS'] += ['Cg']
shared['zlib'] = 1
if not sys.platform == 'win32' and not sys.platform == 'darwin':
conf = env.Configure(custom_tests = tests,
@ -371,6 +366,7 @@ if not sys.platform == 'win32' and not sys.platform == 'darwin':
if env['opencl']:
env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL')
conf.Define('HAVE_OPENCL', env['HAVE_OPENCL'])
conf.Define('USER_DIR', "\"" + env['userdir'] + "\"")
if (env['install'] == 'global'):
@ -395,8 +391,6 @@ if not sys.platform == 'win32' and not sys.platform == 'darwin':
else:
print "Can't build prof without oprofile, disabling"
conf.Define('HAVE_OPENCL', env['HAVE_OPENCL'])
# After all configuration tests are done
conf.Finish()

View File

@ -20,7 +20,7 @@ else:
files += [ 'AlsaSoundStream.cpp' ]
if env['HAVE_AO']:
files += [ 'AOSoundStream.cpp' ]
if env['HAVE_OPENAL']:
if env['HAVE_OPENAL'] or sys.platform == 'win32':
files += [ 'OpenALStream.cpp', 'aldlist.cpp' ]
if env['HAVE_PULSEAUDIO']:
files += [ 'PulseAudioStream.cpp' ]

View File

@ -5,8 +5,6 @@
#ifdef _WIN32
#include <windows.h>
#define PATH_MAX MAX_PATH
#elif __APPLE__
#include <paths.h>
#include <Carbon/Carbon.h>
@ -14,10 +12,8 @@
#include <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IOMedia.h>
#include <IOKit/IOBSD.h>
#elif __linux__
#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>
@ -231,9 +227,9 @@ bool cdio_is_cdrom(std::string device)
for (unsigned int i = 0; i < devices.size(); i++)
{
#ifdef __linux__
if (strncmp(devices[i].c_str(), devname, PATH_MAX) == 0)
if (strncmp(devices[i].c_str(), devname, MAX_PATH) == 0)
#else
if (strncmp(devices[i].c_str(), device.c_str(), PATH_MAX) == 0)
if (strncmp(devices[i].c_str(), device.c_str(), MAX_PATH) == 0)
#endif
{
res = true;

View File

@ -36,42 +36,45 @@ extern const char *netplay_dolphin_ver;
#define LOGGING 1
#endif
#define STACKALIGN
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#include "Log.h"
#include "CommonTypes.h"
#include "MsgHandler.h"
#include "CommonPaths.h"
#include "CommonFuncs.h"
#ifdef _MSC_VER
#define __strdup _strdup
#define __getcwd _getcwd
#define __chdir _chdir
#else
#define __strdup strdup
#define __getcwd getcwd
#define __chdir chdir
#ifdef __APPLE__
// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
// This is only needed on i386 gcc - x86_64 already aligns to 16 bytes.
#if defined __i386__ && defined __GNUC__
#undef STACKALIGN
#define STACKALIGN __attribute__((__force_align_arg_pointer__))
#endif
// We use wxWidgets on OS X only if it is version 2.9+ with Cocoa support.
#ifdef __WXOSX_COCOA__
#define HAVE_WX 1
#define USE_WX 1 // Use wxGLCanvas
#endif
// Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
// This is only needed on i386 gcc - x86_64 already aligns to 16bytes
#if defined(__APPLE__) && defined(__i386__) && defined(__GNUC__)
#define STACKALIGN __attribute__((__force_align_arg_pointer__))
#else
#define STACKALIGN
#endif
#elif defined _WIN32
#ifdef _WIN32
// Check MSC ver
#if !defined _MSC_VER || _MSC_VER <= 1000
#error needs at least version 1000 of MSC
#endif
#define NOMINMAX
// Memory leak checks
#define CHECK_HEAP_INTEGRITY()
#define POSIX 0
#define NOMINMAX
// Alignment
#define GC_ALIGNED16(x) __declspec(align(16)) x
#define GC_ALIGNED32(x) __declspec(align(32)) x
@ -83,8 +86,6 @@ extern const char *netplay_dolphin_ver;
#define HAVE_WIIUSE 1
#define HAVE_WX 1
#define HAVE_OPENAL 1
#define HAVE_ALSA 0
#define HAVE_PORTAUDIO 0
// it is VERY DANGEROUS to mix _SECURE_SCL=0 and _SECURE_SCL=1 compiled libraries.
// You will get bizarre crash bugs whenever you use STL.
@ -109,42 +110,39 @@ extern const char *netplay_dolphin_ver;
//CrtDebugBreak breakAt(614);
#endif // end DEBUG/FAST
#else // Not windows
#ifdef __APPLE__
#if defined HAVE_WX && HAVE_WX
#define MAP_32BIT 0 // MAP_32BIT is a Linux-specific mmap(2) flag
#define USE_WX 1 // Use wxGLCanvas
#endif // HAVE_WX
#else // __APPLE__
#else
#include "Config.h" // SCons autoconfiguration defines
#endif
// General defines
#define POSIX 1
#define MAX_PATH 260
#ifndef __linux__
#define MAP_32BIT 0 // MAP_32BIT is a Linux-specific mmap(2) flag
#endif
// Windows compatibility
#define __forceinline inline __attribute__((always_inline))
#ifndef _WIN32
#include <limits.h>
#define MAX_PATH PATH_MAX
#ifdef _LP64
#define _M_X64 1
#else
#define _M_IX86 1
#endif
#define __forceinline inline __attribute__((always_inline))
#define GC_ALIGNED16(x) __attribute__((aligned(16))) x
#define GC_ALIGNED32(x) __attribute__((aligned(32))) x
#define GC_ALIGNED64(x) __attribute__((aligned(64))) x
#define GC_ALIGNED16_DECL(x) __attribute__((aligned(16))) x
#define GC_ALIGNED64_DECL(x) __attribute__((aligned(64))) x
#endif
#ifdef _LP64
#define _M_X64 1
#else
#define _M_IX86 1
#endif
// Alignment
#define GC_ALIGNED16(x) __attribute__((aligned(16))) x
#define GC_ALIGNED32(x) __attribute__((aligned(32))) x
#define GC_ALIGNED64(x) __attribute__((aligned(64))) x
#define GC_ALIGNED16_DECL(x) __attribute__((aligned(16))) x
#define GC_ALIGNED64_DECL(x) __attribute__((aligned(64))) x
#endif // WIN32
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#ifdef _MSC_VER
#define __strdup _strdup
#define __getcwd _getcwd
#define __chdir _chdir
#else
#define __strdup strdup
#define __getcwd getcwd
#define __chdir chdir
#endif
#endif // _COMMON_H_

View File

@ -19,19 +19,27 @@
#define __OPENCL_H__
#include "Common.h"
// OpenCL on Windows is linked through the CLRun library
// It provides the headers and all the imports
// It could be safe to use it for Linux too, but will require to edit the SCons first
// OpenCL is linked on OSX when possible, it shouldn't require CLRun for now
#ifdef _WIN32
#define HAVE_OPENCL 1
#endif
// The latest (last?) release of Xcode for Leopard does not include the 10.6
// SDK, so we can only build with OpenCL on a Snow Leopard system where we link
// the OpenCL framework weakly so that the application will also run on 10.5.
#ifdef __APPLE__
#import <Foundation/NSObjCRuntime.h>
#ifdef NSFoundationVersionNumber10_5 // First defined in the 10.6 SDK
#include <OpenCL/opencl.h>
#define HAVE_OPENCL 1
#endif
#endif
#if defined(HAVE_OPENCL) && HAVE_OPENCL
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#ifndef __APPLE__
#include <CL/cl.h>
#endif

View File

@ -11,6 +11,7 @@
#ifdef _WIN32
#include <windows.h>
#endif
#include "Common.h"
#include "CommonTypes.h"
// Plugin communication. I place this here rather in Common.h to rebuild less if any of this is changed
@ -90,11 +91,6 @@ typedef struct
char Name[100]; // Name of the DLL
} PLUGIN_INFO;
#ifndef MAX_PATH
// apparently a windows-ism.
#define MAX_PATH 260
#endif
// TODO: Remove, or at least remove the void pointers and replace with data.
// This design is just wrong and ugly - the plugins shouldn't have this much access.
typedef struct

View File

@ -49,12 +49,6 @@ rm -rf $temp_dir
mkdir -p $temp_dir/Dolphin.app
cp -r Darwin-i386/Dolphin.app $temp_dir
fix_shared_object_depends libwx
fix_shared_object_depends libSDL
fix_shared_object_depends libGLEW
fix_shared_object_depends libz
mkdir -p $temp_dir/Dolphin.app/Contents/Library/Frameworks/Cg.framework
cp /Library/Frameworks/Cg.framework/Cg $temp_dir/Dolphin.app/Contents/Library/Frameworks/Cg.framework/Cg
find $temp_dir -name .svn -exec rm -fr {} \; 2>/dev/null
rm $temp_dir.dmg 2>/dev/null