2018-05-28 17:17:25 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# mittorn, 2018
|
|
|
|
|
|
|
|
from waflib import Logs
|
|
|
|
import os
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
|
|
|
|
def options(opt):
|
2019-02-19 14:33:14 +01:00
|
|
|
grp = opt.add_option_group('Engine options')
|
|
|
|
|
2019-10-11 02:46:17 +02:00
|
|
|
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]')
|
2019-11-04 23:35:20 +01:00
|
|
|
|
|
|
|
grp.add_option('--enable-fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False,
|
2019-10-21 20:41:44 +02:00
|
|
|
help = 'build fbdev-only software-only engine')
|
2019-11-04 23:35:20 +01:00
|
|
|
|
2019-10-28 06:31:29 +01:00
|
|
|
grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False,
|
2019-11-04 23:35:20 +01:00
|
|
|
help = 'disable multithreaded operations(asynchronous name resolution)')
|
|
|
|
|
2019-10-28 06:31:29 +01:00
|
|
|
grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
|
2019-10-26 07:12:59 +02:00
|
|
|
help = 'enable custom swap allocator. For devices with no swap support')
|
2019-01-28 15:09:06 +01:00
|
|
|
|
2019-10-24 11:42:20 +02:00
|
|
|
grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False,
|
2019-11-17 21:31:25 +01:00
|
|
|
help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--enable-static-binary', action = 'store_true', dest = 'STATIC', default = False,
|
|
|
|
help = 'build static binary(not recommended, --single-binary required) [default: %default]')
|
2019-10-24 11:42:20 +02:00
|
|
|
|
2019-02-19 14:33:14 +01:00
|
|
|
opt.load('sdl2')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
# check for dedicated server build
|
|
|
|
if conf.options.DEDICATED:
|
2019-09-19 16:07:41 +02:00
|
|
|
if conf.env.DEST_OS == 'linux':
|
2019-11-04 23:01:33 +01:00
|
|
|
conf.check_cc(lib='rt')
|
2019-10-11 02:10:08 +02:00
|
|
|
conf.define('XASH_DEDICATED', 1)
|
2019-09-19 16:07:41 +02:00
|
|
|
elif conf.env.DEST_OS == 'android': # Android doesn't need SDL2
|
|
|
|
for i in ['android', 'log', 'EGL']:
|
|
|
|
conf.check_cc(lib = i)
|
2019-10-21 20:41:44 +02:00
|
|
|
elif conf.options.FBDEV_SW:
|
2019-11-24 01:01:43 +01:00
|
|
|
# unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support
|
|
|
|
# conf.define('XASH_FBDEV', 1)
|
2019-10-26 07:12:59 +02:00
|
|
|
conf.check_cc( lib = 'asound' )
|
|
|
|
conf.check_cc( lib = 'rt' )
|
2019-10-24 11:42:20 +02:00
|
|
|
elif conf.options.SDL12:
|
|
|
|
conf.define('XASH_SDL', 12)
|
|
|
|
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
|
2019-10-26 14:41:22 +02:00
|
|
|
if conf.env.DEST_OS == 'linux':
|
|
|
|
conf.check_cc( lib='rt' )
|
2019-10-24 11:42:20 +02:00
|
|
|
conf.env.HAVE_SDL2 = True
|
2018-12-20 08:15:08 +01:00
|
|
|
else:
|
2018-12-13 06:03:26 +01:00
|
|
|
conf.load('sdl2')
|
|
|
|
if not conf.env.HAVE_SDL2:
|
|
|
|
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
2019-10-24 11:42:20 +02:00
|
|
|
conf.define('XASH_SDL', 2)
|
2019-01-28 15:09:06 +01:00
|
|
|
|
|
|
|
if conf.options.USE_SELECT == None:
|
|
|
|
conf.options.USE_SELECT = conf.options.DEDICATED
|
2019-09-19 16:07:41 +02:00
|
|
|
|
2019-11-17 21:31:25 +01:00
|
|
|
if conf.options.STATIC:
|
|
|
|
conf.env.STATIC = True
|
|
|
|
conf.define('XASH_NO_LIBDL',1)
|
|
|
|
|
2019-10-26 07:12:59 +02:00
|
|
|
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
|
2019-11-04 23:40:06 +01:00
|
|
|
conf.load('pthreads')
|
|
|
|
conf.check_pthread_flag()
|
2019-10-26 07:12:59 +02:00
|
|
|
|
2020-01-19 02:28:37 +01:00
|
|
|
if hasattr(conf.options, 'DLLEMU'):
|
|
|
|
conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU)
|
|
|
|
|
2019-11-17 21:31:25 +01:00
|
|
|
conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING)
|
2019-11-04 23:40:06 +01:00
|
|
|
conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP)
|
2019-10-26 07:12:59 +02:00
|
|
|
conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY)
|
|
|
|
conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE)
|
2019-10-23 19:47:26 +02:00
|
|
|
conf.define_cond('XASH_USE_SELECT', conf.options.USE_SELECT or conf.options.DEDICATED)
|
2019-10-11 02:10:08 +02:00
|
|
|
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
|
2019-05-30 06:38:53 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def build(bld):
|
2019-10-27 23:47:18 +01:00
|
|
|
is_cxx_link = False
|
2020-01-19 01:38:37 +01:00
|
|
|
libs = [ 'public', 'dllemu' ]
|
2018-10-22 00:47:12 +02:00
|
|
|
source = bld.path.ant_glob([
|
2019-04-08 19:38:10 +02:00
|
|
|
'common/*.c',
|
2018-10-22 00:47:12 +02:00
|
|
|
'common/imagelib/*.c',
|
|
|
|
'common/soundlib/*.c',
|
|
|
|
'common/soundlib/libmpg/*.c',
|
|
|
|
'server/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
# basic build: dedicated only, no dependencies
|
|
|
|
if bld.env.DEST_OS != 'win32':
|
2019-11-17 21:31:25 +01:00
|
|
|
libs += [ 'M', 'RT', 'PTHREAD', 'ASOUND']
|
|
|
|
if not bld.env.STATIC:
|
|
|
|
libs += ['DL']
|
2018-10-22 00:47:12 +02:00
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
else:
|
2019-06-29 21:01:32 +02:00
|
|
|
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI', 'WS2_32' ]
|
2018-06-14 19:34:51 +02:00
|
|
|
source += bld.path.ant_glob(['platform/win32/*.c'])
|
|
|
|
|
2018-11-16 14:32:16 +01:00
|
|
|
if bld.env.DEST_OS == 'linux':
|
|
|
|
source += bld.path.ant_glob(['platform/linux/*.c'])
|
|
|
|
|
2019-11-04 23:35:20 +01:00
|
|
|
if bld.get_define('XASH_CUSTOM_SWAP'):
|
2019-11-17 21:31:25 +01:00
|
|
|
source += bld.path.ant_glob(['platform/misc/kmalloc.c', 'platform/misc/sbrk.c'])
|
|
|
|
|
|
|
|
if bld.env.STATIC_LINKING:
|
|
|
|
source += bld.path.ant_glob(['platform/misc/lib_static.c'])
|
|
|
|
is_cxx_link = True
|
2019-10-21 20:41:44 +02:00
|
|
|
|
2018-12-20 07:48:22 +01:00
|
|
|
if bld.env.HAVE_SDL2:
|
|
|
|
libs.append('SDL2')
|
|
|
|
source += bld.path.ant_glob(['platform/sdl/*.c'])
|
|
|
|
|
2019-10-27 23:47:18 +01:00
|
|
|
if bld.env.MAGX:
|
|
|
|
libs.append('MAGX')
|
|
|
|
source += bld.path.ant_glob(['platform/magx/*.cpp'])
|
|
|
|
is_cxx_link = True
|
|
|
|
|
2019-09-19 16:07:41 +02:00
|
|
|
if bld.env.DEST_OS == 'android':
|
2019-05-12 02:03:34 +02:00
|
|
|
libs += ['LOG', 'EGL', 'ANDROID']
|
2019-09-19 16:07:41 +02:00
|
|
|
source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.c', 'platform/linux/*.c'])
|
2018-12-20 07:48:22 +01:00
|
|
|
|
|
|
|
# add client files
|
2018-05-28 17:17:25 +02:00
|
|
|
if not bld.env.DEDICATED:
|
|
|
|
source += bld.path.ant_glob([
|
|
|
|
'client/*.c',
|
|
|
|
'client/vgui/*.c',
|
2018-12-20 07:48:22 +01:00
|
|
|
'client/avi/*.c'])
|
2019-10-25 04:04:11 +02:00
|
|
|
|
2019-11-04 23:35:20 +01:00
|
|
|
# HACK: public headers must be put before SDK common, so we don't get wrong mathlib included
|
2019-03-20 00:40:47 +01:00
|
|
|
includes = ['common', 'server', 'client', 'client/vgui', '.', '../public', '../common', '../pm_shared' ]
|
2018-05-28 17:17:25 +02:00
|
|
|
|
2018-12-13 06:03:26 +01:00
|
|
|
if bld.env.SINGLE_BINARY:
|
2019-05-06 03:38:11 +02:00
|
|
|
install_path = bld.env.BINDIR
|
2019-11-17 21:31:25 +01:00
|
|
|
program = 'cxxprogram' if is_cxx_link else 'cprogram'
|
|
|
|
if bld.env.STATIC:
|
|
|
|
program += '_static'
|
|
|
|
features = ['c', program]
|
2018-05-28 17:17:25 +02:00
|
|
|
else:
|
2019-05-06 03:38:11 +02:00
|
|
|
install_path = bld.env.LIBDIR
|
2019-10-27 23:47:18 +01:00
|
|
|
features = ['c', 'cxxshlib' if is_cxx_link else 'cshlib']
|
2019-05-06 03:38:11 +02:00
|
|
|
|
2019-09-19 16:07:41 +02:00
|
|
|
bld(source = source,
|
2019-05-06 03:38:11 +02:00
|
|
|
target = 'xash',
|
|
|
|
features = features,
|
|
|
|
includes = includes,
|
|
|
|
use = libs,
|
|
|
|
install_path = install_path,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
|
|
|
)
|