diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 6ac7ebb..3d53a7f 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -53,9 +53,13 @@ except: # Set default include directories and data files include_dirs = ['@prefix@/include/gammalib'] data_files = glob.glob('@top_srcdir@/pyext/*.i') -library_dirs = ['../src/.libs','@prefix@/lib'] +library_dirs = ['../src/.libs'] libraries = [libcta,'gamma'] +# Append prefix library directory if it exists +if os.path.exists('@prefix@/lib'): + library_dirs.append(['@prefix@/lib']) + # Add application include files. The method we use here is not very # intelligent as it simple will add all names that start with 'ct' # in the src directory. Once we added the ctatools script we had to @@ -75,18 +79,18 @@ for extra_lib in extra_libs: # Get extra library paths extra_lib_paths = ('@LDFLAGS@').split(' ') for extra_lib_path in extra_lib_paths: - if extra_lib_path.lstrip().find('-L') == 0: + if extra_lib_path.lstrip().find('-L') != -1: dir = extra_lib_path.lstrip().lstrip('-L') if len(dir) > 0: - library_dirs.append(extra_lib_path.lstrip('-L')) + library_dirs.append(dir) # Get extra include directories extra_include_dirs = ('@CPPFLAGS@').split(' ') for extra_include_dir in extra_include_dirs: - if extra_include_dir.lstrip().find('-I') == 0: + if extra_include_dir.lstrip().find('-I') != -1: dir = extra_include_dir.lstrip().lstrip('-I') if len(dir) > 0: - include_dirs.append(extra_include_dir.lstrip('-I')) + include_dirs.append(dir) # Setup setup(name='@PACKAGE_NAME@',