From 1e34d59e3fb62bc699d4e561c89e68adbf594f4e Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 12 Nov 2023 12:51:59 +0100
Subject: Retrieve the right plugin path in regular install modes.

---
 src/core/paths.c | 49 ++++++++++++++++---------------------------------
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/src/core/paths.c b/src/core/paths.c
index 5902e83..c9213bc 100644
--- a/src/core/paths.c
+++ b/src/core/paths.c
@@ -125,15 +125,13 @@ char *get_effective_directory(const char *template)
 char *get_effective_directory_new(TargetDirectoryType type)
 {
     char *result;                           /* Répertoire à retourner      */
-#ifdef DISCARD_LOCAL
+#if defined DISCARD_LOCAL && defined PYTHON_PACKAGE
     Dl_info info;                           /* Informations dynamiques     */
     int ret;                                /* Bilan d'une récupération    */
     char *dyn_path_tmp;                     /* Chemin d'accès modifiable   */
     const char *dyn_path;                   /* Chemin d'accès courant      */
-#   ifdef PYTHON_PACKAGE
     size_t len;                             /* Taille de comparaison       */
     size_t pos;                             /* Position dans une chaîne    */
-#   endif
 #endif
 
     /**
@@ -155,20 +153,6 @@ char *get_effective_directory_new(TargetDirectoryType type)
 
     result = NULL;
 
-#ifdef DISCARD_LOCAL
-
-    ret = dladdr(__FUNCTION__, &info);
-    if (ret == 0)
-    {
-        LOG_ERROR_DL_N("dladdr");
-        goto exit;
-    }
-
-    dyn_path_tmp = strdup(info.dli_fname);
-    dyn_path = dirname(dyn_path_tmp);
-
-#endif
-
     switch (type)
     {
         case TDT_PLUGINS_LIB:
@@ -178,6 +162,16 @@ char *get_effective_directory_new(TargetDirectoryType type)
 #else
 #   ifdef PYTHON_PACKAGE
 
+            ret = dladdr(__FUNCTION__, &info);
+            if (ret == 0)
+            {
+                LOG_ERROR_DL_N("dladdr");
+                break;
+            }
+
+            dyn_path_tmp = strdup(info.dli_fname);
+            dyn_path = dirname(dyn_path_tmp);
+
             len = strlen("chrysalide-libs");
             pos = strlen(dyn_path);
 
@@ -193,9 +187,12 @@ char *get_effective_directory_new(TargetDirectoryType type)
             result[pos] = '\0';
             result = stradd(result, "chrysalide-plugins");
 
+ bad_sync:
+
+            free(dyn_path_tmp);
+
 #   else
-            result = strdup(dyn_path);
-            result = stradd(result, G_DIR_SEPARATOR_S "chrysalide-plugins");
+            result = strdup(PLUGINS_LIB_DIR);
 #   endif
 #endif
             break;
@@ -206,20 +203,6 @@ char *get_effective_directory_new(TargetDirectoryType type)
 
     }
 
-#ifdef DISCARD_LOCAL
-
-#   ifdef PYTHON_PACKAGE
-
- bad_sync:
-
-#   endif
-
-    free(dyn_path_tmp);
-
- exit:
-
-#endif
-
     assert(result != NULL);
 
     return result;
-- 
cgit v0.11.2-87-g4458