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 51fc27a..0befd5e 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 58a1f49..23aba98 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 ebc3420..0b98b42 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 6cd4557..1278949 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 d012dbc..849a54a 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 b1bff08..ed87192 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 d977583..866d51d 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 0f286bf..79c6c1f 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 302737b..e57f9a9 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 0b61819..0dad475 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 6ddc5a2..4ab95dd 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 a6af7da..f28a5f3 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 4f54eb3..d11f317 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 44570b0..edf60f1 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 1d73608..e4d707d 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 39f01ae..db7e835 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 70ffb07..e027f27 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 d8feaa6..27130a3 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 9a29891..cc505a5 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 c74feda..e5d6366 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 d7848e8..b107e66 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 66ca5ea..e637ab9 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 280fd72..5525294 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 72d71c9..2cfb96d 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 cdd7faa..4937c7c 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'])