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