apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject cvs commit: apr/build jlibtool.c
Date Mon, 27 Sep 2004 16:21:16 GMT
jfclere     2004/09/27 09:21:16

  Modified:    build    jlibtool.c
  Log:
  Use -L path -llib_name instead of path/"lib"lib_name."ext".
  That is still not ok because httpd would need something like:
  -Brpath=pathname or -Wl,-Brpath-pathname but we only have this information
  when building the library (when libtool is called with -rpath pathname).
  
  Revision  Changes    Path
  1.10      +53 -10    apr/build/jlibtool.c
  
  Index: jlibtool.c
  ===================================================================
  RCS file: /home/cvs/apr/build/jlibtool.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- jlibtool.c	17 Sep 2004 16:47:24 -0000	1.9
  +++ jlibtool.c	27 Sep 2004 16:21:16 -0000	1.10
  @@ -83,6 +83,7 @@
   #  define SHARED_OPTS "-shared"
   #  define MODULE_OPTS "-shared"
   #  define LINKER_FLAG_PREFIX "-Wl,"
  +#  define ADD_MINUS_L
   #endif
   
   #if defined(_OSD_POSIX)
  @@ -142,6 +143,14 @@
       pic_AVOID,
   };
   
  +enum lib_type {
  +    type_UNKNOWN,
  +    type_DYNAMIC_LIB,
  +    type_STATIC_LIB,
  +    type_MODULE_LIB,
  +    type_OBJECT,
  +};
  +
   typedef struct {
       const char **vals;
       int num; 
  @@ -653,7 +662,7 @@
           } 
   
           if (!cmd->options.silent) {
  -            printf("Checking: %s\n", newarg);
  +            printf("Checking (obj): %s\n", newarg);
           }
           rv = stat(newarg, &sb);
       }
  @@ -674,7 +683,7 @@
    * 1 - .libs suffix
    */
   char *check_library_exists(command_t *cmd, const char *arg, int pathlen,
  -                           int libdircheck)
  +                           int libdircheck, enum lib_type *libtype)
   {
       char *newarg, *ext;
       int pass, rv, newpathlen;
  @@ -701,24 +710,29 @@
           case 0:
               if (cmd->options.pic_mode != pic_AVOID || cmd->options.shared) {
                   strcpy(ext, DYNAMIC_LIB_EXT);
  +                *libtype = type_DYNAMIC_LIB;
                   break;
               }
               pass = 1;
           case 1:
               strcpy(ext, STATIC_LIB_EXT);
  +            *libtype = type_STATIC_LIB;
               break;
           case 2:
               strcpy(ext, MODULE_LIB_EXT);
  +            *libtype = type_MODULE_LIB;
               break;
           case 3:
               strcpy(ext, OBJECT_EXT);
  +            *libtype = type_OBJECT;
               break;
           default:
  +            *libtype = type_UNKNOWN;
               break;
           } 
   
           if (!cmd->options.silent) {
  -            printf("Checking: %s\n", newarg);
  +            printf("Checking (lib): %s\n", newarg);
           }
           rv = stat(newarg, &sb);
       }
  @@ -731,6 +745,27 @@
       return NULL;
   }
   
  +/* use -L -llibname to allow to use installed libraries */
  +void add_minus_l(count_chars *cc, const char *arg)
  +{
  +    char *name = strrchr(arg, '/');
  +    char *file = strrchr(arg, '.');
  +    char *lib  = strstr(name, "lib");
  +
  +    if (name !=NULL && file != NULL && lib == name+1) {
  +        *name = '\0';
  +        *file = '\0';
  +        file = name;
  +        file = file+4;
  +        push_count_chars(cc, "-L ");
  +        push_count_chars(cc, arg);
  +        push_count_chars(cc, "-l");
  +        push_count_chars(cc, file);
  +    } else {
  +        push_count_chars(cc, arg);
  +    }
  +}
  +
   void add_linker_flag_prefix(count_chars *cc, const char *arg)
   {
   #ifndef LINKER_FLAG_PREFIX
  @@ -749,6 +784,7 @@
       char *ext = strrchr(arg, '.');
       char *name = strrchr(arg, '/');
       int pathlen;
  +    enum lib_type libtype;
       char *newarg;
   
       if (!ext) {
  @@ -790,22 +826,29 @@
           switch (cmd_data->mode) {
           case mLink:
               /* Try the .libs dir first! */
  -            newarg = check_library_exists(cmd_data, arg, pathlen, 1);
  +            newarg = check_library_exists(cmd_data, arg, pathlen, 1, &libtype);
               if (!newarg) {
                   /* Try the normal dir next. */
  -                newarg = check_library_exists(cmd_data, arg, pathlen, 0);
  +                newarg = check_library_exists(cmd_data, arg, pathlen, 0, &libtype);
                   if (!newarg) {
                       printf("Can not find suitable library for %s\n", arg);
                       exit(1);
                   }
               }
   
  -            if (cmd_data->mode != mLink) {
  -                push_count_chars(cmd_data->arglist, newarg);
  -            }
  -            else {
  -                push_count_chars(cmd_data->shared_opts.dependencies, newarg);
  +            /* It is not ok to just add the file: a library may added with:
  +               1 - -L path library_name. (For *.so in Linux).
  +               2 - library_name.
  +             */
  +#ifdef ADD_MINUS_L
  +            if (libtype == type_DYNAMIC_LIB) {
  +                 add_minus_l(cmd_data->shared_opts.dependencies, newarg);
  +            } else {
  +                 push_count_chars(cmd_data->shared_opts.dependencies, newarg);
               }
  +#else
  +            push_count_chars(cmd_data->shared_opts.dependencies, newarg);
  +#endif
               break;
           case mInstall:
               /* If we've already recorded a library to install, we're most
  
  
  

Mime
View raw message