initial underpinnings for mingw/cross compilation support

Use canonical host rather than target so that this works:
 CC=i686-w64-mingw32-gcc ./configure --host=i686-w64-mingw32

 Conditionally compile Linux issetugid compatibility function

ok beck@
This commit is contained in:
Brent Cook 2014-07-17 21:20:34 -05:00
parent 0bc4bdde5f
commit d697fdb4af
2 changed files with 22 additions and 13 deletions

View File

@ -1,5 +1,5 @@
AC_INIT([libressl], [VERSION]) AC_INIT([libressl], [VERSION])
AC_CANONICAL_TARGET AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([subdir-objects]) AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
@ -8,29 +8,33 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_SUBST([USER_CFLAGS], "-O2 $CFLAGS") AC_SUBST([USER_CFLAGS], "-O2 $CFLAGS")
CFLAGS="$CFLAGS -Wall -std=c99 -g" CFLAGS="$CFLAGS -Wall -std=c99 -g"
case $target_os in case $host_os in
*darwin*) *darwin*)
TARGET_OS=darwin; HOST_OS=darwin;
LDFLAGS="$LDFLAGS -Qunused-arguments" LDFLAGS="$LDFLAGS -Qunused-arguments"
;; ;;
*linux*) *linux*)
TARGET_OS=linux; HOST_OS=linux;
CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE"
;; ;;
*solaris*) *solaris*)
TARGET_OS=solaris; HOST_OS=solaris;
CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP" CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket']) AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket'])
;; ;;
*openbsd*) *openbsd*)
AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded])
;; ;;
*mingw*)
HOST_OS=win32
;;
*) ;; *) ;;
esac esac
AM_CONDITIONAL(TARGET_DARWIN, test x$TARGET_OS = xdarwin) AM_CONDITIONAL(HOST_DARWIN, test x$HOST_OS = xdarwin)
AM_CONDITIONAL(TARGET_LINUX, test x$TARGET_OS = xlinux) AM_CONDITIONAL(HOST_LINUX, test x$HOST_OS = xlinux)
AM_CONDITIONAL(TARGET_SOLARIS, test x$TARGET_OS = xsolaris) AM_CONDITIONAL(HOST_SOLARIS, test x$HOST_OS = xsolaris)
AM_CONDITIONAL(HOST_WIN, test x$HOST_OS = xwin)
AC_CHECK_FUNC([clock_gettime],, AC_CHECK_FUNC([clock_gettime],,
[AC_SEARCH_LIBS([clock_gettime],[rt posix4])]) [AC_SEARCH_LIBS([clock_gettime],[rt posix4])])
@ -72,8 +76,8 @@ AM_CONDITIONAL(NO_ARC4RANDOM_BUF, test "x$NO_ARC4RANDOM_BUF" = "xyes")
# overrides for arc4random_buf implementations with known issues # overrides for arc4random_buf implementations with known issues
AM_CONDITIONAL(NO_ARC4RANDOM_BUF, AM_CONDITIONAL(NO_ARC4RANDOM_BUF,
test x$TARGET_OS = xdarwin \ test x$HOST_OS = xdarwin \
-o x$TARGET_OS = xsolaris \ -o x$HOST_OS = xsolaris \
-o x$NO_ARC4RANDOM_BUF = xyes) -o x$NO_ARC4RANDOM_BUF = xyes)
AC_CHECK_FUNC(getentropy,[AC_SEARCH_LIBS(write,, [NO_GETENTROPY=], AC_CHECK_FUNC(getentropy,[AC_SEARCH_LIBS(write,, [NO_GETENTROPY=],

View File

@ -45,22 +45,27 @@ if NO_ARC4RANDOM_BUF
libcompat_la_SOURCES += compat/arc4random.c libcompat_la_SOURCES += compat/arc4random.c
if NO_GETENTROPY if NO_GETENTROPY
if TARGET_LINUX if HOST_LINUX
libcompat_la_SOURCES += compat/getentropy_linux.c libcompat_la_SOURCES += compat/getentropy_linux.c
endif endif
if TARGET_DARWIN if HOST_DARWIN
libcompat_la_SOURCES += compat/getentropy_osx.c libcompat_la_SOURCES += compat/getentropy_osx.c
endif endif
if TARGET_SOLARIS if HOST_SOLARIS
libcompat_la_SOURCES += compat/getentropy_solaris.c libcompat_la_SOURCES += compat/getentropy_solaris.c
endif endif
if HOST_WIN
libcompat_la_SOURCES += compat/getentropy_win.c
endif
endif endif
endif endif
if NO_ISSETUGID if NO_ISSETUGID
if HOST_LINUX
libcompat_la_SOURCES += compat/issetugid_linux.c libcompat_la_SOURCES += compat/issetugid_linux.c
endif endif
endif
noinst_HEADERS = des/ncbc_enc.c noinst_HEADERS = des/ncbc_enc.c
noinst_HEADERS += compat/thread_private.h noinst_HEADERS += compat/thread_private.h