/
wscript
135 lines (116 loc) · 4.66 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# vim: ft=python
from sys import platform
from waflib import Logs
from waflib.Build import BuildContext
APPNAME='stuff'
VERSION='0.1'
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c')
# conf.check_cc(header_name = 'linux/fiemap.h', mandatory=False)
conf.check_cc(function_name='fgetgrent',
header_name="grp.h",
mandatory=False)
conf.check_cc(cflags=['-Wall','-Wextra', '-pedantic', '-std=c99'],
defines=['_XOPEN_SOURCE=500'],
uselib_store='base')
conf.check_cc(lib=['m'],
uselib_store='m')
conf.check_cc(lib=['dl'],
defines=['_GNU_SOURCE'],
uselib_store='dl')
conf.check_cc(lib=['pthread'],
uselib_store='pthread')
conf.check_cc(cflags=['-Werror'],
uselib_store='strict')
conf.check_cfg(package='glib-2.0',
args=['--cflags', '--libs'],
use='portable',
uselib_store='glib2',
mandatory=False)
conf.check_cfg(package='libnetfilter_conntrack',
args=['--cflags', '--libs'],
use='portable',
uselib_store='nfconntrack',
mandatory=False)
if conf.env.DEST_OS is 'linux':
conf.env.LINUX = True
summary(conf)
class Summary(BuildContext):
cmd = 'summary'
fun = 'summary'
def summary(smr):
def report_if_missing(var, name):
if not var:
Logs.warn('Binaries requiring {0} will not be compiled!'.format(name))
return var
report_if_missing(smr.env.HAVE_GLIB2,
'glib2')
report_if_missing(smr.env.HAVE_NFCONNTRACK,
'libnetfilter_conntrack')
report_if_missing(smr.env.LINUX,
'Linux')
STANDARD_USE=['base', 'strict', 'm']
def build(build):
build(rule=build.path.abspath()+'/sys/errnos.h.gen ${SRC} ${TGT}',
source='sys/errnos.list',
target='../sys/errnos.h')
# The basics, should be on any recent Unix system, and we're strict :)
for bin in ['fun/b2c', 'fun/mkpasswd', 'fun/nato', 'fun/superglob',
'sys/sethostid', 'auth/grouplist', 'fun/forking']:
build.program(source=bin+'.c',
target=bin,
use=STANDARD_USE)
# mini stuff, shouldn't invade your PATH ever unless you're completely mad
for bin in ['mini/echo', 'mini/false', 'mini/hostid', 'mini/logname',
'mini/sync', 'mini/true', 'mini/yes', 'mini/yes2']:
build.program(source=bin+'.c',
target=bin,
use=STANDARD_USE,
install_path = "${PREFIX}/bin/mini")
# Linux-specific stuff
if build.env.LINUX:
for bin in ['fs/wtfitf', 'mem/hugepagesdoublecheck',
'mem/hugepagesmaxalloc']:
build.program(source=bin+'.c',
target=bin, use=STANDARD_USE)
if build.env.HAVE_NFCONNTRACK:
for nf_bin in ['sys/conntail']:
build.program(source='sys/conntail.c',
target='sys/conntail.c',
use=['base', 'strict', 'nfconntrack'])
# LD_PRELOAD libs
ld_libs = ['diagnostics/gdb4undeads', 'diagnostics/sigomgbt']
if build.env.LINUX:
ld_libs.extend(['diagnostics/mtrace', 'diagnostics/memcpy2memmove'])
for lib in ld_libs:
# I stopped trying to be strict here...
build.shlib(source=lib+'.c',
target=lib,
use=['base', 'm', 'dl'])
# Cool 7-segment stuff
for bin in ['fun/7seg/7plot', 'fun/7seg/7clock']:
build.program(source=[bin+'.c','fun/7seg/7seg.c'],
target=bin,
use=STANDARD_USE)
if build.env.HAVE_GLIB2:
build.program(source='sys/errnos.c',
target='sys/errnos',
includes='.',
use=['base', 'strict', 'glib2'])
build.program(source='sys/i_segv3.c',
target='sys/i_segv3',
use=['base', 'strict', 'pthread'])
# Test stuff (not installed)
for bin in ['fun/async/test-poll', 'fun/async/test-select',
'sys/i_segv', 'sys/i_segv2', 'mem/eatmemory',
'mem/mmapdoublecheck', 'mem/mmapnwait']:
build.program(source=bin+'.c',
target=bin,
use=STANDARD_USE,
install_path=None)
# Python scripts
# build.install_files('${PREFIX}/bin',
# 'auth/pinlock net/bwstats net/throttler fun/slider',
# chmod=0755)