Commits

Anonymous committed a85c69b

use waf for build

Comments (0)

Files changed (4)

 syntax: glob
+build
 rnn_*O2
 rnn_*O3
 rnn_*Ofast
Binary file added.
+top = '.'
+out = 'build'
+
+
+def configure(ctx):
+    # check compilers
+    compiler_list = []
+    for com in ['gcc', 'icc', 'opencc']:
+        try:
+            ctx.find_program(com)
+            compiler_list.append(com)
+        except:
+            ctx.to_log('cannot find %s (ignoring)')
+    ctx.env.COMPILER_LIST = compiler_list
+
+
+def build(bld):
+    # target list
+    trg_list = ['rnn_ca1d', 'rnn_ca2d', 'rnn_opt0', 'rnn_opt1',
+                'rnn_opt2', 'rnn_opt3', 'rnn_opt4']
+    # compiler-specific flags
+    default_flags = dict(
+        gcc = ['-lm', '-ftree-vectorizer-verbose=1'],
+        icc = ['-vec-report1'],
+        opencc = ['-lm'],
+        )
+    # target-specific flags
+    std99 = dict(gcc=['-std=c99'], icc=['-restrict'], opencc=['-std=c99'])
+    trg_flags = dict(rnn_opt3=std99, rnn_opt4=std99)
+
+    for com in bld.env.COMPILER_LIST:
+        flags_list = [['-O2'], ['-O3']]
+        if com == 'opencc':
+            flags_list.append(['-Ofast'])
+        for flags in flags_list:
+            allflags = default_flags[com] + flags
+            for trg in trg_list:
+                allflagsstr = ' '.join(
+                    allflags + trg_flags.get(trg, {}).get(com, []))
+                flagsname = ''.join(flags)
+                bld(rule='%s %s ${SRC} -o ${TGT}' % (com, allflagsstr),
+                    source='%s.c' % trg,
+                    target='%s-%s%s' % (trg, com, flagsname))