examples/ubuntu: Use pkg-config to pull correct package dependencies When adding dependecies on installed libraries, use their .pc files to specify additional library includes, defines and lib dependencies by listing packagaes in 'deps' variable in weave.gyp and then simple rules to pull out dependencies from the package config files. Change-Id: I09ab1329b2fc8cf4a6a94b7e96dacf1e51cbfbdd Reviewed-on: https://weave-review.googlesource.com/1256 Reviewed-by: Johan Euphrosine <proppy@google.com> Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/examples/ubuntu/weave.gyp b/libweave/examples/ubuntu/weave.gyp index 81b492b..a51db93 100644 --- a/libweave/examples/ubuntu/weave.gyp +++ b/libweave/examples/ubuntu/weave.gyp
@@ -3,7 +3,29 @@ { 'target_name': 'weave', 'type': 'executable', - 'cflags': ['-pthread', '-I/usr/include/libnl3'], + 'variables': { + 'deps': [ + 'avahi-client', + 'expat', + 'libcurl', + 'libcrypto', + 'libnl-3.0', + 'libnl-route-3.0', + 'openssl', + ] + }, + 'cflags': [ + '>!@(pkg-config >(deps) --cflags)', + '-pthread', + ], + 'link_settings': { + 'ldflags+': [ + '>!@(pkg-config >(deps) --libs-only-L --libs-only-other)', + ], + 'libraries+': [ + '>!(pkg-config >(deps) --libs-only-l)', + ], + }, 'sources': [ 'avahi_client.cc', 'bluez_client.cc', @@ -21,16 +43,8 @@ ], 'libraries': [ '-levent', - '-lcrypto', - '-lexpat', - '-lcurl', - '-lpthread', - '-lssl', - '-lavahi-common', - '-lavahi-client', '-levent_openssl', - '-lnl-3', - '-lnl-route-3', + '-lpthread', ] } ]