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.
Move the SVG parser and the SVG rendering code to libsvgbird
1 #!/usr/bin/python3 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 11 from scripts.run import run 12 13 TARGETS = ['libbirdfont', 14 'libbirdgems', 15 'birdfont', 16 'birdfont-autotrace', 17 'birdfont-export', 18 'birdfont-import', 19 'birdfont-test'] 20 21 VERSION = version.VERSION 22 23 HEADER = '\033[95m' 24 OKBLUE = '\033[94m' 25 OKGREEN = '\033[92m' 26 WARNING = '\033[93m' 27 FAIL = '\033[91m' 28 ENDC = '\033[0m' 29 30 gee = ''; 31 32 def test_program_version (program, a, b, c): 33 print ('Checking for %s version >= %s.%s.%s' % (program, a, b, c)) 34 process = subprocess.Popen (program + ' --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 35 v = process.stdout.readline().decode('utf-8') 36 process.communicate()[0] 37 if not process.returncode == 0: 38 print (FAIL + 'Not found' + ENDC) 39 exit (1) 40 print ('Found ' + v) 41 42 o = v.split (' '); 43 for s in o: 44 if re.search( r'[0-9]*\.', s): 45 v = s 46 break 47 48 v = re.sub(r'[a-zA-Z\-].*', '0', v) 49 version = [int(n) for n in v.split ('.')] 50 return [a,b,c] <= version 51 52 def test_library_version (lib, required=True, version=None): 53 print ('Looking for library: ' + lib + '\t\t') 54 process = subprocess.Popen ('pkg-config --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 55 v = process.stdout.readline().decode('utf-8') 56 process.communicate()[0] 57 58 if not process.returncode == 0: 59 if required: 60 print (FAIL + lib + ' not found' + ENDC) 61 exit (1) 62 else: 63 return False 64 65 if version == None: 66 return True 67 68 installed_version = v.split ('.'); 69 library_version = version.split ('.'); 70 71 if installed_version < library_version: 72 if required: 73 print (FAIL + lib + ' version >= ' + version + ' not found.' + ENDC) 74 exit (1) 75 else: 76 return False 77 78 return True 79 80 def has_posixvala (): 81 posixvala = test_library_version ('posixvala') 82 if not posixvala: 83 print (OKGREEN + 'Glib will be used instead of Posix (libc).' + ENDC) 84 return 'False' 85 else: 86 print (OKGREEN + 'Using posix profile.' + ENDC) 87 return 'True' 88 89 def configure(gtk, libbgee): 90 global gee 91 92 if not test_program_version ('valac', 0, 16, 0): 93 print (FAIL + 'valac is too old.' + ENDC) 94 exit (1) 95 96 if gtk: 97 libs = [ 98 'cairo', 99 'gdk-pixbuf-2.0', 100 'gio-2.0', 101 'glib-2.0', 102 'gtk+-3.0', 103 'webkitgtk-3.0', 104 'libsoup-2.4', 105 'libnotify', 106 'sqlite3', 107 ] 108 else: 109 libs = [ 110 'gio-2.0', 111 'glib-2.0', 112 'sqlite3', 113 'fontconfig', 114 ] 115 116 test_library_version ('xmlbird', True, '1.1.0') 117 118 for lib in libs: 119 test_library_version (lib) 120 121 if libbgee == 'Any': 122 if test_library_version ('gee-0.8', False): 123 gee = 'gee-0.8' 124 elif test_library_version ('gee-1.0', False): 125 gee = 'gee-1.0' 126 else: 127 print (FAIL + 'Can not find libgee (version 0.8 or version 1.0).' + ENDC) 128 exit (1) 129 else: 130 if not test_library_version (libbgee): 131 exit (1) 132 gee = libbgee; 133 134 run ('mkdir -p build') 135 run ('touch build/configured') 136 137 print (''); 138 print (OKGREEN + 'Done' + ENDC); 139 140 141 parser = OptionParser() 142 parser.add_option('-p', '--prefix', dest='prefix', help='Install prefix', metavar='PREFIX') 143 parser.add_option('-d', '--dest', dest='dest', help='Install to this directory', metavar='DEST') 144 parser.add_option('-c', '--cc', dest='cc', help='C compiler', metavar='CC') 145 parser.add_option('-g', '--gtk', dest='gtk', help='Build Gtk version, default is True', metavar='GTK') 146 parser.add_option('-e', '--gee', dest='gee', help='Version of libgee', metavar='GEE') 147 parser.add_option('-v', '--valac', dest='valac', help='Vala compiler', metavar='VALAC') 148 parser.add_option('-n', '--nonnull', dest='nonnull', action="store_true", help='Enable compiletime checks for null pointers', metavar='NONNULL') 149 150 parser.add_option('', '--valac-flags', dest='valac_flags', help='Vala compiler flags for all targets', metavar='VALAC_FLAGS', default='') 151 for target in TARGETS: 152 parser.add_option('', '--valac-flags-' + target, dest='valac_flags_' + target, help='Vala compiler flags for ' + target, metavar='VALAC_FLAGS', default='') 153 154 parser.add_option('', '--cflags', dest='cflags', help='C compiler flags for all targets', metavar='CFLAGS', default='') 155 for target in TARGETS: 156 parser.add_option('', '--cflags-' + target, dest='cflags_' + target, help='C compiler flags for ' + target, metavar='CFLAGS', default='') 157 158 parser.add_option('', '--ldflags', dest='ldflags', help='Linker flags for all targets', metavar='LDFLAGS', default='') 159 for target in TARGETS: 160 parser.add_option('', '--ldflags-' + target, dest='ldflags_' + target, help='Linker flags for ' + target, metavar='LDFLAGS', default='') 161 162 (options, args) = parser.parse_args() 163 option_dict = vars(options) 164 165 valacflags = dict() 166 cflags = dict() 167 ldflags = dict() 168 169 for target in TARGETS: 170 cflags[target] = options.cflags 171 cflags[target] = cflags[target] + ' ' + option_dict.get('cflags_' + target, "") 172 cflags[target] = cflags[target].strip() 173 174 ldflags[target] = options.ldflags 175 ldflags[target] = ldflags[target] + ' ' + option_dict.get('ldflags_' + target, "") 176 ldflags[target] = ldflags[target].strip() 177 178 valacflags[target] = options.valac_flags 179 valacflags[target] = valacflags[target] + ' ' + option_dict.get('valac_flags_' + target, "") 180 valacflags[target] = valacflags[target].strip() 181 182 if not options.prefix: 183 if 'bsd' in sys.platform: 184 options.prefix = '${DESTDIR}${PREFIX}' 185 else: 186 options.prefix = '/usr' 187 188 if not options.dest: 189 options.dest = '' 190 if not options.cc: 191 options.cc = 'gcc' 192 if not options.gtk: 193 options.gtk = True 194 if options.gtk == 'False': 195 options.gtk = False 196 if not options.gee: 197 options.gee = 'Any' 198 if not options.valac: 199 options.valac = 'valac' 200 if not options.nonnull: 201 options.nonnull = False 202 else: 203 options.nonnull = True 204 205 configure(options.gtk, options.gee) 206 207 configfile.write_config(options.prefix) 208 configfile.write_compile_parameters(options.prefix, 209 options.dest, 210 options.cc, 211 gee, 212 options.valac, 213 options.nonnull, 214 valacflags, 215 cflags, 216 ldflags, 217 options.gtk) 218