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')
|
|
|
|
grp.add_option(
|
|
|
|
'--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
|
|
|
|
help = 'build engine with BSP2 map support(recommended for Quake, breaks compatibility!)')
|
|
|
|
|
|
|
|
grp.add_option(
|
2019-01-28 15:09:06 +01:00
|
|
|
'--stdin-input', action = 'store_true', dest = 'USE_SELECT', default = None,
|
|
|
|
help = 'enable console input from stdin (default for dedicated)')
|
|
|
|
|
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:
|
2018-06-14 19:34:51 +02:00
|
|
|
if(conf.env.DEST_OS == 'linux'):
|
2018-12-16 15:10:01 +01:00
|
|
|
conf.check_cc( lib='rt' )
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'XASH_DEDICATED')
|
2018-12-20 08:15:08 +01:00
|
|
|
elif conf.env.DEST_OS2 == 'android': # Android doesn't need SDL2
|
2019-05-12 02:03:34 +02:00
|
|
|
conf.check_cc(lib='android')
|
2018-12-20 08:15:08 +01:00
|
|
|
conf.check_cc(lib='log')
|
2019-05-02 17:07:03 +02:00
|
|
|
conf.check_cc(lib='EGL')
|
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')
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'XASH_SDL')
|
|
|
|
|
2019-02-19 15:49:09 +01:00
|
|
|
if conf.env.SINGLE_BINARY:
|
2019-01-28 15:09:06 +01:00
|
|
|
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
|
|
|
|
|
|
|
|
if conf.options.USE_SELECT == None:
|
|
|
|
conf.options.USE_SELECT = conf.options.DEDICATED
|
|
|
|
if conf.options.USE_SELECT:
|
|
|
|
conf.env.append_unique('DEFINES', 'XASH_USE_SELECT')
|
|
|
|
|
2018-12-13 06:03:26 +01:00
|
|
|
if conf.options.SUPPORT_BSP2_FORMAT:
|
2018-07-10 16:29:05 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'SUPPORT_BSP2_FORMAT')
|
|
|
|
|
2018-06-14 19:34:51 +02:00
|
|
|
if conf.env.DEST_OS == 'win32':
|
2018-10-24 19:17:44 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'DBGHELP')
|
2019-04-07 21:26:27 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'PSAPI_VERSION=1')
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def build(bld):
|
2019-03-19 23:17:46 +01:00
|
|
|
libs = [ 'public' ]
|
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':
|
2018-11-18 23:19:24 +01:00
|
|
|
libs += [ 'DL' , 'M', 'PTHREAD' ]
|
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:
|
2018-11-18 23:19:24 +01:00
|
|
|
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI']
|
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'])
|
|
|
|
|
2018-12-20 07:48:22 +01:00
|
|
|
if bld.env.HAVE_SDL2:
|
|
|
|
libs.append('SDL2')
|
|
|
|
source += bld.path.ant_glob(['platform/sdl/*.c'])
|
|
|
|
|
|
|
|
if bld.env.DEST_OS2 == 'android':
|
2019-05-12 02:03:34 +02:00
|
|
|
libs += ['LOG', 'EGL', 'ANDROID']
|
|
|
|
source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.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'])
|
2018-05-28 17:17:25 +02:00
|
|
|
else:
|
2018-12-20 07:48:22 +01:00
|
|
|
if bld.env.DEST_OS == 'linux':
|
2018-05-28 17:17:25 +02:00
|
|
|
libs.append('RT')
|
2018-11-18 21:59:23 +01:00
|
|
|
|
2019-03-20 00:40:47 +01:00
|
|
|
# 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' ]
|
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
|
|
|
|
features = 'c cprogram'
|
2018-05-28 17:17:25 +02:00
|
|
|
else:
|
2019-05-06 03:38:11 +02:00
|
|
|
install_path = bld.env.LIBDIR
|
|
|
|
features = 'c cshlib'
|
|
|
|
|
|
|
|
bld(
|
|
|
|
source = source,
|
|
|
|
target = 'xash',
|
|
|
|
features = features,
|
|
|
|
includes = includes,
|
|
|
|
use = libs,
|
|
|
|
install_path = install_path,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
|
|
|
)
|