[PATCH] OS/2 patches

2012-11-04 Thread KO Myung-Hun
Hi/2.

These are the patches for OS/2.

Review, please.




[PATCH 1/9] libtool: add -shortname option

2012-11-04 Thread KO Myung-Hun
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 short name is needed.

* NEWS: Add news for -shortname.
* build-aux/ltmain.in(func_mode_help): Add a description for -shortname.
(fund_mode_link): Add -shortname.
* doc/libtool.texi: Add -shortname item.
* m4/libtool.m4: Introduce shortname_cmds for -shortname.
---
 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 081e82f..33beb68 100644
--- a/NEWS
+++ b/NEWS
@@ -98,6 +98,8 @@ New in 2.4.2 2011-10-17: git version 2.4.1a, Libtool team:
 package names.  This can be used to build some static libraries with PIC
 objects while building others with non-PIC objects.
 
+  - Added -shortname option to specify a short name for a DLL (OS/2 only)
+
   - Initial support for Go, using the gccgo compiler.
 
   - On Mac OS X .dylib is now tried as well as .so with
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 6151ee9..4e53936 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -1797,6 +1797,7 @@ The following components of LINK-COMMAND are treated 
specially:
   -rpath LIBDIR the created library will eventually be installed in LIBDIR
   -R[ ]LIBDIR   add LIBDIR to the runtime path of programs and libraries
   -shared   only do dynamic linking of libtool libraries
+  -shortname NAME   specify a short name for a DLL(effect on OS/2 only)
   -shrext SUFFIXoverride the standard shared library file extension
   -static   do not do any dynamic linking of uninstalled libtool 
libraries
   -static-libtool-libs
@@ -4827,6 +4828,11 @@ func_mode_link ()
  prev=
  continue
  ;;
+   shortname)
+ shortname_cmds="$ECHO $arg | cut -b -8"
+ prev=
+ continue
+ ;;
shrext)
  shrext_cmds=$arg
  prev=
@@ -5147,6 +5153,11 @@ func_mode_link ()
continue
;;
 
+  -shortname)
+   prev=shortname
+   continue
+   ;;
+
   -shrext)
prev=shrext
continue
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 57b5485..14082ba 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -1567,6 +1567,10 @@ In the later case, libtool will signal an error if it 
was configured
 with @option{--disable-shared}, or if the host does not support shared
 libraries.
 
+@item -shortname @var{name}
+If @var{name} is specified, replace a name for a DLL with @var{suffix} (effect
+on OS/2 only)
+
 @item -shrext @var{suffix}
 If @var{output-file} is a libtool library, replace the system's standard
 file name extension for shared libraries with @var{suffix} (most systems
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 37f7d7c..f269fc4 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2228,6 +2228,7 @@ BEGIN {RS = " "; FS = "/|\n";} {
 else
   sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
 fi])
+shortname_cmds=
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -2732,9 +2733,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.
+  shortname_cmds='$ECHO $libname | cut -b -8'
+  library_names_spec='`eval $shortname_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*)
@@ -2880,6 +2887,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([], [shortname_cmds], [2], [Command to make a short 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]])
@@ -4769,6 +4777,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 $shortname_cmds` 
INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION 
\"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> 
$output_objdir/$libname.def~$ECHO "  MULTIPLE NONSHARED" >> 

[PATCH 2/9] libtool: don't eliminate duplications in $postdeps and $predeps on OS/2

2012-11-04 Thread KO Myung-Hun
* build-aux/ltmain.h(libtool_validate_options): Add *os2* to the list.
---
 build-aux/ltmain.in |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 4e53936..ede32eb 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -497,7 +497,7 @@ libtool_validate_options ()
 test : = "$debug_cmd" || func_append preserve_args " --debug"
 
 case $host in
-  *cygwin* | *mingw* | *pw32* | *cegcc*)
+  *cygwin* | *mingw* | *pw32* | *cegcc* | *os2*)
 # don't eliminate duplications in $postdeps and $predeps
 opt_duplicate_compiler_generated_deps=:
 ;;
-- 
1.7.3.2




[PATCH 3/9] libtool: set lt_prog_compiler_static to -Bstatic on OS/2

2012-11-04 Thread KO Myung-Hun
* m4/libtool.m4(_LT_COMPILER_PIC): Same as the title.
---
 m4/libtool.m4 |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index f269fc4..3d36d5d 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -3901,6 +3901,11 @@ m4_if([$1], [CXX], [
   # (--disable-auto-import) libraries
   m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+  case $host_os in
+  os2*)
+_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+;;
+  esac
   ;;
 darwin* | rhapsody*)
   # PIC is the default on this platform
@@ -4220,6 +4225,11 @@ m4_if([$1], [CXX], [
   # (--disable-auto-import) libraries
   m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+  case $host_os in
+  os2*)
+_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+;;
+  esac
   ;;
 
 darwin* | rhapsody*)
@@ -4317,6 +4327,11 @@ m4_if([$1], [CXX], [
   # built for inclusion in a dll (and should export symbols for example).
   m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+  case $host_os in
+  os2*)
+_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+;;
+  esac
   ;;
 
 hpux9* | hpux10* | hpux11*)
-- 
1.7.3.2




[PATCH 4/9] ltdl: OS/2 uses other APIs to load a DLL than LoadLibrary() on Windows

2012-11-04 Thread KO Myung-Hun
*m4/ltdl.m4: Remove os2* from a list for loadlibrary.la.
---
 m4/ltdl.m4 |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/m4/ltdl.m4 b/m4/ltdl.m4
index b129716..28beadb 100644
--- a/m4/ltdl.m4
+++ b/m4/ltdl.m4
@@ -703,7 +703,7 @@ darwin[[1567]].*)
 beos*)
   LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la"
   ;;
-cygwin* | mingw* | os2* | pw32*)
+cygwin* | mingw* | pw32*)
   AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include ]])
   LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la"
   ;;
-- 
1.7.3.2




[PATCH 5/9] libtool: there is no need to relink DLLs on OS/2

2012-11-04 Thread KO Myung-Hun
*build-aux/ltmain.in(func_mode_link): Set need_relink to no on OS/2.
---
 build-aux/ltmain.in |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index ede32eb..10396a7 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -6098,7 +6098,7 @@ func_mode_link ()
if test -n "$library_names" &&
   { test no = "$use_static_libs" || test -z "$old_library"; }; then
  case $host in
- *cygwin* | *mingw* | *cegcc*)
+ *cygwin* | *mingw* | *cegcc* | *os2*)
  # No point in relinking DLLs because paths are not encoded
  func_append notinst_deplibs " $lib"
  need_relink=no
-- 
1.7.3.2




[PATCH 6/9] libtool: set lt_cv_deplibs_check_method to pass_all on OS/2

2012-11-04 Thread KO Myung-Hun
*m4/libtool.m4(_LT_CHECK_MAGIC_METHOD): Same as the title.
---
 m4/libtool.m4 |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 3d36d5d..3a80989 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -3345,6 +3345,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
-- 
1.7.3.2




[PATCH 7/9] libtool: support -Zxxx options used on OS/2

2012-11-04 Thread KO Myung-Hun
*build-aux/ltmain.in(fund_mode_link): Add -Z* case.
---
 build-aux/ltmain.in |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 10396a7..3fcaed5 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -5272,6 +5272,17 @@ func_mode_link ()
 continue
 ;;
 
+  # OS/2 uses -Zxxx to specify OS/2-specific options
+  -Z*)
+   compiler_flags="$compiler_flags $arg"
+   func_append compile_command " $arg"
+   func_append finalize_command " $arg"
+   case $arg in
+   -Zlinker | -Zstack) prev=xcompiler;;
+   esac
+   continue
+   ;;
+
   # Some other compiler flag.
   -* | +*)
 func_quote_for_eval "$arg"
-- 
1.7.3.2




[PATCH 8/9] libtool: create an import libraries instead of links to the real library on OS/2

2012-11-04 Thread KO Myung-Hun
Link is not supported on OS/2.
*build-aux/ltmain.in(fund_mode_install): Create an import library.
(fund_mode_link): Likewise.
---
 build-aux/ltmain.in |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 3fcaed5..bf989d7 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -2385,8 +2385,17 @@ func_mode_install ()
# so we also need to try rm && ln -s.
for linkname
do
- test "$linkname" != "$realname" \
-   && func_show_eval "(cd $destdir && { $LN_S -f $realname 
$linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ if test "$linkname" != "$realname"; then
+   case $host_os in
+   os2*)
+ # Create import libraries instead of links on OS/2
+ func_show_eval "(emximp -o $destdir/$linkname 
$dir/${linkname%%_dll.$libext}.def)"
+ ;;
+   *)
+ func_show_eval "(cd $destdir && { $LN_S -f $realname 
$linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ ;;
+   esac
+ fi
done
  fi
 
@@ -7997,7 +8006,15 @@ EOF
# Create links to the real library.
for linkname in $linknames; do
  if test "$realname" != "$linkname"; then
-   func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S 
"$realname" "$linkname")' 'exit $?'
+   case $host_os in
+   os2*)
+ # Create import libraries instead of links on OS/2
+ func_show_eval '(emximp -o $output_objdir/$linkname 
$output_objdir/$libname.def)' 'exit $?'
+ ;;
+   *)
+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S 
"$realname" "$linkname")' 'exit $?'
+ ;;
+   esac
  fi
done
 
-- 
1.7.3.2




[PATCH 9/9] libtool: fix a problem that it fails to find proper libraries if .la is a dependency on OS/2

2012-11-04 Thread KO Myung-Hun
*build-aux/ltmain.in(func_mode_link): Same as the title.
---
 build-aux/ltmain.in |  103 +++
 1 files changed, 79 insertions(+), 24 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index bf989d7..7de3676 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -5637,33 +5637,66 @@ func_mode_link ()
# If $allow_libtool_libs_with_static_runtimes && $deplib is a 
stdlib,
# We need to do some special things here, and not later.
if test yes = "$allow_libtool_libs_with_static_runtimes"; then
- case " $predeps $postdeps " in
- *" $deplib "*)
-   if func_lalib_p "$lib"; then
- library_names=
- old_library=
- func_source "$lib"
- for l in $old_library $library_names; do
-   ll=$l
- done
- if test "X$ll" = "X$old_library"; then # only static version 
available
-   found=false
-   func_dirname "$lib" "" "."
-   ladir=$func_dirname_result
-   lib=$ladir/$old_library
-   if test prog,link = "$linkmode,$pass"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
-   else
- deplibs="$deplib $deplibs"
- test lib = "$linkmode" && newdependency_libs="$deplib 
$newdependency_libs"
+ case $host_os in
+ os2*)
+   case " $predeps $postdeps " in
+   *" $deplib "*) ;;
+   *)
+ if func_lalib_p "$lib"; then
+   library_names=
+   old_library=
+   func_source "$lib"
+   for l in $old_library $library_names; do
+ ll="$l"
+   done
+   if test "X$ll" = "X$old_library" ; then # only static 
version available
+ found=false
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test prog,link = "$linkmode,$pass"; then
+   compile_deplibs="$deplib $compile_deplibs"
+   finalize_deplibs="$deplib $finalize_deplibs"
+ else
+   deplibs="$deplib $deplibs"
+   test lib = "$linkmode" && newdependency_libs="$deplib 
$newdependency_libs"
+ fi
+ continue
fi
-   continue
  fi
-   fi
+ ;;
+   esac
;;
- *) ;;
- esac
+ *)
+   case " $predeps $postdeps " in
+   *" $deplib "*)
+ if func_lalib_p "$lib"; then
+   library_names=
+   old_library=
+   func_source "$lib"
+   for l in $old_library $library_names; do
+ ll="$l"
+   done
+   if test "X$ll" = "X$old_library" ; then # only static 
version available
+ found=false
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test prog,link = "$linkmode,$pass"; then
+   compile_deplibs="$deplib $compile_deplibs"
+   finalize_deplibs="$deplib $finalize_deplibs"
+ else
+   deplibs="$deplib $deplibs"
+   test lib = "$linkmode" && newdependency_libs="$deplib 
$newdependency_libs"
+ fi
+ continue
+   fi
+ fi
+ ;;
+   *) ;;
+   esac
+   ;;
+ esac # case $host_os in
fi
  else
# deplib doesn't seem to be a libtool library
@@ -6501,6 +6534,28 @@ func_mode_link ()
fi
  fi
  ;;
+   *-*-os2*)
+ depdepl=
+ deplibrary_names=
+ if test "$build_old_libs" != yes && test "$link_static" != 
yes ; then
+   eval deplibrary_names=`${SED} -n -e 
's/^library_names=\(.*\)$/\1/p' $deplib`
+ fi
+ if test -z "$deplibrary_names" ; then
+   # fall back to static library
+   eval deplibrary_names=`${SED} -n -e 
's/^old_library=\(.*\)$/\1/p' $deplib`
+ fi
+ if test -n "$deplibrary_names" ; then
+   for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+   don