Preliminary fix for linking in DynaLoader
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 22 Feb 2013 21:41:23 +0000 (16:41 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 23 Feb 2013 03:04:58 +0000 (22:04 -0500)
scripts/jlibtool.c

index 49dba3e..551c2cd 100644 (file)
 #endif
 
 #ifndef CC
-#define CC             "gcc"
+#define CC                             "gcc"
 #endif
 
 #ifndef CXX
-#define CXX            "g++"
+#define CXX                            "g++"
 #endif
 
 #ifndef LINK_c
-#define LINK_c         "gcc"
+#define LINK_c                         "gcc"
 #endif
 
 #ifndef LINK_cxx
-#define LINK_cxx       "g++"
+#define LINK_cxx                       "g++"
 #endif
 
 #ifndef LIBDIR
-#define LIBDIR         "/usr/local/lib"
+#define LIBDIR                         "/usr/local/lib"
 #endif
 
-#define OBJDIR         ".libs"
+#define OBJDIR                         ".libs"
 
 #ifndef SHELL_CMD
 #error Unsupported platform: Please add defines for SHELL_CMD etc. for your platform.
@@ -1090,9 +1090,9 @@ static char *check_library_exists(command_t *cmd, const char *arg, int pathlen,
        ext = strrchr(newarg, '.');
        if (!ext) {
                printf("Error: Library path does not have an extension");
-       free(newarg);
+               free(newarg);
        
-       return NULL;
+               return NULL;
        }
        ext++;
 
@@ -1480,6 +1480,22 @@ static int parse_input_file_name(char *arg, command_t *cmd_data)
 
        pathlen = name - arg;
 
+       /*
+        *      If we have an external static lib not associated with 
+        *      an argument and were linking, add it to the list of input
+        *      files for GCC so it gets statically linked into the library
+        *      were building.
+        *
+        *      @fixme not sure if this is correct, but it lets us build shared
+        *      libraries that are linked against static .a files.
+        */
+       if ((strcmp(ext, STATIC_LIB_EXT) == 0) && (cmd_data->mode == mLink)) {
+               struct stat sb;
+               if (!stat(arg, &sb)) {
+                       push_count_chars(cmd_data->obj_files, arg);
+               }
+       }
+
        if (strcmp(ext, "lo") == 0) {
                newarg = check_object_exists(cmd_data, arg, ext - arg);
                if (!newarg) {