2015-11-18  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* Configure:  -march=i386 -mtune=i586 flags added to CFLAGS.
	Replaced -DTERMIO by -DTERMIOS in CFLAGS.

	* demos/bio/Makefile:  -march=i386 -mtune=i586 flags added to CFLAGS.

	* demos/prime/Makefile:  -march=i386 -mtune=i586 flags added to CFLAGS.

	* demos/sign/Makefile:  -march=i386 -mtune=i586 flags added to CFLAGS.

	* demos/state_machine/Makefile:  -march=i386 -mtune=i586 flags added
	to CFLAGS.

	* demos/state_machine/Makefile:  Adjust for use with DJGPP.

	* tools/Makefile:  Add INSTALL_OPENSSLDIR to variable list to pass to
	recursive makefiles.

	* apps/Makefile:  Add INSTALL_OPENSSLDIR to variable list to pass to
	recursive makefiles.

	* Makefile.org:  Use INSTALL_OPENSSLDIR, INSTALL_MANDIR and
	INSTALL_HTMLDIR for installing into DJGPP installation tree.

	* Configure:  Adjust openssldir for DJGPP.

	* util/mklink.pl:  Do not use symlinks for DJGPP.

	* demos/bio/Makefile:  Adjust for use with DJGPP.

	* demos/prime/Makefile:  Adjust for use with DJGPP.

	* demos/sign/Makefile:  Adjust for use with DJGPP.





diff -aprNU5 openssl-1.0.1p.orig/apps/Makefile openssl-1.0.1p/apps/Makefile
--- openssl-1.0.1p.orig/apps/Makefile	2015-07-09 14:22:22 +0200
+++ openssl-1.0.1p/apps/Makefile	2015-11-18 23:38:00 +0100
@@ -110,17 +110,17 @@ install:
 	 mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
 	 done;
 	@set -e; for i in $(SCRIPTS); \
 	do  \
 	(echo installing $$i; \
-	 cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
-	 chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
-	 mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
+	 cp $$i $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new; \
+	 chmod 755 $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new; \
+	 mv -f $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i ); \
 	 done
-	@cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
-	chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
-	mv -f  $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
+	@cp openssl.cnf $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/openssl.cnf.new; \
+	chmod 644 $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/openssl.cnf.new; \
+	mv -f  $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/openssl.cnf
 
 tags:
 	ctags $(SRC)
 
 tests:
diff -aprNU5 openssl-1.0.1p.orig/Configure openssl-1.0.1p/Configure
--- openssl-1.0.1p.orig/Configure	2015-07-09 14:21:24 +0200
+++ openssl-1.0.1p/Configure	2015-11-18 23:38:48 +0100
@@ -565,11 +565,11 @@ my %table=(
 "netware-libc-bsdsock", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::",
 "netware-libc-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -I/ndk/libc/include/winsock -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::",
 "netware-libc-bsdsock-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -DNETWARE_BSDSOCK -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::",
 
 # DJGPP
-"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:",
+"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN -march=i386 -mtune=i586 -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:",
 
 # Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at>
 "ultrix-cc","cc:-std1 -O -Olimit 2500 -DL_ENDIAN::(unknown):::::::",
 "ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::BN_LLONG::::",
 # K&R C is no longer supported; you need gcc on old Ultrix installations
@@ -1142,12 +1142,17 @@ my $make = $ENV{'MAKE'} || "make";
 $cross_compile_prefix=$ENV{'CROSS_COMPILE'} if $cross_compile_prefix eq "";
 
 chop $openssldir if $openssldir =~ /\/$/;
 chop $prefix if $prefix =~ /.\/$/;
 
-$openssldir=$prefix . "/ssl" if $openssldir eq "";
-$openssldir=$prefix . "/" . $openssldir if $openssldir !~ /(^\/|^[a-zA-Z]:[\\\/])/;
+if ($^O eq 'dos') {
+  # For DJGPP.
+  $openssldir=$prefix . "/share/ssl" if $openssldir eq "";
+} else {
+  $openssldir=$prefix . "/ssl" if $openssldir eq "";
+  $openssldir=$prefix . "/" . $openssldir if $openssldir !~ /(^\/|^[a-zA-Z]:[\\\/])/;
+}
 
 
 print "IsMK1MF=$IsMK1MF\n";
 
 my @fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
diff -aprNU5 openssl-1.0.1p.orig/demos/bio/Makefile openssl-1.0.1p/demos/bio/Makefile
--- openssl-1.0.1p.orig/demos/bio/Makefile	2015-07-09 14:21:24 +0200
+++ openssl-1.0.1p/demos/bio/Makefile	2015-11-18 23:38:00 +0100
@@ -1,16 +1,17 @@
-CC=cc
-CFLAGS= -g -I../../include
-LIBS= -L../.. ../../libssl.a ../../libcrypto.a
-EXAMPLES=saccept sconnect
+CC=gcc
+CFLAGS= -g2 -O0 -march=i386 -mtune=i586 -I../../include
+LIBS= -L../.. ../../libssl.a ../../libcrypto.a /dev/env/DJDIR/net/watt/lib/libwatt.a -lz
+EXE=.exe
+EXAMPLES=saccept$(EXE) sconnect$(EXE)
 
 all: $(EXAMPLES) 
 
-saccept: saccept.o
-	$(CC) -o saccept saccept.o $(LIBS)
+saccept$(EXE): saccept.o
+	$(CC) -o saccept$(EXE) saccept.o $(LIBS)
 
-sconnect: sconnect.o
-	$(CC) -o sconnect sconnect.o $(LIBS)
+sconnect$(EXE): sconnect.o
+	$(CC) -o sconnect$(EXE) sconnect.o $(LIBS)
 
 clean:	
 	rm -f $(EXAMPLES) *.o
 
diff -aprNU5 openssl-1.0.1p.orig/demos/prime/Makefile openssl-1.0.1p/demos/prime/Makefile
--- openssl-1.0.1p.orig/demos/prime/Makefile	2015-01-15 15:43:14 +0100
+++ openssl-1.0.1p/demos/prime/Makefile	2015-11-18 23:38:00 +0100
@@ -1,14 +1,15 @@
-CC=cc
-CFLAGS= -g -I../../include -Wall
-LIBS=  -L../.. -lcrypto
-EXAMPLES=prime
+CC=gcc
+CFLAGS= -g2 -O0 -march=i386 -mtune=i586 -I../../include -Wall
+LIBS=  -L../.. -lcrypto /dev/env/DJDIR/net/watt/lib/libwatt.a -lz
+EXE=.exe
+EXAMPLES=prime$(EXE)
 
 all: $(EXAMPLES) 
 
-prime: prime.o
-	$(CC) -o prime prime.o $(LIBS)
+prime$(EXE): prime.o
+	$(CC) -o prime$(EXE) prime.o $(LIBS)
 
 clean:	
 	rm -f $(EXAMPLES) *.o
 
 test: all
diff -aprNU5 openssl-1.0.1p.orig/demos/sign/Makefile openssl-1.0.1p/demos/sign/Makefile
--- openssl-1.0.1p.orig/demos/sign/Makefile	2015-01-15 15:43:14 +0100
+++ openssl-1.0.1p/demos/sign/Makefile	2015-11-18 23:38:00 +0100
@@ -1,14 +1,15 @@
-CC=cc
-CFLAGS= -g -I../../include -Wall
-LIBS=  -L../.. -lcrypto
-EXAMPLES=sign
+CC=gcc
+CFLAGS= -g2 -O0 -march=i386 -mtune=i586 -I../../include -Wall
+LIBS=  -L../.. -lcrypto /dev/env/DJDIR/net/watt/lib/libwatt.a -lz
+EXE=.exe
+EXAMPLES=sign$(EXE)
 
 all: $(EXAMPLES) 
 
-sign: sign.o
-	$(CC) -o sign sign.o $(LIBS)
+sign$(EXE): sign.o
+	$(CC) -o sign$(EXE) sign.o $(LIBS)
 
 clean:	
 	rm -f $(EXAMPLES) *.o
 
 test: all
diff -aprNU5 openssl-1.0.1p.orig/demos/state_machine/Makefile openssl-1.0.1p/demos/state_machine/Makefile
--- openssl-1.0.1p.orig/demos/state_machine/Makefile	2015-01-15 15:43:14 +0100
+++ openssl-1.0.1p/demos/state_machine/Makefile	2015-11-18 23:38:00 +0100
@@ -1,9 +1,10 @@
-CFLAGS=-I../../include -Wall -Werror -g
+CFLAGS=-I../../include -Wall -g2 -O0 -march=i386 -mtune=i586
+EXE=.exe
 
-all: state_machine
+all: state_machine$(EXE)
 
-state_machine: state_machine.o
-	$(CC) -o state_machine state_machine.o -L../.. -lssl -lcrypto
+state_machine$(EXE): state_machine.o
+	$(CC) -o state_machine$(EXE) state_machine.o -L../.. -lssl -lcrypto /dev/env/DJDIR/net/watt/lib/libwatt.a -lz
 
 test: state_machine
 	./state_machine 10000 ../../apps/server.pem ../../apps/server.pem
diff -aprNU5 openssl-1.0.1p.orig/Makefile.org openssl-1.0.1p/Makefile.org
--- openssl-1.0.1p.orig/Makefile.org	2015-07-09 14:21:24 +0200
+++ openssl-1.0.1p/Makefile.org	2015-11-18 23:38:00 +0100
@@ -155,10 +155,13 @@ SDIRS=  \
 # should be performed.
 TESTS = alltests
 
 MAKEFILE= Makefile
 
+INSTALL_OPENSSLDIR=$(INSTALLTOP)/share/ssl
+INSTALL_HTMLDIR=$(INSTALLTOP)/share/ssl/html
+INSTALL_MANDIR=$(INSTALLTOP)/share/ssl/man
 MANDIR=$(OPENSSLDIR)/man
 MAN1=1
 MAN3=3
 MANSUFFIX=
 HTMLSUFFIX=html
@@ -209,11 +212,11 @@ BUILDENV=	PLATFORM='$(PLATFORM)' PROCESS
 		CROSS_COMPILE='$(CROSS_COMPILE)'	\
 		PERL='$(PERL)' ENGDIRS='$(ENGDIRS)'		\
 		SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)'	\
 		INSTALL_PREFIX='$(INSTALL_PREFIX)'		\
 		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
-		LIBDIR='$(LIBDIR)'				\
+		INSTALL_OPENSSLDIR='$(INSTALL_OPENSSLDIR)' LIBDIR='$(LIBDIR)'	\
 		MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
 		DEPFLAG='-DOPENSSL_NO_DEPRECATED $(DEPFLAG)'	\
 		MAKEDEPPROG='$(MAKEDEPPROG)'			\
 		SHARED_LDFLAGS='$(SHARED_LDFLAGS)'		\
 		KRB5_INCLUDES='$(KRB5_INCLUDES)' LIBKRB5='$(LIBKRB5)'	\
@@ -527,21 +530,22 @@ dist:
 	@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
 
 dist_pem_h:
 	(cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
 
-install: all install_docs install_sw
+# install: all install_docs install_sw
+install: install_html_docs install_docs install_sw
 
 install_sw:
 	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
 		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
 		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
 		$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
 		$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
-		$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
-		$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
-		$(INSTALL_PREFIX)$(OPENSSLDIR)/private
+		$(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc \
+		$(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/certs \
+		$(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/private
 	@set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
 	do \
 	(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
 	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
 	done;
@@ -605,34 +609,34 @@ install_sw:
 	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
 
 install_html_docs:
 	here="`pwd`"; \
 	for subdir in apps crypto ssl; do \
-		mkdir -p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
+		mkdir -p $(INSTALL_PREFIX)$(INSTALL_HTMLDIR)/$$subdir; \
 		for i in doc/$$subdir/*.pod; do \
 			fn=`basename $$i .pod`; \
 			echo "installing html/$$fn.$(HTMLSUFFIX)"; \
 			cat $$i \
 			| sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
 			| pod2html --podroot=doc --htmlroot=.. --podpath=apps:crypto:ssl \
 			| sed -r 's/<!DOCTYPE.*//g' \
-			> $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
+			> $(INSTALL_PREFIX)$(INSTALL_HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
 			$(PERL) util/extract-names.pl < $$i | \
 				grep -v $$filecase "^$$fn\$$" | \
-				(cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
+				(cd $(INSTALL_PREFIX)$(INSTALL_HTMLDIR)/$$subdir; \
 				 while read n; do \
 					PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
 				 done); \
 		done; \
 	done
 
 install_docs:
 	@$(PERL) $(TOP)/util/mkdir-p.pl \
-		$(INSTALL_PREFIX)$(MANDIR)/man1 \
-		$(INSTALL_PREFIX)$(MANDIR)/man3 \
-		$(INSTALL_PREFIX)$(MANDIR)/man5 \
-		$(INSTALL_PREFIX)$(MANDIR)/man7
+		$(INSTALL_PREFIX)$(INSTALL_MANDIR)/man1 \
+		$(INSTALL_PREFIX)$(INSTALL_MANDIR)/man3 \
+		$(INSTALL_PREFIX)$(INSTALL_MANDIR)/man5 \
+		$(INSTALL_PREFIX)$(INSTALL_MANDIR)/man7
 	@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
 	here="`pwd`"; \
 	filecase=; \
 	if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \
 		filecase=-i; \
@@ -643,15 +647,15 @@ install_docs:
 		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
 		(cd `$(PERL) util/dirname.pl $$i`; \
 		sh -c "$$pod2man \
 			--section=$$sec --center=OpenSSL \
 			--release=$(VERSION) `basename $$i`") \
-			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
+			>  $(INSTALL_PREFIX)$(INSTALL_MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
 		$(PERL) util/extract-names.pl < $$i | \
 			(grep -v $$filecase "^$$fn\$$"; true) | \
 			(grep -v "[	]"; true) | \
-			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
+			(cd $(INSTALL_PREFIX)$(INSTALL_MANDIR)/man$$sec/; \
 			 while read n; do \
 				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
 			 done); \
 	done; \
 	set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
@@ -660,15 +664,15 @@ install_docs:
 		echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
 		(cd `$(PERL) util/dirname.pl $$i`; \
 		sh -c "$$pod2man \
 			--section=$$sec --center=OpenSSL \
 			--release=$(VERSION) `basename $$i`") \
-			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
+			>  $(INSTALL_PREFIX)$(INSTALL_MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
 		$(PERL) util/extract-names.pl < $$i | \
 			(grep -v $$filecase "^$$fn\$$"; true) | \
 			(grep -v "[	]"; true) | \
-			(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
+			(cd $(INSTALL_PREFIX)$(INSTALL_MANDIR)/man$$sec/; \
 			 while read n; do \
 				PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
 			 done); \
 	done
 
diff -aprNU5 openssl-1.0.1p.orig/tools/Makefile openssl-1.0.1p/tools/Makefile
--- openssl-1.0.1p.orig/tools/Makefile	2015-07-09 13:53:20 +0200
+++ openssl-1.0.1p/tools/Makefile	2015-11-18 23:38:00 +0100
@@ -26,13 +26,13 @@ install:
 	chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
 	mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
 	done;
 	@for i in $(MISC_APPS) ; \
 	do  \
-	(cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
-	chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
-	mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
+	(cp $$i $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new; \
+	chmod 755 $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new; \
+	mv -f $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(INSTALL_OPENSSLDIR)/misc/$$i ); \
 	done;
 
 files:
 	$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
 
diff -aprNU5 openssl-1.0.1p.orig/util/mklink.pl openssl-1.0.1p/util/mklink.pl
--- openssl-1.0.1p.orig/util/mklink.pl	2015-07-09 13:53:20 +0200
+++ openssl-1.0.1p/util/mklink.pl	2015-11-18 23:38:00 +0100
@@ -49,11 +49,16 @@ foreach $dirname (@from_path) {
 
 my $to = join('/', @to_path);
 
 my $file;
 $symlink_exists=eval {symlink("",""); 1};
-if ($^O eq "msys") { $symlink_exists=0 };
+if ($^O eq 'dos') {
+   # Do not use symlinks for DJGPP.
+   $symlink_exists = 0;
+} else {
+   if ($^O eq "msys") { $symlink_exists=0 };
+}
 foreach $file (@files) {
     my $err = "";
     if ($symlink_exists) {
 	unlink "$from/$file";
 	symlink("$to/$file", "$from/$file") or $err = " [$!]";
