41ccc2d1f10703203291cd71f40c625bd7264808
[jelmer/winexe.git] / source / wscript
1 import os
2 from Configure import conf
3
4 top = '.'
5 out = 'build'
6 samba = os.path.abspath('../samba')
7
8 @conf
9 def win32_program(self, *k, **kw):
10     kw['features'] = 'c cprogram'
11     kw['env'] = self.env.copy()
12     kw['env'].update({"CC": kw['cc'], "LINK_CC": kw['cc']})
13     return self(*k, **kw)
14
15 def options(ctx):
16     ctx.load('compiler_c')
17
18 def configure(ctx):
19     platform = ['mingw32', 'mingw32msvc']
20     ctx.find_program([ a + '-' + p + '-gcc' for a in ['i386', 'i586'] for p in platform], var='CC_WIN32')
21     ctx.find_program([ a + '-' + p + '-gcc' for a in ['x86_64', 'amd64'] for p in platform], var='CC_WIN64')
22     ctx.load('compiler_c')
23     os.system('cd ' + samba + ' && grep -q "bld.RECURSE(\'../source\')" wscript_build || sed -i "s#bld.RECURSE(\'source3\')#bld.RECURSE(\'source3\')\\nbld.RECURSE(\'../source\')#" wscript_build')
24     os.system('cd ' + samba + ' && ./buildtools/bin/waf configure')
25
26 def build(bld):
27     if bld.env._SAMBA_BUILD_ == 4:
28         bld.SAMBA_BINARY (
29             binname='winexe',
30             source='winexe.c svcinstall.c async.c build/winexesvc32_exe.c build/winexesvc64_exe.c',
31             deps='POPT_SAMBA POPT_CREDENTIALS dcerpc')
32         return
33
34     bld.win32_program(target='winexesvc32.exe', source='winexesvc_launch.c winexesvc_loop.c', cc=bld.env.CC_WIN32)
35     bld.win32_program(target='winexesvc64.exe', source='winexesvc_launch.c winexesvc_loop.c', cc=bld.env.CC_WIN64)
36     bld.program(target='bin2c', source='bin2c.c', cflags='')
37
38     bld(rule='${SRC[0].abspath()} winexesvc32_exe ${SRC[1]} > ${TGT}', target='winexesvc32_exe.c', source='bin2c winexesvc32.exe')
39     bld(rule='${SRC[0].abspath()} winexesvc64_exe ${SRC[1]} > ${TGT}', target='winexesvc64_exe.c', source='bin2c winexesvc64.exe')
40
41     bld(rule='cd ' + samba + ' && ./buildtools/bin/waf build --targets=winexe && cp bin/winexe ${TGT[0].abspath()}',
42         target='winexe',
43         source='winexe.c svcinstall.c async.c winexesvc32_exe.c winexesvc64_exe.c')