5 from Configure
import g_maxlen
14 # these variables are mandatory ('/' are converted automatically)
18 def create_gitversion_gen(bld
, header
='gitversion.h', define
=None):
19 cmd
= '../gitversion_regenerate.sh ${TGT}'
22 cls
= Task
.simple_task_type('gitversion', cmd
, color
='BLUE')
23 cls
.must_run
= lambda self
: True
27 rt
= Params
.h_file(self
.m_outputs
[0].abspath(self
.env()))
33 # return (r, r, r, r, r)
34 #cls.cache_sig = property(sg, None)
37 tsk
= cls('gitversion', bld
.env().copy())
39 tsk
.m_outputs
= [bld
.path
.find_or_declare(header
)]
40 tsk
.prio
= 1 # execute this task first
42 def display_msg(msg
, status
= None, color
= None):
45 g_maxlen
= max(g_maxlen
, len(msg
))
47 print "%s :" % msg
.ljust(g_maxlen
),
48 Params
.pprint(color
, status
)
50 print "%s" % msg
.ljust(g_maxlen
)
53 opt
.tool_options('compiler_cc')
54 opt
.add_option('--enable-pkg-config-dbus-service-dir', action
='store_true', default
=False, help='force D-Bus service install dir to be one returned by pkg-config')
55 opt
.add_option('--disable-dbus', action
='store_true', default
=False, help="Don't enable D-Bus support even if required dependencies are present")
56 opt
.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man]")
59 conf
.check_tool('compiler_cc')
61 conf
.check_pkg('alsa', mandatory
=True)
62 conf
.check_pkg('jack', vnum
="0.109.0", mandatory
=True)
63 if not Params
.g_options
.disable_dbus
:
64 conf
.check_pkg('dbus-1', mandatory
=False, pkgvars
=['session_bus_services_dir'])
65 conf
.env
['DBUS_ENABLED'] = 'LIB_DBUS-1' in conf
.env
67 conf
.env
['DBUS_ENABLED'] = False
69 conf
.env
['LIB_DL'] = ['dl']
71 #conf.check_header('expat.h', mandatory=True)
72 #conf.env['LIB_EXPAT'] = ['expat']
73 conf
.check_header('getopt.h', mandatory
=True)
75 if conf
.env
['DBUS_ENABLED']:
76 if Params
.g_options
.enable_pkg_config_dbus_service_dir
:
77 conf
.env
['DBUS_SERVICES_DIR'] = conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
79 conf
.env
['DBUS_SERVICES_DIR'] = os
.path
.normpath(conf
.env
['PREFIX'] + '/share/dbus-1/services')
81 conf
.check_tool('misc') # dbus service file subst tool
83 if Params
.g_options
.mandir
:
84 conf
.env
['MANDIR'] = Params
.g_options
.mandir
86 conf
.env
['MANDIR'] = conf
.env
['PREFIX'] + '/share/man'
88 conf
.define('A2J_VERSION', VERSION
)
89 conf
.write_config_header('config.h')
92 if os
.access('gitversion.h', os
.R_OK
):
93 data
= file('gitversion.h').read()
94 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
99 display_msg("==================")
100 version_msg
= "a2jmidid-" + VERSION
102 version_msg
+= " exported from " + gitrev
104 version_msg
+= " git revision will checked and eventually updated during build"
108 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
109 if conf
.env
['DBUS_ENABLED']:
110 have_dbus_status
= "yes"
112 have_dbus_status
= "no"
113 display_msg("D-Bus support", have_dbus_status
)
114 if conf
.env
['DBUS_ENABLED']:
115 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
116 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
118 print Params
.g_colors
['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
119 print Params
.g_colors
['RED'] + "WARNING:",
120 print Params
.g_colors
['CYAN'] + conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
121 print Params
.g_colors
['RED'] + 'WARNING: but service file will be installed in'
122 print Params
.g_colors
['RED'] + "WARNING:",
123 print Params
.g_colors
['CYAN'] + conf
.env
['DBUS_SERVICES_DIR']
124 print Params
.g_colors
['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing'
125 print 'WARNING: You can override dbus service install directory'
126 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
127 print Params
.g_colors
['NORMAL'],
131 if not os
.access('gitversion.h', os
.R_OK
):
132 create_gitversion_gen(bld
)
134 prog
= bld
.create_obj('cc', 'program')
147 if bld
.env()['DBUS_ENABLED']:
148 prog
.source
.append('dbus.c')
149 prog
.source
.append('dbus_iface_introspectable.c')
150 prog
.source
.append('dbus_iface_control.c')
151 prog
.source
.append('sigsegv.c')
153 prog
.includes
= '.' # make waf dependency tracking work
154 prog
.target
= 'a2jmidid'
155 prog
.uselib
= 'ALSA JACK DL'
156 if bld
.env()['DBUS_ENABLED']:
157 prog
.uselib
+= " DBUS-1"
158 prog
= bld
.create_obj('cc', 'program')
159 prog
.source
= 'a2jmidi_bridge.c'
160 prog
.target
= 'a2jmidi_bridge'
161 prog
.uselib
= 'ALSA JACK'
163 prog
= bld
.create_obj('cc', 'program')
164 prog
.source
= 'j2amidi_bridge.c'
165 prog
.target
= 'j2amidi_bridge'
166 prog
.uselib
= 'ALSA JACK'
168 if bld
.env()['DBUS_ENABLED']:
169 # process org.gna.home.a2jmidid.service.in -> org.gna.home.a2jmidid.service
170 obj
= bld
.create_obj('subst')
171 obj
.source
= 'org.gna.home.a2jmidid.service.in'
172 obj
.target
= 'org.gna.home.a2jmidid.service'
173 obj
.dict = {'BINDIR': bld
.env()['PREFIX'] + '/bin'}
174 obj
.inst_var
= bld
.env()['DBUS_SERVICES_DIR']
177 install_files('PREFIX', 'bin', 'a2j_control', chmod
=0755)
178 install_files('PREFIX', 'bin', 'a2j', chmod
=0755)
187 if bld
.env()['DBUS_ENABLED']:
188 man_pages
.append("a2j.1")
189 man_pages
.append("a2j_control.1")
191 for i
in range(len(man_pages
)):
192 man_pages
[i
] = "man/" + man_pages
[i
]
194 install_files('MANDIR', 'man1', man_pages
)
197 os
.remove('gitversion_regenerate.sh')
198 os
.system('../gitversion_regenerate.sh gitversion.h')