fceux/SConstruct

188 lines
6.8 KiB
Python
Raw Normal View History

#
# SConstruct - build script for the SDL port of fceux
#
# You can adjust the BoolVariables below to include/exclude features at compile-time
#
# Use "scons" to compile and "scons install" to install.
#
import os
import sys
2008-09-24 07:56:16 +00:00
import platform
2009-06-13 16:20:17 +00:00
opts = Variables()
opts.AddVariables(
2009-06-13 16:20:17 +00:00
BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),
BoolVariable('OPENGL', 'Enable OpenGL support', 1),
BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
BoolVariable('DEBUG', 'Build with debugging symbols', 1),
2009-06-13 16:20:17 +00:00
BoolVariable('LUA', 'Enable Lua support', 1),
BoolVariable('NEWPPU', 'Enable new PPU core', 1),
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1),
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'),
BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),
BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 0),
)
AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix')
prefix = GetOption('prefix')
env = Environment(options = opts)
#### Uncomment this for a public release ###
# env.Append(CPPDEFINES=["PUBLIC_RELEASE"])
# env['DEBUG'] = 0
############################################
# 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:
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-Isrc/lua/src'])
if os.environ.has_key('PLATFORM'):
env.Replace(PLATFORM = os.environ['PLATFORM'])
if os.environ.has_key('CC'):
env.Replace(CC = os.environ['CC'])
if os.environ.has_key('CXX'):
env.Replace(CXX = os.environ['CXX'])
if os.environ.has_key('WINDRES'):
2008-06-04 00:15:00 +00:00
env.Replace(WINDRES = os.environ['WINDRES'])
if os.environ.has_key('CFLAGS'):
2009-03-14 19:15:19 +00:00
env.Append(CCFLAGS = os.environ['CFLAGS'].split())
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())
print "platform: ", env['PLATFORM']
# 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
if env['PLATFORM'] == 'cygwin':
env.Append(CCFLAGS = " -mno-cygwin")
env.Append(LINKFLAGS = " -mno-cygwin")
env['LIBS'] = ['wsock32'];
if env['PLATFORM'] == 'win32':
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"])
else:
2008-06-04 00:15:00 +00:00
conf = Configure(env)
if conf.CheckFunc('asprintf'):
conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
if not conf.CheckLib('SDL'):
print 'Did not find libSDL or SDL.lib, exiting!'
Exit(1)
if env['GTK']:
if not conf.CheckLib('gtk-x11-2.0'):
print 'Could not find libgtk-2.0, exiting!'
Exit(1)
# Add compiler and linker flags from pkg-config
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
env.Append(CPPDEFINES=["_GTK2"])
env.Append(CCFLAGS = ["-D_GTK"])
if env['GTK3']:
# Add compiler and linker flags from pkg-config
env.ParseConfig('pkg-config --cflags --libs gtk+-3.0')
env.Append(CPPDEFINES=["_GTK3"])
env.Append(CCFLAGS = ["-D_GTK"])
### 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"])
if env['PLATFORM'] == 'darwin':
# Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])
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"])
if conf.CheckLib('lua5.1'):
env.Append(LINKFLAGS = ["-ldl", "-llua5.1"])
elif conf.CheckLib('lua'):
env.Append(LINKFLAGS = ["-ldl", "-llua"])
# "--as-needed" no longer available on OSX (probably BSD as well? TODO: test)
if env['PLATFORM'] != 'darwin':
env.Append(LINKFLAGS=['-Wl,--as-needed'])
### Search for gd if we're not in Windows
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:
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.'
if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1):
conf.env.Append(CCFLAGS = "-DOPENGL")
2008-06-04 00:15:00 +00:00
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
# parse SDL cflags/libs
env.ParseConfig('sdl-config --cflags --libs')
2008-07-23 05:19:27 +00:00
env = conf.Finish()
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
env.Append(CPPDEFINES = ['LSB_FIRST'])
if env['FRAMESKIP']:
env.Append(CPPDEFINES = ['FRAMESKIP'])
2008-06-04 00:15:00 +00:00
print "base CPPDEFINES:",env['CPPDEFINES']
print "base CCFLAGS:",env['CCFLAGS']
if env['DEBUG']:
env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])
else:
env.Append(CCFLAGS = ['-O2'])
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:
env['CREATE_AVI']=0;
Export('env')
fceux = SConscript('src/SConscript')
env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"])
2008-06-04 00:15:00 +00:00
# Install rules
if prefix == None:
prefix = "/usr/local"
2008-06-04 00:15:00 +00:00
exe_suffix = ''
if env['PLATFORM'] == 'win32':
exe_suffix = '.exe'
2008-06-04 00:15:00 +00:00
fceux_src = 'src/fceux' + exe_suffix
fceux_dst = 'bin/fceux' + exe_suffix
auxlib_src = 'src/auxlib.lua'
auxlib_dst = 'bin/auxlib.lua'
auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua'
2008-06-04 00:15:00 +00:00
fceux_h_src = 'src/drivers/win/help/fceux.chm'
fceux_h_dst = 'bin/fceux.chm'
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)])
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
2008-08-03 00:09:00 +00:00
man_src = 'documentation/fceux.6'
man_dst = prefix + '/share/man/man6/fceux.6'
share_src = 'output/'
share_dst = prefix + '/share/fceux/'
env.Install(prefix + "/bin/", fceux)
# TODO: Where to put auxlib on "scons install?"
env.Alias('install', env.Command(auxlib_inst_dst, auxlib_src, [Copy(auxlib_inst_dst, auxlib_src)]))
env.Alias('install', env.Command(share_dst, share_src, [Copy(share_dst, share_src)]))
env.Alias('install', env.Command(man_dst, man_src, [Copy(man_dst, man_src)]))
env.Alias('install', (prefix + "/bin/"))