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
|
|
|
|
2006-07-31 00:03:35 +00:00
|
|
|
opts = Options()
|
2006-08-04 17:32:08 +00:00
|
|
|
opts.AddOptions(
|
2008-08-10 10:56:55 +00:00
|
|
|
BoolOption('FRAMESKIP', 'Enable frameskipping', 1),
|
2008-08-10 13:38:39 +00:00
|
|
|
BoolOption('OPENGL', 'Enable OpenGL support', 1),
|
2008-09-24 06:40:35 +00:00
|
|
|
BoolOption('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
|
2008-09-24 06:06:31 +00:00
|
|
|
BoolOption('DEBUG', 'Build with debugging symbols', 0),
|
2008-09-24 06:27:28 +00:00
|
|
|
BoolOption('LUA', 'Enable Lua support', 1),
|
2008-10-25 12:36:03 +00:00
|
|
|
BoolOption('NEWPPU', 'Enable new PPU core', 0),
|
|
|
|
BoolOption('CREATE_AVI', 'Enable avi creation support (SDL only)', 0),
|
|
|
|
BoolOption('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1')
|
2006-08-04 17:32:08 +00:00
|
|
|
)
|
2006-07-31 00:03:35 +00:00
|
|
|
|
2008-05-27 05:29:00 +00:00
|
|
|
env = Environment(options = opts)
|
2008-08-03 00:08:17 +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:
|
2008-08-10 13:38:39 +00:00
|
|
|
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-O2'])
|
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())
|
2006-07-31 22:24:21 +00:00
|
|
|
if os.environ.has_key('LDFLAGS'):
|
2009-03-14 19:15:19 +00:00
|
|
|
env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())
|
2006-07-31 20:07:15 +00:00
|
|
|
|
2006-07-31 00:03:35 +00:00
|
|
|
print "platform: ", env['PLATFORM']
|
|
|
|
|
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)
|
2008-05-27 05:29:00 +00:00
|
|
|
if not conf.CheckLib('SDL'):
|
|
|
|
print 'Did not find libSDL or SDL.lib, exiting!'
|
|
|
|
Exit(1)
|
|
|
|
if not conf.CheckLib('z', autoadd=1):
|
|
|
|
print 'Did not find libz or z.lib, exiting!'
|
|
|
|
Exit(1)
|
2008-09-24 06:06:31 +00:00
|
|
|
if env['LUA']:
|
|
|
|
lua51 = conf.CheckLib('lua5.1', autoadd=1)
|
|
|
|
lua = conf.CheckLib('lua', autoadd=1)
|
|
|
|
if lua == 0 and lua51 == 0:
|
|
|
|
print 'Did not find liblua5.1, liblua, lua.lib or lua5.1.lib, compiling anyway!'
|
|
|
|
env['LUA'] = 0
|
2008-08-14 14:50:27 +00:00
|
|
|
|
2008-08-12 07:39:52 +00:00
|
|
|
### Search for zenity if we're not in windows
|
|
|
|
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin':
|
|
|
|
path = os.getenv('PATH')
|
|
|
|
directories = []
|
|
|
|
dir = ''
|
|
|
|
# check for '$' so last entry is processed
|
|
|
|
for x in path + '$':
|
|
|
|
if x != ':' and x != '$':
|
|
|
|
dir += x
|
|
|
|
else:
|
|
|
|
directories.append(dir)
|
|
|
|
dir = ''
|
2008-08-10 09:34:45 +00:00
|
|
|
|
2008-08-12 07:39:52 +00:00
|
|
|
zenity = 0
|
2008-08-12 16:48:02 +00:00
|
|
|
print "Checking for zenity...",
|
2008-08-12 07:39:52 +00:00
|
|
|
for x in directories:
|
|
|
|
if os.path.isfile(os.path.join(x, "zenity")):
|
|
|
|
zenity = 1
|
2008-08-12 16:48:02 +00:00
|
|
|
if zenity:
|
|
|
|
print 'yes'
|
|
|
|
else:
|
2008-08-12 07:39:52 +00:00
|
|
|
print "*** WARNING ***"
|
|
|
|
print "Zenity could not be found in the PATH. File dialogs will not work without zenity installed."
|
|
|
|
raw_input('Press any key to continue. . .')
|
2008-10-25 12:36:03 +00:00
|
|
|
|
|
|
|
### 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.'
|
|
|
|
|
2008-05-27 05:29:00 +00:00
|
|
|
if conf.CheckFunc('asprintf'):
|
|
|
|
conf.env.Append(CCFLAGS = " -DHAVE_ASPRINTF")
|
|
|
|
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'])
|
2008-05-27 05:29:00 +00:00
|
|
|
# parse SDL cflags/libs
|
|
|
|
env.ParseConfig('sdl-config --cflags --libs')
|
2008-09-24 06:06:31 +00:00
|
|
|
if env['LUA']:
|
|
|
|
# parse liblua cflags
|
|
|
|
if lua51:
|
|
|
|
env.Append(CPPPATH = ['/usr/local/include/lua5.1', '/usr/include/lua5.1'])
|
|
|
|
if lua:
|
|
|
|
env.Append(CPPPATH = ['/usr/local/include/lua', '/usr/include/lua'])
|
|
|
|
env.Append(CPPDEFINES=["_S9XLUA_H"])
|
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']:
|
|
|
|
env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])
|
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')
|
2008-06-04 00:15:00 +00:00
|
|
|
SConscript('src/SConscript')
|
|
|
|
|
|
|
|
# Install rules
|
|
|
|
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
|
|
|
|
|
2008-08-03 00:08:17 +00:00
|
|
|
auxlib_src = 'src/auxlib.lua'
|
|
|
|
auxlib_dst = 'bin/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'
|
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)])
|
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
|
|
|
|
2008-08-11 03:16:46 +00:00
|
|
|
# TODO: Fix this build script to gracefully install auxlib and the man page
|
|
|
|
#env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source=("bin/fceux", "bin/auxlib.lua")))
|
|
|
|
env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source="bin/fceux"))
|