OS/2 limits a length of a DLL base name up to 8 characters. If a name of
a shared library is longer than 8 characters, OS/2 cannot load it. So the
option to specify a OS/2 DLL name shorter than 8 characters is needed.
As well as, OS/2 does not allow OS/2 DLL name to contain '.'.

* NEWS: Add news for -os2dllname.
* build-aux/ltmain.in (func_mode_help): Add a description for -os2dllname.
(fund_mode_link): Add -os2dllname.
* doc/libtool.texi: Add -os2dllname item.
* m4/libtool.m4: Introduce os2dllname_cmds for -os2dllname.
---
 NEWS                |    2 ++
 build-aux/ltmain.in |   11 +++++++++++
 doc/libtool.texi    |    4 ++++
 m4/libtool.m4       |   38 ++++++++++++++++++++++++++++++++++----
 4 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 1ca6d65..b2479db 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,8 @@ NEWS - list of user-visible changes between releases of GNU 
Libtool
 
         make check-local TESTSUITEFLAGS='-k "!expensive"'
 
+  - Added -os2dllname option to specify a OS/2 DLL name (OS/2 only)
+
 ** Bug fixes:
 
   - Fix a long-standing latent bug in autom4te include path for autotests
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 65b5a2d..0dea055 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -1819,6 +1819,7 @@ The following components of LINK-COMMAND are treated 
specially:
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
   -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -os2dllname NAME  specify a OS/2 DLL name(effect on OS/2 only)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -4856,6 +4857,11 @@ func_mode_link ()
          prev=
          continue
          ;;
+       os2dllname)
+         os2dllname_cmds="$ECHO $arg | cut -b -8 | tr . _"
+         prev=
+         continue
+         ;;
        precious_regex)
          precious_files_regex=$arg
          prev=
@@ -5165,6 +5171,11 @@ func_mode_link ()
        continue
        ;;
 
+      -os2dllname)
+       prev=os2dllname
+       continue
+       ;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 89c5d1a..65d63a3 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -1531,6 +1531,10 @@ Create @var{output-file} from the specified objects and 
libraries.
 @item -objectlist @var{file}
 Use a list of object files found in @var{file} to specify objects.
 
+@item -os2dllname @var{name}
+If @var{name} is specified, replace a name for a DLL with @var{suffix} (effect
+on OS/2 only)
+
 @item -precious-files-regex @var{regex}
 Prevents removal of files from the temporary output directory whose
 names match this regular expression.  You might specify @samp{\.bbg?$}
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 320d8b3..da29e57 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2286,6 +2286,7 @@ BEGIN {RS = " "; FS = "/|\n";} {
 else
   sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
 fi])
+os2dllname_cmds=
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -2810,9 +2811,15 @@ os2*)
   libname_spec='$name'
   shrext_cmds=.dll
   need_lib_prefix=no
-  library_names_spec='$libname$shared_ext $libname.a'
+  # OS/2 limits a length of a DLL basename up to 8 characters.
+  # So there is need to use a short name instead of a original name
+  # longer than 8 characters. And replace '.' with '_'.
+  os2dllname_cmds='$ECHO $libname | cut -b -8 | tr . _'
+  library_names_spec='`eval $os2dllname_cmds`${shared_ext} 
${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
 osf3* | osf4* | osf5*)
@@ -2958,6 +2965,7 @@ _LT_DECL([], [shlibpath_var], [0],[Shared library path 
variable])
 _LT_DECL([], [shlibpath_overrides_runpath], [0],
     [Is shlibpath searched before the hard-coded library search path?])
 _LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [os2dllname_cmds], [2], [Command to make a OS/2 DLL name])
 _LT_DECL([], [library_names_spec], [1],
     [[List of archive names.  First name is the real one, the rest are links.
     The last name is the one that the linker finds with -lNAME]])
@@ -4942,6 +4950,16 @@ _LT_EOF
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=".dll"
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY `eval $os2dllname_cmds` 
INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION 
\"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> 
$output_objdir/$libname.def~$ECHO "  MULTIPLE NONSHARED" >> 
$output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp 
$libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~$CC -Zdll 
-Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o 
$output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -5560,8 +5578,10 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > 
$output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> 
$output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " 
SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> 
$output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC 
-Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags 
$output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o 
$output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=".dll"
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY `eval $os2dllname_cmds` 
INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION 
\"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> 
$output_objdir/$libname.def~$ECHO "  MULTIPLE NONSHARED" >> 
$output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp 
$libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~$CC -Zdll 
-Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o 
$output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
@@ -6354,6 +6374,16 @@ if test yes != "$_lt_caught_CXX_error"; then
         _LT_DARWIN_LINKER_FEATURES($1)
        ;;
 
+      os2*)
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+       _LT_TAGVAR(hardcode_minus_L, $1)=yes
+       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+       shrext_cmds=".dll"
+       _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY `eval $os2dllname_cmds` 
INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION 
\"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> 
$output_objdir/$libname.def~$ECHO "  MULTIPLE NONSHARED" >> 
$output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp 
$libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~$CC -Zdll 
-Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+       _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o 
$output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+       ;;
+       
       dgux*)
         case $cc_basename in
           ec++*)
-- 
1.7.3.2


Reply via email to