Hi Ralf,

Thanks for the review!

Den 2010-06-26 22:42 skrev Ralf Wildenhues:
* Peter Rosin wrote on Fri, Jun 25, 2010 at 12:20:53AM CEST:
Den 2010-06-24 20:17 skrev Ralf Wildenhues:
I guess.  Wait.  Will mt be needed for programs also in packages using
only static libraries on w32, that maybe won't (or don't want to) use
the win32-dll option?  Then it needs to be outside of this option,
preferably in a new macro in libtool.m4, AC_REQUIREd by the macro(s)
that use(s) mt.

Yes, it might well be. It will be needed as soon as libtool is involved
with linking a program (and when it is using cl for that, of course).

Putting the check for mt outside the win32-dll option is right then.

Will it also be needed by packages using Automake but not Libtool?  IOW,
does your cl always create manifest files?  If not: when does it?

Yes, I suppose it does.

or should I add a macro somewhere (where?) that is more like LT_PATH_NM?
I.e. walks the PATH and discards mt:s that do not appear to be the
intended mt.

Let's try the easy way first, but after the AC_CHECK_TOOL, ensure -? is
accepted.  I don't want magnetic tape action anywhere due to libtool.

Here's a first shot.

I know that I haven't addressed the exeext comment
in your other reply, but I don't know what you want me to do. Please
advise further...

Step 0 would be using
   case ... in
   *.exe | *.EXE ) ...

because nobody mixes case.  Step 1 (optional) would be having a variable
in ltmain which contains exeext-normalized value (i.e., either always
with, or always without the extension), so you don't have to put the
case in the tag code.  Step 2: IIUC then this particular .EXE can only
come from some makefile(.am) author using upper-case .EXE *in* the file.
Slap that author.  ;-)

I don't really grok step 1, so I stopped at step 0. But I wish I could get
to the LART step though :-)

Do I need a NEWS entry for the new MT environment variable?

Yes that could help I guess.

Ok, added.

Is the name
MT in too much contention? I can easily imagine that this is not going
to be the first MT variable in the world...

codesearch.google.com exists to answer such questions for the open and
free software world.  Use the regex search interface.

Ok, looked and...

But what should it be instead?

$MANIFEST or $MANIFEST_TOOL?  What is Microsoft's verbose name for the
tool?  I don't have a big problem with MT though.

...I changed it to $MANIFEST_TOOL.

This is what mt (from Visual Studio 2005) says at the top:

Microsoft (R) Manifest Tool version 5.2.3790.2075
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

Other than that, I think you too have a couple unneeded eval in the
change.  I don't remember if I already approved of the patch but in case
not, you may commit after fixing issues, posting updated version, and
waiting 72h then, unless you have further questions you want answered.

I simply plagiarized those evals from the name lister macro above. Oh
well, I fixed that.

I have run the testsuite over the last couple of days on the following
systems, but without this last round of trivial changes (but I have
verified that the trivial changes didn't trivially break anything, i.e.
it looks good on one system). The regression testing was done against
3d2d3ef8 "Ensure getopts.m4sh is compatible with Autoconf-2.61 and newer."

MSYS/MinGW
MSYS/MSVC
Cygwin/gcc
Debian Linux cross to mingw32 (with Wine)
Debian Linux/gcc

No regressions and this is the (slightly edited for readability) summary
from the MSVC run (lots of expected failures since I don't have Automake
installed in this environment, I use Cygwin for that part):

abs_srcdir=`CDPATH="${ZSH_VERSION+.}:" && cd .. && pwd`; cd tests; \
        CONFIG_SHELL="/bin/sh" /bin/sh $abs_srcdir/tests/testsuite \
          MAKE="make" CC="/path/to/compile cl" CFLAGS="-MD -Zi -EHsc" \
        CPP="/path/to/compile cl -E" CPPFLAGS="" LD="link" LDFLAGS="" \
        LIBS="" LN_S="ln -s" NM="dumpbin -symbols" RANLIB=":" MT="mt" \
        STRIP=":" lt_INSTALL="/bin/install -c" OBJEXT="obj" EXEEXT=".exe" \
        SHELL="/bin/sh" CONFIG_SHELL="/bin/sh" CXX="/path/to/compile cl" \
        CXXFLAGS="-MD -Zi -EHsc" CXXCPP="/path/to/compile cl -E" F77="no" \
        FFLAGS="" FC="no" FCFLAGS="" GCJ="no" GCJFLAGS="-g -O2" \
        _lt_pkgdatadir="/path/to/libtool/msvc/.." \
        LIBTOOLIZE="/path/to/libtool/libtoolize" \
        LIBTOOL="/path/to/libtool/libtool" \
        tst_aclocaldir="/path/to/libtool/msvc/../libltdl/m4"

## ------------------------------- ##
## GNU Libtool 2.2.11a test suite. ##
## ------------------------------- ##

Libtoolize operation.

  1: libtoolize macro installation                   ok
  2: libtoolize macro directory mismatch error       ok
  3: libtoolize macro serial update                  ok
  4: libtoolize config files serial update           ok
  5: diagnose missing LT_CONFIG_LTDL_DIR             ok
  6: copy ltdl.m4 with shared macro directory        ok
  7: correctly parse LTDL_INIT from configure.ac     ok
  8: diagnose missing LTDL_INIT invocation           ok
  9: upgrading verbatim style aclocal.m4             expected failure 
(libtoolize.at:601)
 10: verbatim aclocal.m4 w/o AC_CONFIG_MACRO_DIR     expected failure 
(libtoolize.at:692)
 11: nonrecursive ltdl with AC_CONFIG_MACRO_DIR      ok
 12: subproject ltdl with non-shared directories     ok
 13: LIBTOOLIZE_OPTIONS                              ok
 14: cleanup old installation                        ok

Testing libtool functions.

 15: standard command line options                   ok
 16: mode short-hands                                ok
 17: duplicate members in archive tests              ok
 18: duplicate convenience archive names             FAILED 
(duplicate_conv.at:79)
 19: preserve duplicate convenience deps             skipped 
(duplicate_deps.at:66)
 20: passing CC flags through libtool                ok
 21: passing CXX flags through libtool               ok
 22: passing F77 flags through libtool               skipped (flags.at:24)
 23: passing FC flags through libtool                skipped (flags.at:24)
 24: passing GCJ flags through libtool               skipped (flags.at:24)
 25: inherited_linker_flags                          ok
 26: C convenience archives                          ok
 27: C++ convenience archives                        ok
 28: F77 convenience archives                        skipped 
(convenience.at:111)
 29: FC convenience archives                         skipped 
(convenience.at:171)
 30: Java convenience archives                       skipped 
(convenience.at:231)
 31: Link order test                                 FAILED (link-order.at:69)
 32: Link order of deplibs                           ok
 33: Failure tests                                   ok
 34: shlibpath_overrides_runpath                     skipped (shlibpath.at:54)
 35: Runpath in libtool library files                ok
 36: static linking flags for programs               FAILED (static.at:198)
 37: ccache -all-static                              FAILED (static.at:374)
 38: Export test                                     FAILED (export.at:157)
 39: sys_lib_search_path                             skipped (search-path.at:57)
 40: indirect convenience                            ok
 41: indirect uninstalled                            ok
 42: static library contains static library          UNEXPECTED PASS
 43: both of -o prog and -o prog$EXEEXT work         ok
 44: execute mode                                    ok
 45: bindir compile check                            ok
 46: bindir basic lib test                           ok
 47: bindir install tests                            ok
 48: cwrapper for uninstalled executables            ok
 49: deplib in subdir                                ok
 50: inferred tag                                    ok
 51: CXX inferred tag                                ok
 52: F77 inferred tag                                skipped (infer-tag.at:56)
 53: FC inferred tag                                 skipped (infer-tag.at:70)
 54: GCJ inferred tag                                skipped (infer-tag.at:84)
 55: localized compiler messages                     ok
 56: nocase library search                           ok
 57: Install tests                                   ok
 58: versioning                                      ok

DESTDIR tests

 59: Simple DESTDIR install                          ok
 60: DESTDIR with in-package deplibs                 ok

Support for older m4 interface.

 61: AM_PROG_LIBTOOL                                 ok
 62: AC_WITH_LTDL                                    expected failure 
(old-m4-iface.at:160)

Libtool subdir-objects support.

 63: C subdir-objects                                expected failure 
(am-subdir.at:78)
 64: C++ subdir-objects                              expected failure 
(am-subdir.at:146)

Libltdl functionality.

 65: lt_dlexit unloading libs                        FAILED (lt_dlexit.at:147)
 66: lt_dlopenadvise library loading                 FAILED (lt_dladvise.at:387)
 67: lt_dlopen error messages                        skipped (lt_dlopen.at:31)
 68: lt_dlopen archive                               skipped (lt_dlopen_a.at:94)
 69: lt_dlopenext error messages                     ok
 70: libdir of installed modules                     ok
 71: ltdl API                                        ok
 72: dlloader API                                    ok
 73: loadlibrary error messages                      FAILED (loadlibrary.at:238)
 74: syntax of .la files                             ok
 75: resident modules                                ok
 76: SList functionality                             ok
 77: enforced lib prefix                             FAILED 
(need_lib_prefix.at:170)

Standalone Libltdl.

 78: compiling softlinked libltdl                    ok
 79: compiling copied libltdl                        ok
 80: installable libltdl                             ok
 81: linking libltdl without autotools               ok

Subproject Libltdl.

 82: compiling softlinked libltdl                    expected failure 
(subproject.at:61)
 83: compiling copied libltdl                        expected failure 
(subproject.at:77)
 84: installable libltdl                             expected failure 
(subproject.at:95)
 85: linking libltdl without autotools               ok

Nonrecursive Automake Libltdl.

 86: compiling softlinked libltdl                    expected failure 
(nonrecursive.at:90)
 87: compiling copied libltdl                        expected failure 
(nonrecursive.at:114)
 88: installable libltdl                             expected failure 
(nonrecursive.at:140)

Recursive Automake Libltdl.

 89: compiling softlinked libltdl                    expected failure 
(recursive.at:68)
 90: compiling copied libltdl                        expected failure 
(recursive.at:88)
 91: installable libltdl                             expected failure 
(recursive.at:110)

C++ template tests.

 92: simple template test                            ok
 93: template test with subdirs                      ok

Constructors.

 94: C++ static constructors                         ok
 95: C++ exception handling                          FAILED (exceptions.at:268)

libtool script generation.

 96: config.status                                   expected failure 
(early-libtool.at:109)
 97: config.lt                                       expected failure 
(early-libtool.at:216)

Libtool usage in GCC

 98: AC_NO_EXECUTABLES                               expected failure 
(no-executables.at:74)

Detecting identical deplibs.

 99: build tree relpaths                             expected failure 
(deplibs-ident.at:68)

configure interface to libltdl.

100: installable libltdl                             expected failure 
(configure-iface.at:144)
101: --with-ltdl-include/lib                         expected failure 
(configure-iface.at:227)
102: --with-included-ltdl                            expected failure 
(configure-iface.at:282)
103: convenience libltdl                             expected failure 
(configure-iface.at:321)

Libtool stress test.

104: Link option thorough search test                FAILED (stresstest.at:260)
105: Run tests with low max_cmd_len                  FAILED (cmdline_wrap.at:43)
106: override pic_flag at configure time             FAILED (pic_flag.at:48)

Mac OS X tests

107: darwin fat compile                              skipped (darwin.at:42)
108: darwin concurrent library extraction            ok
109: darwin gdb debug information                    skipped (darwin.at:154)
110: deplibs without file command                    ok

## ------------- ##
## Test results. ##
## ------------- ##

ERROR: 94 tests were run,
1 passed unexpectedly,
35 failed (22 expected failures).
16 tests were skipped.

The reason for the failures have been beaten to death previously, some
of the failures have fixes, some not. I'm not going through that here.

Cheers,
Peter
commit 041240c34bf63fab6d6f6370982c896d9e530c1a
Author: Peter Rosin <peda@lysator.liu.se>
Date:   Mon Jun 28 09:31:11 2010 +0200

    For MSVC, embed the manifest as a resource in the executable.
    
    Fixes a lot of testsuite failures with MSVC 2003 (v8.0) and
    above (and perhaps also MSVC .Net) related to running programs
    that have been moved (e.g. installed) without their manifests
    also having been moved.
    
    * libltdl/m4/libtool.m4 (_LT_PATH_MANIFEST_TOOL): New macro
    that locates the Manifest Tool (mt) and verifies that it is
    indeed the manifest tool. The result is stored in the new
    variable MANIFEST_TOOL.
    (_LT_LINKER_SHLIBS) <postlink_cmds>: New tag variable.
    [ cygwin, mingw, cegcc ] <cl*>: Embed the manifest file as a
    resource. Make sure the embedding work regardless of if the
    @OUTPUT@ file name includes a trailing $EXEEXT.
    (_LT_LANG_CXX_CONFIG): Likewise.
    (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG): Require the above
    _LT_PATH_MANIFEST_TOOL.
    * libltdl/config/ltmain.m4sh (func_mode_link): After linking
    a program, replace @OUTPUT@ in $postlink_cmds and then execute
    the commands.
    * doc/libtool.texi (libtool script contents): Document
    new postlink_cmds variable.
    (LT_INIT): Add that the MANIFEST_TOOL environment variable can
    be used to override the manifest tool to use.
    * tests/exeext.at: New. Make sure linking with both -o prog
    and -o prog$EXEEXT works.
    * Makefile.am (TESTSUITE_AT): Update.
    (TESTS_ENVIRONMENT): Propagate $(MANIFEST_TOOL) to the
    testsuite.
    * NEWS: Add note of the new MANIFEST_TOOL environment variable.

diff --git a/ChangeLog b/ChangeLog
index 12e9168..1168bb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2010-06-28  Peter Rosin  <peda@lysator.liu.se>
+
+	For MSVC, embed the manifest as a resource in the executable.
+	Fixes a lot of testsuite failures with MSVC 2003 (v8.0) and
+	above (and perhaps also MSVC .Net) related to running programs
+	that have been moved (e.g. installed) without their manifests
+	also having been moved.
+	* libltdl/m4/libtool.m4 (_LT_PATH_MANIFEST_TOOL): New macro
+	that locates the Manifest Tool (mt) and verifies that it is
+	indeed the manifest tool. The result is stored in the new
+	variable MANIFEST_TOOL.
+	(_LT_LINKER_SHLIBS) <postlink_cmds>: New tag variable.
+	[ cygwin, mingw, cegcc ] <cl*>: Embed the manifest file as a
+	resource. Make sure the embedding work regardless of if the
+	@OUTPUT@ file name includes a trailing $EXEEXT.
+	(_LT_LANG_CXX_CONFIG): Likewise.
+	(_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG): Require the above
+	_LT_PATH_MANIFEST_TOOL.
+	* libltdl/config/ltmain.m4sh (func_mode_link): After linking
+	a program, replace @OUTPUT@ in $postlink_cmds and then execute
+	the commands.
+	* doc/libtool.texi (libtool script contents): Document
+	new postlink_cmds variable.
+	(LT_INIT): Add that the MANIFEST_TOOL environment variable can
+	be used to override the manifest tool to use.
+	* tests/exeext.at: New. Make sure linking with both -o prog
+	and -o prog$EXEEXT works.
+	* Makefile.am (TESTSUITE_AT): Update.
+	(TESTS_ENVIRONMENT): Propagate $(MANIFEST_TOOL) to the
+	testsuite.
+	* NEWS: Add note of the new MANIFEST_TOOL environment variable.
+
 2010-06-24  Peter Rosin  <peda@lysator.liu.se>
 
 	Add MSVC support.
diff --git a/Makefile.am b/Makefile.am
index 320a2a3..ef3c984 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -472,6 +472,7 @@ TESTSUITE_AT	= tests/testsuite.at \
 		  tests/search-path.at \
 		  tests/indirect_deps.at \
 		  tests/archive-in-archive.at \
+		  tests/exeext.at \
 		  tests/execute-mode.at \
 		  tests/bindir.at \
 		  tests/cwrapper.at \
@@ -521,6 +522,7 @@ TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
 	CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
 	LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
 	M4SH="$(M4SH)" SED="$(SED)" STRIP="$(STRIP)" lt_INSTALL="$(INSTALL)" \
+	MANIFEST_TOOL="$(MANIFEST_TOOL)" \
 	OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \
 	SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \
 	CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \
diff --git a/NEWS b/NEWS
index 5735b01..95fa97d 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,9 @@ New in 2.2.12 2010-08-??: git version 2.2.11a, Libtool team:
 
 * Changes in supported systems or compilers:
   - Initial support for the Microsoft C/C++ Compiler, with help from
-    the compile script in unreleased Automake 1.12.
+    the compile script in unreleased Automake 1.12. Override the manifest
+    tool used to embed the manifest resource through the environment
+    variable MANIFEST_TOOL.
 
 New in 2.2.10 2010-06-10: git version 2.2.9a, Libtool team:
 
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 7ae2c66..af6e13d 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -2306,6 +2306,11 @@ Program to use rather than checking for @command{as}.  Only used on
 Cygwin/MS-Windows at the moment.
 @end defvar
 
+@defvar MANIFEST_TOOL
+Program to use rather than checking for @command{mt}, the Manifest Tool.
+Only used on Cygwin/MS-Windows at the moment.
+@end defvar
+
 With 1.3 era libtool, if you wanted to know any details of what
 libtool had discovered about your architecture and environment, you
 had to run the script with @option{--config} and grep through the
@@ -6199,6 +6204,15 @@ Commands run after installing a shared or static library, respectively.
 Commands run after uninstalling a shared or static library, respectively.
 @end defvar
 
+@defvar postlink_cmds
+Commands necessary for finishing linking programs. @code{postlink_cmds}
+are executed immediately after the program is linked. Any occurance of
+the string @code{@@OUTPUT@@} in @code{postlink_cmds} is replaced by the
+name of the created executable (i.e. not the wrapper, if a wrapper is
+generated) prior to execution. Normally disabled (i.e.
+@code{postlink_cmds} empty).
+@end defvar
+
 @defvar reload_cmds
 @defvarx reload_flag
 Commands to create a reloadable object.
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 46a8aa3..519051c 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -7423,6 +7423,11 @@ EOF
 	exit_status=0
 	func_show_eval "$link_command" 'exit_status=$?'
 
+	if test -n "$postlink_cmds"; then
+	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g'`
+	  func_execute_cmds "$postlink_cmds" 'exit $?'
+	fi
+
 	# Delete the generated files.
 	if test -f "$output_objdir/${outputname}S.${objext}"; then
 	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
@@ -7468,6 +7473,12 @@ EOF
 	$opt_dry_run || $RM $output
 	# Link the executable and exit
 	func_show_eval "$link_command" 'exit $?'
+
+	if test -n "$postlink_cmds"; then
+	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g'`
+	  func_execute_cmds "$postlink_cmds" 'exit $?'
+	fi
+
 	exit $EXIT_SUCCESS
       fi
 
@@ -7501,6 +7512,11 @@ EOF
 
       func_show_eval "$link_command" 'exit $?'
 
+      if test -n "$postlink_cmds"; then
+	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+	func_execute_cmds "$postlink_cmds" 'exit $?'
+      fi
+
       # Now create the wrapper script.
       func_verbose "creating $output"
 
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 18eedb3..0a93a58 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -3320,6 +3320,28 @@ dnl AC_DEFUN([AM_PROG_NM], [])
 dnl AC_DEFUN([AC_PROG_NM], [])
 
 
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+  [lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
+  fi
+  rm -f conftest*])
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -4256,6 +4278,7 @@ _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
 m4_defun([_LT_LINKER_SHLIBS],
 [AC_REQUIRE([LT_PATH_LD])dnl
 AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_DECL_SED])dnl
@@ -4855,6 +4878,15 @@ _LT_EOF
 	_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+	  case $lt_outputfile in
+	    *.exe | *.EXE) ;;
+	    *) lt_outputfile="$lt_outputfile.exe" ;;
+	  esac~
+	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	    $MANIFEST_TOOL -manifest "$lt_outputfile.manifest" -outputresource:"$lt_outputfile" || exit 1;
+	    $RM "$lt_outputfile.manifest";
+	  fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5408,6 +5440,8 @@ _LT_TAGDECL([], [include_expsyms], [1],
     [Symbols that must always be exported])
 _LT_TAGDECL([], [prelink_cmds], [2],
     [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+    [Commands necessary for finishing linking programs])
 _LT_TAGDECL([], [file_list_spec], [1],
     [Specify filename containing input files])
 dnl FIXME: Not yet implemented
@@ -5509,6 +5543,7 @@ CC="$lt_save_CC"
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
     ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
     (test "X$CXX" != "Xg++"))) ; then
@@ -5831,6 +5866,15 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+	    case $lt_outputfile in
+	      *.exe *.EXE) ;;
+	      *) lt_outputfile="$lt_outputfile.exe" ;;
+	    esac~
+	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	      $MANIFEST_TOOL -manifest "$lt_outputfile.manifest" -outputresource:"$lt_outputfile" || exit 1;
+	      $RM "$lt_outputfile.manifest";
+	    fi'
 	  ;;
 	*)
 	  # g++
diff --git a/tests/exeext.at b/tests/exeext.at
new file mode 100644
index 0000000..ee5d755
--- /dev/null
+++ b/tests/exeext.at
@@ -0,0 +1,53 @@
+# exeext.at -- ensure that exeext handling works  -*- Autotest -*-
+#
+#   Copyright (C) 2010 Free Software Foundation, Inc.
+#   Written by Peter Rosin
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+
+AT_SETUP([both of -o prog and -o prog$EXEEXT work])
+AT_KEYWORDS([libtool])
+
+AT_CHECK([test -n "$EXEEXT" || exit 77])
+
+bin=`pwd`/bin
+binext=`pwd`/binext
+mkdir src $bin srcext $binext
+
+AT_DATA(src/prog.c,
+[[
+int main(void) { return 0; }
+]])
+
+$CC $CPPFLAGS $CFLAGS -c src/prog.c -o src/prog.$OBJEXT
+
+AT_CHECK($LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/prog src/prog.$OBJEXT,
+	 [0], [ignore], [ignore])
+AT_CHECK($LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o srcext/prog$EXEEXT src/prog.$OBJEXT,
+	 [0], [ignore], [ignore])
+
+$LIBTOOL --mode=install cp src/prog $bin/prog
+$LIBTOOL --mode=install cp srcext/prog$EXEEXT $binext/prog$EXEEXT
+
+LT_AT_EXEC_CHECK([$bin/prog])
+LT_AT_EXEC_CHECK([$binext/prog$EXEEXT])
+
+AT_CLEANUP

Reply via email to