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.
Platform independent overwrite dialog
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 else: 55 print (OKGREEN + "Using posix profile." + ENDC) 56 return "True" 57 58 def configure (gtk, libbgee, posixvala): 59 global gee 60 61 if not test_program_version ("valac", 0, 16, 0): 62 print (FAIL + "valac is too old." + ENDC) 63 exit (1) 64 65 if gtk: 66 libs = [ 67 'cairo', 68 'gdk-pixbuf-2.0', 69 'gio-2.0', 70 'glib-2.0', 71 'gtk+-3.0', 72 'webkitgtk-3.0', 73 'libsoup-2.4', 74 'libnotify', 75 'sqlite3', 76 'xmlbird' 77 ] 78 else: 79 libs = [ 80 'gdk-pixbuf-2.0', 81 'gio-2.0', 82 'glib-2.0', 83 'sqlite3', 84 'fontconfig', 85 'xmlbird' 86 ] 87 88 for lib in libs: 89 if not test_library_version (lib): 90 print (FAIL + "Can not find " + lib + ENDC) 91 exit (1) 92 93 if libbgee == "Any": 94 if test_library_version ('gee-0.8'): 95 gee = "gee-0.8" 96 elif test_library_version ('gee-1.0'): 97 gee = "gee-1.0" 98 else: 99 print (FAIL + "Can not find libgee (version 0.8 or version 1.0)." + ENDC) 100 exit (1) 101 else: 102 if not test_library_version (libbgee): 103 print (FAIL + "Can not find lib gee." + ENDC) 104 exit (1) 105 gee = libbgee; 106 107 run ('mkdir -p build') 108 run ('touch build/configured') 109 110 print (""); 111 print (OKGREEN + "Done" + ENDC); 112 113 114 parser = OptionParser() 115 parser.add_option("-p", "--prefix", dest="prefix", help="Install prefix", metavar="PREFIX") 116 parser.add_option("-d", "--dest", dest="dest", help="Install to this directory", metavar="DEST") 117 parser.add_option("-c", "--cc", dest="cc", help="C compiler", metavar="CC") 118 parser.add_option("-g", "--gtk", dest="gtk", help="Build Gtk version, default is True", metavar="GTK") 119 parser.add_option("-e", "--gee", dest="gee", help="Version of libgee", metavar="GEE") 120 parser.add_option("-x", "--posix", dest="posix", help="Use posixvala", metavar="POSIX") 121 122 (options, args) = parser.parse_args() 123 124 if not options.prefix: 125 if "bsd" in sys.platform: 126 options.prefix = "${DESTDIR}${PREFIX}" 127 else: 128 options.prefix = "/usr" 129 if not options.dest: 130 options.dest = "" 131 if not options.cc: 132 options.cc = "gcc" 133 if not options.gtk: 134 options.gtk = True 135 if options.gtk == "False": 136 options.gtk = False 137 if not options.gee: 138 options.gee = "Any" 139 if not options.posix: 140 options.posix = has_posixvala () 141 142 configure (options.gtk, options.gee, options.posix) 143 144 configfile.write_config (options.prefix) 145 configfile.write_compile_parameters (options.prefix, options.dest, options.cc, gee, options.posix) 146