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

« back to all changes in this revision

Viewing changes to .pc/0003-install-to-games-instead-of-bin.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
# tell g++ to support c++0x, used for static_assert()
 
81
if env['CXX'] == 'g++':
 
82
  env.Append(CXXFLAGS = "-std=c++0x")
 
83
 
 
84
if env['PLATFORM'] == 'win32':
 
85
  env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
 
86
  env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
 
87
  env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
 
88
else:
 
89
  conf = Configure(env)
 
90
  # If libdw is available, compile in backward-cpp support
 
91
  if conf.CheckLib('dw'):
 
92
    conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1")
 
93
    conf.env.Append(LINKFLAGS = "-ldw")
 
94
  if conf.CheckFunc('asprintf'):
 
95
    conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
 
96
  if env['SYSTEM_MINIZIP']:
 
97
    assert conf.CheckLibWithHeader('minizip', 'minizip/unzip.h', 'C', 'unzOpen;', 1), "please install: libminizip"
 
98
    assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
 
99
    env.Append(CPPDEFINES=["_SYSTEM_MINIZIP"])
 
100
  else:
 
101
    assert conf.CheckLibWithHeader('z', 'zlib.h', 'c', 'inflate;', 1), "please install: zlib"
 
102
  if env['SDL2']:
 
103
    if not conf.CheckLib('SDL2'):
 
104
      print 'Did not find libSDL2 or SDL2.lib, exiting!'
 
105
      Exit(1)
 
106
    env.Append(CPPDEFINES=["_SDL2"])
 
107
    env.ParseConfig('pkg-config sdl2 --cflags --libs')
 
108
  else:
 
109
    if not conf.CheckLib('SDL'):
 
110
      print 'Did not find libSDL or SDL.lib, exiting!'
 
111
      Exit(1)
 
112
    env.ParseConfig('sdl-config --cflags --libs')
 
113
  if env['GTK']:
 
114
    if not conf.CheckLib('gtk-x11-2.0'):
 
115
      print 'Could not find libgtk-2.0, exiting!'
 
116
      Exit(1)
 
117
    # Add compiler and linker flags from pkg-config
 
118
    config_string = 'pkg-config --cflags --libs gtk+-2.0'
 
119
    if env['PLATFORM'] == 'darwin':
 
120
      config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
 
121
    env.ParseConfig(config_string)
 
122
    env.Append(CPPDEFINES=["_GTK2"])
 
123
    env.Append(CCFLAGS = ["-D_GTK"])
 
124
  if env['GTK3']:
 
125
    # Add compiler and linker flags from pkg-config
 
126
    config_string = 'pkg-config --cflags --libs gtk+-3.0'
 
127
    if env['PLATFORM'] == 'darwin':
 
128
      config_string = 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ ' + config_string
 
129
    env.ParseConfig(config_string)
 
130
    env.Append(CPPDEFINES=["_GTK3"])
 
131
    env.Append(CCFLAGS = ["-D_GTK"])
 
132
 
 
133
  ### Lua platform defines
 
134
  ### Applies to all files even though only lua needs it, but should be ok
 
135
  if env['LUA']:
 
136
    env.Append(CPPDEFINES=["_S9XLUA_H"])
 
137
    if env['PLATFORM'] == 'darwin':
 
138
      # Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
 
139
      env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])    
 
140
    if env['PLATFORM'] == 'posix':
 
141
      # If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.
 
142
      # Should work on any *nix
 
143
      env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
 
144
    lua_available = False
 
145
    if conf.CheckLib('lua5.1'):
 
146
      env.Append(LINKFLAGS = ["-ldl", "-llua5.1"])
 
147
      env.Append(CCFLAGS = ["-I/usr/include/lua5.1"])
 
148
      lua_available = True
 
149
    elif conf.CheckLib('lua'):
 
150
      env.Append(LINKFLAGS = ["-ldl", "-llua"])
 
151
      env.Append(CCFLAGS = ["-I/usr/include/lua"])
 
152
      lua_available = True
 
153
    if lua_available == False:
 
154
      print 'Could not find liblua, exiting!'
 
155
      Exit(1)
 
156
  # "--as-needed" no longer available on OSX (probably BSD as well? TODO: test)
 
157
  if env['PLATFORM'] != 'darwin':
 
158
    env.Append(LINKFLAGS=['-Wl,--as-needed'])
 
159
  
 
160
  ### Search for gd if we're not in Windows
 
161
  if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:
 
162
    gd = conf.CheckLib('gd', autoadd=1)
 
163
    if gd == 0:
 
164
      env['LOGO'] = 0
 
165
      print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
 
166
   
 
167
  if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c', autoadd=1):
 
168
    conf.env.Append(CCFLAGS = "-DOPENGL")
 
169
  conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
 
170
  
 
171
  env = conf.Finish()
 
172
 
 
173
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
 
174
  env.Append(CPPDEFINES = ['LSB_FIRST'])
 
175
 
 
176
if env['FRAMESKIP']:
 
177
  env.Append(CPPDEFINES = ['FRAMESKIP'])
 
178
 
 
179
print "base CPPDEFINES:",env['CPPDEFINES']
 
180
print "base CCFLAGS:",env['CCFLAGS']
 
181
 
 
182
if env['DEBUG']:
 
183
  env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g', '-O0'])
 
184
else:
 
185
  env.Append(CCFLAGS = ['-O2'])
 
186
 
 
187
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
 
188
  env.Append(CPPDEFINES=["CREATE_AVI"])
 
189
else:
 
190
  env['CREATE_AVI']=0;
 
191
 
 
192
Export('env')
 
193
fceux = SConscript('src/SConscript')
 
194
env.Program(target="fceux-net-server", source=["fceux-server/server.cpp", "fceux-server/md5.cpp", "fceux-server/throttle.cpp"])
 
195
 
 
196
# Installation rules
 
197
if prefix == None:
 
198
  prefix = "/usr/local"
 
199
 
 
200
exe_suffix = ''
 
201
if env['PLATFORM'] == 'win32':
 
202
  exe_suffix = '.exe'
 
203
 
 
204
fceux_src = 'src/fceux' + exe_suffix
 
205
fceux_dst = 'bin/fceux' + exe_suffix
 
206
 
 
207
fceux_net_server_src = 'fceux-net-server' + exe_suffix
 
208
fceux_net_server_dst = 'bin/fceux-net-server' + exe_suffix
 
209
 
 
210
auxlib_src = 'src/auxlib.lua'
 
211
auxlib_dst = 'bin/auxlib.lua'
 
212
 
 
213
fceux_h_src = 'output/fceux.chm'
 
214
fceux_h_dst = 'bin/fceux.chm'
 
215
 
 
216
env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])
 
217
env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])
 
218
env.Command(fceux_net_server_dst, fceux_net_server_src, [Copy(fceux_net_server_dst, fceux_net_server_src)])
 
219
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
 
220
 
 
221
man_src = 'documentation/fceux.6'
 
222
man_net_src = 'documentation/fceux-net-server.6'
 
223
 
 
224
share_src = 'output/'
 
225
 
 
226
image_src = 'fceux.png'
 
227
 
 
228
desktop_src = 'fceux.desktop'
 
229
 
 
230
env.Install(prefix + "/bin/", [fceux, fceux_net_server_src])
 
231
env.InstallAs(prefix + '/share/fceux/', share_src)
 
232
env.Install(prefix + '/share/fceux/', auxlib_src)
 
233
env.Install(prefix + '/share/pixmaps/', image_src)
 
234
env.Install(prefix + '/share/applications/', desktop_src)
 
235
env.Install(prefix + "/share/man/man6/", [man_src, man_net_src])
 
236
env.Alias('install', prefix)