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

« back to all changes in this revision

Viewing changes to .pc/0001-Use-C-11-standard-static-assertion-functionality.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 
 
5
# at compile-time.  You may also use arguments to specify the parameters.
 
6
#   ie: scons RELEASE=1 GTK3=1
 
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(None, ARGUMENTS)
 
16
opts.AddVariables( 
 
17
  BoolVariable('DEBUG',     'Build with debugging symbols', 0),
 
18
  BoolVariable('RELEASE',   'Set to 1 to build for release', 1),
 
19
  BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),
 
20
  BoolVariable('OPENGL',    'Enable OpenGL support', 1),
 
21
  BoolVariable('LUA',       'Enable Lua support', 1),
 
22
  BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),
 
23
  BoolVariable('GTK3', 'Enable GTK3 GUI (SDL only)', 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('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 1),
 
28
  BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0),
 
29
  BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
 
30
  BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0),
 
31
  BoolVariable('SDL2', 'Compile using SDL2 instead of SDL 1.2 (experimental/non-functional)', 0)
 
32
)
 
33
AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix')
 
34
 
 
35
prefix = GetOption('prefix')
 
36
env = Environment(options = opts)
 
37
 
 
38
if env['RELEASE']:
 
39
  env.Append(CPPDEFINES=["PUBLIC_RELEASE"])
 
40
  env['DEBUG'] = 0
 
41
 
 
42
# LSB_FIRST must be off for PPC to compile
 
43
if platform.system == "ppc":
 
44
  env['LSB_FIRST'] = 0
 
45
 
 
46
# Default compiler flags:
 
47
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare'])
 
48
 
 
49
if os.environ.has_key('PLATFORM'):
 
50
  env.Replace(PLATFORM = os.environ['PLATFORM'])
 
51
if os.environ.has_key('CC'):
 
52
  env.Replace(CC = os.environ['CC'])
 
53
if os.environ.has_key('CXX'):
 
54
  env.Replace(CXX = os.environ['CXX'])
 
55
if os.environ.has_key('WINDRES'):
 
56
  env.Replace(WINDRES = os.environ['WINDRES'])
 
57
if os.environ.has_key('CFLAGS'):
 
58
  env.Append(CCFLAGS = os.environ['CFLAGS'].split())
 
59
if os.environ.has_key('CXXFLAGS'):
 
60
  env.Append(CXXFLAGS = os.environ['CXXFLAGS'].split())
 
61
if os.environ.has_key('CPPFLAGS'):
 
62
  env.Append(CPPFLAGS = os.environ['CPPFLAGS'].split())
 
63
if os.environ.has_key('LDFLAGS'):
 
64
  env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())
 
65
 
 
66
print "platform: ", env['PLATFORM']
 
67
 
 
68
# compile with clang
 
69
if env['CLANG']:
 
70
  env.Replace(CC='clang')
 
71
  env.Replace(CXX='clang++')
 
72
 
 
73
# special flags for cygwin
 
74
# we have to do this here so that the function and lib checks will go through mingw
 
75
if env['PLATFORM'] == 'cygwin':
 
76
  env.Append(CCFLAGS = " -mno-cygwin")
 
77
  env.Append(LINKFLAGS = " -mno-cygwin")
 
78
  env['LIBS'] = ['wsock32'];
 
79
 
 
80
if env['PLATFORM'] == 'win32':
 
81
  env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
 
82
  env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
 
83
  env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
 
84
else:
 
85
  conf = Configure(env)
 
86
  # If libdw is available, compile in backward-cpp support
 
87
  if conf.CheckLib('dw'):
 
88
    conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1")
 
89
    conf.env.Append(LINKFLAGS = "-ldw")
 
90
  if conf.CheckFunc('asprintf'):
 
91
    conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
 
92
  if env['SYSTEM_MINIZIP']:
 
93
    assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip"
 
94
    assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
 
95
    env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"])
 
96
  else:
 
97
    assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
 
98
  if env['SDL2']:
 
99
    if not conf.CheckLib('SDL2'):
 
100
      print 'Did not find libSDL2 or SDL2.lib, exiting!'
 
101
      Exit(1)
 
102
    env.Append(CPPDEFINES=["_SDL2"])
 
103
    env.ParseConfig('pkg-config sdl2 --cflags --libs')
 
104
  else:
 
105
    if not conf.CheckLib('SDL'):
 
106
      print 'Did not find libSDL or SDL.lib, exiting!'
 
107
      Exit(1)
 
108
    env.ParseConfig('sdl-config --cflags --libs')
 
109
  if env['GTK']:
 
110
    if not conf.CheckLib('gtk-x11-2.0'):
 
111
      print 'Could not find libgtk-2.0, exiting!'
 
112
      Exit(1)
 
113
    # Add compiler and linker flags from pkg-config
 
114
    config_string = 'pkg-config --cflags --libs gtk+-2.0'
 
115
    if env['PLATFORM'] == 'darwin':
 
116
      config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
 
117
    env.ParseConfig(config_string)
 
118
    env.Append(CPPDEFINES=["_GTK2"])
 
119
    env.Append(CCFLAGS = ["-D_GTK"])
 
120
  if env['GTK3']:
 
121
    # Add compiler and linker flags from pkg-config
 
122
    config_string = 'pkg-config --cflags --libs gtk+-3.0'
 
123
    if env['PLATFORM'] == 'darwin':
 
124
      config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
 
125
    env.ParseConfig(config_string)
 
126
    env.Append(CPPDEFINES=["_GTK3"])
 
127
    env.Append(CCFLAGS = ["-D_GTK"])
 
128
 
 
129
  ### Lua platform defines
 
130
  ### Applies to all files even though only lua needs it, but should be ok
 
131
  if env['LUA']:
 
132
    env.Append(CPPDEFINES=["_S9XLUA_H"])
 
133
    if env['PLATFORM'] == 'darwin':
 
134
      # Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
 
135
      env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])    
 
136
    if env['PLATFORM'] == 'posix':
 
137
      # If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.
 
138
      # Should work on any *nix
 
139
      env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
 
140
    lua_available = False
 
141
    if conf.CheckLib('lua5.1'):
 
142
      env.Append(LINKFLAGS = ["-ldl", "-llua5.1"])
 
143
      env.Append(CCFLAGS = ["-I/usr/include/lua5.1"])
 
144
      lua_available = True
 
145
    elif conf.CheckLib('lua'):
 
146
      env.Append(LINKFLAGS = ["-ldl", "-llua"])
 
147
      env.Append(CCFLAGS = ["-I/usr/include/lua"])
 
148
      lua_available = True
 
149
    if lua_available == False:
 
150
      print 'Could not find liblua, exiting!'
 
151
      Exit(1)
 
152
  # "--as-needed" no longer available on OSX (probably BSD as well? TODO: test)
 
153
  if env['PLATFORM'] != 'darwin':
 
154
    env.Append(LINKFLAGS=['-Wl,--as-needed'])
 
155
  
 
156
  ### Search for gd if we're not in Windows
 
157
  if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:
 
158
    gd = conf.CheckLib('gd', autoadd=1)
 
159
    if gd == 0:
 
160
      env['LOGO'] = 0
 
161
      print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
 
162
   
 
163
  if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1):
 
164
    conf.env.Append(CCFLAGS = "-DOPENGL")
 
165
  conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
 
166
  
 
167
  env = conf.Finish()
 
168
 
 
169
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
 
170
  env.Append(CPPDEFINES = ['LSB_FIRST'])
 
171
 
 
172
if env['FRAMESKIP']:
 
173
  env.Append(CPPDEFINES = ['FRAMESKIP'])
 
174
 
 
175
print "base CPPDEFINES:",env['CPPDEFINES']
 
176
print "base CCFLAGS:",env['CCFLAGS']
 
177
 
 
178
if env['DEBUG']:
 
179
  env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g', '-O0'])
 
180
else:
 
181
  env.Append(CCFLAGS = ['-O2'])
 
182
 
 
183
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
 
184
  env.Append(CPPDEFINES=["CREATE_AVI"])
 
185
else:
 
186
  env['CREATE_AVI']=0;
 
187
 
 
188
Export('env')
 
189
fceux = SConscript('src/SConscript')
 
190
env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"])
 
191
 
 
192
# Installation rules
 
193
if prefix == None:
 
194
  prefix = "/usr/local"
 
195
 
 
196
exe_suffix = ''
 
197
if env['PLATFORM'] == 'win32':
 
198
  exe_suffix = '.exe'
 
199
 
 
200
fceux_src = 'src/fceux' + exe_suffix
 
201
fceux_dst = 'bin/fceux' + exe_suffix
 
202
 
 
203
fceux_net_server_src = 'fceux-net-server' + exe_suffix
 
204
fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix
 
205
 
 
206
auxlib_src = 'src/auxlib.lua'
 
207
auxlib_dst = 'bin/auxlib.lua'
 
208
auxlib_inst_dst = prefix + '/share/fceux/auxlib.lua'
 
209
 
 
210
fceux_h_src = 'output/fceux.chm'
 
211
fceux_h_dst = 'bin/fceux.chm'
 
212
 
 
213
env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])
 
214
env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])
 
215
env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)])
 
216
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
 
217
 
 
218
man_src = 'documentation/fceux.6'
 
219
man_net_src = 'documentation/fceux-net-server.6'
 
220
man_dst = prefix + '/share/man/man6/fceux.6'
 
221
man_net_dst = prefix + '/share/man/man6/fceux-net-server.6'
 
222
 
 
223
share_src = 'output/'
 
224
share_dst = prefix + '/share/fceux/'
 
225
 
 
226
image_src = 'fceux.png'
 
227
image_dst = prefix + '/share/pixmaps'
 
228
 
 
229
desktop_src = 'fceux.desktop'
 
230
desktop_dst = prefix + '/share/applications/'
 
231
 
 
232
env.Install(prefix + "/bin/", fceux)
 
233
env.Install(prefix + "/bin/", "fceux-net-server")
 
234
# TODO:  Where to put auxlib on "scons install?"
 
235
env.Alias('install', env.Command(auxlib_inst_dst, auxlib_src, [Copy(auxlib_inst_dst, auxlib_src)]))
 
236
env.Alias('install', env.Command(share_dst, share_src, [Copy(share_dst, share_src)]))
 
237
env.Alias('install', env.Command(man_dst, man_src, [Copy(man_dst, man_src)]))
 
238
env.Alias('install', env.Command(man_net_dst, man_net_src, [Copy(man_net_dst, man_net_src)]))
 
239
env.Alias('install', env.Command(image_dst, image_src, [Copy(image_dst, image_src)]))
 
240
env.Alias('install', env.Command(desktop_dst, desktop_src, [Copy(desktop_dst, desktop_src)]))
 
241
env.Alias('install', (prefix + "/bin/"))