#!/bin/bash # skript to cross-compile openssl with mingw from linux # based on ms/mingw32.bat # Copyright (C) Jens Georg, 2005 perl Configure mingw $* if [ "$1" != "no-asm" ]; then echo Generating x86 for GNU assembler echo Cpuid cd crypto perl x86cpuid.pl gaswin > x86cpuid.s cd .. echo Bignum cd crypto/bn/asm perl bn-586.pl gaswin > bn-win32.s perl co-586.pl gaswin > co-win32.s cd ../../.. echo DES cd crypto/des/asm perl des-586.pl gaswin > d-win32.s cd ../../.. echo crypt cd crypto/des/asm perl crypt586.pl gaswin > y-win32.s cd ../../.. echo Blowfish cd crypto/bf/asm perl bf-586.pl gaswin > b-win32.s cd ../../.. echo CAST5 cd crypto/cast/asm perl cast-586.pl gaswin > c-win32.s cd ../../.. echo RC4 cd crypto/rc4/asm perl rc4-586.pl gaswin > r4-win32.s cd ../../.. echo MD5 cd crypto/md5/asm perl md5-586.pl gaswin > m5-win32.s cd ../../.. echo SHA1 cd crypto/sha/asm perl sha1-586.pl gaswin > s1-win32.s cd ../../.. echo RIPEMD160 cd crypto/ripemd/asm perl rmd-586.pl gaswin > rm-win32.s cd ../../.. echo RC5/32 cd crypto/rc5/asm perl rc5-586.pl gaswin > r5-win32.s cd ../../.. fi echo Generating makefile perl util/mkfiles.pl >MINFO perl util/mk1mf.pl gaswin Mingw32 >ms/mingw32a.mak.tmp # using sed magic to prepare makefile for cross-compiling; this does: # - replace gcc, as, ar and ranlib with it's mingw32 equivalents # - nename -mcpu to -mtune (reduce compiler noise) # - make windows commands "copy" and "del" to use linux equivalents # - replace "if exists" with rm -f # - add x86cpuid to dependencies # - do not build test programs - they run fine with wine, but are a bit # useless sed \ -e 's/CC=gcc/CC=i586-mingw32msvc-gcc -mms-bitfields/g' \ -e 's/-mcpu/-mtune/g' \ -e 's/ASM=as/ASM=i586-mingw32msvc-as/g' \ -e 's/MKLIB=ar/MKLIB=i586-mingw32msvc-ar/g' \ -e 's/RANLIB=ranlib/RANLIB=i586-mingw32msvc-ranlib/g' \ -e 's/CP=copy/CP=cp/g' \ -e 's/RM=del/RM=rm/g' \ -e 's/if exist \$(O_SSL).*/\$(RM) -f \$(O_SSL)/' \ -e 's/if exist \$(O_CRYPTO).*/\$(RM) -f \$(O_CRYPTO)/' \ -e 's,\\,/,g' \ -e 's,/$,\\,' \ -e 's,RSC=$,RSC=\nCPUID_ASM_OBJ=\$(OBJ_D)/x86cpuid.o\nCPUID_ASM_SRC=crypto/x86cpuid.s,' \ -e 's,\$(SRC_D)\(.*\)rm-win32.s$,\$(SRC_D)\1rm-win32.s\n\n\$(OBJ_D)/x86cpuid.o: crypto/x86cpuid.s\n\t\$(ASM) -o \$(OBJ_D)/x86cpuid.o \$(SRC_D)/crypto/x86cpuid.s,' \ -e 's,^CRYPTOOBJ=,CRYPTOOBJ=\$(CPUID_ASM_OBJ) ,' \ -e 's,^exe: \$(T_EXE),exe:,' \ < ms/mingw32a.mak.tmp >ms/mingw32a.mak echo Generating DLL definition files perl util/mkdef.pl 32 libeay >ms/libeay32.def if [ $? -eq 1 ]; then exit; fi perl util/mkdef.pl 32 ssleay >ms/ssleay32.def if [ $? -eq 1 ]; then exit; fi # cp ms/tlhelp32.h outinc echo Building the libraries make -f ms/mingw32a.mak if [ $? -eq 1 ]; then exit; fi echo Generating the DLLs and input libraries i586-mingw32msvc-dllwrap --dllname libeay32.dll --output-lib out/libeay32.a --def ms/libeay32.def out/libcrypto.a -lwsock32 -lgdi32 if [ $? -eq 1 ]; then exit; fi i586-mingw32msvc-dllwrap --dllname libssl32.dll --output-lib out/libssl32.a --def ms/ssleay32.def out/libssl.a out/libeay32.a if [ $? -eq 1 ]; then exit; fi echo Done compiling OpenSSL