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.
Build configuration
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 'gdk-pixbuf-2.0', 89 'gio-2.0', 90 'glib-2.0', 91 'sqlite3', 92 'fontconfig', 93 'xmlbird' 94 ] 95 96 for lib in libs: 97 if not test_library_version (lib): 98 print (FAIL + 'Can not find ' + lib + ENDC) 99 exit (1) 100 101 if libbgee == 'Any': 102 if test_library_version ('gee-0.8'): 103 gee = 'gee-0.8' 104 elif test_library_version ('gee-1.0'): 105 gee = 'gee-1.0' 106 else: 107 print (FAIL + 'Can not find libgee (version 0.8 or version 1.0).' + ENDC) 108 exit (1) 109 else: 110 if not test_library_version (libbgee): 111 print (FAIL + 'Can not find lib gee.' + ENDC) 112 exit (1) 113 gee = libbgee; 114 115 run ('mkdir -p build') 116 run ('touch build/configured') 117 118 print (''); 119 print (OKGREEN + 'Done' + ENDC); 120 121 122 parser = OptionParser() 123 parser.add_option('-p', '--prefix', dest='prefix', help='Install prefix', metavar='PREFIX') 124 parser.add_option('-d', '--dest', dest='dest', help='Install to this directory', metavar='DEST') 125 parser.add_option('-c', '--cc', dest='cc', help='C compiler', metavar='CC') 126 parser.add_option('-g', '--gtk', dest='gtk', help='Build Gtk version, default is True', metavar='GTK') 127 parser.add_option('-e', '--gee', dest='gee', help='Version of libgee', metavar='GEE') 128 parser.add_option('-v', '--valac', dest='valac', help='Vala compiler', metavar='VALAC') 129 parser.add_option('-n', '--nonnull', dest='nonnull', help='Enable compiletime checks for null pointers', metavar='NONNULL') 130 131 parser.add_option('', '--valac-flags', dest='valac_flags', help='Vala compiler flags for all targets', metavar='VALAC_FLAGS', default='') 132 for target in TARGETS: 133 parser.add_option('', '--valac-flags-' + target, dest='valac_flags_' + target, help='Vala compiler flags for ' + target, metavar='VALAC_FLAGS', default='') 134 135 parser.add_option('', '--cflags', dest='cflags', help='C compiler flags for all targets', metavar='CFLAGS', default='') 136 for target in TARGETS: 137 parser.add_option('', '--cflags-' + target, dest='cflags_' + target, help='C compiler flags for ' + target, metavar='CFLAGS', default='') 138 139 parser.add_option('', '--ldflags', dest='ldflags', help='Linker flags for all targets', metavar='LDFLAGS', default='') 140 for target in TARGETS: 141 parser.add_option('', '--ldflags-' + target, dest='ldflags_' + target, help='Linker flags for ' + target, metavar='LDFLAGS', default='') 142 143 (options, args) = parser.parse_args() 144 option_dict = vars(options) 145 146 valacflags = dict() 147 cflags = dict() 148 ldflags = dict() 149 150 for target in TARGETS: 151 cflags[target] = options.cflags 152 cflags[target] = cflags[target] + ' ' + option_dict.get('cflags_' + target, "") 153 cflags[target] = cflags[target].strip() 154 155 ldflags[target] = options.ldflags 156 ldflags[target] = ldflags[target] + ' ' + option_dict.get('ldflags_' + target, "") 157 ldflags[target] = ldflags[target].strip() 158 159 valacflags[target] = options.valac_flags 160 valacflags[target] = valacflags[target] + ' ' + option_dict.get('valac_flags_' + target, "") 161 valacflags[target] = valacflags[target].strip() 162 163 if not options.prefix: 164 if 'bsd' in sys.platform: 165 options.prefix = '${DESTDIR}${PREFIX}' 166 else: 167 options.prefix = '/usr' 168 169 if not options.dest: 170 options.dest = '' 171 if not options.cc: 172 options.cc = 'gcc' 173 if not options.gtk: 174 options.gtk = True 175 if options.gtk == 'False': 176 options.gtk = False 177 if not options.gee: 178 options.gee = 'Any' 179 if not options.valac: 180 options.valac = 'valac' 181 if not options.nonnull: 182 options.nonnull = False 183 else: 184 options.nonnull = True 185 186 configure (options.gtk, options.gee) 187 188 configfile.write_config (options.prefix) 189 configfile.write_compile_parameters (options.prefix, 190 options.dest, 191 options.cc, 192 gee, 193 options.valac, 194 options.nonnull, 195 valacflags, 196 cflags, 197 ldflags) 198