[go: up one dir, main page]

Menu

[b8d1a6]: / mscript.py  Maximize  Restore  History

Download this file

358 lines (314 with data), 13.2 kB

  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
#!/usr/bin/env python
import errno, os, re, sys, time
from maitch import *
ctx = Context(PACKAGE = "roxterm", SRC_DIR = "${TOP_DIR}/src",
CFLAGS = "-O2 -g -Wall -I. -I${SRC_DIR} -D_GNU_SOURCE -DHAVE_CONFIG_H")
MINILIB_SOURCES = "colourscheme.c dlg.c display.c dragrcv.c dynopts.c " \
"encodings.c globalopts.c logo.c options.c optsfile.c rtdbus.c"
ROXTERM_CONFIG_SOURCES = "capplet.c colourgui.c configlet.c getname.c " \
"optsdbus.c profilegui.c"
ROXTERM_SOURCES = "about.c main.c multitab.c multitab-close-button.c " \
"multitab-label.c menutree.c optsdbus.c roxterm.c shortcuts.c " \
"uri.c x11support.c"
LOGO_PNG = "${TOP_DIR}/Help/lib/roxterm_logo.png"
FAVICON = "${TOP_DIR}/Help/lib/favicon.ico"
TEXT_LOGO = "${TOP_DIR}/Help/lib/logo_text.png"
DCH = "${TOP_DIR}/debian/changelog"
APPINFO = "${TOP_DIR}/AppInfo.xml"
VFILE = "${TOP_DIR}/version"
if ctx.mode == 'configure' or ctx.mode == 'help':
ctx.arg_disable('gtk-native-tab-dragging',
"Use ROXTerm's legacy code for dragging tabs "
"instead of GTK+'s functions")
ctx.arg_with('gnome-default-applications',
"Where to install GNOME Default Applications file",
default = None)
ctx.arg_disable('sm', "Don't enable session management")
ctx.arg_disable('gtk3', "Use GTK+2 instead of GTK+3 and compatible "
"version of VTE", default = None)
if ctx.mode == 'configure':
git = os.path.exists(ctx.subst(opj("${TOP_DIR}", ".git")))
try:
ctx.find_prog_env("git")
except MaitchNotFoundError:
git = False
vfile = ctx.subst(VFILE)
if git:
version = ctx.prog_output(["${GIT}", "describe"])[0].strip()
version = version.replace('-', '.', 1).replace('-', '~', 1)
ctx.save_if_different(vfile, version + '\n')
gitlog = ctx.prog_output(["${GIT}", "log"])[0]
fp = open(ctx.subst("${TOP_DIR}/ChangeLog.old"), 'r')
gitlog += fp.read()
fp.close()
# Can't use ctx.save_if_different because it tries to subst
# content and fails
save_if_different(ctx.subst("${TOP_DIR}/ChangeLog"), gitlog)
else:
fp = open(vfile, 'r')
version = fp.read().strip()
fp.close()
ctx.setenv('VERSION', version)
try:
ctx.find_prog_env("xslto", "XMLTOMAN")
except MaitchNotFoundError:
try:
ctx.find_prog_env("xsltproc", "XMLTOMAN")
except MaitchNotFoundError:
try:
ctx.find_prog_env("xmltoman", "XMLTOMAN")
except MaitchNotFoundError:
mprint("Unable to build manpages without xmlto or xsltproc",
file = sys.stderr)
ctx.setenv("XMLTOMAN", "")
else:
ctx.setenv("XMLTOMAN_OPTS", "")
ctx.setenv("XMLTOMAN_OUTPUT", "> ${TGT}")
else:
ctx.setenv("XMLTOMAN_OPTS", "--nonet --novalid " \
"--param man.charmap.use.subset 0 " \
"http://docbook.sourceforge.net/release/xsl/" \
"current/manpages/docbook.xsl")
ctx.setenv("XMLTOMAN_OUTPUT", "")
else:
ctx.setenv("XMLTOMAN_OPTS", "man")
ctx.setenv("XMLTOMAN_OUTPUT", "")
ctx.find_prog_env("convert")
ctx.find_prog_env("composite")
gda = ctx.env.get("WITH_GNOME_DEFAULT_APPLICATIONS")
if gda == None or gda == True:
try:
gda = ctx.prog_output("${PKG_CONFIG} "
"--variable=defappsdir gnome-default-applications")
except MaitchChildError:
if gda == True:
raise
else:
gda = ""
elif gda == False:
gda = ""
ctx.setenv("WITH_GNOME_DEFAULT_APPLICATIONS", gda)
gtk3 = ctx.env['ENABLE_GTK3']
if gtk3 != False:
try:
ctx.pkg_config('gtk+-3.0', 'GTK')
ctx.pkg_config('vte-2.90', 'VTE')
except MaitchChildError:
if gtk3 == True:
raise
gtk3 = False
else:
gtk3 = True
if not gtk3:
ctx.pkg_config('gtk+-2.0', 'GTK', '2.18')
ctx.pkg_config('vte', 'VTE', '0.20')
sm = ctx.env['ENABLE_SM']
if sm != False:
try:
ctx.pkg_config('sm ice', 'SM')
except MaitchChildError:
if sm == True:
raise
sm = False
else:
sm = True
ctx.define('ENABLE_SM', sm)
ctx.pkg_config('dbus-1', 'DBUS', '1.0')
ctx.pkg_config('dbus-glib-1', 'DBUS', '0.22')
for f in "get_current_dir_name g_mkdir_with_parents " \
"gdk_window_get_display gdk_window_get_screen " \
"gtk_widget_get_realized gtk_widget_get_mapped " \
"gtk_combo_box_text_new gtk_rc_style_unref".split():
ctx.check_func(f, "${CFLAGS} ${GTK_CFLAGS}", "${LIBS} ${GTK_LIBS}")
ctx.check_func("vte_terminal_search_set_gregex",
"${CFLAGS} ${VTE_CFLAGS}", "${LIBS} ${VTE_LIBS}")
ctx.setenv('CORE_CFLAGS',
"${CFLAGS} ${GTK_CFLAGS} ${DBUS_CFLAGS}")
ctx.setenv('CORE_LIBS',
"${LIBS} ${GTK_LIBS} ${DBUS_LIBS}")
ctx.setenv('ROXTERM_CFLAGS',
"${CFLAGS} ${VTE_CFLAGS} ${SM_CFLAGS} ${DBUS_CFLAGS}")
ctx.setenv('ROXTERM_LIBS',
"${LIBS} ${VTE_LIBS} ${SM_LIBS} ${DBUS_LIBS}")
ctx.setenv('ROXTERM_CONFIG_CFLAGS',
"${CFLAGS} ${GTK_CFLAGS} ${DBUS_CFLAGS} -DROXTERM_CAPPLET")
ctx.setenv('ROXTERM_CONFIG_LIBS',
"${LIBS} ${GTK_LIBS} ${DBUS_LIBS}")
ctx.define_from_var('PACKAGE')
ctx.define('DO_OWN_TAB_DRAGGING',
ctx.env.get('ENABLE_GTK_NATIVE_TAB_DRAGGING', True))
ctx.define('SYS_CONF_DIR', ctx.env['SYSCONFDIR'])
ctx.define('DATA_DIR', ctx.env['DATADIR'])
ctx.define('PKG_DATA_DIR', opj(ctx.env['DATADIR'], "roxterm"))
ctx.define('ICON_DIR',
opj(ctx.env['DATADIR'], "icons", "hicolor", "scalable", "apps"))
ctx.define('LOCALE_DIR', opj(ctx.env['DATADIR'], "locale"))
ctx.define('HTML_DIR', ctx.env['HTMLDIR'])
ctx.define('BIN_DIR', ctx.env['BINDIR'])
ctx.subst_file("${TOP_DIR}/roxterm.1.xml.in", "roxterm.1.xml")
ctx.subst_file("${TOP_DIR}/roxterm-config.1.xml.in", "roxterm-config.1.xml")
ctx.setenv('APPINFO_STRING', "${VERSION} (%s)" % \
time.strftime("%Y-%m-%d", time.gmtime(time.time())))
ctx.subst_file(APPINFO + ".in", APPINFO)
ctx.save_if_different("version.h",
'/* Auto-generated by mscript.py */\n' \
'#ifndef VERSION_H\n' \
'#define VERSION_H\n' \
'#define VERSION "${VERSION}"\n' \
'#endif\n')
src = DCH + ".in"
if os.path.exists(ctx.subst(src)):
ctx.subst_file(src, DCH, at = True)
elif ctx.mode == 'build':
# Private library
ctx.add_rule(StaticLibCRule(
cflags = "${CORE_CFLAGS}",
prefix = "libroxterm-",
quiet = True))
ctx.add_rule(StaticLibRule(
sources = change_suffix_with_prefix(MINILIB_SOURCES,
".c", ".lo", "libroxterm-"),
targets = "libroxterm.la",
cflags = "${CORE_CFLAGS}",
libs = "${CORE_LIBS}",
quiet = True))
# roxterm
if bool(ctx.env['ENABLE_SM']):
ROXTERM_SOURCES += " session.c"
if bool(ctx.env['HAVE_VTE_TERMINAL_SEARCH_SET_GREGEX']):
ROXTERM_SOURCES += " search.c"
ctx.add_rule(CRule(
cflags = "${ROXTERM_CFLAGS}",
prefix = "roxterm-",
wdeps = "version.h"))
ctx.add_rule(LibtoolProgramRule(
sources = change_suffix_with_prefix(ROXTERM_SOURCES,
".c", ".o", "roxterm-"),
targets = "roxterm",
cflags = "${ROXTERM_CFLAGS}",
libs = "${ROXTERM_LIBS} -lroxterm",
deps = "libroxterm.la",
quiet = True))
# roxterm-config
ctx.add_rule(CRule(
cflags = "${ROXTERM_CONFIG_CFLAGS}",
prefix = "roxterm-config-"))
ctx.add_rule(LibtoolProgramRule(
sources = change_suffix_with_prefix(ROXTERM_CONFIG_SOURCES,
".c", ".o", "roxterm-config-"),
targets = "roxterm-config",
cflags = "${ROXTERM_CONFIG_CFLAGS}",
libs = "${ROXTERM_CONFIG_LIBS} -lroxterm",
deps = "libroxterm.la",
quiet = True))
# Stuff other than the program
# Graphics
ctx.add_rule(Rule(rule = "${CONVERT} -background #0000 " \
"${SRC} -geometry 64x64 ${TGT}",
targets = LOGO_PNG,
sources = "roxterm.svg",
where = TOP))
ctx.add_rule(Rule(rule = "${CONVERT} ${SRC} -geometry 16x16 ${TGT}",
targets = FAVICON,
sources = LOGO_PNG,
where = TOP))
ctx.add_rule(Rule(rule = "${COMPOSITE} -gravity SouthWest ${SRC} ${TGT}",
targets = TEXT_LOGO,
sources = [LOGO_PNG, "${TOP_DIR}/Help/lib/logo_text_only.png"],
where = TOP))
# man pages
if ctx.env['XMLTOMAN']:
ctx.add_rule(SuffixRule(
rule = "${XMLTOMAN} ${XMLTOMAN_OPTS} ${SRC} ${XMLTOMAN_OUTPUT}",
targets = ".1",
sources = ".1.xml",
use_shell = True,
where = TOP))
# Force invocation of above suffix rule
ctx.add_rule(TouchRule(
targets = "manpages",
sources = "roxterm.1 roxterm-config.1"))
# Make sure .ui file is GTK2-compatible
def process_ui(ctx, env, targets, sources):
fp = open(sources[0], 'r')
s = fp.read()
fp.close()
s = re.sub(r'class="GtkBox" id=(.*)hbox',
r'class="GtkHBox" id=\1hbox', s)
s = re.sub(r'class="GtkBox" id=(.*)vbox',
r'class="GtkVBox" id=\1vbox', s)
save_if_different(sources[0], s)
fp = open(targets[0], 'w')
fp.close()
ctx.add_rule(Rule(rule = process_ui,
sources = "${SRC_DIR}/roxterm-config.ui",
targets = "roxterm-config.ui-stamp"))
elif ctx.mode == "install" or ctx.mode == "uninstall":
ctx.install_bin("roxterm roxterm-config")
ctx.install_data("roxterm-config.ui")
ctx.install_data("roxterm.desktop", "${DATADIR}/applications")
if ctx.env['XMLTOMAN']:
ctx.install_man("roxterm.1 roxterm-config.1")
ctx.install_doc("AUTHORS ChangeLog COPYING README")
ctx.install_doc(ctx.glob("*", subdir = "${TOP_DIR}/Help/en"),
"${HTMLDIR}/en")
ctx.install_doc(ctx.glob("*", subdir = "${TOP_DIR}/Help/lib"),
"${HTMLDIR}/lib")
ctx.install_data("roxterm.svg", "${DATADIR}/icons/hicolor/scalable/apps")
ctx.install_data(["Config/Colours/Tango", "Config/Colours/GTK"],
"${PKGDATADIR}/Config/Colours")
ctx.install_data("Config/Shortcuts/Default",
"${PKGDATADIR}/Config/Shortcuts")
gda = ctx.env['WITH_GNOME_DEFAULT_APPLICATIONS']
if gda:
ctx.install_data("roxterm.xml", gda)
elif ctx.mode == 'distclean' or ctx.mode == 'clean':
clean = [LOGO_PNG, TEXT_LOGO, FAVICON, APPINFO]
if ctx.mode == 'distclean':
clean += [VFILE, DCH]
for f in clean:
f = ctx.subst(f)
try:
os.unlink(f)
except OSError:
pass
elif ctx.mode == 'dist':
ctx.add_dist("AUTHORS builddeb " \
"ChangeLog ChangeLog.old Config " \
"COPYING debian Help/en Help/lib/header.png " \
"Help/lib/logo_text_only.png " \
"Help/lib/roxterm.css Help/lib/roxterm_ie.css "
"Help/lib/sprites.png " \
"INSTALL INSTALL.Debian " \
"NEWS README README.translations " \
"roxterm.1.xml.in roxterm-config.1.xml.in " \
"roxterm.desktop roxterm.lsm.in roxterm.spec.in " \
"roxterm.svg roxterm.xml src TODO update-locales")
ctx.add_dist(ctx.glob("*.[c|h]", os.curdir, "src"))
ctx.add_dist("src/roxterm-config.ui src/roxterm-config.glade")
# Debian files
ctx.add_dist("debian builddeb")
# maitch-specific
ctx.add_dist("version maitch.py mscript.py")
# ROX bits
ctx.add_dist("AppInfo.xml.in AppRun .DirIcon " \
"Help/Changes Help/COPYING Help/NEWS Help/README")
# Translations (currently not properly supported)
ctx.add_dist("ABOUT-NLS po po4a")
# Stuff to be removed when we no longer support autotools
ctx.add_dist("acinclude.m4 bootstrap.sh configure.ac.in " \
"Makefile.am src/Makefile.am")
try:
ctx.add_dist("m4 acinclude.m4 aclocal.m4 " \
"bootstrap.sh compile config.guess config.h.in " \
"config.sub config.rpath configure configure.ac " \
"depcomp install-sh intl ltmain.sh " \
"Makefile.in src/Makefile.in missing")
except:
pass
ctx.run()
if ctx.mode == 'uninstall':
ctx.prune_directory("${DATADIR}/icons")
ctx.prune_directory("${PKGDATADIR}")
ctx.prune_directory("${DOCDIR}")
ctx.prune_directory("${HTMLDIR}")