From d697fdb4afb08bb46027a5efd1f8040bfdb8380e Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 17 Jul 2014 21:20:34 -0500 Subject: [PATCH] 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@ --- configure.ac.tpl | 24 ++++++++++++++---------- crypto/Makefile.am.tpl | 11 ++++++++--- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/configure.ac.tpl b/configure.ac.tpl index 8accb4d..cbd62a0 100644 --- a/configure.ac.tpl +++ b/configure.ac.tpl @@ -1,5 +1,5 @@ AC_INIT([libressl], [VERSION]) -AC_CANONICAL_TARGET +AC_CANONICAL_HOST AM_INIT_AUTOMAKE([subdir-objects]) AC_CONFIG_MACRO_DIR([m4]) @@ -8,29 +8,33 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_SUBST([USER_CFLAGS], "-O2 $CFLAGS") CFLAGS="$CFLAGS -Wall -std=c99 -g" -case $target_os in +case $host_os in *darwin*) - TARGET_OS=darwin; + HOST_OS=darwin; LDFLAGS="$LDFLAGS -Qunused-arguments" ;; *linux*) - TARGET_OS=linux; + HOST_OS=linux; CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" ;; *solaris*) - TARGET_OS=solaris; + HOST_OS=solaris; CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP" AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket']) ;; *openbsd*) AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) ;; + *mingw*) + HOST_OS=win32 + ;; *) ;; esac -AM_CONDITIONAL(TARGET_DARWIN, test x$TARGET_OS = xdarwin) -AM_CONDITIONAL(TARGET_LINUX, test x$TARGET_OS = xlinux) -AM_CONDITIONAL(TARGET_SOLARIS, test x$TARGET_OS = xsolaris) +AM_CONDITIONAL(HOST_DARWIN, test x$HOST_OS = xdarwin) +AM_CONDITIONAL(HOST_LINUX, test x$HOST_OS = xlinux) +AM_CONDITIONAL(HOST_SOLARIS, test x$HOST_OS = xsolaris) +AM_CONDITIONAL(HOST_WIN, test x$HOST_OS = xwin) AC_CHECK_FUNC([clock_gettime],, [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 AM_CONDITIONAL(NO_ARC4RANDOM_BUF, - test x$TARGET_OS = xdarwin \ - -o x$TARGET_OS = xsolaris \ + test x$HOST_OS = xdarwin \ + -o x$HOST_OS = xsolaris \ -o x$NO_ARC4RANDOM_BUF = xyes) AC_CHECK_FUNC(getentropy,[AC_SEARCH_LIBS(write,, [NO_GETENTROPY=], diff --git a/crypto/Makefile.am.tpl b/crypto/Makefile.am.tpl index 20c3495..d79a270 100644 --- a/crypto/Makefile.am.tpl +++ b/crypto/Makefile.am.tpl @@ -45,22 +45,27 @@ if NO_ARC4RANDOM_BUF libcompat_la_SOURCES += compat/arc4random.c if NO_GETENTROPY -if TARGET_LINUX +if HOST_LINUX libcompat_la_SOURCES += compat/getentropy_linux.c endif -if TARGET_DARWIN +if HOST_DARWIN libcompat_la_SOURCES += compat/getentropy_osx.c endif -if TARGET_SOLARIS +if HOST_SOLARIS libcompat_la_SOURCES += compat/getentropy_solaris.c endif +if HOST_WIN +libcompat_la_SOURCES += compat/getentropy_win.c +endif endif endif if NO_ISSETUGID +if HOST_LINUX libcompat_la_SOURCES += compat/issetugid_linux.c endif +endif noinst_HEADERS = des/ncbc_enc.c noinst_HEADERS += compat/thread_private.h