~ubuntu-branches/ubuntu/utopic/fceux/utopic

« back to all changes in this revision

Viewing changes to .pc/use_system_lua.patch/SConstruct

  • Committer: Package Import Robot
  • Author(s): Joe Nahmias
  • Date: 2014-03-02 19:22:04 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140302192204-9f0aehi5stfnhn7d
Tags: 2.2.2+dfsg0-1
* Imported Upstream version 2.2.2
  + remove patches merged upstream; refresh remaining
  + remove windows compiled help files and non-free Visual C files
* Use C++11 standard static assertion functionality
* fix upstream installation of support files
* New patch 0004-ignore-missing-windows-help-CHM-file.patch
* update d/copyright for new, renamed, deleted files
* d/control: bump std-ver to 3.9.5, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# SConstruct - build script for the SDL port of fceux
3
 
#
4
 
# You can adjust the BoolVariables below to include/exclude features at compile-time
5
 
#
6
 
# You may need to wipe the scons cache ("scons -c") and recompile for some options to take effect.
7
 
#
8
 
# Use "scons" to compile and "scons install" to install.
9
 
#
10
 
 
11
 
import os
12
 
import sys
13
 
import platform 
14
 
 
15
 
opts = Variables()
16
 
opts.AddVariables( 
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)
30
 
)
31
 
AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix')
32
 
 
33
 
prefix = GetOption('prefix')
34
 
env = Environment(options = opts)
35
 
 
36
 
#### Uncomment this for a public release ###
37
 
env.Append(CPPDEFINES=["PUBLIC_RELEASE"])
38
 
env['DEBUG'] = 0
39
 
############################################
40
 
 
41
 
# LSB_FIRST must be off for PPC to compile
42
 
if platform.system == "ppc":
43
 
  env['LSB_FIRST'] = 0
44
 
 
45
 
# Default compiler flags:
46
 
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-Isrc/lua/src'])
47
 
 
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())
64
 
 
65
 
print "platform: ", env['PLATFORM']
66
 
 
67
 
# compile with clang
68
 
if env['CLANG']:
69
 
  env.Replace(CC='clang')
70
 
  env.Replace(CXX='clang++')
71
 
 
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'];
78
 
 
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"])
83
 
else:
84
 
  conf = Configure(env)
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"])
91
 
  else:
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!'
95
 
    Exit(1)
96
 
  if env['GTK']:
97
 
    if not conf.CheckLib('gtk-x11-2.0'):
98
 
      print 'Could not find libgtk-2.0, exiting!'
99
 
      Exit(1)
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"])
107
 
  if env['GTK3']:
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"])
115
 
 
116
 
  ### Lua platform defines
117
 
  ### Applies to all files even though only lua needs it, but should be ok
118
 
  if env['LUA']:
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"])
130
 
      lua_available = True
131
 
    elif conf.CheckLib('lua'):
132
 
      env.Append(LINKFLAGS = ["-ldl", "-llua"])
133
 
      lua_available = True
134
 
    if lua_available == False:
135
 
      print 'Could not find liblua, exiting!'
136
 
      Exit(1)
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'])
140
 
  
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)
144
 
    if gd == 0:
145
 
      env['LOGO'] = 0
146
 
      print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
147
 
   
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')
153
 
  
154
 
  env = conf.Finish()
155
 
 
156
 
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
157
 
  env.Append(CPPDEFINES = ['LSB_FIRST'])
158
 
 
159
 
if env['FRAMESKIP']:
160
 
  env.Append(CPPDEFINES = ['FRAMESKIP'])
161
 
 
162
 
print "base CPPDEFINES:",env['CPPDEFINES']
163
 
print "base CCFLAGS:",env['CCFLAGS']
164
 
 
165
 
if env['DEBUG']:
166
 
  env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])
167
 
else:
168
 
  env.Append(CCFLAGS = ['-O2'])
169
 
 
170
 
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
171
 
  env.Append(CPPDEFINES=["CREATE_AVI"])
172
 
else:
173
 
  env['CREATE_AVI']=0;
174
 
 
175
 
Export('env')
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"])
178
 
# Install rules
179
 
if prefix == None:
180
 
  prefix = "/usr/local"
181
 
 
182
 
exe_suffix = ''
183
 
if env['PLATFORM'] == 'win32':
184
 
  exe_suffix = '.exe'
185
 
 
186
 
fceux_src = 'src/fceux' + exe_suffix
187
 
fceux_dst = 'bin/fceux' + exe_suffix
188
 
 
189
 
fceux_net_server_src = 'fceux-net-server' + exe_suffix
190
 
fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix
191
 
 
192
 
auxlib_src = 'src/auxlib.lua'
193
 
auxlib_dst = 'bin/auxlib.lua'
194
 
auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua'
195
 
 
196
 
fceux_h_src = 'src/drivers/win/help/fceux.chm'
197
 
fceux_h_dst = 'bin/fceux.chm'
198
 
 
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)])
203
 
 
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'
208
 
 
209
 
share_src = 'output/'
210
 
share_dst = prefix + '/share/fceux/'
211
 
 
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/"))
220
 
 
221