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")
58 conf
.check_tool('compiler_cc')
60 conf
.check_pkg('alsa', mandatory
=True)
61 conf
.check_pkg('jack', vnum
="0.109.0", mandatory
=True)
62 if not Params
.g_options
.disable_dbus
:
63 conf
.check_pkg('dbus-1', mandatory
=False, pkgvars
=['session_bus_services_dir'])
64 conf
.env
['DBUS_ENABLED'] = 'LIB_DBUS-1' in conf
.env
66 conf
.env
['DBUS_ENABLED'] = False
68 conf
.env
['LIB_DL'] = ['dl']
70 #conf.check_header('expat.h', mandatory=True)
71 #conf.env['LIB_EXPAT'] = ['expat']
72 conf
.check_header('getopt.h', mandatory
=True)
74 if conf
.env
['DBUS_ENABLED']:
75 if Params
.g_options
.enable_pkg_config_dbus_service_dir
:
76 conf
.env
['DBUS_SERVICES_DIR'] = conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
78 conf
.env
['DBUS_SERVICES_DIR'] = os
.path
.normpath(conf
.env
['PREFIX'] + '/share/dbus-1/services')
80 conf
.check_tool('misc') # dbus service file subst tool
82 conf
.env
['MANDIR'] = os
.path
.normpath(conf
.env
['PREFIX'] + '/share/man')
84 conf
.define('A2J_VERSION', VERSION
)
85 conf
.write_config_header('config.h')
88 if os
.access('gitversion.h', os
.R_OK
):
89 data
= file('gitversion.h').read()
90 m
= re
.match(r
'^#define GIT_VERSION "([^"]*)"$', data
)
95 display_msg("==================")
96 version_msg
= "a2jmidid-" + VERSION
98 version_msg
+= " exported from " + gitrev
100 version_msg
+= " git revision will checked and eventually updated during build"
104 display_msg("Install prefix", conf
.env
['PREFIX'], 'CYAN')
105 if conf
.env
['DBUS_ENABLED']:
106 have_dbus_status
= "yes"
108 have_dbus_status
= "no"
109 display_msg("D-Bus support", have_dbus_status
)
110 if conf
.env
['DBUS_ENABLED']:
111 display_msg('D-Bus service install directory', conf
.env
['DBUS_SERVICES_DIR'], 'CYAN')
112 if conf
.env
['DBUS_SERVICES_DIR'] != conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
114 print Params
.g_colors
['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
115 print Params
.g_colors
['RED'] + "WARNING:",
116 print Params
.g_colors
['CYAN'] + conf
.env
['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
117 print Params
.g_colors
['RED'] + 'WARNING: but service file will be installed in'
118 print Params
.g_colors
['RED'] + "WARNING:",
119 print Params
.g_colors
['CYAN'] + conf
.env
['DBUS_SERVICES_DIR']
120 print Params
.g_colors
['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing'
121 print 'WARNING: You can override dbus service install directory'
122 print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
123 print Params
.g_colors
['NORMAL'],
127 if not os
.access('gitversion.h', os
.R_OK
):
128 create_gitversion_gen(bld
)
130 prog
= bld
.create_obj('cc', 'program')
143 if bld
.env()['DBUS_ENABLED']:
144 prog
.source
.append('dbus.c')
145 prog
.source
.append('dbus_iface_introspectable.c')
146 prog
.source
.append('dbus_iface_control.c')
147 prog
.source
.append('sigsegv.c')
149 prog
.includes
= '.' # make waf dependency tracking work
150 prog
.target
= 'a2jmidid'
151 prog
.uselib
= 'ALSA JACK DL'
152 if bld
.env()['DBUS_ENABLED']:
153 prog
.uselib
+= " DBUS-1"
154 prog
= bld
.create_obj('cc', 'program')
155 prog
.source
= 'a2jmidi_bridge.c'
156 prog
.target
= 'a2jmidi_bridge'
157 prog
.uselib
= 'ALSA JACK'
159 prog
= bld
.create_obj('cc', 'program')
160 prog
.source
= 'j2amidi_bridge.c'
161 prog
.target
= 'j2amidi_bridge'
162 prog
.uselib
= 'ALSA JACK'
164 if bld
.env()['DBUS_ENABLED']:
165 # process org.gna.home.a2jmidid.service.in -> org.gna.home.a2jmidid.service
166 obj
= bld
.create_obj('subst')
167 obj
.source
= 'org.gna.home.a2jmidid.service.in'
168 obj
.target
= 'org.gna.home.a2jmidid.service'
169 obj
.dict = {'BINDIR': bld
.env()['PREFIX'] + '/bin'}
170 obj
.inst_var
= bld
.env()['DBUS_SERVICES_DIR']
173 install_files('PREFIX', 'bin', 'a2j_control', chmod
=0755)
174 install_files('PREFIX', 'bin', 'a2j', chmod
=0755)
183 if bld
.env()['DBUS_ENABLED']:
184 man_pages
.append("a2j.1")
185 man_pages
.append("a2j_control.1")
187 for i
in range(len(man_pages
)):
188 man_pages
[i
] = "man/" + man_pages
[i
]
190 install_files('MANDIR', 'man1', man_pages
)
193 os
.remove('gitversion_regenerate.sh')
194 os
.system('../gitversion_regenerate.sh gitversion.h')