Here is a slightly redone patch so that openssl-0.9.7 compiles under
DJGPP. This is against the June 1 snapshot. I removed the part of the
patch relating to Cygwin, since the Cygwin settings in Configure have
now changed. This configures, builds, and does "make test" without
problem, except for the usual inability to load "random state", since
there is no built-in method of gathering entropy under DJGPP.
There are some problems building under Cygwin, related to the use of
assembly code. So as not to confuse issues, I'll send a separate post
about that. While Cygwin builds with warnings, an attempt to use the
assembly code in DJGPP led to errors that stopped the compilation.
Doug
--- openssl-0.9.7/e_os.h.orig Sat Apr 6 12:02:18 2002
+++ openssl-0.9.7/e_os.h Thu Apr 18 18:42:26 2002
@@ -191,6 +191,14 @@
#if (defined(WINDOWS) || defined(MSDOS))
+# ifdef __DJGPP__
+# include <unistd.h>
+# include <sys/stat.h>
+# define _setmode setmode
+# define _O_TEXT O_TEXT
+# define _O_BINARY O_BINARY
+# endif /* __DJGPP__ */
+
# ifndef S_IFDIR
# define S_IFDIR _S_IFDIR
# endif
@@ -336,7 +344,7 @@
/*************/
#ifdef USE_SOCKETS
-# if defined(WINDOWS) || defined(MSDOS)
+# if (defined(WINDOWS) || defined(MSDOS)) && !defined(__DJGPP__)
/* windows world */
# ifdef OPENSSL_NO_SOCK
@@ -423,7 +431,9 @@
# define SSLeay_Write(a,b,c) write((a),(b),(c))
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
+# ifndef INVALID_SOCKET
# define INVALID_SOCKET (-1)
+# endif /* INVALID_SOCKET */
# endif
#endif
--- openssl-0.9.7/install.djgpp.orig Thu Apr 18 18:42:26 2002
+++ openssl-0.9.7/install.djgpp Thu Apr 18 18:42:26 2002
@@ -0,0 +1,32 @@
+
+
+ INSTALLATION ON THE DOS PLATFORM WITH DJGPP
+ -------------------------------------------
+
+ Openssl has been ported to DOS, but only with long filename support. If
+ you wish to compile on native DOS with 8+3 filenames, you will have to
+ tweak the installation yourself, including renaming files with illegal
+ or duplicate names.
+
+ You should have a full DJGPP environment installed, including the
+ latest versions of DJGPP, GCC, BINUTILS, BASH, etc. This package
+ requires that PERL and BC also be installed.
+
+ All of these can be obtained from the usual DJGPP mirror sites, such as
+ "ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp". You also need to have
+ the WATT-32 networking package installed before you try to compile
+ openssl. This can be obtained from "http://www.bgnett.no/~giva/". The
+ Makefile assumes that the WATT-32 code is in directory "watt32" under
+ $DJDIR.
+
+ To compile openssl, start your BASH shell. Then configure for DOS by
+ running "./Configure" with appropriate arguments. The basic syntax for
+ DOS is:
+ ./Configure no-threads --prefix=$DJDIR DJGPP
+
+ You may run out of DPMI selectors when running in a DOS box under
+ Windows. If so, just close the BASH shell, go back to Windows, and
+ restart BASH. Then run "make" again.
+
+ Building openssl under DJGPP has been tested with DJGPP 2.03,
+ GCC 2.952, GCC 2.953, perl 5.005_02 and perl 5.006_01.
--- openssl-0.9.7/Configure.orig 2002-05-30 10:08:08.000000000 -0800
+++ openssl-0.9.7/Configure 2002-06-02 15:23:38.000000000 -0800
@@ -513,6 +513,9 @@
"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486
-Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486
-Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des}
${x86_gcc_opts}:${x86_out_asm}:win32:cygwin-shared:::.dll",
+# DJGPP
+"DJGPP", "gcc:-I/dev/env/DJDIR/watt32/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer
+-O2 -Wall:::MSDOS:-L/dev/env/DJDIR/watt32/lib -lwatt:BN_LLONG ${x86_gcc_des}
+${x86_gcc_opts}::::::::::",
+
# Ultrix from Bernhard Simon <[EMAIL PROTECTED]>
"ultrix-cc","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::(unknown):::::::",
"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::::::",
@@ -894,6 +897,7 @@
my $IsWindows=scalar grep /^$target$/,@WinTargets;
$exe_ext=".exe" if ($target eq "Cygwin");
+$exe_ext=".exe" if ($target eq "DJGPP");
$openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq "");
$prefix=$openssldir if $prefix eq "";
@@ -901,7 +905,7 @@
chop $prefix if $prefix =~ /\/$/;
$openssldir=$prefix . "/ssl" if $openssldir eq "";
-$openssldir=$prefix . "/" . $openssldir if $openssldir !~ /^\//;
+$openssldir=$prefix . "/" . $openssldir if $openssldir !~ /(^\/|^[a-zA-Z]:[\\\/])/;
print "IsWindows=$IsWindows\n";
@@ -1226,6 +1230,50 @@
close(IN);
close(OUT);
+my $dir;
+my $crypt1;
+my $crypt2;
+my $crypt3;
+my $crypt4;
+my $crypt5;
+my $crypt6;
+my $symlink_exists;
+mkdir ('include/openssl', 0777) unless -d 'include/openssl';
+$symlink_exists=eval {symlink("",""); 1};
+foreach $dir (@skip) {
+ $crypt1=join('','crypto/', "$dir", '/', "$dir", 'test.c');
+ $crypt2=join('', 'test/', "$dir", 'test.c');
+ $crypt3=join('', '../', "$crypt1");
+ $crypt4=join('', 'crypto/', "$dir", '/', "$dir", '.h');
+ $crypt5=join('', 'include/openssl/', "$dir", '.h');
+ $crypt6=join('', '../../', "$crypt4");
+ if ($symlink_exists) {
+ unlink "$crypt2";
+ unlink "$crypt5";
+ symlink("$crypt3", "$crypt2");
+ symlink("$crypt6", "$crypt5");
+ } else {
+ open (OLD, "<$crypt1") or die "Can't open $crypt1\n";
+ open (NEW, ">$crypt2") or die "Can't open $crypt2\n";
+ open (OLD1, "<$crypt4") or die "Can't open $crypt4\n";
+ open (NEW1, ">$crypt5") or die "Can't open $crypt5\n";
+ binmode(OLD);
+ binmode(NEW);
+ while (<OLD>) {
+ (print NEW $_);
+ }
+ binmode(OLD1);
+ binmode(NEW1);
+ while (<OLD1>) {
+ (print NEW1 $_);
+ }
+ close (OLD);
+ close (NEW);
+ close (OLD1);
+ close (NEW1);
+ }
+ }
+
print "CC =$cc\n";
print "CFLAG =$cflags\n";
print "EX_LIBS =$lflags\n";
--- openssl-0.9.7/util/mklink.pl.orig Wed Apr 4 15:50:22 2001
+++ openssl-0.9.7/util/mklink.pl Thu Apr 18 18:42:26 2002
@@ -18,10 +18,10 @@
my $from = shift;
my @files = @ARGV;
-my @from_path = split(/\//, $from);
+my @from_path = split(/[\\\/]/, $from);
my $pwd = `pwd`;
chop($pwd);
-my @pwd_path = split(/\//, $pwd);
+my @pwd_path = split(/[\\\/]/, $pwd);
my @to_path = ();
@@ -52,9 +52,18 @@
foreach $file (@files) {
my $err = "";
if ($symlink_exists) {
+ unlink "$from/$file";
symlink("$to/$file", "$from/$file") or $err = " [$!]";
} else {
- system ("cp", "$file", "$from/$file") and $err = " [$!]";
+ open (OLD, "<$file") or die "Can't open $file: $!";
+ open (NEW, ">$from/$file") or die "Can't open $from/$file: $!";
+ binmode(OLD);
+ binmode(NEW);
+ while (<OLD>) {
+ (print NEW $_);
+ }
+ close (OLD) or die "Can't close $file: $!";
+ close (NEW) or die "Can't close $from/$file: $!";
}
print $file . " => $from/$file$err\n";
}
--- openssl-0.9.7/util/point.sh.orig Sat Mar 6 12:32:06 1999
+++ openssl-0.9.7/util/point.sh Thu Apr 18 18:42:26 2002
@@ -1,6 +1,9 @@
#!/bin/sh
rm -f $2
-ln -s $1 $2
+if test "$OSTYPE" = msdosdjgpp;
+then cp -fR $1 $2;
+else ln -s $1 $2;
+fi
echo "$2 => $1"
--- openssl-0.9.7/tools/c_rehash.in.orig Fri Aug 17 04:35:58 2001
+++ openssl-0.9.7/tools/c_rehash.in Thu Apr 18 18:42:26 2002
@@ -17,7 +17,7 @@
$ENV{PATH} .= ":$dir/bin";
-if(! -f $openssl) {
+if(! -x $openssl) {
my $found = 0;
foreach (split /:/, $ENV{PATH}) {
if(-f "$_/$openssl") {
--- openssl-0.9.7/test/tx509.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/tx509 Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl x509'
--- openssl-0.9.7/test/tsid.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/tsid Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl sess_id'
--- openssl-0.9.7/test/trsa.orig Mon Mar 13 20:31:46 2000
+++ openssl-0.9.7/test/trsa Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
if ../apps/openssl no-rsa; then
--- openssl-0.9.7/test/treq.orig Mon Mar 13 19:24:38 2000
+++ openssl-0.9.7/test/treq Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl req -config ../apps/openssl.cnf'
--- openssl-0.9.7/test/tpkcs7d.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/tpkcs7d Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl pkcs7'
--- openssl-0.9.7/test/tpkcs7.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/tpkcs7 Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl pkcs7'
--- openssl-0.9.7/test/testgen.orig Mon Mar 13 20:31:44 2000
+++ openssl-0.9.7/test/testgen Thu Apr 18 18:42:26 2002
@@ -6,7 +6,11 @@
/bin/rm -f $T.1 $T.2 $T.key
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH;
+else
PATH=../apps:$PATH;
+fi
export PATH
echo "generating certificate request"
--- openssl-0.9.7/test/testca.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/testca Thu Apr 18 18:42:26 2002
@@ -1,7 +1,11 @@
#!/bin/sh
SH="/bin/sh"
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=./apps\;../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export SH PATH
SSLEAY_CONFIG="-config CAss.cnf"
--- openssl-0.9.7/test/tcrl.orig Sat Jan 2 19:01:40 1999
+++ openssl-0.9.7/test/tcrl Thu Apr 18 18:42:26 2002
@@ -1,6 +1,10 @@
#!/bin/sh
+if test "$OSTYPE" = msdosdjgpp; then
+PATH=../apps\;$PATH
+else
PATH=../apps:$PATH
+fi
export PATH
cmd='../apps/openssl crl'
--- openssl-0.9.7/crypto/ui/ui_openssl.c.orig Thu Feb 14 17:06:24 2002
+++ openssl-0.9.7/crypto/ui/ui_openssl.c Thu Apr 18 18:42:26 2002
@@ -269,7 +269,7 @@
static long status;
static unsigned short channel = 0;
#else
-#ifndef OPENSSL_SYS_MSDOS
+#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
static TTY_STRUCT tty_orig,tty_new;
#endif
#endif
--- openssl-0.9.7/crypto/rand/rand_egd.c.orig 2002-05-22 04:02:16.000000000 -0800
+++ openssl-0.9.7/crypto/rand/rand_egd.c 2002-06-02 15:26:16.000000000 -0800
@@ -94,7 +94,7 @@
* RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
*/
-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__)
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
{
return(-1);
--- openssl-0.9.7/crypto/des/read_pwd.c.orig Thu Feb 21 14:09:38 2002
+++ openssl-0.9.7/crypto/des/read_pwd.c Thu Apr 18 18:42:26 2002
@@ -246,7 +246,7 @@
long status;
unsigned short channel = 0;
#else
-#ifndef OPENSSL_SYS_MSDOS
+#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
TTY_STRUCT tty_orig,tty_new;
#endif
#endif
--- openssl-0.9.7/crypto/des/Makefile.ssl.orig Sat Apr 6 20:06:28 2002
+++ openssl-0.9.7/crypto/des/Makefile.ssl Thu Apr 18 18:42:26 2002
@@ -108,7 +108,7 @@
links:
@$(TOP)/util/point.sh Makefile.ssl Makefile
- @$(TOP)/util/point.sh ../../perlasm asm/perlasm
+ @$(TOP)/util/point.sh `cd ../perlasm;pwd` asm/perlasm
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
--- openssl-0.9.7/crypto/bn/bn_mul.c.orig Sun Oct 14 00:57:16 2001
+++ openssl-0.9.7/crypto/bn/bn_mul.c Thu Apr 18 18:42:26 2002
@@ -66,7 +66,7 @@
#include "cryptlib.h"
#include "bn_lcl.h"
-#if defined(OPENSSL_NO_ASM) || !(defined(__i386) || defined(__i386__))/* Assembler
implementation exists only for x86 */
+#if defined(OPENSSL_NO_ASM) || !(defined(__i386) || defined(__i386__)) ||
+defined(__DJGPP__) /* Assembler implementation exists only for x86 */
/* Here follows specialised variants of bn_add_words() and
bn_sub_words(). They have the property performing operations on
arrays of different sizes. The sizes of those arrays is expressed through
--- openssl-0.9.7/crypto/bio/b_sock.c.orig Sat Mar 30 00:02:20 2002
+++ openssl-0.9.7/crypto/bio/b_sock.c Thu Apr 18 18:42:26 2002
@@ -484,7 +484,11 @@
{
int i;
+#ifdef __DJGPP__
+ i=ioctlsocket(fd,type,(char *)arg);
+#else
i=ioctlsocket(fd,type,arg);
+#endif /* __DJGPP__ */
if (i < 0)
SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
return(i);
__
Doug Kaufman
Internet: [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]