summaryrefslogtreecommitdiff
path: root/m4/msnative-struct.m4
blob: 84d773efb456c04bec79a23f1f327762a631df8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#############################################################
# when compiling on Win32 we have to add the option
# -fnative-struct for gcc2 or
# --mms-bitfields for gcc3
# parts from glib configure.in

dnl AC_GCC_MSNATIVE_STRUCT
dnl test if gcc supports option for MSnative struct
dnl
AC_DEFUN(AC_GCC_MSNATIVE_STRUCT,
[dnl
dnl Add ms native struct gcc option to CFLAGS if available
dnl
dnl  if test x"$glib_native_win32" = xyes; then
 AC_CHECK_HEADERS(windows.h,
 [
    if test x"$GCC" = xyes; then
      msnative_struct=''
      AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
      if test -z "$ac_cv_prog_CC"; then
        our_gcc="$CC"
      else
        our_gcc="$ac_cv_prog_CC"
      fi
      case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
        2.)
          if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
            msnative_struct='-fnative-struct'
          fi
          ;;
        *)
         if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
           msnative_struct='-mms-bitfields'
         fi
         ;;
      esac
      if test x"$msnative_struct" = x ; then
        AC_MSG_RESULT([no way])
        AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
      else
        CFLAGS="$CFLAGS $msnative_struct"
        AC_MSG_RESULT([${msnative_struct}])
      fi
    fi
dnl  fi
 ])
])