Skip to content

Commit

Permalink
Win32: OpenSSL compilation for x64 targets with MSVC.
Browse files Browse the repository at this point in the history
To ensure proper target selection the NGX_MACHINE variable is now set
based on the MSVC compiler output, and the OpenSSL target is set based
on it.

This is not important as long as "no-asm" is used (as in misc/GNUmakefile
and win32 build instructions), but might be beneficial if someone is trying
to build OpenSSL with assembler code.
  • Loading branch information
mdounin committed Feb 23, 2023
1 parent 62b790c commit dad6ec3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions auto/cc/msvc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ have=NGX_COMPILER value="\"cl $NGX_MSVC_VER\"" . auto/define
ngx_msvc_ver=`echo $NGX_MSVC_VER | sed -e 's/^\([0-9]*\).*/\1/'`


# detect x64 builds

case "$NGX_MSVC_VER" in

*x64)
NGX_MACHINE=amd64
;;

*)
NGX_MACHINE=i386
;;

esac


# optimizations

# maximize speed, equivalent to -Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy
Expand Down
15 changes: 14 additions & 1 deletion auto/lib/openssl/make
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ case "$CC" in

cl)

case "$NGX_MACHINE" in

amd64)
OPENSSL_TARGET=VC-WIN64A
;;

*)
OPENSSL_TARGET=VC-WIN32
;;

esac

cat << END >> $NGX_MAKEFILE

$OPENSSL/openssl/include/openssl/ssl.h: $NGX_MAKEFILE
\$(MAKE) -f auto/lib/openssl/makefile.msvc \
OPENSSL="$OPENSSL" OPENSSL_OPT="$OPENSSL_OPT"
OPENSSL="$OPENSSL" OPENSSL_OPT="$OPENSSL_OPT" \
OPENSSL_TARGET="$OPENSSL_TARGET"

END

Expand Down
2 changes: 1 addition & 1 deletion auto/lib/openssl/makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
all:
cd $(OPENSSL)

perl Configure VC-WIN32 no-shared no-threads \
perl Configure $(OPENSSL_TARGET) no-shared no-threads \
--prefix="%cd%/openssl" \
--openssldir="%cd%/openssl/ssl" \
$(OPENSSL_OPT)
Expand Down

0 comments on commit dad6ec3

Please sign in to comment.