build: Use global RPATH value
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Fri, 21 Jul 2017 11:52:38 +0000 (13:52 +0200)
committerMats Wichmann <mats@linux.com>
Thu, 28 Sep 2017 00:52:49 +0000 (00:52 +0000)
Also introduce ORIGIN for crosscompiler.

RPATH can be convenient to avoid developer to deal with environment variables
(LD_LIBRARY_PATH or PATH on windows), as we're using them for now.

In longer term, this can be replaced by relative pathes,
once the installation process is fixed
(at least on systems supporting ORIGIN).

It was tested on yocto poky master.

Bug: https://jira.iotivity.org/browse/IOT-1745
Change-Id: Ibaabc31b8dc744267e4c6c1c682d2090da9ada96
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Origin: https://gerrit.iotivity.org/gerrit/#/c/21589/

25 files changed:
bridging/common/SConscript
bridging/mini_plugin_manager/SConscript
bridging/mpm_client/SConscript
bridging/plugins/hue_plugin/SConscript
bridging/plugins/lifx_plugin/SConscript
bridging/plugins/lyric_plugin/SConscript
bridging/plugins/nest_plugin/SConscript
build_common/SConscript
plugins/samples/linux/SConscript
plugins/src/SConscript
plugins/zigbee_wrapper/src/SConscript
resource/csdk/resource-directory/SConscript
resource/csdk/resource-directory/samples/SConscript
resource/csdk/resource-directory/unittests/SConscript
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/tool/SConscript
resource/csdk/stack/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/provisioning/examples/SConscript
resource/src/SConscript
service/easy-setup/enrollee/SConscript
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/SConscript
service/simulator/SConscript
service/simulator/ramlparser/SConscript

index 51fc27a5e0f3c8d747f9941f1dee51fa7ebeb45c..0befd5e634526f186f5c13d455b29ce688c7a481 100644 (file)
@@ -57,7 +57,6 @@ if target_os not in ['arduino', 'windows']:
     mpmcommon_env.AppendUnique(
         CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror', '-fpic'])
 
-mpmcommon_env.AppendUnique(RPATH=[mpmcommon_env.get('BUILD_DIR')])
 mpmcommon_env['LINKFLAGS'] = maskFlags(mpmcommon_env['LINKFLAGS'])
 
 mpmcommon_env.PrependUnique(LIBS=[
index 58a1f49bae68f19e52cbd502f0d489d4678dfdac..23aba98712c813db5abb80864ef8b7058487eeae 100644 (file)
@@ -48,7 +48,6 @@ manager_env.PrependUnique(CPPPATH=[
 if target_os not in ['arduino', 'windows']:
         manager_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
 
-manager_env.AppendUnique(RPATH=[manager_env.get('BUILD_DIR')])
 manager_env.PrependUnique(LIBS=['mpmcommon'])
 
 #####################################################################
index ebc342067cdc3a13e429014fbaa352d0069c379d..0b98b429ca9844da74df71c232061b7779cc1b51 100644 (file)
@@ -48,8 +48,6 @@ mpmclient_env.AppendUnique(LIBS=['pthread'])
 mpmclient_env.AppendUnique(LIBS=[
     'm', 'octbstack', 'ocsrm', 'mpmcommon', 'connectivity_abstraction', 'coap', 'curl'
 ])
-mpmclient_env.AppendUnique(
-    RPATH=[os.path.join(env.get('BUILD_DIR'), 'bridging', 'plugins')])
 
 if target_os in ['linux', 'tizen', 'yocto']:
     mpmclient_env.AppendUnique(LIBS = ['rt'])
index 6cd4557cabd5d24ad976d3038d2fa13041045991..12789495ea0b94f52d72ba6445501252ca46c756 100644 (file)
@@ -69,7 +69,6 @@ if target_os in ['darwin', 'ios']:
     hue_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 
 hue_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
-hue_env.AppendUnique(RPATH=[hue_env.get('BUILD_DIR')])
 
 if hue_env.get('LOGGING'):
     hue_env.AppendUnique(CPPDEFINES=['TB_LOG'])
index d012dbc6e1c7049e7e14bfa098a7d8d3f85a109b..849a54aa563bea73187b546822f3078ca8df8d26 100644 (file)
@@ -65,8 +65,6 @@ if 'g++' in lifx_env.get('CXX'):
     lifx_env.AppendUnique(
         CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
 
-lifx_env.AppendUnique(RPATH=[lifx_env.get('BUILD_DIR')])
-
 lifx_env['LINKFLAGS'] = maskFlags(env['LINKFLAGS'])
 lifx_env.AppendUnique(LINKFLAGS=['-Wl,--allow-shlib-undefined'])
 lifx_env.AppendUnique(LINKFLAGS=[
index b1bff08ec29bcf3719caa39b94b3dd44bcd4ca36..ed8719270f4088e09824a12fd521b76ee5816d12 100644 (file)
@@ -67,8 +67,6 @@ if 'g++' in lyric_env.get('CXX'):
     lyric_env.AppendUnique(
         CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
 
-lyric_env.AppendUnique(RPATH=[lyric_env.get('BUILD_DIR')])
-
 lyric_env['LINKFLAGS'] = maskFlags(env['LINKFLAGS'])
 lyric_env.AppendUnique(LINKFLAGS=['-Wl,--allow-shlib-undefined'])
 lyric_env.AppendUnique(LINKFLAGS=[
index d977583a1c638c5b69f8204f6d0002bdce335d3a..866d51d5f7486b9c5e494c0459015243bd2863e6 100644 (file)
@@ -72,8 +72,6 @@ if 'g++' in nest_env.get('CXX'):
     nest_env.AppendUnique(
         CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
 
-nest_env.AppendUnique(RPATH=[nest_env.get('BUILD_DIR')])
-
 if nest_env.get('LOGGING'):
     nest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
index 0f286bfd0681dc939e862eecf3670ee635587aae..79c6c1fe583f865037a2ff7d9527831392b5f442 100755 (executable)
@@ -596,7 +596,6 @@ rd_mode = env.get('RD_MODE')
 with_ra_ibb = env.get('WITH_RA_IBB')
 
 env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
 
 if (env.get('WITH_UPSTREAM_LIBCOAP') == '1'):
     env.AppendUnique(CPPDEFINES=['WITH_UPSTREAM_LIBCOAP'])
@@ -788,6 +787,11 @@ else:
     # Load config of target os
     env.SConscript(target_os + '/SConscript')
 
+if env.get('CROSS_COMPILE'):
+    env.Append(RPATH=env.Literal('\\$$ORIGIN'))
+else:
+    env.Append(RPATH=env.get('BUILD_DIR'))
+
 # Delete the temp files of configuration
 if env.GetOption('clean'):
     dir = env.get('SRC_DIR')
index 302737b38fa11b41ba56bdebfa6614095efc5ef9..e57f9a94d1b9d11c5699455054a544e26307b5f1 100644 (file)
@@ -40,7 +40,6 @@ samples_env.PrependUnique(CPPPATH=[
 
 samples_env.AppendUnique(
     CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
-samples_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
 
 if target_os in ['darwin', 'ios']:
     samples_env.PrependUnique(
index 0b61819b135a859293c7cbb73c26e16d50b219f4..0dad4755c68bda73e95055dca16c8df303d10fef 100644 (file)
@@ -67,7 +67,6 @@ if target_os in ['darwin', 'ios']:
     env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 
 env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
-env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
 
 env.PrependUnique(LIBS=['zigbee_wrapper'])
 
index 6ddc5a244be268d9a3834cac3d3b0df1028b8f3f..4ab95dd2cb41c004ae933720c5f39f87eb3ef493 100644 (file)
@@ -59,8 +59,6 @@ if target_os in ['darwin', 'ios']:
     env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 
 env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
-env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
-
 env.PrependUnique(LIBS=['telegesis_wrapper'])
 
 #####################################################################
index a6af7da5b55e8ae3ead7e0df0944af6e6c1184e6..f28a5f3db8aa56d82e224b5e34f208cd52fb9a51 100644 (file)
@@ -53,8 +53,6 @@ if 'CLIENT' in rd_mode:
 if 'SERVER' in rd_mode:
     rd_env.AppendUnique(CPPDEFINES=['RD_SERVER'])
 
-if target_os != 'android':
-    rd_env.PrependUnique(RPATH=[rd_env.get('BUILD_DIR')])
 rd_env.PrependUnique(
     LIBS=['octbstack', 'oc', 'oc_logger', 'connectivity_abstraction'])
 
index 4f54eb3b4f0c134d839e9c14c58968422a6b9539..d11f31756786d9d3892133f64e41f8f14ef82cf3 100644 (file)
@@ -47,7 +47,6 @@ rd_sample_app_env.AppendUnique(CPPPATH=[
 if target_os not in ['windows']:
     rd_sample_app_env.AppendUnique(
         CXXFLAGS=['-O2', '-g', '-Wall', '-Wextra', '-std=c++0x'])
-rd_sample_app_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
 rd_sample_app_env.PrependUnique(LIBS=['resource_directory', 'octbstack'])
 
 if env.get('SECURED') == '1':
index 44570b023a14d1d9446b699d24c593bfb6fb79df..edf60f165bc1d4cad2c17f9aa5a140cc7594615b 100644 (file)
@@ -73,7 +73,6 @@ rd_test_env.AppendUnique(CPPPATH=[
     src_dir + '/resource/oc_logger/include',
 ])
 
-rd_test_env.AppendUnique(RPATH=[lib_env.get('BUILD_DIR')])
 rd_test_env.PrependUnique(LIBS=['octbstack'])
 
 if rd_test_env.get('RD_MODE'):
index 1d736087d9b5de076ea9f08a354820414e6beb3a..e4d707dc308edbe9c3a909572ed1c74f94f3e2e9 100644 (file)
@@ -35,7 +35,6 @@ provisioning_sample_env.AppendUnique(CPPPATH=[
 ])
 
 target_os = env.get('TARGET_OS')
-provisioning_sample_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
 provisioning_sample_env.AppendUnique(CPPDEFINES=['__WITH_DTLS__'])
 
 if target_os not in ['windows']:
index 39f01ae40cca12e5b58fd832a153763d15b634e0..db7e8358411bff3cb465e90d01e79dc129027fce 100644 (file)
@@ -49,7 +49,6 @@ tools_env.PrependUnique(CPPPATH=[
     '#/resource/csdk/security/provisioning/include/internal'
 ])
 tools_env.AppendUnique(CXXFLAGS=['-O2', '-g', '-Wall', '-Wextra', '-std=c++0x'])
-tools_env.AppendUnique(RPATH=[tools_env.get('BUILD_DIR')])
 
 if target_os in ['windows', 'msys_nt']:
     # Macro needed for Windows builds to avoid __declspec(dllexport) and
index 70ffb0784428cfdd333152cfd1dd62e504ed8193..e027f27b65b163d8143577abe24155453f02ddee 100644 (file)
@@ -96,7 +96,7 @@ if target_os not in ['windows']:
 liboctbstack_env.PrependUnique(LIBS=['ocsrm', 'coap'])
 
 if target_os in ['linux'] and liboctbstack_env.get('SIMULATOR', False):
-    liboctbstack_env.Append(RPATH=liboctbstack_env.Literal('\\$$ORIGIN'))
+    liboctbstack_env['RPATH']=liboctbstack_env.Literal('\\$$ORIGIN')
 
 if env.get('SECURED') == '1':
     liboctbstack_env.AppendUnique(LIBS=['mbedtls', 'mbedx509'])
index d8feaa6e294a1b9323f6060832531ec60af6bace..27130a39c93acab83e9dc88785ec5be287858bc9 100644 (file)
@@ -49,8 +49,6 @@ compiler = samples_env.get('CXX')
 if 'g++' in compiler:
     samples_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall'])
 
-samples_env.AppendUnique(RPATH=[samples_env.get('BUILD_DIR')])
-
 samples_env.PrependUnique(LIBS=['coap'])
 
 if target_os not in ['msys_nt', 'windows']:
index 9a298913d7d8c717fc0320696a7f8ac74c9b3767..cc505a5b56a5a57b6f03b39ad2539c7e2aa347a6 100644 (file)
@@ -56,7 +56,6 @@ examples_env.AppendUnique(CPPPATH=[
     '../../csdk/security/provisioning/include/internal'
 ])
 
-examples_env.AppendUnique(RPATH=[examples_env.get('BUILD_DIR')])
 examples_env.PrependUnique(LIBS=[
     'ocprovision',
     'oc',
index c74feda809730da1a50ab0b1da9e0f17cb34fcd0..e5d63669d081955e0bca90ccd10c20104580eaa9 100644 (file)
@@ -83,7 +83,7 @@ if target_os in ['linux', 'tizen']:
     oclib_env.ParseConfig('pkg-config --cflags --libs sqlite3')
 
 if target_os in ['linux'] and oclib_env.get('SIMULATOR', False):
-    oclib_env.Append(RPATH=oclib_env.Literal('\\$$ORIGIN'))
+    oclib_env['RPATH']=oclib_env.Literal('\\$$ORIGIN')
 
 if target_os in ['msys_nt', 'windows']:
     oclib_env.AppendUnique(LIBS=[
index d7848e8d35b295dcf855a120f465bcf85859869e..b107e66bcb17349231a8a172fab619fe1b830186 100644 (file)
@@ -76,7 +76,6 @@ if not env.get('RELEASE'):
 if target_os in ['linux']:
     enrollee_env.AddPthreadIfNeeded()
     enrollee_env.AppendUnique(LIBS=['dl'])
-    enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.PrependUnique(LIBS=[
         'oc',
         'octbstack',
@@ -91,7 +90,6 @@ if target_os in ['linux']:
 # Tizen Enrollee
 ######################################################################
 if target_os == 'tizen':
-    enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.AppendUnique(CXXFLAGS=['-pthread'])
     enrollee_env.PrependUnique(LIBS=[
         'oc',
@@ -105,7 +103,6 @@ if target_os == 'tizen':
 # Arduino Enrollee
 ######################################################################
 if target_os == 'arduino':
-    enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.PrependUnique(LIBS=[
         'oc',
         'octbstack',
index 66ca5ea441958e930f65db1b715eb10370585834..e637ab983dbd050eb0435a9e36d802c95fbc8873 100644 (file)
@@ -80,7 +80,6 @@ if target_os in ['android']:
             env.get('SRC_DIR') +
             '/java/iotivity-android/build/native-libs/armeabi'
         ])
-    easy_setup_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
     easy_setup_env.AppendUnique(CXXFLAGS=['-frtti', '-fexceptions'])
     easy_setup_env.PrependUnique(LIBS=[
         'oc',
@@ -95,7 +94,6 @@ if target_os in ['android']:
         easy_setup_env.AppendUnique(LIBS=['log'])
 
 if target_os in ['linux', 'tizen']:
-    easy_setup_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
     easy_setup_env.AppendUnique(CXXFLAGS=['-pthread'])
     easy_setup_env.PrependUnique(LIBS=[
         'oc',
index 280fd72d6a45af83dde281e9c992c5aaf1439a8f..5525294e2df0a0e3c87d8101c8f425cb18b747f5 100644 (file)
@@ -60,20 +60,23 @@ mediator_env.PrependUnique(CPPPATH=[
     '#/service/easy-setup/inc',
 ])
 
-if env.get('SECURED') == '1':
-    mediator_env.PrependUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
+mediator_env.PrependUnique(LIBS=['ESMediatorRich'])
 
-mediator_env.PrependUnique(LIBS=[
-    'ESMediatorRich',
-    'oc',
+if env.get('SECURED') == '1':
+    mediator_env.AppendUnique(LIBS=[
+        'ocpmapi',
+        'ocprovision',
+        'mbedtls',
+        'mbedx509',
+        'mbedcrypto',
+    ])
+
+mediator_env.AppendUnique(LIBS=['oc',
     'octbstack',
     'oc_logger',
     'connectivity_abstraction',
 ])
 
-if env.get('SECURED') == '1':
-    mediator_env.PrependUnique(LIBS=['ocpmapi', 'ocprovision'])
-
 mediator = mediator_env.Program('mediator', 'mediator.cpp')
 submediator = mediator_env.Program('submediator', 'submediator.cpp')
 
index 72d71c9f03bb673e5d25ee054c3cfaa4782190e6..2cfb96d6791cf938ae71d835c86c501be244773a 100644 (file)
@@ -74,8 +74,7 @@ java_headers.append(os.path.join(java_headers[0], 'win32'))
 java_headers.append(os.path.join(java_headers[0], 'linux'))
 java_headers.append(os.path.join(java_headers[0], 'solaris'))
 simulator_env.AppendUnique(CPPPATH=java_headers)
-
-simulator_env.Append(RPATH=env.Literal('\\$$ORIGIN'))
+simulator_env['RPATH']=env.Literal('\\$$ORIGIN')
 
 simulator_env.AppendUnique(CPPPATH=['../../extlibs/cjson'])
 simulator_env.PrependUnique(LIBS=['oc', 'octbstack', 'RamlParser'])
index cdd7faaf5f2fe3ba894bef2e7c121b0ce925ef2a..4937c7cffd8fc758b51754d457031159d305d70e 100644 (file)
@@ -42,7 +42,7 @@ raml_env.AppendUnique(CXXFLAGS=[
     '-fmessage-length=0'
 ])
 raml_env.AppendUnique(CPPDEFINES=['LINUX'])
-raml_env.Append(RPATH=env.Literal('\\$$ORIGIN'))
+raml_env['RPATH']=env.Literal('\\$$ORIGIN')
 
 raml_env.PrependUnique(LIBS=['octbstack', 'YamlParser'])
 raml_env.AppendUnique(LIBS=['pthread', 'm', 'cjson'])