Commit 1e9122e
build: allow pkg-config to be specified It is common for cross-compilers to include a wrapped pkg-config like armv7a-linux-gnueabi-pkg-config that is set up to find all the right target libs. By forcing pkg-config everywhere, it means the code can only locate the build libs which are for the wrong architecture. This also better aligns with upstream pkg-config build code where you can control the full program name via the PKG_CONFIG env var.
Changed files (3)
Diff
@@ -50,9 +50,9 @@ def test_program_version (program, a, b, c): version = [int(n) for n in v.split ('.')] return [a,b,c] <= version -def test_library_version (lib, required=True, version=None):+def test_library_version(pkg_config, lib, required=True, version=None): print ('Looking for library: ' + lib + '\t\t')- process = subprocess.Popen ('pkg-config --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)+ process = subprocess.Popen(pkg_config + ' --modversion ' + lib, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) v = process.stdout.readline().decode('utf-8') process.communicate()[0] @@ -78,7 +78,7 @@ def test_library_version (lib, required=True, version=None): return True -def configure(gtk, libbgee, valac):+def configure(gtk, libbgee, valac, pkg_config): global gee if not test_program_version(valac, 0, 16, 0):@@ -105,21 +105,21 @@ def configure(gtk, libbgee, valac): 'fontconfig', ] - test_library_version ('xmlbird', True, '1.2.0')+ test_library_version(pkg_config, 'xmlbird', True, '1.2.0') for lib in libs:- test_library_version (lib)+ test_library_version(pkg_config, lib) if libbgee == 'Any':- if test_library_version ('gee-0.8', False):+ if test_library_version(pkg_config, 'gee-0.8', False): gee = 'gee-0.8'- elif test_library_version ('gee-1.0', False):+ elif test_library_version(pkg_config, 'gee-1.0', False): gee = 'gee-1.0' else: print (FAIL + 'Can not find libgee (version 0.8 or version 1.0).' + ENDC) exit (1) else:- if not test_library_version (libbgee):+ if not test_library_version(pkg_config, libbgee): exit (1) gee = libbgee; @@ -137,6 +137,7 @@ parser.add_option('-c', '--cc', dest='cc', help='C compiler', metavar='CC') parser.add_option('-g', '--gtk', dest='gtk', help='Build Gtk version, default is True', metavar='GTK') parser.add_option('-e', '--gee', dest='gee', help='Version of libgee', metavar='GEE') parser.add_option('-v', '--valac', dest='valac', help='Vala compiler', metavar='VALAC')+parser.add_option('-P', '--pkg-config', dest='pkg_config', help='Package config tool', metavar='PKG_CONFIG') parser.add_option('-n', '--nonnull', dest='nonnull', action="store_true", help='Enable compiletime checks for null pointers', metavar='NONNULL') parser.add_option('', '--valac-flags', dest='valac_flags', help='Vala compiler flags for all targets', metavar='VALAC_FLAGS', default='')@@ -189,12 +190,14 @@ if not options.gee: options.gee = 'Any' if not options.valac: options.valac = 'valac'+if not options.pkg_config:+ options.pkg_config = 'pkg-config' if not options.nonnull: options.nonnull = False else: options.nonnull = True -configure(options.gtk, options.gee, options.valac)+configure(options.gtk, options.gee, options.valac, options.pkg_config) configfile.write_config(options.prefix) configfile.write_compile_parameters(options.prefix,@@ -202,6 +205,7 @@ configfile.write_compile_parameters(options.prefix, options.cc, gee, options.valac,+ options.pkg_config, options.nonnull, valacflags, cflags,@@ -94,28 +94,28 @@ def make_birdfont(target_binary, deps): -D 'GETTEXT_PACKAGE="birdfont"' \ -I./build/libbirdfont \ -I./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \- $(pkg-config --cflags gdk-pixbuf-2.0) \- $(pkg-config --cflags webkitgtk-3.0) \- $(pkg-config --cflags libnotify) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \+ $({pkg-config} --cflags gdk-pixbuf-2.0) \+ $({pkg-config} --cflags webkitgtk-3.0) \+ $({pkg-config} --cflags libnotify) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = """{cc} {ldflags[birdfont]} \ build/birdfont/*.o \ -L./build/bin -lbirdfont \- $(pkg-config --libs sqlite3) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs gdk-pixbuf-2.0) \- $(pkg-config --libs webkitgtk-3.0) \- $(pkg-config --libs xmlbird) \- $(pkg-config --libs libnotify) \+ $({pkg-config} --libs sqlite3) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs gdk-pixbuf-2.0) \+ $({pkg-config} --libs webkitgtk-3.0) \+ $({pkg-config} --libs xmlbird) \+ $({pkg-config} --libs libnotify) \ -L./build -L./build/bin -l birdgems -l svgbird \ -o build/bin/""".format(**config.SETTINGS) + target_binary @@ -155,23 +155,23 @@ def make_birdfont_export(target_binary, deps): -D 'GETTEXT_PACKAGE="birdfont"' \ -I./build/libbirdfont \ -I./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = """{cc} {ldflags[birdfont-export]} \ build/birdfont-export/*.o \ -Lbuild/bin/ -lbirdfont \ -lm \- $(pkg-config --libs sqlite3) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs sqlite3) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin -l birdgems -l svgbird \ -o ./build/bin/""".format(**config.SETTINGS) + target_binary @@ -210,23 +210,23 @@ def make_birdfont_import(target_binary, deps): -D 'GETTEXT_PACKAGE="birdfont"' \ -I./build/libbirdfont \ -I./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = """{cc} {ldflags[birdfont-import]} \ build/birdfont-import/*.o \ -Lbuild/bin/ -lbirdfont \ -lm \- $(pkg-config --libs sqlite3) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs sqlite3) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin -l birdgems -l svgbird \ -o ./build/bin/""".format(**config.SETTINGS) + target_binary @@ -265,11 +265,11 @@ def make_birdfont_autotrace(target_binary, deps): -D 'GETTEXT_PACKAGE="birdfont"' \ -I./build/libbirdfont \ -I./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = """{cc} {ldflags[birdfont-autotrace]} \@@ -278,12 +278,12 @@ def make_birdfont_autotrace(target_binary, deps): -I./build/libsvgbird \ -Lbuild/bin/ -lbirdfont \ -lm \- $(pkg-config --libs sqlite3) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs sqlite3) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin -l birdgems -l svgbird\ -o ./build/bin/""".format(**config.SETTINGS) + target_binary @@ -331,27 +331,27 @@ def make_libbirdfont(target_binary, deps): -I ./build/libbirdfont \ -I ./build/libbirdgems \ -I ./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags fontconfig) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \- $(pkg-config --cflags xmlbird) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags fontconfig) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \+ $({pkg-config} --cflags xmlbird) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = ("""{cc} {ldflags[libbirdfont]} \ -shared \ """ + soname(target_binary) + """ \ build/libbirdfont/*.o \- $(pkg-config --libs sqlite3) \+ $({pkg-config} --libs sqlite3) \ $(freetype-config --libs) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs fontconfig) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs fontconfig) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin -l birdgems -l svgbird \ -o ./build/bin/""").format(**config.SETTINGS) + target_binary @@ -390,22 +390,22 @@ def make_libsvgbird(target_binary, deps): -c C_SOURCE \ -fPIC \ -I ./build/libsvgbird \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \- $(pkg-config --cflags xmlbird) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \+ $({pkg-config} --cflags xmlbird) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = ("""{cc} {ldflags[libsvgbird]} \ -shared \ """ + soname(target_binary) + """ \ build/libsvgbird/*.o \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin \ -o ./build/bin/""").format(**config.SETTINGS) + target_binary @@ -441,7 +441,7 @@ def make_libbirdgems(target_binary, deps): cc_command = """{cc} {cflags[libbirdgems]} \ -fPIC \- $(pkg-config --cflags glib-2.0) \+ $({pkg-config} --cflags glib-2.0) \ -c C_SOURCE \ -o OBJECT_FILE \ """.format(**config.SETTINGS)@@ -451,8 +451,8 @@ def make_libbirdgems(target_binary, deps): """ + soname(target_binary) + """ \ -fPIC \ build/libbirdgems/*.o \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs gobject-2.0) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs gobject-2.0) \ -o build/bin/""").format(**config.SETTINGS) + target_binary libbirdgems = Builder('libbirdgems',@@ -527,22 +527,22 @@ def make_birdfont_test(target_binary, deps): -D 'GETTEXT_PACKAGE="birdfont"' \ -I./build/libbirdfont \ -I./build/libsvgbird \- $(pkg-config --cflags sqlite3) \- $(pkg-config --cflags {gee}) \- $(pkg-config --cflags gio-2.0) \- $(pkg-config --cflags cairo) \- $(pkg-config --cflags glib-2.0) \+ $({pkg-config} --cflags sqlite3) \+ $({pkg-config} --cflags {gee}) \+ $({pkg-config} --cflags gio-2.0) \+ $({pkg-config} --cflags cairo) \+ $({pkg-config} --cflags glib-2.0) \ -o OBJECT_FILE""".format(**config.SETTINGS) linker_command = """{cc} {ldflags[birdfont-test]} \ build/birdfont-test/*.o \ -L./build/bin -lbirdfont \- $(pkg-config --libs sqlite3) \- $(pkg-config --libs {gee}) \- $(pkg-config --libs gio-2.0) \- $(pkg-config --libs cairo) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs xmlbird) \+ $({pkg-config} --libs sqlite3) \+ $({pkg-config} --libs {gee}) \+ $({pkg-config} --libs gio-2.0) \+ $({pkg-config} --libs cairo) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs xmlbird) \ -L./build -L./build/bin -l birdgems -l svgbird\ -o build/bin/""".format(**config.SETTINGS) + target_binary @@ -576,10 +576,10 @@ def make_birdui(target_binary, deps): cc_command = """{cc}"" \ -fPIC \- $(pkg-config --cflags gtk+-3.0) \- $(pkg-config --cflags glib-2.0) \- $(pkg-config --cflags xmlbird) \- $(pkg-config --cflags {gee}) \+ $({pkg-config} --cflags gtk+-3.0) \+ $({pkg-config} --cflags glib-2.0) \+ $({pkg-config} --cflags xmlbird) \+ $({pkg-config} --cflags {gee}) \ -g \ -I ./build/libsvgbird \ -c C_SOURCE \@@ -591,11 +591,11 @@ def make_birdui(target_binary, deps): -fPIC \ -g \ build/birdui/*.o \- $(pkg-config --libs gtk+-3.0) \- $(pkg-config --libs glib-2.0) \- $(pkg-config --libs gobject-2.0) \- $(pkg-config --libs xmlbird) \- $(pkg-config --libs {gee}) \+ $({pkg-config} --libs gtk+-3.0) \+ $({pkg-config} --libs glib-2.0) \+ $({pkg-config} --libs gobject-2.0) \+ $({pkg-config} --libs xmlbird) \+ $({pkg-config} --libs {gee}) \ -L ./build/bin -l m -l svgbird \ -o build/bin/""".format(**config.SETTINGS) + target_binary @@ -37,8 +37,8 @@ def write_config (prefix): f.write("}") -def write_compile_parameters (prefix, dest, cc, gee, valac, non_null,- valacflags, cflags, ldflags, gtk):+def write_compile_parameters(prefix, dest, cc, gee, valac, pkg_config,+ non_null, valacflags, cflags, ldflags, gtk): settings = { 'prefix': prefix, 'dest': dest,@@ -47,6 +47,7 @@ def write_compile_parameters (prefix, dest, cc, gee, valac, non_null, 'ldflags': ldflags, 'valac': valac, 'valacflags': valacflags,+ 'pkg-config': pkg_config, 'non_null': '--enable-experimental-non-null' if non_null else '', 'gee': gee, }