|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# mittorn, 2018
|
|
|
|
|
|
|
|
from waflib import Logs
|
|
|
|
import os
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
grp = opt.add_option_group('Engine options')
|
|
|
|
|
|
|
|
grp.add_option('--enable-stdin-input', action = 'store_true', dest = 'USE_SELECT', default = False,
|
|
|
|
help = 'enable console input from stdin (always enabled for dedicated) [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False,
|
|
|
|
help = 'build fbdev-only software-only engine')
|
|
|
|
grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False,
|
|
|
|
help = 'disable asynchronous name resolution')
|
|
|
|
grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
|
|
|
|
help = 'enable custom swap allocator. For devices with no swap support')
|
|
|
|
|
|
|
|
grp.add_option('--enable-magx', action = 'store_true', dest = 'MAGX', default = False,
|
|
|
|
help = 'enable targetting for MotoMAGX phones [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False,
|
|
|
|
help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %default')
|
|
|
|
|
|
|
|
opt.load('sdl2')
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
conf.env.MAGX = conf.options.MAGX
|
|
|
|
if conf.options.MAGX:
|
|
|
|
# useless to change toolchain path, as toolchain meant to be placed in this path
|
|
|
|
toolchain_path = '/opt/toolchains/motomagx/arm-eabi2/lib/'
|
|
|
|
conf.env.INCLUDES_MAGX = [toolchain_path + i for i in ['ezx-z6/include', 'qt-2.3.8/include']]
|
|
|
|
conf.env.LIBPATH_MAGX = [toolchain_path + i for i in ['ezx-z6/lib', 'qt-2.3.8/lib']]
|
|
|
|
conf.env.LINKFLAGS_MAGX = ['-Wl,-rpath-link=' + i for i in conf.env.LIBPATH_MAGX]
|
|
|
|
for lib in ['qte-mt', 'ezxappbase', 'ezxpm', 'log_util']:
|
|
|
|
conf.check_cc(lib=lib, use='MAGX', uselib_store='MAGX')
|
|
|
|
conf.options.SDL12 = True
|
|
|
|
|
|
|
|
# check for dedicated server build
|
|
|
|
if conf.options.DEDICATED:
|
|
|
|
if conf.env.DEST_OS == 'linux':
|
|
|
|
conf.check_cc( lib='rt' )
|
|
|
|
conf.define('XASH_DEDICATED', 1)
|
|
|
|
elif conf.env.DEST_OS == 'android': # Android doesn't need SDL2
|
|
|
|
for i in ['android', 'log', 'EGL']:
|
|
|
|
conf.check_cc(lib = i)
|
|
|
|
elif conf.options.FBDEV_SW:
|
|
|
|
conf.define('XASH_FBDEV', 1)
|
|
|
|
conf.check_cc( lib = 'asound' )
|
|
|
|
conf.check_cc( lib = 'rt' )
|
|
|
|
elif conf.options.SDL12:
|
|
|
|
conf.define('XASH_SDL', 12)
|
|
|
|
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
|
|
|
|
if conf.env.DEST_OS == 'linux':
|
|
|
|
conf.check_cc( lib='rt' )
|
|
|
|
conf.env.HAVE_SDL2 = True
|
|
|
|
else:
|
|
|
|
conf.load('sdl2')
|
|
|
|
if not conf.env.HAVE_SDL2:
|
|
|
|
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
|
|
|
conf.define('XASH_SDL', 2)
|
|
|
|
|
|
|
|
if conf.options.USE_SELECT == None:
|
|
|
|
conf.options.USE_SELECT = conf.options.DEDICATED
|
|
|
|
|
|
|
|
|
|
|
|
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
|
|
|
|
conf.check_cc( lib='pthread' )
|
|
|
|
|
|
|
|
if conf.options.CUSTOM_SWAP:
|
|
|
|
conf.define('XASH_CUSTOM_SWAP',1)
|
|
|
|
conf.env.CUSTOM_SWAP = True
|
|
|
|
conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY)
|
|
|
|
conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE)
|
|
|
|
conf.define_cond('XASH_USE_SELECT', conf.options.USE_SELECT or conf.options.DEDICATED)
|
|
|
|
conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
|
|
|
|
conf.define_cond('XASH_64BIT', conf.env.DEST_SIZEOF_VOID_P != 4)
|
|
|
|
conf.define_cond('DBGHELP', conf.env.DEST_OS == 'win32')
|
|
|
|
conf.define_cond('PSAPI_VERSION', conf.env.DEST_OS == 'win32') # will be defined as 1
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
is_cxx_link = False
|
|
|
|
libs = [ 'public' ]
|
|
|
|
source = bld.path.ant_glob([
|
|
|
|
'common/*.c',
|
|
|
|
'common/imagelib/*.c',
|
|
|
|
'common/soundlib/*.c',
|
|
|
|
'common/soundlib/libmpg/*.c',
|
|
|
|
'server/*.c'])
|
|
|
|
|
|
|
|
# basic build: dedicated only, no dependencies
|
|
|
|
if bld.env.DEST_OS != 'win32':
|
|
|
|
libs += [ 'DL' , 'M' , 'RT', 'PTHREAD', 'ASOUND']
|
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
|
|
|
|
|
|
|
else:
|
|
|
|
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI', 'WS2_32' ]
|
|
|
|
source += bld.path.ant_glob(['platform/win32/*.c'])
|
|
|
|
|
|
|
|
if bld.env.DEST_OS == 'linux':
|
|
|
|
source += bld.path.ant_glob(['platform/linux/*.c'])
|
|
|
|
|
|
|
|
if bld.env.CUSTOM_SWAP:
|
|
|
|
source += bld.path.ant_glob(['platform/swap/*.c'])
|
|
|
|
|
|
|
|
if bld.env.HAVE_SDL2:
|
|
|
|
libs.append('SDL2')
|
|
|
|
source += bld.path.ant_glob(['platform/sdl/*.c'])
|
|
|
|
|
|
|
|
if bld.env.MAGX:
|
|
|
|
libs.append('MAGX')
|
|
|
|
source += bld.path.ant_glob(['platform/magx/*.cpp'])
|
|
|
|
is_cxx_link = True
|
|
|
|
|
|
|
|
if bld.env.DEST_OS == 'android':
|
|
|
|
libs += ['LOG', 'EGL', 'ANDROID']
|
|
|
|
source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.c', 'platform/linux/*.c'])
|
|
|
|
|
|
|
|
# add client files
|
|
|
|
if not bld.env.DEDICATED:
|
|
|
|
source += bld.path.ant_glob([
|
|
|
|
'client/*.c',
|
|
|
|
'client/vgui/*.c',
|
|
|
|
'client/avi/*.c'])
|
|
|
|
|
|
|
|
# HACK: public headers must be put before common, so we don't get wrong mathlib included
|
|
|
|
includes = ['common', 'server', 'client', 'client/vgui', '.', '../public', '../common', '../pm_shared' ]
|
|
|
|
|
|
|
|
if bld.env.SINGLE_BINARY:
|
|
|
|
install_path = bld.env.BINDIR
|
|
|
|
features = ['c', 'cxxprogram' if is_cxx_link else 'cprogram']
|
|
|
|
else:
|
|
|
|
install_path = bld.env.LIBDIR
|
|
|
|
features = ['c', 'cxxshlib' if is_cxx_link else 'cshlib']
|
|
|
|
|
|
|
|
bld(source = source,
|
|
|
|
target = 'xash',
|
|
|
|
features = features,
|
|
|
|
includes = includes,
|
|
|
|
use = libs,
|
|
|
|
install_path = install_path,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
|
|
|
)
|