2011-10-20 01:01:48 +00:00
|
|
|
#
|
|
|
|
# SConstruct - build script for the SDL port of fceux
|
|
|
|
#
|
2013-03-15 17:39:01 +00:00
|
|
|
# You can adjust the BoolVariables below to include/exclude features
|
|
|
|
# at compile-time. You may also use arguments to specify the parameters.
|
|
|
|
# ie: scons RELEASE=1 GTK3=1
|
2012-11-11 12:04:22 +00:00
|
|
|
#
|
2011-10-20 01:01:48 +00:00
|
|
|
# Use "scons" to compile and "scons install" to install.
|
|
|
|
#
|
|
|
|
|
2006-07-31 22:24:21 +00:00
|
|
|
import os
|
2006-08-08 23:20:16 +00:00
|
|
|
import sys
|
2008-09-24 07:56:16 +00:00
|
|
|
import platform
|
2006-07-31 22:24:21 +00:00
|
|
|
|
2013-03-15 17:39:01 +00:00
|
|
|
opts = Variables(None, ARGUMENTS)
|
2011-10-19 21:42:34 +00:00
|
|
|
opts.AddVariables(
|
2013-04-12 01:34:48 +00:00
|
|
|
BoolVariable('DEBUG', 'Build with debugging symbols', 1),
|
|
|
|
BoolVariable('RELEASE', 'Set to 1 to build for release', 0),
|
2009-06-13 16:20:17 +00:00
|
|
|
BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),
|
|
|
|
BoolVariable('OPENGL', 'Enable OpenGL support', 1),
|
|
|
|
BoolVariable('LUA', 'Enable Lua support', 1),
|
2013-03-15 17:39:01 +00:00
|
|
|
BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),
|
|
|
|
BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 0),
|
2010-02-18 02:02:37 +00:00
|
|
|
BoolVariable('NEWPPU', 'Enable new PPU core', 1),
|
2011-02-03 00:27:38 +00:00
|
|
|
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1),
|
2012-11-11 12:04:22 +00:00
|
|
|
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', 1),
|
2014-11-22 02:03:33 +00:00
|
|
|
BoolVariable('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 0),
|
2013-03-15 17:39:01 +00:00
|
|
|
BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0),
|
|
|
|
BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
|
2013-03-20 12:37:31 +00:00
|
|
|
BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0),
|
2013-03-10 23:54:01 +00:00
|
|
|
BoolVariable('SDL2', 'Compile using SDL2 instead of SDL 1.2 (experimental/non-functional)', 0)
|
2006-08-04 17:32:08 +00:00
|
|
|
)
|
2011-10-19 23:36:33 +00:00
|
|
|
AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix')
|
2008-08-03 00:08:17 +00:00
|
|
|
|
2011-10-19 23:36:33 +00:00
|
|
|
prefix = GetOption('prefix')
|
2011-10-20 01:01:48 +00:00
|
|
|
env = Environment(options = opts)
|
2011-10-19 21:42:34 +00:00
|
|
|
|
2013-03-15 17:39:01 +00:00
|
|
|
if env['RELEASE']:
|
|
|
|
env.Append(CPPDEFINES=["PUBLIC_RELEASE"])
|
|
|
|
env['DEBUG'] = 0
|
2011-06-04 05:33:05 +00:00
|
|
|
|
2008-09-24 06:40:35 +00:00
|
|
|
# LSB_FIRST must be off for PPC to compile
|
|
|
|
if platform.system == "ppc":
|
|
|
|
env['LSB_FIRST'] = 0
|
|
|
|
|
2008-06-04 00:15:00 +00:00
|
|
|
# Default compiler flags:
|
2013-07-08 23:05:36 +00:00
|
|
|
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare'])
|
2006-07-31 00:03:35 +00:00
|
|
|
|
2008-05-27 05:29:00 +00:00
|
|
|
if os.environ.has_key('PLATFORM'):
|
|
|
|
env.Replace(PLATFORM = os.environ['PLATFORM'])
|
2006-07-31 22:24:21 +00:00
|
|
|
if os.environ.has_key('CC'):
|
|
|
|
env.Replace(CC = os.environ['CC'])
|
2006-08-01 01:15:30 +00:00
|
|
|
if os.environ.has_key('CXX'):
|
|
|
|
env.Replace(CXX = os.environ['CXX'])
|
2008-05-27 05:29:00 +00:00
|
|
|
if os.environ.has_key('WINDRES'):
|
2008-06-04 00:15:00 +00:00
|
|
|
env.Replace(WINDRES = os.environ['WINDRES'])
|
2006-07-31 22:24:21 +00:00
|
|
|
if os.environ.has_key('CFLAGS'):
|
2009-03-14 19:15:19 +00:00
|
|
|
env.Append(CCFLAGS = os.environ['CFLAGS'].split())
|
2012-06-24 16:01:19 +00:00
|
|
|
if os.environ.has_key('CXXFLAGS'):
|
|
|
|
env.Append(CXXFLAGS = os.environ['CXXFLAGS'].split())
|
|
|
|
if os.environ.has_key('CPPFLAGS'):
|
|
|
|
env.Append(CPPFLAGS = os.environ['CPPFLAGS'].split())
|
|
|
|
if os.environ.has_key('LDFLAGS'):
|
|
|
|
env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())
|
2013-10-21 17:41:50 +00:00
|
|
|
if os.environ.has_key('PKG_CONFIG_PATH'):
|
|
|
|
env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
|
|
|
|
if os.environ.has_key('PKG_CONFIG_LIBDIR'):
|
|
|
|
env['ENV']['PKG_CONFIG_LIBDIR'] = os.environ['PKG_CONFIG_LIBDIR']
|
2006-07-31 20:07:15 +00:00
|
|
|
|
2006-07-31 00:03:35 +00:00
|
|
|
print "platform: ", env['PLATFORM']
|
|
|
|
|
2012-08-12 22:29:00 +00:00
|
|
|
# compile with clang
|
|
|
|
if env['CLANG']:
|
|
|
|
env.Replace(CC='clang')
|
|
|
|
env.Replace(CXX='clang++')
|
|
|
|
|
2006-07-31 22:24:21 +00:00
|
|
|
# special flags for cygwin
|
2008-06-04 00:15:00 +00:00
|
|
|
# we have to do this here so that the function and lib checks will go through mingw
|
2006-07-31 00:03:35 +00:00
|
|
|
if env['PLATFORM'] == 'cygwin':
|
2006-07-31 22:24:21 +00:00
|
|
|
env.Append(CCFLAGS = " -mno-cygwin")
|
|
|
|
env.Append(LINKFLAGS = " -mno-cygwin")
|
2006-08-22 06:27:18 +00:00
|
|
|
env['LIBS'] = ['wsock32'];
|
2006-07-29 05:46:15 +00:00
|
|
|
|
2008-05-27 05:29:00 +00:00
|
|
|
if env['PLATFORM'] == 'win32':
|
2008-08-12 05:04:40 +00:00
|
|
|
env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
|
2008-06-04 00:15:00 +00:00
|
|
|
env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
|
|
|
|
env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
|
2008-05-27 05:29:00 +00:00
|
|
|
else:
|
2008-06-04 00:15:00 +00:00
|
|
|
conf = Configure(env)
|
2013-03-15 18:22:38 +00:00
|
|
|
# If libdw is available, compile in backward-cpp support
|
|
|
|
if conf.CheckLib('dw'):
|
|
|
|
conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1")
|
|
|
|
conf.env.Append(LINKFLAGS = "-ldw")
|
2012-06-24 17:03:44 +00:00
|
|
|
if conf.CheckFunc('asprintf'):
|
|
|
|
conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
|
2013-03-10 20:10:39 +00:00
|
|
|
if env['SYSTEM_MINIZIP']:
|
|
|
|
assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip"
|
|
|
|
assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
|
|
|
|
env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"])
|
|
|
|
else:
|
|
|
|
assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
|
2013-03-10 23:54:01 +00:00
|
|
|
if env['SDL2']:
|
|
|
|
if not conf.CheckLib('SDL2'):
|
|
|
|
print 'Did not find libSDL2 or SDL2.lib, exiting!'
|
|
|
|
Exit(1)
|
|
|
|
env.Append(CPPDEFINES=["_SDL2"])
|
|
|
|
env.ParseConfig('pkg-config sdl2 --cflags --libs')
|
|
|
|
else:
|
|
|
|
if not conf.CheckLib('SDL'):
|
|
|
|
print 'Did not find libSDL or SDL.lib, exiting!'
|
|
|
|
Exit(1)
|
|
|
|
env.ParseConfig('sdl-config --cflags --libs')
|
2011-10-19 06:35:53 +00:00
|
|
|
if env['GTK']:
|
2011-10-20 01:01:48 +00:00
|
|
|
if not conf.CheckLib('gtk-x11-2.0'):
|
|
|
|
print 'Could not find libgtk-2.0, exiting!'
|
|
|
|
Exit(1)
|
2011-10-19 06:35:53 +00:00
|
|
|
# Add compiler and linker flags from pkg-config
|
2013-02-07 00:48:06 +00:00
|
|
|
config_string = 'pkg-config --cflags --libs gtk+-2.0'
|
|
|
|
env.ParseConfig(config_string)
|
2011-10-19 06:35:53 +00:00
|
|
|
env.Append(CPPDEFINES=["_GTK2"])
|
|
|
|
env.Append(CCFLAGS = ["-D_GTK"])
|
|
|
|
if env['GTK3']:
|
|
|
|
# Add compiler and linker flags from pkg-config
|
2013-02-07 00:48:06 +00:00
|
|
|
config_string = 'pkg-config --cflags --libs gtk+-3.0'
|
|
|
|
env.ParseConfig(config_string)
|
2011-10-19 06:35:53 +00:00
|
|
|
env.Append(CPPDEFINES=["_GTK3"])
|
|
|
|
env.Append(CCFLAGS = ["-D_GTK"])
|
2011-04-09 03:20:48 +00:00
|
|
|
|
2015-09-20 20:11:35 +00:00
|
|
|
### Just make every configuration use -ldl, it may be needed for some reason.
|
|
|
|
env.Append(LINKFLAGS = ["-ldl"])
|
|
|
|
|
2009-12-14 03:48:15 +00:00
|
|
|
### Lua platform defines
|
|
|
|
### Applies to all files even though only lua needs it, but should be ok
|
|
|
|
if env['LUA']:
|
2010-07-02 07:49:03 +00:00
|
|
|
env.Append(CPPDEFINES=["_S9XLUA_H"])
|
2009-12-14 03:48:15 +00:00
|
|
|
if env['PLATFORM'] == 'darwin':
|
|
|
|
# Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
|
2011-10-18 21:35:37 +00:00
|
|
|
env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])
|
2009-12-14 03:48:15 +00:00
|
|
|
if env['PLATFORM'] == 'posix':
|
|
|
|
# If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.
|
|
|
|
# Should work on any *nix
|
|
|
|
env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
|
2012-11-24 20:51:09 +00:00
|
|
|
lua_available = False
|
2014-11-22 02:03:33 +00:00
|
|
|
if env['SYSTEM_LUA']:
|
|
|
|
if conf.CheckLib('lua5.1'):
|
2015-09-20 20:11:35 +00:00
|
|
|
env.Append(LINKFLAGS = ["-llua5.1"])
|
2014-11-22 02:03:33 +00:00
|
|
|
env.Append(CCFLAGS = ["-I/usr/include/lua5.1"])
|
|
|
|
lua_available = True
|
|
|
|
elif conf.CheckLib('lua'):
|
2015-09-20 20:11:35 +00:00
|
|
|
env.Append(LINKFLAGS = ["-llua"])
|
2014-11-22 02:03:33 +00:00
|
|
|
env.Append(CCFLAGS = ["-I/usr/include/lua"])
|
|
|
|
lua_available = True
|
|
|
|
if lua_available == False:
|
|
|
|
print 'Could not find liblua, exiting!'
|
|
|
|
Exit(1)
|
|
|
|
else:
|
|
|
|
env.Append(CCFLAGS = ["-Isrc/lua/src"])
|
2012-11-24 20:51:09 +00:00
|
|
|
lua_available = True
|
2012-07-18 13:57:21 +00:00
|
|
|
# "--as-needed" no longer available on OSX (probably BSD as well? TODO: test)
|
|
|
|
if env['PLATFORM'] != 'darwin':
|
|
|
|
env.Append(LINKFLAGS=['-Wl,--as-needed'])
|
2008-10-25 12:36:03 +00:00
|
|
|
|
|
|
|
### Search for gd if we're not in Windows
|
2015-03-15 18:53:06 +00:00
|
|
|
if (env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin') and (env['CREATE_AVI'] or env['LOGO']):
|
2008-10-25 12:36:03 +00:00
|
|
|
gd = conf.CheckLib('gd', autoadd=1)
|
|
|
|
if gd == 0:
|
|
|
|
env['LOGO'] = 0
|
|
|
|
print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
|
|
|
|
|
2012-06-23 22:31:27 +00:00
|
|
|
if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1):
|
2010-03-31 03:41:39 +00:00
|
|
|
conf.env.Append(CCFLAGS = "-DOPENGL")
|
2008-06-04 00:15:00 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
|
2009-12-21 10:28:01 +00:00
|
|
|
|
2008-07-23 05:19:27 +00:00
|
|
|
env = conf.Finish()
|
2006-07-29 05:46:15 +00:00
|
|
|
|
2008-07-24 03:01:39 +00:00
|
|
|
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
|
2008-05-27 05:29:00 +00:00
|
|
|
env.Append(CPPDEFINES = ['LSB_FIRST'])
|
2006-08-08 23:20:16 +00:00
|
|
|
|
|
|
|
if env['FRAMESKIP']:
|
2008-05-27 05:29:00 +00:00
|
|
|
env.Append(CPPDEFINES = ['FRAMESKIP'])
|
2006-08-08 23:20:16 +00:00
|
|
|
|
2008-06-04 00:15:00 +00:00
|
|
|
print "base CPPDEFINES:",env['CPPDEFINES']
|
|
|
|
print "base CCFLAGS:",env['CCFLAGS']
|
|
|
|
|
2008-08-10 13:38:39 +00:00
|
|
|
if env['DEBUG']:
|
2013-04-12 17:26:08 +00:00
|
|
|
env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g', '-O0'])
|
2011-10-19 21:42:34 +00:00
|
|
|
else:
|
2011-10-26 15:52:10 +00:00
|
|
|
env.Append(CCFLAGS = ['-O2'])
|
2008-06-04 01:14:53 +00:00
|
|
|
|
2008-10-25 12:36:03 +00:00
|
|
|
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
|
|
|
|
env.Append(CPPDEFINES=["CREATE_AVI"])
|
2008-10-25 15:45:17 +00:00
|
|
|
else:
|
2008-10-25 12:36:03 +00:00
|
|
|
env['CREATE_AVI']=0;
|
|
|
|
|
2006-07-29 05:46:15 +00:00
|
|
|
Export('env')
|
2011-10-19 21:42:34 +00:00
|
|
|
fceux = SConscript('src/SConscript')
|
2011-10-23 23:31:19 +00:00
|
|
|
env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"])
|
2013-03-15 17:39:01 +00:00
|
|
|
|
|
|
|
# Installation rules
|
2011-10-20 00:21:29 +00:00
|
|
|
if prefix == None:
|
|
|
|
prefix = "/usr/local"
|
|
|
|
|
2008-06-04 00:15:00 +00:00
|
|
|
exe_suffix = ''
|
|
|
|
if env['PLATFORM'] == 'win32':
|
|
|
|
exe_suffix = '.exe'
|
2008-08-10 09:34:45 +00:00
|
|
|
|
2008-06-04 00:15:00 +00:00
|
|
|
fceux_src = 'src/fceux' + exe_suffix
|
|
|
|
fceux_dst = 'bin/fceux' + exe_suffix
|
|
|
|
|
2012-11-02 13:57:47 +00:00
|
|
|
fceux_net_server_src = 'fceux-net-server' + exe_suffix
|
|
|
|
fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix
|
|
|
|
|
2008-08-03 00:08:17 +00:00
|
|
|
auxlib_src = 'src/auxlib.lua'
|
|
|
|
auxlib_dst = 'bin/auxlib.lua'
|
|
|
|
|
2013-09-23 19:43:47 +00:00
|
|
|
fceux_h_src = 'output/fceux.chm'
|
2008-06-04 00:15:00 +00:00
|
|
|
fceux_h_dst = 'bin/fceux.chm'
|
2006-07-29 05:46:15 +00:00
|
|
|
|
2008-06-04 00:15:00 +00:00
|
|
|
env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])
|
|
|
|
env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])
|
2012-11-02 13:57:47 +00:00
|
|
|
env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)])
|
2008-08-03 00:08:17 +00:00
|
|
|
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
|
2008-08-03 00:09:00 +00:00
|
|
|
|
2011-10-20 00:03:43 +00:00
|
|
|
man_src = 'documentation/fceux.6'
|
2012-11-02 13:57:47 +00:00
|
|
|
man_net_src = 'documentation/fceux-net-server.6'
|
2011-10-20 00:03:43 +00:00
|
|
|
|
|
|
|
share_src = 'output/'
|
|
|
|
|
2013-08-28 16:25:02 +00:00
|
|
|
image_src = 'fceux.png'
|
|
|
|
|
|
|
|
desktop_src = 'fceux.desktop'
|
2014-03-06 04:20:15 +00:00
|
|
|
|
|
|
|
env.Install(prefix + "/bin/", [fceux, fceux_net_server_src])
|
|
|
|
env.InstallAs(prefix + '/share/fceux/', share_src)
|
|
|
|
env.Install(prefix + '/share/fceux/', auxlib_src)
|
|
|
|
env.Install(prefix + '/share/pixmaps/', image_src)
|
|
|
|
env.Install(prefix + '/share/applications/', desktop_src)
|
|
|
|
env.Install(prefix + "/share/man/man6/", [man_src, man_net_src])
|
|
|
|
env.Alias('install', prefix)
|