The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

configure

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of configure.
Create plugin interface for the rendering classes
1 #!/usr/bin/python 2 import subprocess 3 import os 4 import sys 5 import time; 6 from optparse import OptionParser 7 from scripts import version 8 from scripts import configfile 9 import re 10 from scripts.run import run 11 12 VERSION = version.VERSION 13 14 HEADER = '\033[95m' 15 OKBLUE = '\033[94m' 16 OKGREEN = '\033[92m' 17 WARNING = '\033[93m' 18 FAIL = '\033[91m' 19 ENDC = '\033[0m' 20 21 gee = ""; 22 23 def test_program_version (program, a, b, c): 24 print ("Checking for %s version >= %s.%s.%s" % (program, a, b, c)) 25 process = subprocess.Popen (program + ' --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 26 v = process.stdout.readline() 27 process.communicate()[0] 28 if not process.returncode == 0: 29 print (FAIL + "Not found" + ENDC) 30 exit (1) 31 print ("Found " + v) 32 33 o = v.split (" "); 34 for s in o: 35 if re.search( r'[0-9]*\.', s): 36 v = s 37 break 38 39 v = re.sub(r'[a-zA-Z\-].*', '0', v) 40 version = [int(n) for n in v.split (".")] 41 return [a,b,c] <= version 42 43 def test_library_version (lib): 44 print ("Looking for library: " + lib + "\t\t") 45 process = subprocess.Popen ('pkg-config --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 46 process.communicate()[0] 47 return process.returncode == 0 48 49 def has_posixvala (): 50 posixvala = test_library_version ('posixvala') 51 if not posixvala: 52 print (OKGREEN + "Glib will be used instead of Posix (libc)." + ENDC) 53 return "False" 54 55 return "True" 56 57 def configure (gtk, libbgee, posixvala): 58 global gee 59 60 if not test_program_version ("valac", 0, 16, 0): 61 print (FAIL + "valac is too old." + ENDC) 62 exit (1) 63 64 if gtk: 65 libs = [ 66 'cairo', 67 'gdk-pixbuf-2.0', 68 'gio-2.0', 69 'glib-2.0', 70 'gtk+-3.0', 71 'webkitgtk-3.0', 72 'libsoup-2.4', 73 'libnotify' 74 ] 75 else: 76 libs = [ 77 'gdk-pixbuf-2.0', 78 'gio-2.0', 79 'glib-2.0', 80 ] 81 82 83 for lib in libs: 84 if not test_library_version (lib): 85 print (FAIL + "Can not find " + lib + ENDC) 86 exit (1) 87 88 if libbgee == "Any": 89 if test_library_version ('gee-0.8'): 90 gee = "gee-0.8" 91 elif test_library_version ('gee-1.0'): 92 gee = "gee-1.0" 93 else: 94 print (FAIL + "Can not find libgee (version 0.8 or version 1.0)." + ENDC) 95 exit (1) 96 else: 97 if not test_library_version (libbgee): 98 print (FAIL + "Can not find lib gee." + ENDC) 99 exit (1) 100 gee = libbgee; 101 102 run ('mkdir -p build') 103 run ('touch build/configured') 104 105 print (""); 106 print (OKGREEN + "Done" + ENDC); 107 108 109 parser = OptionParser() 110 parser.add_option("-p", "--prefix", dest="prefix", help="Install prefix", metavar="PREFIX") 111 parser.add_option("-d", "--dest", dest="dest", help="Install to this directory", metavar="DEST") 112 parser.add_option("-c", "--cc", dest="cc", help="C compiler", metavar="CC") 113 parser.add_option("-g", "--gtk", dest="gtk", help="Build Gtk version, default is True", metavar="GTK") 114 parser.add_option("-e", "--gee", dest="gee", help="Version of libgee", metavar="GEE") 115 parser.add_option("-x", "--posix", dest="posix", help="Use posixvala", metavar="POSIX") 116 117 (options, args) = parser.parse_args() 118 119 if not options.prefix: 120 options.prefix = "/usr" 121 if not options.dest: 122 options.dest = "" 123 if not options.cc: 124 options.cc = "gcc" 125 if not options.gtk: 126 options.gtk = True 127 if options.gtk == "False": 128 options.gtk = False 129 if not options.gee: 130 options.gee = "Any" 131 if not options.posix: 132 options.posix = has_posixvala () 133 134 configure (options.gtk, options.gee, options.posix) 135 configfile.write_config (options.prefix) 136 configfile.write_compile_parameters (options.prefix, options.dest, options.cc, gee, options.posix) 137