2
# SConstruct - build script for the SDL port of fceux
4
# You can adjust the BoolVariables below to include/exclude features at compile-time
6
# You may need to wipe the scons cache ("scons -c") and recompile for some options to take effect.
8
# Use "scons" to compile and "scons install" to install.
17
BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),
18
BoolVariable('OPENGL', 'Enable OpenGL support', 1),
19
BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
20
BoolVariable('DEBUG', 'Build with debugging symbols', 1),
21
BoolVariable('LUA', 'Enable Lua support', 1),
22
BoolVariable('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 1),
23
BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0),
24
BoolVariable('NEWPPU', 'Enable new PPU core', 1),
25
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 1),
26
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', 1),
27
BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),
28
BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 0),
29
BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0)
31
AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix')
33
prefix = GetOption('prefix')
34
env = Environment(options = opts)
36
#### Uncomment this for a public release ###
37
env.Append(CPPDEFINES=["PUBLIC_RELEASE"])
39
############################################
41
# LSB_FIRST must be off for PPC to compile
42
if platform.system == "ppc":
45
# Default compiler flags:
46
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-Isrc/lua/src'])
48
if os.environ.has_key('PLATFORM'):
49
env.Replace(PLATFORM = os.environ['PLATFORM'])
50
if os.environ.has_key('CC'):
51
env.Replace(CC = os.environ['CC'])
52
if os.environ.has_key('CXX'):
53
env.Replace(CXX = os.environ['CXX'])
54
if os.environ.has_key('WINDRES'):
55
env.Replace(WINDRES = os.environ['WINDRES'])
56
if os.environ.has_key('CFLAGS'):
57
env.Append(CCFLAGS = os.environ['CFLAGS'].split())
58
if os.environ.has_key('CXXFLAGS'):
59
env.Append(CXXFLAGS = os.environ['CXXFLAGS'].split())
60
if os.environ.has_key('CPPFLAGS'):
61
env.Append(CPPFLAGS = os.environ['CPPFLAGS'].split())
62
if os.environ.has_key('LDFLAGS'):
63
env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())
65
print "platform: ", env['PLATFORM']
69
env.Replace(CC='clang')
70
env.Replace(CXX='clang++')
72
# special flags for cygwin
73
# we have to do this here so that the function and lib checks will go through mingw
74
if env['PLATFORM'] == 'cygwin':
75
env.Append(CCFLAGS = " -mno-cygwin")
76
env.Append(LINKFLAGS = " -mno-cygwin")
77
env['LIBS'] = ['wsock32'];
79
if env['PLATFORM'] == 'win32':
80
env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
81
env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
82
env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
85
if conf.CheckFunc('asprintf'):
86
conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
87
if env['SYSTEM_MINIZIP']:
88
assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip"
89
assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
90
env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"])
92
assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
93
if not conf.CheckLib('SDL'):
94
print 'Did not find libSDL or SDL.lib, exiting!'
97
if not conf.CheckLib('gtk-x11-2.0'):
98
print 'Could not find libgtk-2.0, exiting!'
100
# Add compiler and linker flags from pkg-config
101
config_string = 'pkg-config --cflags --libs gtk+-2.0'
102
if env['PLATFORM'] == 'darwin':
103
config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
104
env.ParseConfig(config_string)
105
env.Append(CPPDEFINES=["_GTK2"])
106
env.Append(CCFLAGS = ["-D_GTK"])
108
# Add compiler and linker flags from pkg-config
109
config_string = 'pkg-config --cflags --libs gtk+-3.0'
110
if env['PLATFORM'] == 'darwin':
111
config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
112
env.ParseConfig(config_string)
113
env.Append(CPPDEFINES=["_GTK3"])
114
env.Append(CCFLAGS = ["-D_GTK"])
116
### Lua platform defines
117
### Applies to all files even though only lua needs it, but should be ok
119
env.Append(CPPDEFINES=["_S9XLUA_H"])
120
if env['PLATFORM'] == 'darwin':
121
# Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
122
env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])
123
if env['PLATFORM'] == 'posix':
124
# If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.
125
# Should work on any *nix
126
env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
127
lua_available = False
128
if conf.CheckLib('lua5.1'):
129
env.Append(LINKFLAGS = ["-ldl", "-llua5.1"])
131
elif conf.CheckLib('lua'):
132
env.Append(LINKFLAGS = ["-ldl", "-llua"])
134
if lua_available == False:
135
print 'Could not find liblua, exiting!'
137
# "--as-needed" no longer available on OSX (probably BSD as well? TODO: test)
138
if env['PLATFORM'] != 'darwin':
139
env.Append(LINKFLAGS=['-Wl,--as-needed'])
141
### Search for gd if we're not in Windows
142
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:
143
gd = conf.CheckLib('gd', autoadd=1)
146
print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
148
if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1):
149
conf.env.Append(CCFLAGS = "-DOPENGL")
150
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
151
# parse SDL cflags/libs
152
env.ParseConfig('sdl-config --cflags --libs')
156
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
157
env.Append(CPPDEFINES = ['LSB_FIRST'])
160
env.Append(CPPDEFINES = ['FRAMESKIP'])
162
print "base CPPDEFINES:",env['CPPDEFINES']
163
print "base CCFLAGS:",env['CCFLAGS']
166
env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])
168
env.Append(CCFLAGS = ['-O2'])
170
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
171
env.Append(CPPDEFINES=["CREATE_AVI"])
176
fceux = SConscript('src/SConscript')
177
env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"])
180
prefix = "/usr/local"
183
if env['PLATFORM'] == 'win32':
186
fceux_src = 'src/fceux' + exe_suffix
187
fceux_dst = 'bin/fceux' + exe_suffix
189
fceux_net_server_src = 'fceux-net-server' + exe_suffix
190
fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix
192
auxlib_src = 'src/auxlib.lua'
193
auxlib_dst = 'bin/auxlib.lua'
194
auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua'
196
fceux_h_src = 'src/drivers/win/help/fceux.chm'
197
fceux_h_dst = 'bin/fceux.chm'
199
env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])
200
env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])
201
env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)])
202
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
204
man_src = 'documentation/fceux.6'
205
man_net_src = 'documentation/fceux-net-server.6'
206
man_dst = prefix + '/share/man/man6/fceux.6'
207
man_net_dst = prefix + '/share/man/man6/fceux-net-server.6'
209
share_src = 'output/'
210
share_dst = prefix + '/share/fceux/'
212
env.Install(prefix + "/bin/", fceux)
213
env.Install(prefix + "/bin/", "fceux-net-server")
214
# TODO: Where to put auxlib on "scons install?"
215
env.Alias('install', env.Command(auxlib_inst_dst, auxlib_src, [Copy(auxlib_inst_dst, auxlib_src)]))
216
env.Alias('install', env.Command(share_dst, share_src, [Copy(share_dst, share_src)]))
217
env.Alias('install', env.Command(man_dst, man_src, [Copy(man_dst, man_src)]))
218
env.Alias('install', env.Command(man_net_dst, man_net_src, [Copy(man_net_dst, man_net_src)]))
219
env.Alias('install', (prefix + "/bin/"))