-
Notifications
You must be signed in to change notification settings - Fork 9
/
wscript
41 lines (33 loc) · 1.27 KB
/
wscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env python
# encoding: utf-8
from waflib import Options
# the following two variables are used by the target "waf dist"
VERSION='1.0.0'
APPNAME='c-tlv-serialize'
# these variables are mandatory ('/' are converted automatically)
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
opt.add_option('--mode', action='store', default='release', help='Compile mode: release or debug', choices=['debug', 'release'])
opt.add_option('--cross', default='', help='Cross compiler prefix, e.g. mips-linux-gnu-')
opt.add_option('--cc', default='gcc')
def configure(conf):
conf.env.CROSS = conf.options.cross
conf.env.CC = conf.env.CROSS + conf.options.cc
conf.load('compiler_c')
include_dirs = ['lib']
cflags = ['-Werror', '-Wall']
ldflags = []
if Options.options.mode == 'debug':
cflags += ['-DDEBUG', '-g3', '-O0']
elif Options.options.mode == 'release':
cflags += ['-g0', '-Os']
conf.env.append_value('INCLUDES', include_dirs)
conf.env.append_value('CFLAGS', cflags)
conf.env.append_value('LINKFLAGS', ldflags)
def build(bld):
libsrc = bld.path.get_src().ant_glob('lib/*.c')
bld.stlib(source=libsrc, target='tlvserialize-static')
bld.shlib(source=libsrc, target='tlvserialize-shared')
bld.program(source='main.c', target='main', use='tlvserialize-static')