abstract_compiler: check the presence of pkgconfig libraries in the Makefile
authorJean Privat <jean@pryen.org>
Tue, 4 Nov 2014 16:28:27 +0000 (11:28 -0500)
committerJean Privat <jean@pryen.org>
Tue, 4 Nov 2014 18:01:59 +0000 (13:01 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit

index e80e566..104380a 100644 (file)
@@ -404,6 +404,24 @@ class MakefileToolchain
                for f in compiler.extern_bodies do
                        pkgconfigs.add_all f.pkgconfigs
                end
+               # Protect pkg-config
+               if not pkgconfigs.is_empty then
+                       makefile.write """
+# does pkg-config exists?
+ifneq ($(shell which pkg-config >/dev/null; echo $$?), 0)
+$(error "Command `pkg-config` not found. Please install it")
+endif
+"""
+                       for p in pkgconfigs do
+                               makefile.write """
+# Check for library {{{p}}}
+ifneq ($(shell pkg-config --exists '{{{p}}}'; echo $$?), 0)
+$(error "pkg-config: package {{{p}}} is not found.")
+endif
+"""
+                       end
+               end
+
                # Compile each required extern body into a specific .o
                for f in compiler.extern_bodies do
                        var o = f.makefile_rule_name