~ubuntu-branches/ubuntu/vivid/birdfont/vivid

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
#!/usr/bin/python
import subprocess
import os
import sys
import time;
from optparse import OptionParser
from scripts import version
from scripts import configfile
import re
from scripts.run import run

VERSION = version.VERSION

HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'

gee = "";

def test_program_version (program, a, b, c):
	print ("Checking for %s version >= %s.%s.%s" % (program, a, b, c))
	process = subprocess.Popen (program + ' --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	v = process.stdout.readline()
	process.communicate()[0]
	if not process.returncode == 0:
		print (FAIL + "Not found" + ENDC)
		exit (1)		
	print ("Found version " + v)
	
	o = v.split (" ");
	for s in o:
		if re.search( r'[0-9]*\.', s):
			v = s
			break
			
	v = re.sub(r'[a-zA-Z\-].*', '0', v)
	version = [int(n) for n in v.split (".")]
	return [a,b,c] <= version	

def test_library_version (lib):
	print ("Looking for library: " + lib + "\t\t")
	process = subprocess.Popen ('pkg-config --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
	process.communicate()[0]
	return process.returncode == 0

def configure (gtk, libbgee):
	global gee
	
	if not test_program_version ("valac", 0, 16, 0):
		print (FAIL + "valac is too old." + ENDC)
		exit (1)

	if gtk:
		libs = [
				'cairo', 
				'gdk-pixbuf-2.0',
				'gio-2.0', 
				'glib-2.0', 
				'gtk+-3.0',
				'libxml-2.0', 
				'webkitgtk-3.0', 
				'libsoup-2.4',
				'libnotify'
				]
	else:
		libs = [
				'gdk-pixbuf-2.0',
				'gio-2.0', 
				'glib-2.0', 
				'libxml-2.0', 
				]
	

	for lib in libs:
		if not test_library_version (lib):
			print (FAIL + "Can not find " + lib + ENDC)
			exit (1)

	if libbgee == "Any":
		if test_library_version ('gee-0.8'):
			gee = "gee-0.8"
		elif test_library_version ('gee-1.0'):
			gee = "gee-1.0"
		else:
			print (FAIL + "Can not find libgee (version 0.8 or version 1.0)." + ENDC)
			exit (1)
	else:
		if not test_library_version (libbgee):
			print (FAIL + "Can not find lib gee." + ENDC)
			exit (1)
		gee = libbgee;

	run ('mkdir -p build')
	run ('touch build/configured')

	print ("");
	print (OKGREEN + "Done" + ENDC);


parser = OptionParser()
parser.add_option("-p", "--prefix", dest="prefix", help="Install prefix", metavar="PREFIX")
parser.add_option("-d", "--dest", dest="dest", help="Install to this directory", metavar="DEST")
parser.add_option("-c", "--cc", dest="cc", help="C compiler", metavar="CC")
parser.add_option("-g", "--gtk", dest="gtk", help="Build Gtk version, default is True", metavar="GTK")
parser.add_option("-e", "--gee", dest="gee", help="Version of libgee", metavar="GEE")

(options, args) = parser.parse_args()

if not options.prefix:
	options.prefix = "/usr"
if not options.dest:
	options.dest = ""
if not options.cc:
	options.cc = "gcc"
if not options.gtk:
	options.gtk = True
if options.gtk == "False":
	options.gtk = False
if not options.gee:
	options.gee = "Any"
	
configure (options.gtk, options.gee)
configfile.write_config (options.prefix)
configfile.write_compile_parameters (options.prefix, options.dest, options.cc, gee)