Generate the __ASM_NAME and __ASM_FUNC macros directly from
configure.
Simplified the WINE_TRY_ASM_LINK test.
Moved DECL_GLOBAL_CONSTRUCTOR to wine/port.h.

diff --git a/aclocal.m4 b/aclocal.m4
index 17a4c85..af46003 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -76,14 +76,8 @@
 dnl Usage: WINE_TRY_ASM_LINK(asm-code,includes,function,[action-if-found,[action-if-not-found]])
 dnl
 AC_DEFUN([WINE_TRY_ASM_LINK],
-[ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-[$1]
-EOF
-AC_TRY_LINK([$2],[$3],[$4],[$5])
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs])
+[AC_TRY_LINK([static void ac_asm(void) { asm([$1]); }
+[$2]],[$3],[$4],[$5])])
 
 dnl **** Check if we can link an empty program with special CFLAGS ****
 dnl
diff --git a/configure b/configure
index 3ddb266..87e53be 100755
--- a/configure
+++ b/configure
@@ -9441,22 +9441,15 @@
 fi
 
 
-echo "$as_me:$LINENO: checking whether .type must sit inside a .def directive" >&5
-echo $ECHO_N "checking whether .type must sit inside a .def directive... $ECHO_C" >&6
-if test "${ac_cv_c_type_in_def+set}" = set; then
+echo "$as_me:$LINENO: checking how to define a function in assembly code" >&5
+echo $ECHO_N "checking how to define a function in assembly code... $ECHO_C" >&6
+if test "${ac_cv_asm_func_def+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-	.globl _ac_test
-	.def _ac_test; .scl 2; .type 32; .endef
-_ac_test:
-	.long 0
-EOF
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+static void ac_asm(void) { asm("\t.globl _ac_test\n\t.def _ac_test; .scl 2; .type 32; .endef\n_ac_test:\t.long 0"); }
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -9484,44 +9477,14 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_c_type_in_def="yes"
+  ac_cv_asm_func_def=".def"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_c_type_in_def="no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_type_in_def" >&5
-echo "${ECHO_T}$ac_cv_c_type_in_def" >&6
-if test "$ac_cv_c_type_in_def" = "yes"
-then
-
-cat >>confdefs.h <<\_ACEOF
-#define NEED_TYPE_IN_DEF 1
-_ACEOF
-
-fi
-
-
-echo "$as_me:$LINENO: checking whether @function is defined" >&5
-echo $ECHO_N "checking whether @function is defined... $ECHO_C" >&6
-if test "${ac_cv_at_function_is_defined+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-	.globl _ac_test
-	.type _ac_test,@function
-_ac_test:
-	.long 0
-EOF
 cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+static void ac_asm(void) { asm("\t.globl _ac_test\n\t.type _ac_test,@function\n_ac_test:\t.long 0"); }
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -9549,26 +9512,80 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_at_function_is_defined="yes"
+  ac_cv_asm_func_def=".type @function"
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-ac_cv_at_function_is_defined="no"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+static void ac_asm(void) { asm("\t.globl _ac_test\n\t.type _ac_test,2\n_ac_test:\t.long 0"); }
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_asm_func_def=".type 2"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_asm_func_def="unknown"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs
 fi
-echo "$as_me:$LINENO: result: $ac_cv_at_function_is_defined" >&5
-echo "${ECHO_T}$ac_cv_at_function_is_defined" >&6
-if test "$ac_cv_at_function_is_defined" = "yes"
-then
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_asm_func_def" >&5
+echo "${ECHO_T}$ac_cv_asm_func_def" >&6
 
-cat >>confdefs.h <<\_ACEOF
-#define AT_FUNCTION_IS_DEFINED 1
+
+
+case "$ac_cv_asm_func_def" in
+  ".def")
+     cat >>confdefs.h <<\_ACEOF
+#define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
 _ACEOF
-
-fi
+ ;;
+  ".type @function")
+     cat >>confdefs.h <<\_ACEOF
+#define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
+_ACEOF
+ ;;
+  ".type 2")
+     cat >>confdefs.h <<\_ACEOF
+#define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",2"
+_ACEOF
+ ;;
+  *)
+     cat >>confdefs.h <<\_ACEOF
+#define __ASM_FUNC(name) ""
+_ACEOF
+ ;;
+esac
 
 
 echo "$as_me:$LINENO: checking whether external symbols need an underscore prefix" >&5
@@ -9576,16 +9593,10 @@
 if test "${ac_cv_c_extern_prefix+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-	.globl _ac_test
-_ac_test:
-	.long 0
-EOF
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+static void ac_asm(void) { asm(".globl _ac_test\n_ac_test:\t.long 0"); }
 extern int ac_test;
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -9620,16 +9631,21 @@
 ac_cv_c_extern_prefix="no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs
 fi
 echo "$as_me:$LINENO: result: $ac_cv_c_extern_prefix" >&5
 echo "${ECHO_T}$ac_cv_c_extern_prefix" >&6
+
+
+
 if test "$ac_cv_c_extern_prefix" = "yes"
 then
+  cat >>confdefs.h <<\_ACEOF
+#define __ASM_NAME(name) "_" name
+_ACEOF
 
-cat >>confdefs.h <<\_ACEOF
-#define NEED_UNDERSCORE_PREFIX 1
+else
+  cat >>confdefs.h <<\_ACEOF
+#define __ASM_NAME(name) name
 _ACEOF
 
 fi
@@ -9640,17 +9656,10 @@
 if test "${ac_cv_c_stdcall_decoration+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-	.globl _ac_test@0
-_ac_test@0:
-	.globl ac_test@0
-ac_test@0:
-EOF
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+static void ac_asm(void) { asm("\t.globl _ac_test@0\n_ac_test@0:\n\t.globl ac_test@0\nac_test@0:"); }
 extern void __attribute__((__stdcall__)) ac_test(void);
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -9685,8 +9694,6 @@
 ac_cv_c_stdcall_decoration="no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs
 fi
 echo "$as_me:$LINENO: result: $ac_cv_c_stdcall_decoration" >&5
 echo "${ECHO_T}$ac_cv_c_stdcall_decoration" >&6
@@ -9705,14 +9712,10 @@
 if test "${ac_cv_c_asm_string+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_try_asm_link_saved_libs=$LIBS
-LIBS="conftest_asm.s $LIBS"
-cat > conftest_asm.s <<EOF
-	.string "test"
-EOF
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
+static void ac_asm(void) { asm(".string \"test\""); }
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -9747,8 +9750,6 @@
 ac_cv_c_asm_string="no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-rm -f conftest_asm.s
-LIBS=$ac_try_asm_link_saved_libs
 fi
 echo "$as_me:$LINENO: result: $ac_cv_c_asm_string" >&5
 echo "${ECHO_T}$ac_cv_c_asm_string" >&6
diff --git a/configure.ac b/configure.ac
index 86cb918..91d3505 100644
--- a/configure.ac
+++ b/configure.ac
@@ -643,61 +643,53 @@
   fi
 fi
 
-dnl **** Check if we need to place .type inside a .def directive ****
+dnl **** Check how to define a function in assembly code ****
 
-AC_CACHE_CHECK([whether .type must sit inside a .def directive], ac_cv_c_type_in_def,
-    WINE_TRY_ASM_LINK(
-[	.globl _ac_test
-	.def _ac_test; .scl 2; .type 32; .endef
-_ac_test:
-	.long 0],,,
-    ac_cv_c_type_in_def="yes",ac_cv_c_type_in_def="no"))
-if test "$ac_cv_c_type_in_def" = "yes"
-then
-  AC_DEFINE(NEED_TYPE_IN_DEF, 1, [Define if .type asm directive must be inside a .def directive])
-fi
+AC_CACHE_CHECK([how to define a function in assembly code], ac_cv_asm_func_def,
+  WINE_TRY_ASM_LINK(
+      ["\t.globl _ac_test\n\t.def _ac_test; .scl 2; .type 32; .endef\n_ac_test:\t.long 0"],,,
+      ac_cv_asm_func_def=".def",
+    [WINE_TRY_ASM_LINK(["\t.globl _ac_test\n\t.type _ac_test,@function\n_ac_test:\t.long 0"],,,
+      ac_cv_asm_func_def=".type @function",
+    [WINE_TRY_ASM_LINK(["\t.globl _ac_test\n\t.type _ac_test,2\n_ac_test:\t.long 0"],,,
+      ac_cv_asm_func_def=".type 2",
+      ac_cv_asm_func_def="unknown")])]))
 
-dnl **** Check if @function is defined ****
-
-AC_CACHE_CHECK([whether @function is defined], ac_cv_at_function_is_defined,
-    WINE_TRY_ASM_LINK(
-[	.globl _ac_test
-	.type _ac_test,@function
-_ac_test:
-	.long 0],,,
-    ac_cv_at_function_is_defined="yes",ac_cv_at_function_is_defined="no"))
-if test "$ac_cv_at_function_is_defined" = "yes"
-then
-  AC_DEFINE(AT_FUNCTION_IS_DEFINED, 1, [Define if @function is defined])
-fi
+AH_TEMPLATE(__ASM_FUNC,[Define to a macro to generate an assembly function directive])
+case "$ac_cv_asm_func_def" in
+  ".def")
+     AC_DEFINE([__ASM_FUNC(name)], [".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"]) ;;
+  ".type @function")
+     AC_DEFINE([__ASM_FUNC(name)], [".type " __ASM_NAME(name) ",@function"]) ;;
+  ".type 2")
+     AC_DEFINE([__ASM_FUNC(name)], [".type " __ASM_NAME(name) ",2"]) ;;
+  *)
+     AC_DEFINE([__ASM_FUNC(name)], [""]) ;;
+esac
 
 dnl **** Check for underscore on external symbols ****
 
 AC_CACHE_CHECK([whether external symbols need an underscore prefix], ac_cv_c_extern_prefix,
-    WINE_TRY_ASM_LINK(
-[	.globl _ac_test
-_ac_test:
-	.long 0],
-[extern int ac_test;],
-[if (ac_test) return 1],
-    ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no"))
+    WINE_TRY_ASM_LINK([".globl _ac_test\n_ac_test:\t.long 0"],
+                      [extern int ac_test;],
+                      [if (ac_test) return 1],
+                      ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no"))
+
+AH_TEMPLATE(__ASM_NAME,[Define to a macro to generate an assembly name from a C symbol])
 if test "$ac_cv_c_extern_prefix" = "yes"
 then
-  AC_DEFINE(NEED_UNDERSCORE_PREFIX, 1,
-            [Define if symbols declared in assembly code need an underscore prefix])
+  AC_DEFINE([__ASM_NAME(name)], ["_" name])
+else
+  AC_DEFINE([__ASM_NAME(name)], [name])
 fi
 
 dnl **** Check whether stdcall symbols need to be decorated ****
 
 AC_CACHE_CHECK([whether stdcall symbols need to be decorated], ac_cv_c_stdcall_decoration,
-    WINE_TRY_ASM_LINK(
-[	.globl _ac_test@0
-_ac_test@0:
-	.globl ac_test@0
-ac_test@0:],
-[extern void __attribute__((__stdcall__)) ac_test(void);],
-[ac_test()],
-    ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no"))
+    WINE_TRY_ASM_LINK(["\t.globl _ac_test@0\n_ac_test@0:\n\t.globl ac_test@0\nac_test@0:"],
+                      [extern void __attribute__((__stdcall__)) ac_test(void);],
+                      [ac_test()],
+                      ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no"))
 if test "$ac_cv_c_stdcall_decoration" = "yes"
 then
   AC_DEFINE(NEED_STDCALL_DECORATION, 1, [Define if stdcall symbols need to be decorated])
@@ -706,8 +698,7 @@
 dnl **** Check for .string in assembler ****
 
 AC_CACHE_CHECK([whether assembler accepts .string], ac_cv_c_asm_string,
-    WINE_TRY_ASM_LINK(
-[	.string "test"],,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no"))
+    WINE_TRY_ASM_LINK([".string \"test\""],,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no"))
 if test "$ac_cv_c_asm_string" = "yes"
 then
   AC_DEFINE(HAVE_ASM_STRING, 1, [Define to use .string instead of .ascii])
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c
index 0236acd..c10cf53 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/debugtools.c
@@ -18,6 +18,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/include/config.h.in b/include/config.h.in
index e864320..38b78c5 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -2,9 +2,6 @@
 
 #define __WINE_CONFIG_H
 
-/* Define if  is defined */
-#undef AT_FUNCTION_IS_DEFINED
-
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    systems. This function is required for `alloca.c' support on those systems.
    */
@@ -626,12 +623,6 @@
 /* Define if stdcall symbols need to be decorated */
 #undef NEED_STDCALL_DECORATION
 
-/* Define if .type asm directive must be inside a .def directive */
-#undef NEED_TYPE_IN_DEF
-
-/* Define if symbols declared in assembly code need an underscore prefix */
-#undef NEED_UNDERSCORE_PREFIX
-
 /* Define to disable all debug messages. */
 #undef NO_DEBUG_MSGS
 
@@ -707,6 +698,12 @@
 /* Set this to 64 to enable 64-bit file support on Linux */
 #undef _FILE_OFFSET_BITS
 
+/* Define to a macro to generate an assembly function directive */
+#undef __ASM_FUNC
+
+/* Define to a macro to generate an assembly name from a C symbol */
+#undef __ASM_NAME
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
diff --git a/include/wine/port.h b/include/wine/port.h
index 6b4f32e..3d95259 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -131,20 +131,6 @@
 
 /* Macros to define assembler functions somewhat portably */
 
-#ifdef NEED_UNDERSCORE_PREFIX
-# define __ASM_NAME(name) "_" name
-#else
-# define __ASM_NAME(name) name
-#endif
-
-#ifdef NEED_TYPE_IN_DEF
-# define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
-#elif defined(AT_FUNCTION_IS_DEFINED)
-# define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
-#else
-# define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",2"
-#endif
-
 #ifdef __GNUC__
 # define __ASM_GLOBAL_FUNC(name,code) \
       __asm__( ".align 4\n\t" \
@@ -164,6 +150,32 @@
 #endif  /* __GNUC__ */
 
 
+/* Constructor functions */
+
+#ifdef __GNUC__
+# define DECL_GLOBAL_CONSTRUCTOR(func) \
+    static void func(void) __attribute__((constructor)); \
+    static void func(void)
+#elif defined(__i386__)
+# define DECL_GLOBAL_CONSTRUCTOR(func) \
+    static void __dummy_init_##func(void) { \
+        asm(".section .init,\"ax\"\n\t" \
+            "call " #func "\n\t" \
+            ".previous"); } \
+    static void func(void)
+#elif defined(__sparc__)
+# define DECL_GLOBAL_CONSTRUCTOR(func) \
+    static void __dummy_init_##func(void) { \
+        asm("\t.section \".init\",#alloc,#execinstr\n" \
+            "\tcall " #func "\n" \
+            "\tnop\n" \
+            "\t.section \".text\",#alloc,#execinstr\n" ); } \
+    static void func(void)
+#else
+# error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
+#endif
+
+
 /****************************************************************
  * Function definitions (only when using libwine)
  */
diff --git a/include/winnt.h b/include/winnt.h
index 49eeacc..d824e71 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -1213,35 +1213,6 @@
 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
 #endif
 
-/* Constructor functions */
-
-#ifdef __GNUC__
-# define DECL_GLOBAL_CONSTRUCTOR(func) \
-    static void func(void) __attribute__((constructor)); \
-    static void func(void)
-#else  /* __GNUC__ */
-# ifdef __i386__
-#  define DECL_GLOBAL_CONSTRUCTOR(func) \
-    static void __dummy_init_##func(void) { \
-        asm(".section .init,\"ax\"\n\t" \
-            "call " #func "\n\t" \
-            ".previous"); } \
-    static void func(void)
-# else  /* __i386__ */
-#  ifdef __sparc__
-#   define DECL_GLOBAL_CONSTRUCTOR(func) \
-     static void __dummy_init_##func(void) { \
-         asm("\t.section \".init\",#alloc,#execinstr\n" \
-             "\tcall " #func "\n" \
-             "\tnop\n" \
-	     "\t.section \".text\",#alloc,#execinstr\n" ); } \
-     static void func(void)
-#  else
-#   error You must define the DECL_GLOBAL_CONSTRUCTOR macro for your platform
-#  endif
-# endif
-#endif  /* __GNUC__ */
-
 #endif  /* __WINE__ */