Codebase list guitarix / debian/0.23.3-1 wscript
debian/0.23.3-1

Tree @debian/0.23.3-1 (Download .tar.gz)

wscript @debian/0.23.3-1raw · history · blame

  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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
#! /usr/bin/env python
# encoding: utf-8

import sys, os, re, shutil
import Build, Utils, Options, Logs, Configure, Scripting
from Constants import HEXVERSION
from Configure import ConfigurationError
from TaskGen import feature
import wscript_dsp

# Waf version check, for global waf installs

try:
    from Constants import WAFVERSION
except:
    WAFVERSION='1.0.0'
if WAFVERSION[:3] != '1.5':
    print('Incompatible Waf, use 1.5')
    sys.exit (1)

# these variables are mandatory ('/' are converted automatically)
srcdir = '.'
blddir = 'build'
use_2to3 = True

# used by waf dist and waf build
VERSION='0.23.3'
APPNAME='guitarix'

good_faust_versions = ['0.9.43']

g_maxlen = 40 # maximum width of message for 2-column display


################################################################
# options defined for waf configure
################################################################

def set_options(opt):
    
    def add_enable_option (option, desc, group=None, disable=False):
        if group == None:
            group = opt
        option_ = option.replace ('-', '_')
        group.add_option ('--enable-' + option, action='store_true',
            default=False, help='Enable ' + desc, dest='enable_' + option_)
        group.add_option ('--disable-' + option, action='store_true',
            default=disable, help='Disable ' + desc, dest='disable_' + option_)

    opt.tool_options('gcov')
    opt.tool_options ('intltool')
    group = opt.add_option_group ('Localization and documentation', '')
    add_enable_option ('nls', 'native language support', group)

    opt.tool_options('compiler_cxx')
    comp = opt.get_option_group("--check-cxx-compiler")

    comp.add_option('--debug',
                    action='store_const',
                    default=False,
                    const=True,
                    help='set compiler flags for a debug build')

    comp.add_option('--cxxflags-release',
                    type='string',
                    default='-O3 -DNDEBUG',
                    dest='cxxflags_release',
                    help='additional C++ compiler flags for release version (not used if --debug) [Default: %default]')

    comp.add_option('--cxxflags-debug',
                    type='string',
                    default='-O2 -g -fstack-protector-all',
                    dest='cxxflags_debug',
                    help='additional C++ compiler flags for debug version (only used if --debug) [Default: %default]')

    comp.add_option('--cxxflags',
                    type='string',
                    default='-Wall', # -fomit-frame-pointer -ffast-math -fstrength-reduce -mmmx -mfpmath=sse -DUSE_XMMINTRIN -pipe
                    dest='cxxflags',
                    help='C++ base compiler flags [Default: %default]')

    comp.add_option('--optimization',
                    action='store_const',
                    default=False, #'-fomit-frame-pointer -ffast-math -fstrength-reduce -pipe',
                    const=True,
                    help='automatically select additional C++ compiler optimization flags for the current platform')

    opt.recurse('libgxw/gxw')
    opt.recurse('libgxwmm/gxwmm')

    comp = opt.add_option_group("Additional Library Options")

    comp.add_option('--includeresampler',
                    action='store_const',
                    default=False,
                    const=True,
                    help='build with included local zita-resample libary (Default NO)')

    comp.add_option('--includeconvolver',
                    action='store_const',
                    default=False,
                    const=True,
                    help='build with included local zita-convolver libary (Default NO)')


    comp.add_option('--no-ladspa',
                    action='store_const',
                    default=False,
                    const=True,
                    help="don't build ladspa plugins (Default yes)")

    comp.add_option('--no-new-ladspa',
                    action='store_const',
                    default=False,
                    const=True,
                    help=("don't build with new ladspa plugins"))

    faust = opt.add_option_group("Faust-Compiler")

    if len(good_faust_versions) == 1:
        faust_vers_str = good_faust_versions[0]
    else:
        faust_vers_str = "in [%s]" % ", ".join(good_faust_versions)

    faust.add_option('--faust',
                     action='store_const',
                     default=False,
                     const=True,
                     help=('use faust even if the installed version is not %s'
                           % faust_vers_str))

    faust.add_option('--no-faust',
                     action='store_const',
                     default=False,
                     const=True,
                     help="don't use faust, use the pre-built files in faust-generated")

    faust.add_option('--faust-float',
                     action='store_const',
                     default=False,
                     const=True,
                     help="build with faust, single precision")


    ladspa = opt.add_option_group("LADSPA Options (installing ladspa modules)")

    ladspa.add_option('--ladspadir',
                    type='string',
                    help='LADSPA plugin directory [Default: <prefix>/lib/ladspa]')

    opt.recurse('pygxw')
    opt.recurse('glade-gxw')

    opt.tool_options('compiler_cc') # for pygxw and glade-gxw

    opt.add_option('--dist-tree',
                   type='string',
                   dest='dist_tree',
                   help=("option for 'dist' command: git tree-ish to build"
                         " the archive from [Default: %s]" % 'V%s' % VERSION))


################################################################
# waf configure
################################################################

################################################################
# configuration display helper functions
#

def print_msg(msg, nl=True):
    if HEXVERSION > 0x10500:
        s = sys.stderr
    else:
        s = sys.stdout
    if nl:
        t = "\n"
    else:
        t = " "
    s.write(msg+t)

# a bit of waf display formatting
def display_msg(msg, status = None, color = None):
    sr = msg
    global g_maxlen
    g_maxlen = max(g_maxlen, len(msg))
    if status:
        print_msg("%s :" % msg.ljust(g_maxlen),False)
        Utils.pprint(color, status)
    else:
        print_msg("%s" % msg.ljust(g_maxlen))

def error_msg(msg):
    Utils.pprint('RED', msg)

def display_feature(msg, build):
    if build:
        display_msg(msg, "yes", 'CYAN')
    else:
        display_msg(msg, "no", 'YELLOW')

################################################################
# configuration utility functions
#

def option_enabled (option):
    if getattr (Options.options, 'enable_' + option):
        return True
    if getattr (Options.options, 'disable_' + option):
        return False
    return True

def append_optimization_flags(cxxflags):
    cpu_model = None
    x86_flags = None
    try:
        for line in open("/proc/cpuinfo"):
            if cpu_model is None:
                if line.startswith("model name"):
                    cpu_model = line.split(":",1)[1].strip()
            elif x86_flags is None:
                if line.startswith("flags"):
                    x86_flags = line.split(":",1)[1].strip()
            else:
                break
    except IOError:
        pass
    if cpu_model is None or x86_flags is None:
        display_msg("Checking CPU Architecture",
                    "cpu model not found in /proc/cpuinfo",
                    "YELLOW")
        return None
    model = cpu_model.split()
    arch = os.uname()[4]
    if "AMD" in model and "x86_64" in arch:
        cxxflags.append ("-march=k8")
    elif "AMD" in model and "Sempron(tm)" in model:
        cxxflags.append ("-march=native")
    elif "Geode" in model :
        cxxflags.append ("-march=geode")
    elif "Core" in model and "x86_64" in arch:
        cxxflags.append ("-march=core2")
    elif "i386" in arch:
        cxxflags.append ("-march=i386")
    elif "i486" in arch:
        cxxflags.append ("-march=i486")
    elif "i586" in arch:
        cxxflags.append ("-march=i586")
    elif "i686" in arch:
        cxxflags.append ("-march=i686")
    else:
        cxxflags.append ("-march=native")

    if "mmx" in x86_flags:
        cxxflags.append ("-mmmx")
    if "3dnow" in x86_flags:
        cxxflags.append ("-m3dnow")

    if "sse5" in x86_flags:
        cxxflags.append ("-msse5")
        cxxflags.append ("-mfpmath=sse")
    elif "sse4_2" in x86_flags:
        cxxflags.append ("-msse4.2")
        cxxflags.append ("-mfpmath=sse")
    elif "sse4_1" in x86_flags:
        cxxflags.append ("-msse4.1")
        cxxflags.append ("-mfpmath=sse")
    elif "ssse3" in x86_flags:
        cxxflags.append ("-mssse3")
        cxxflags.append ("-mfpmath=sse")
    elif "sse4" in x86_flags:
        cxxflags.append ("-msse4")
        cxxflags.append ("-mfpmath=sse")
    elif "sse3" in x86_flags:
        cxxflags.append ("-msse3")
        cxxflags.append ("-mfpmath=sse")
    elif "sse2" in x86_flags:
        cxxflags.append ("-msse2")
        cxxflags.append ("-mfpmath=sse")
        #cxxflags.append ("-DUSE_XMMINTRIN")
    elif "sse" in x86_flags:
        cxxflags.append ("-msse")
        cxxflags.append ("-mfpmath=sse")
        # cxxflags.append ("-DUSE_XMMINTRIN")

    if not Options.options.debug:
        cxxflags.append ("-fomit-frame-pointer")
    cxxflags.append ("-ftree-loop-linear")
    cxxflags.append ("-ffinite-math-only")
    cxxflags.append ("-fno-math-errno")
    cxxflags.append ("-fno-signed-zeros")
    #cxxflags.append ("-ffast-math") # quicker but doesn't seem to work (difference in sound output)
    #cxxflags.append ("-malign-double")
    cxxflags.append ("-fstrength-reduce")
    cxxflags.append ("-pipe")
    return cpu_model

@Configure.conf
def cfg_get_variable(self, package, variable, prefix=""):
    p = Utils.pproc.Popen(["pkg-config", "--variable="+variable, package],
                          stdout=Utils.pproc.PIPE, shell=False)
    v = p.communicate()[0].strip()
    if p.returncode or not v:
        self.fatal('fail to get variable %s for package %s' % (variable, package))
    self.env[prefix+variable.upper()] = v


################################################################
# configuration helper functions
#

def check_faust(conf):
    if Options.options.no_faust:
        conf.env['FAUST'] = None
        return
    conf.find_program("faust", var='FAUST')
    if not conf.env['FAUST']:
        return
    try:
        s = Utils.cmd_output('%s --version' % conf.env['FAUST'])
    except ValueError:
        Logs.warn('count not execute faust')
        return
    m = re.match(r".*Version\s*(.*)", s)
    if not m:
        Logs.warn('could not determine faust version')
    vers = m.group(1)
    conf.env["FAUST_VERSION"] = vers
    if vers not in good_faust_versions and not Options.options.faust:
        conf.env['FAUST'] = None
        conf.check_message_custom('faust','version',"can't use %s (check ./waf --help)" % vers,color='YELLOW')
    else:
        conf.check_message('faust','version',1,vers)
    conf.env['FAUST_DOUBLE'] = not Options.options.faust_float

def check_boost(conf):
    code="""
    #include <boost/system/error_code.hpp>
    int main() { boost::system::error_code c; }
    """
    msg = "Checking for boost-system " 
    conf.check_cxx(msg = msg, fragment=code, lib="boost_system", uselib_store="BOOST_SYSTEM", mandatory=1)
    # some boost (>1.49) versions depend on boost-system so we will check for it first
    # and later link against boost_system were boost headers are included.
    boost_atleast_version = 104200
    boost_atleast_vermsg = "1.42"
    code="""
    #include <boost/version.hpp>
    #include <boost/format.hpp>
    #include <boost/thread.hpp>
    #if BOOST_VERSION < %d
    #error
    #endif
    int main(){ return 0; }
    """ % boost_atleast_version
    msg = "Checking for boost >= %s" % boost_atleast_vermsg
    conf.check_cxx(msg = msg, fragment=code, lib="boost_system", mandatory=1)
    # not needed: with boost 1.42 Guitarix doesn't generate code which
    #             references the boost threading lib
    #msg = "Checking for boost_thread%%s >= %s" % boost_atleast_vermsg
    #try:
    #    conf.check_cxx(
    #        msg = msg % "", fragment=code, lib="boost_thread", uselib_store="BOOST_THREAD",
    #        errmsg="not found, trying boost_thread-mt", mandatory=1)
    #except ConfigurationError:
    #    conf.check_cxx(
    #        msg = msg % "-mt",fragment=code, lib="boost_thread-mt",
    #        uselib_store="BOOST_THREAD", mandatory=1)

def check_zita_convolver(opt, conf):
    if opt.includeconvolver:
        conf.env['ZITA_CONVOLVER'] = False
    else:
        expected_zita_convolver_version = 3
        code="""
        #include <zita-convolver.h>
        #if ZITA_CONVOLVER_MAJOR_VERSION != %d
        #error
        #endif
        int main(){ return 0; }
        """ % expected_zita_convolver_version
        conf.check_cxx(
            fragment=code,
            lib="zita-convolver",
            uselib_store='ZITA_CONVOLVER',
            msg='Checking for zita-convolver >= %d.0' % expected_zita_convolver_version,
            errmsg="version %d not found, using ours" % expected_zita_convolver_version,
            define_name="ZITA_CONVOLVER")

def check_zita_resampler(opt, conf):
    if opt.includeresampler:
        conf.env['ZITA_RESAMPLER'] = False
    else:
        expected_zita_resampler_version = 1
        code="""
        #include <zita-resampler/resampler.h>
        #include <zita-resampler/resampler-table.h>
        #if ZITA_RESAMPLER_MAJOR_VERSION != %d
        #error
        #endif
        int main(){ return 0; }
        """ % expected_zita_resampler_version
        conf.check_cxx(
            fragment=code,
            lib='zita-resampler',
            uselib_store='ZITA_RESAMPLER',
            msg='Checking for zita-resampler >= %d.0' % expected_zita_resampler_version,
            errmsg="version %d not found, using ours" % expected_zita_resampler_version,
            define_name="ZITA_RESAMPLER")

# Taken from Geany's wscript, modified to support LINGUAS variable
def write_linguas_file (self):
    linguas = ''
    # Depending on Waf version, getcwd() is different
    if os.path.exists ('./po'):
        podir = './po'
    else:
        podir = '../po'
    if 'LINGUAS' in Build.bld.env:
        files = Build.bld.env['LINGUAS']
        for f in files.split (' '):
            if os.path.exists (podir + '/' + f + '.po'):
                linguas += f + ' '
    else:
        files = os.listdir (podir)
        for f in files:
            if f.endswith ('.po'):
                linguas += '%s \n' % f[:-3]
    f = open (podir + '/LINGUAS', 'w')
    f.write ('# This file is autogenerated. Do not edit.\n%s' % linguas)
    f.close ()
write_linguas_file = feature ('intltool_po')(write_linguas_file)


################################################################
# guitarix waf configuration
#

def configure(conf):
    opt = Options.options
    if 'LINGUAS' in os.environ: conf.env['LINGUAS'] = os.environ['LINGUAS']

    platform = Utils.detect_platform()
    conf.env['IS_MACOSX'] = platform == 'darwin'
    conf.env['IS_LINUX'] = platform == 'linux' or platform == 'posix'
    conf.env['IS_SUN'] = platform == 'sunos'

    if conf.env['IS_LINUX']:
        conf.define ('IS_LINUX', platform )

    if conf.env['IS_MACOSX']:
        conf.define ('IS_MACOSX', platform )

    if conf.env['IS_SUN']:
        conf.define ('IS_SUN', platform )

    conf.env['OS'] = platform

    def option_checkfatal (option, desc):
        if hasattr (opt, 'enable_' + option):
            if getattr (opt, 'enable_' + option):
                Utils.pprint ('RED', desc + ' N/A')
                sys.exit (1)
                
    if option_enabled ('nls'):
        conf.check_tool ('intltool')
        if conf.env['INTLTOOL'] and conf.env['POCOM']:
            nls = 'yes'
        else:
            option_checkfatal ('nls', 'localization')
            nls = 'N/A'
            conf.define ('DISABLE_NLS', 1)
    else:
        nls = 'no '
        conf.define ('DISABLE_NLS', 1)
    conf.define ('GETTEXT_PACKAGE', APPNAME)

    conf.define ('ENABLE_NLS', [0,1][nls == 'yes'])
    # compiler
    conf.check_tool('compiler_cxx')
    if opt.with_gcov:
        conf.check_tool('gcov')
    if opt.python_wrapper or opt.glade_support:
        conf.check_tool('compiler_cc')
    conf.env['shlib_LINKFLAGS'].append("-fPIC") # error in waf 1.5.18?
    # needed libaries
    try:
        conf.check_cfg(package='jack', atleast_version='0.116.2', max_version='1.8.0', args='--cflags --libs', uselib_store='JACK', mandatory=1)
    except ConfigurationError:
        conf.check_cfg(package='jack', atleast_version='1.9.2', args='--cflags --libs', uselib_store='JACK', mandatory=1)
    # jack_session support
    code = "#include <jack/session.h>\nint main(){return JackSessionID != 0;}"
    conf.check_cxx(fragment=code, msg="Checking for jack session support", define_name='HAVE_JACK_SESSION')

    conf.check_cfg(package='sndfile', atleast_version='1.0.17', args='--cflags --libs', uselib_store='SNDFILE', mandatory=1)
    conf.check_cfg(package='gmodule-export-2.0', args='--cflags --libs', uselib_store='GMODULE_EXPORT', mandatory=1)
    conf.check_cfg(package='gtk+-2.0', atleast_version='2.20', args='--cflags --libs', uselib_store='GTK2', mandatory=1)
    conf.check_cfg(package='gthread-2.0', atleast_version='2.24', args='--cflags --libs', uselib_store='GTHREAD', mandatory=1)
    conf.check_cfg(package='glibmm-2.4', atleast_version='2.24', args='--cflags --libs', uselib_store='GLIBMM', mandatory=1)
    conf.check_cfg(package='gtkmm-2.4', atleast_version='2.20', args='--cflags --libs', uselib_store='GTKMM', mandatory=1)
    conf.check_cfg(package='giomm-2.4', atleast_version='2.24', args='--cflags --libs', uselib_store='GIOMM', mandatory=1)
    conf.check_cfg(package='fftw3f', atleast_version='3.1.2', args='--cflags --libs', uselib_store='FFTW3', mandatory=1)
    conf.check_cfg(package='lrdf', args='--cflags --libs', uselib_store='LRDF', mandatory=1)
    if not opt.no_ladspa:
        conf.check(header_name='ladspa.h', mandatory=1)

    check_boost(conf)
    check_zita_convolver(opt, conf)
    check_zita_resampler(opt, conf)
    check_faust(conf)

    # directory
    conf.env['SHAREDIR'] = conf.env['PREFIX'] + '/share'

    # defines for compilation
    gxsharedir = os.path.normpath(os.path.join(conf.env['SHAREDIR'], 'gx_head'))
    conf.define('GX_STYLE_DIR', os.path.join(gxsharedir,'skins'))
    conf.define('GX_FACTORY_DIR', os.path.join(gxsharedir,'factorysettings'))
    conf.define('GX_SOUND_DIR', os.path.join(gxsharedir,'sounds'))
    conf.define('GX_BUILDER_DIR', os.path.join(gxsharedir,'builder'))
    conf.define('GX_ICON_DIR', os.path.normpath(os.path.join(conf.env['SHAREDIR'], 'guitarix','icons')))
    conf.define('GX_PIXMAPS_DIR', os.path.normpath(os.path.join(conf.env['SHAREDIR'], 'pixmaps')))
    conf.define('GX_VERSION', VERSION)

    if conf.env.DEST_CPU=='x86_64': 
        conf.define('OS_64_BIT', 1)
    else:
        conf.define('OS_32_BIT', 1)
    # writing config.h
    conf.write_config_header('config.h')

    conf.define('LIBDIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'lib')))
    conf.define('BINDIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
    conf.define('DESKAPPS_DIR', os.path.normpath(os.path.join(conf.env['SHAREDIR'], 'applications')))
    conf.define('BIN_NAME', APPNAME)

    conf.env['NEW_LADSPA'] = not opt.no_ladspa and not opt.no_new_ladspa
    conf.env['LADSPA'] = not opt.no_ladspa
    if not opt.no_ladspa:
        if opt.ladspadir:
            conf.env['LADSPADIR'] = opt.ladspadir
        else:
            conf.env['LADSPADIR'] = os.path.normpath(os.path.join(
                conf.env['LIBDIR'], 'ladspa'))

    # g++ flags
    cxxflags = opt.cxxflags.split()
    if opt.debug:
        cxxflags += opt.cxxflags_debug.split()
    else:
        cxxflags += opt.cxxflags_release.split()
    cpu_model = None
    if opt.optimization:
        cpu_model = append_optimization_flags(cxxflags)
    conf.env['CXXFLAGS'] += cxxflags

    # pygobject is used by both python and c++ wrapper
    if opt.python_wrapper or opt.generate_cpp_wrapper:
        conf.check_tool('python')
        conf.check_cfg(package='pygobject-2.0', args='--cflags --libs', uselib_store='PYGOBJECT', mandatory=True)
        conf.cfg_get_variable(package='pygobject-2.0', variable='codegendir')

    # config subdirs
    conf.sub_config('pygxw');
    conf.sub_config('glade-gxw');
    conf.sub_config('libgxwmm');
    conf.sub_config('libgxw/gxw');

    conf.sub_config('src/gx_head');
    if conf.env['FAUST']:
        conf.sub_config('src/faust');
    conf.sub_config('src/plugins');
    if conf.env["LADSPA"]:   
        conf.sub_config('ladspa');
    conf.sub_config('rcstyles');

    # some output
    print("")
    display_msg("==================")
    version_msg = "GUITARIX II " + VERSION
    print_msg(version_msg)
    
    print_msg("")
    display_msg("OS ", conf.env['OS'], 'CYAN')

    if cpu_model:
        display_msg("CPU version" , "%s" % cpu_model, "CYAN")
    display_msg("C++ flags", " ".join(conf.env['CXXFLAGS']), 'CYAN')
    display_msg("Compiler %s version" %conf.env["CXX"], "%s" % ".".join(conf.env["CC_VERSION"]), "CYAN")
    display_feature("Use prebuild faust files", not conf.env['FAUST'])
    if not opt.faust_float:
        display_msg("Use faust precision", "double", 'CYAN')
    else:
        display_msg("Use faust precision", "single", 'CYAN')
    display_feature("Use internal zita-resampler", not conf.env['ZITA_RESAMPLER'])
    display_feature("Use internal zita-convolver", not conf.env['ZITA_CONVOLVER'])
    display_feature("Jack Session Support", conf.env['HAVE_JACK_SESSION'])


    display_feature("build ladspa plugins", conf.env['LADSPA'])
    display_feature("skip Python Library Wrapper", not conf.env['GX_PYTHON_WRAPPER'])
    display_feature("use prebuild C++ Library Wrapper", conf.env['USE_GENERATED_CPP'])
    display_feature("skip building shared lib", not conf.env['GX_LIB_SHARED'])
    display_feature("Localization  (intltool)", conf.env['ENABLE_NLS'])
    display_feature("skip glade support", not conf.env['GX_GLADE_SUPPORT'])
    if conf.env['GX_GLADE_SUPPORT']:
        display_msg("glade catalog dir", conf.env['GLADE_CATALOG_DIR'], 'CYAN')
        display_msg("glade modules dir", conf.env['GLADE_MODULES_DIR'], 'CYAN')
    display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
    display_msg("Install binary", conf.env['BINDIR'], 'CYAN')
    
    if not opt.no_ladspa:
        display_msg("Install ladspa", conf.env['LADSPADIR'], 'CYAN')
    display_msg("Guitarix shared files directory", gxsharedir, 'CYAN')
    display_msg("Guitarix pixmaps directory", conf.env['GX_PIXMAPS_DIR'], 'CYAN')
    if conf.env['g++']:
       error_msg("ERROR       !!! Compiler version is too old !!!")

    print_msg("")


################################################################
# Build / Install
################################################################

def post(ctx):
    if os.geteuid() == 0:
        Utils.exec_command('/sbin/ldconfig')

def build(bld):
    if bld.env['INTLTOOL']:
        obj = bld.new_task_gen ('intltool_po')
        obj.podir = 'po'
        obj.appname = APPNAME

    # process subfolders from here
    if bld.env["LADSPA"]:
        bld.add_subdirs('ladspa')
    bld.add_subdirs('libgxw/gxw')
    bld.add_group()
    bld.add_subdirs('libgxwmm')
    bld.add_subdirs('glade-gxw')
    bld.add_subdirs('pygxw')
    bld.add_subdirs('src/faust')
    bld.add_subdirs('src/plugins')
    
    bld.add_subdirs('rcstyles')
    bld.add_subdirs('pixmaps')

    pa = bld.env['GX_SOUND_DIR']
    bld.add_subdirs('src/gx_head')
    if bld.env["NEW_LADSPA"]:
        bld.add_subdirs('src/ladspa')
    bld.install_files(bld.env['DESKAPPS_DIR'], 'guitarix.desktop', chmod=0o644)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/dirlist.js', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/funkmuscle.gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/dlp_ae.gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/zettberlin.gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/autoandimat.gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/jp_n_o_s.gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/univibe', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/univibe_mono', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/flanger_mono_gx', chmod=0o664)
    bld.install_files(bld.env['GX_FACTORY_DIR'], 'factorysettings/jconv', chmod=0o664)
    # "greathall.wav" is referenced in the source (keep in sync when changing)
    bld.install_files(bld.env['GX_SOUND_DIR'], './IR/greathall.wav', chmod=0o664)

    gen_desktop = bld(features  = "intltool_in",
        podir     = "po",
        flags     = ["-d", "-q", "-u", "-c"],
        source    = 'guitarix.desktop.in',
        target    = 'guitarix.desktop',
        install_path = "${DATADIR}/applications",
	)
    # hacked in scanner method so the desktop file gets rebuild
    # when any po file changes; don't know if there is a better way
    gen_desktop_create_task = gen_desktop.create_task
    def gen_desktop_add_scanner(*args,**kw):
        task = gen_desktop_create_task(*args,**kw)
        def po_scanner():
            gen = task.generator
            podir = gen.bld.srcnode.find_dir(gen.podir)
            return (podir.ant_glob("*.po", flat=False), [])
        task.scan = po_scanner
        return task
    gen_desktop.create_task = gen_desktop_add_scanner
    if Options.commands["install"]:  ## newer waf version: bld.cmd == 'install'
        try:
            bld.exec_command(["update-desktop-database", Utils.subst_vars("${DATADIR}/applications", bld.env)])
        except:
            pass

    if bld.env["GX_LIB_SHARED"]:
        bld.add_post_fun(post)


################################################################
# other commands
################################################################

def etags(ctx):
    "Create an Emacs ETAGS file for the src directory"
    cmd = ("etags -o TAGS libgxw/gxw/*.cpp libgxwmm/gxwmm/*.ccg libgxwmm/gxwmm/*.hg"
           " libgxw/gxw/*.h src/gx_head/engine/*.cpp src/gx_head/engine/*.cc"
           " src/gx_head/gui/*.cpp src/headers/*.h")
    Logs.debug("runner: system command -> %s" % cmd)
    Utils.exec_command(cmd)

def update_pot(ctx):
    "extract all text for localization into po/untitled.pot"
    Utils.exec_command("cd po && intltool-update -p")

dir_prefix = "guitarix"
tar_prefix = "guitarix2"
tar_ext = ".tar.bz2"

def _make_dict():
    import Options
    t = Options.options.dist_tree
    if not t:
        t = 'V%s' % VERSION
    d = dict(t=t, d=dir_prefix, p=tar_prefix, e=tar_ext)
    if re.match(r"V\d", t):
        d["v"] = t[1:]
        if Utils.exec_command("git show-ref --verify --quiet --tags refs/tags/'%(t)s'" % d) != 0:
            raise Utils.WafError(
                "tag '%(t)s' not found: please create revision tag" % d)
    else:
        d["v"] = t[1:]
        try:
            s = Utils.cmd_output("git show-ref --hash=8 '%(t)s' | sort -u" % d)
            if not s:
                raise ValueError
            s = s.split()
            if len(s) > 1:
                raise Utils.WafError(
                    "git tree-ish '%(t)s' is ambiguous" % d)
            s = s[0]
        except ValueError:
            raise Utils.WafError(
                "git tree-ish '%(t)s' not found" % d)
        d["v"] = "git-" + s.strip()
    return d

def dist(ctx):
    "makes a tarball for redistributing the sources"
    Utils.exec_command(
        "git archive --prefix=%(d)s-%(v)s/ %(t)s ."
        " | bzip2 > %(p)s-%(v)s%(e)s" % _make_dict())

def distcheck(ctx):
    '''checks if the sources compile (tarball from 'dist')'''
    import tempfile, tarfile
    waf = os.path.abspath(sys.argv[0])
    d = _make_dict()
    tarball = "%(p)s-%(v)s%(e)s" % d
    path = "%(d)s-%(v)s" % d
    if os.path.exists(path):
        try:
            raw_input("%s exists, press enter to remove (stop with Ctrl-C)\n" % path)
        except KeyboardInterrupt:
            print("")
            raise Utils.WafError('distcheck cancelled')
            return
        else:
            print("removing %s" % path)
        shutil.rmtree(path)
    print("creating tarball and extracting files into %s" % path)
    dist(ctx)
    t = tarfile.open(tarball)
    for x in t:
        t.extract(x)
    t.close()
    build_path = path
    instdir = tempfile.mkdtemp('.inst', path)
    cmdargs = [waf,'configure','build','install','uninstall','--destdir='+instdir]
    print('starting "%s"' % (" ".join(cmdargs)))
    print("")
    ret = Utils.pproc.Popen(cmdargs, cwd=build_path).wait()
    if ret:
        raise Utils.WafError('distcheck failed with code %i'%ret)
    if os.path.exists(instdir):
        raise Utils.WafError('distcheck succeeded, but files were left in %s'%instdir)
    shutil.rmtree(path)