Stop symlinking, move files to intended directory

Rather than making include/openssl/foo.h a symlink to
crypto/foo/foo.h, this change moves the file to include/openssl/foo.h
once and for all.

Likewise, move crypto/foo/footest.c to test/footest.c, instead of
symlinking it there.

Originally-by: Geoff Thorpe <geoff@openssl.org>

Reviewed-by: Rich Salz <rsalz@openssl.org>
diff --git a/.gitignore b/.gitignore
index 2f27dc6..9f85632 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,7 +14,6 @@
 /MINFO
 /TABLE
 /*.a
-/include
 /*.pc
 /rehash.time
 /inc.*
@@ -22,17 +21,6 @@
 /out.*
 /tmp.*
 
-# Most *.c files under test/ are symlinks
-/test/*.c
-# Apart from these
-!/test/asn1test.c
-!/test/methtest.c
-!/test/dummytest.c
-!/test/igetest.c
-!/test/r160test.c
-!/test/fips_algvs.c
-!/test/testutil.c
-
 /test/*.ss
 /test/*.srl
 /test/.rnd
@@ -94,8 +82,8 @@
 !/crypto/des/times/486-50.sol
 
 # Misc auto generated files
+include/openssl/opensslconf.h
 /tools/c_rehash
-/test/evptests.txt
 lib
 Makefile.save
 *.bak
diff --git a/Configure b/Configure
index ba8cd96..97c2573 100755
--- a/Configure
+++ b/Configure
@@ -779,13 +779,13 @@
 my @skip=();
 my $Makefile="Makefile";
 my $des_locl="crypto/des/des_locl.h";
-my $des	="crypto/des/des.h";
-my $bn	="crypto/bn/bn.h";
-my $md2	="crypto/md2/md2.h";
-my $rc4	="crypto/rc4/rc4.h";
+my $des	="include/openssl/des.h";
+my $bn	="include/openssl/bn.h";
+my $md2	="include/openssl/md2.h";
+my $rc4	="include/openssl/rc4.h";
 my $rc4_locl="crypto/rc4/rc4_locl.h";
-my $idea	="crypto/idea/idea.h";
-my $rc2	="crypto/rc2/rc2.h";
+my $idea	="include/openssl/idea.h";
+my $rc2	="include/openssl/rc2.h";
 my $bf	="crypto/bf/bf_locl.h";
 my $bn_asm	="bn_asm.o";
 my $des_enc="des_enc.o fcrypt_b.o";
@@ -848,7 +848,6 @@
 my $libkrb5="";
 my $target;
 my $options;
-my $symlink;
 my $make_depend=0;
 my %withargs=();
 my $build_prefix = "release_";
@@ -869,7 +868,6 @@
 	$libs="";
 	$target="";
 	$options="";
-	$symlink=1;
 
 	$argv_unprocessed=0;
 	$argvstring=join(' ',@argvcopy);
@@ -1192,8 +1190,6 @@
 		{ }
 	elsif (/^zlib-dynamic$/)
 		{ }
-	elsif (/^symlinks$/)
-		{ $symlink = 0; }
 	elsif (/^sse2$/)
 		{ $no_sse2 = 1; }
 	else
@@ -1702,7 +1698,7 @@
 my $shlib_major = "unknown";
 my $shlib_minor = "unknown";
 
-open(IN,'<crypto/opensslv.h') || die "unable to read opensslv.h:$!\n";
+open(IN,'<include/openssl/opensslv.h') || die "unable to read opensslv.h:$!\n";
 while (<IN>)
 	{
 	$version=$1 if /OPENSSL.VERSION.TEXT.*OpenSSL (\S+) /;
@@ -1923,8 +1919,8 @@
 	}
 
 open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
-unlink("crypto/opensslconf.h.new") || die "unable to remove old crypto/opensslconf.h.new:$!\n" if -e "crypto/opensslconf.h.new";
-open(OUT,'>crypto/opensslconf.h.new') || die "unable to create crypto/opensslconf.h.new:$!\n";
+unlink("include/openssl/opensslconf.h.new") || die "unable to remove old include/openssl/opensslconf.h.new:$!\n" if -e "include/openssl/opensslconf.h.new";
+open(OUT,'>include/openssl/opensslconf.h.new') || die "unable to create include/openssl/opensslconf.h.new:$!\n";
 print OUT "/* opensslconf.h */\n";
 print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
 
@@ -2039,8 +2035,8 @@
 print OUT "}\n";
 print OUT "#endif\n";
 close(OUT);
-rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
-rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
+rename("include/openssl/opensslconf.h","include/openssl/opensslconf.h.bak") || die "unable to rename include/openssl/opensslconf.h\n" if -e "include/openssl/opensslconf.h";
+rename("include/openssl/opensslconf.h.new","include/openssl/opensslconf.h") || die "unable to rename include/openssl/opensslconf.h.new\n";
 
 
 # Fix the date
@@ -2082,9 +2078,7 @@
 } else {
 	my $make_command = "$make PERL=\'$perl\'";
 	my $make_targets = "";
-	$make_targets .= " links" if $symlink;
 	$make_targets .= " depend" if $depflags ne $default_depflags && $make_depend;
-	$make_targets .= " gentests" if $symlink;
 	(system $make_command.$make_targets) == 0 or die "make $make_targets failed"
 		if $make_targets ne "";
 	if ( $perl =~ m@^/@) {
diff --git a/Makefile.org b/Makefile.org
index 0d09ad4..5e510f2 100644
--- a/Makefile.org
+++ b/Makefile.org
@@ -137,6 +137,7 @@
 DIRS=   crypto ssl engines apps test tools
 ENGDIRS= ccgost
 SHLIBDIRS= crypto ssl
+INSTALL_SUBS= engines apps tools
 
 # dirs in crypto to build
 SDIRS=  \
@@ -426,11 +427,6 @@
 	$(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
 	@set -e; target=files; $(RECURSIVE_BUILD_CMD)
 
-links:
-	@$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
-	@$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
-	@set -e; target=links; $(RECURSIVE_BUILD_CMD)
-
 gentests:
 	@(cd test && echo "generating dummy tests (if needed)..." && \
 	$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
@@ -486,10 +482,10 @@
 util/ssleay.num::
 	$(PERL) util/mkdef.pl ssl update
 
-crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
-	$(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
-crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
-	$(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
+crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl include/openssl/obj_mac.h
+	$(PERL) crypto/objects/obj_dat.pl include/openssl/obj_mac.h crypto/objects/obj_dat.h
+include/openssl/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
+	$(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num include/openssl/obj_mac.h
 crypto/objects/obj_xref.h: crypto/objects/objxref.pl crypto/objects/obj_xref.txt crypto/objects/obj_mac.num
 	$(PERL) crypto/objects/objxref.pl crypto/objects/obj_mac.num crypto/objects/obj_xref.txt >crypto/objects/obj_xref.h
 
@@ -547,12 +543,11 @@
 
 install_sw:
 	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALLDIRS)
-	@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 ); \
+	@set -e; for i in include/openssl/*.h; do \
+	(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$$i; \
+	chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$$i ); \
 	done;
-	@set -e; target=install; $(RECURSIVE_BUILD_CMD)
+	@set -e; target=install; for dir in $(INSTALL_SUBS); do $(BUILD_CMD); done
 	@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
 	do \
 		if [ -f "$$i" ]; then \
diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec
index 3c268d2..8a10b80 100644
--- a/crypto/err/openssl.ec
+++ b/crypto/err/openssl.ec
@@ -4,37 +4,38 @@
 
 # files that may have to be rewritten by util/mkerr.pl
 L ERR		NONE				NONE
-L BN		crypto/bn/bn.h			crypto/bn/bn_err.c
-L RSA		crypto/rsa/rsa.h		crypto/rsa/rsa_err.c
-L DH		crypto/dh/dh.h			crypto/dh/dh_err.c
-L EVP		crypto/evp/evp.h		crypto/evp/evp_err.c
-L BUF		crypto/buffer/buffer.h		crypto/buffer/buf_err.c
-L OBJ		crypto/objects/objects.h	crypto/objects/obj_err.c
-L PEM		crypto/pem/pem.h		crypto/pem/pem_err.c
-L DSA		crypto/dsa/dsa.h		crypto/dsa/dsa_err.c
-L X509		crypto/x509/x509.h		crypto/x509/x509_err.c
-L ASN1		crypto/asn1/asn1.h		crypto/asn1/asn1_err.c
-L CONF		crypto/conf/conf.h		crypto/conf/conf_err.c
-L CRYPTO	crypto/crypto.h			crypto/cpt_err.c
-L EC		crypto/ec/ec.h			crypto/ec/ec_err.c
-L SSL		ssl/ssl.h			ssl/ssl_err.c
-L BIO		crypto/bio/bio.h		crypto/bio/bio_err.c
-L PKCS7		crypto/pkcs7/pkcs7.h		crypto/pkcs7/pkcs7err.c
-L X509V3	crypto/x509v3/x509v3.h		crypto/x509v3/v3err.c
-L PKCS12	crypto/pkcs12/pkcs12.h		crypto/pkcs12/pk12err.c
-L RAND		crypto/rand/rand.h		crypto/rand/rand_err.c
-L DSO		crypto/dso/dso.h		crypto/dso/dso_err.c
-L ENGINE	crypto/engine/engine.h		crypto/engine/eng_err.c
-L OCSP		crypto/ocsp/ocsp.h		crypto/ocsp/ocsp_err.c
-L UI		crypto/ui/ui.h			crypto/ui/ui_err.c
-L COMP		crypto/comp/comp.h		crypto/comp/comp_err.c
-L ECDSA		crypto/ecdsa/ecdsa.h		crypto/ecdsa/ecs_err.c
-L ECDH		crypto/ecdh/ecdh.h		crypto/ecdh/ech_err.c
-L STORE		crypto/store/store.h		crypto/store/str_err.c
-L TS		crypto/ts/ts.h			crypto/ts/ts_err.c
-L HMAC		crypto/hmac/hmac.h		crypto/hmac/hmac_err.c
-L CMS		crypto/cms/cms.h		crypto/cms/cms_err.c
-L JPAKE		crypto/jpake/jpake.h		crypto/jpake/jpake_err.c
+L BN		include/openssl/bn.h		crypto/bn/bn_err.c
+L RSA		include/openssl/rsa.h		crypto/rsa/rsa_err.c
+L DH		include/openssl/dh.h		crypto/dh/dh_err.c
+L EVP		include/openssl/evp.h		crypto/evp/evp_err.c
+L BUF		include/openssl/buffer.h	crypto/buffer/buf_err.c
+L OBJ		include/openssl/objects.h	crypto/objects/obj_err.c
+L PEM		include/openssl/pem.h		crypto/pem/pem_err.c
+L DSA		include/openssl/dsa.h		crypto/dsa/dsa_err.c
+L X509		include/openssl/x509.h		crypto/x509/x509_err.c
+L ASN1		include/openssl/asn1.h		crypto/asn1/asn1_err.c
+L CONF		include/openssl/conf.h		crypto/conf/conf_err.c
+L CRYPTO	include/openssl/crypto.h	crypto/cpt_err.c
+L EC		include/openssl/ec.h		crypto/ec/ec_err.c
+L SSL		include/openssl/ssl.h		ssl/ssl_err.c
+L BIO		include/openssl/bio.h		crypto/bio/bio_err.c
+L PKCS7		include/openssl/pkcs7.h		crypto/pkcs7/pkcs7err.c
+L X509V3	include/openssl/x509v3.h	crypto/x509v3/v3err.c
+L PKCS12	include/openssl/pkcs12.h	crypto/pkcs12/pk12err.c
+L RAND		include/openssl/rand.h		crypto/rand/rand_err.c
+L DSO		include/openssl/dso.h		crypto/dso/dso_err.c
+L ENGINE	include/openssl/engine.h	crypto/engine/eng_err.c
+L OCSP		include/openssl/ocsp.h		crypto/ocsp/ocsp_err.c
+L UI		include/openssl/ui.h		crypto/ui/ui_err.c
+L COMP		include/openssl/comp.h		crypto/comp/comp_err.c
+L ECDSA		include/openssl/ecdsa.h		crypto/ecdsa/ecs_err.c
+L ECDH		include/openssl/ecdh.h		crypto/ecdh/ech_err.c
+L STORE		include/openssl/store.h		crypto/store/str_err.c
+L TS		include/openssl/ts.h		crypto/ts/ts_err.c
+L HMAC		include/openssl/hmac.h		crypto/hmac/hmac_err.c
+L CMS		include/openssl/cms.h		crypto/cms/cms_err.c
+L JPAKE		include/openssl/jpake.h		crypto/jpake/jpake_err.c
+L FIPS		include/openssl/fips.h		crypto/fips_err.h
 
 # additional header files to be scanned for function names
 L NONE		crypto/x509/x509_vfy.h		NONE
diff --git a/crypto/objects/Makefile b/crypto/objects/Makefile
index c6ea71e..26a30bb 100644
--- a/crypto/objects/Makefile
+++ b/crypto/objects/Makefile
@@ -38,13 +38,13 @@
 	$(RANLIB) $(LIB) || echo Never mind.
 	@touch lib
 
-obj_dat.h: obj_dat.pl obj_mac.h
-	$(PERL) obj_dat.pl obj_mac.h obj_dat.h
+obj_dat.h: obj_dat.pl ../../include/openssl/obj_mac.h
+	$(PERL) obj_dat.pl ../../include/openssl/obj_mac.h obj_dat.h
 
 # objects.pl both reads and writes obj_mac.num
-obj_mac.h: objects.pl objects.txt obj_mac.num
-	$(PERL) objects.pl objects.txt obj_mac.num obj_mac.h
-	@sleep 1; touch obj_mac.h; sleep 1
+../../include/openssl/obj_mac.h: objects.pl objects.txt obj_mac.num
+	$(PERL) objects.pl objects.txt obj_mac.num ../../include/openssl/obj_mac.h
+	@sleep 1; touch ../../include/openssl/obj_mac.h; sleep 1
 
 obj_xref.h: objxref.pl obj_xref.txt obj_mac.num
 	$(PERL) objxref.pl obj_mac.num obj_xref.txt > obj_xref.h
diff --git a/crypto/aes/aes.h b/include/openssl/aes.h
similarity index 100%
rename from crypto/aes/aes.h
rename to include/openssl/aes.h
diff --git a/crypto/asn1/asn1.h b/include/openssl/asn1.h
similarity index 100%
rename from crypto/asn1/asn1.h
rename to include/openssl/asn1.h
diff --git a/crypto/asn1/asn1_mac.h b/include/openssl/asn1_mac.h
similarity index 100%
rename from crypto/asn1/asn1_mac.h
rename to include/openssl/asn1_mac.h
diff --git a/crypto/asn1/asn1t.h b/include/openssl/asn1t.h
similarity index 100%
rename from crypto/asn1/asn1t.h
rename to include/openssl/asn1t.h
diff --git a/crypto/bio/bio.h b/include/openssl/bio.h
similarity index 100%
rename from crypto/bio/bio.h
rename to include/openssl/bio.h
diff --git a/crypto/bf/blowfish.h b/include/openssl/blowfish.h
similarity index 100%
rename from crypto/bf/blowfish.h
rename to include/openssl/blowfish.h
diff --git a/crypto/bn/bn.h b/include/openssl/bn.h
similarity index 100%
rename from crypto/bn/bn.h
rename to include/openssl/bn.h
diff --git a/crypto/buffer/buffer.h b/include/openssl/buffer.h
similarity index 100%
rename from crypto/buffer/buffer.h
rename to include/openssl/buffer.h
diff --git a/crypto/camellia/camellia.h b/include/openssl/camellia.h
similarity index 100%
rename from crypto/camellia/camellia.h
rename to include/openssl/camellia.h
diff --git a/crypto/cast/cast.h b/include/openssl/cast.h
similarity index 100%
rename from crypto/cast/cast.h
rename to include/openssl/cast.h
diff --git a/crypto/cmac/cmac.h b/include/openssl/cmac.h
similarity index 100%
rename from crypto/cmac/cmac.h
rename to include/openssl/cmac.h
diff --git a/crypto/cms/cms.h b/include/openssl/cms.h
similarity index 100%
rename from crypto/cms/cms.h
rename to include/openssl/cms.h
diff --git a/crypto/comp/comp.h b/include/openssl/comp.h
similarity index 100%
rename from crypto/comp/comp.h
rename to include/openssl/comp.h
diff --git a/crypto/conf/conf.h b/include/openssl/conf.h
similarity index 100%
rename from crypto/conf/conf.h
rename to include/openssl/conf.h
diff --git a/crypto/conf/conf_api.h b/include/openssl/conf_api.h
similarity index 100%
rename from crypto/conf/conf_api.h
rename to include/openssl/conf_api.h
diff --git a/crypto/crypto.h b/include/openssl/crypto.h
similarity index 100%
rename from crypto/crypto.h
rename to include/openssl/crypto.h
diff --git a/crypto/des/des.h b/include/openssl/des.h
similarity index 100%
rename from crypto/des/des.h
rename to include/openssl/des.h
diff --git a/crypto/dh/dh.h b/include/openssl/dh.h
similarity index 100%
rename from crypto/dh/dh.h
rename to include/openssl/dh.h
diff --git a/crypto/dsa/dsa.h b/include/openssl/dsa.h
similarity index 100%
rename from crypto/dsa/dsa.h
rename to include/openssl/dsa.h
diff --git a/crypto/dso/dso.h b/include/openssl/dso.h
similarity index 100%
rename from crypto/dso/dso.h
rename to include/openssl/dso.h
diff --git a/ssl/dtls1.h b/include/openssl/dtls1.h
similarity index 100%
rename from ssl/dtls1.h
rename to include/openssl/dtls1.h
diff --git a/e_os2.h b/include/openssl/e_os2.h
similarity index 100%
rename from e_os2.h
rename to include/openssl/e_os2.h
diff --git a/crypto/ebcdic.h b/include/openssl/ebcdic.h
similarity index 100%
rename from crypto/ebcdic.h
rename to include/openssl/ebcdic.h
diff --git a/crypto/ec/ec.h b/include/openssl/ec.h
similarity index 100%
rename from crypto/ec/ec.h
rename to include/openssl/ec.h
diff --git a/crypto/ecdh/ecdh.h b/include/openssl/ecdh.h
similarity index 100%
rename from crypto/ecdh/ecdh.h
rename to include/openssl/ecdh.h
diff --git a/crypto/ecdsa/ecdsa.h b/include/openssl/ecdsa.h
similarity index 100%
rename from crypto/ecdsa/ecdsa.h
rename to include/openssl/ecdsa.h
diff --git a/crypto/engine/engine.h b/include/openssl/engine.h
similarity index 100%
rename from crypto/engine/engine.h
rename to include/openssl/engine.h
diff --git a/crypto/err/err.h b/include/openssl/err.h
similarity index 100%
rename from crypto/err/err.h
rename to include/openssl/err.h
diff --git a/crypto/evp/evp.h b/include/openssl/evp.h
similarity index 100%
rename from crypto/evp/evp.h
rename to include/openssl/evp.h
diff --git a/crypto/hmac/hmac.h b/include/openssl/hmac.h
similarity index 100%
rename from crypto/hmac/hmac.h
rename to include/openssl/hmac.h
diff --git a/crypto/idea/idea.h b/include/openssl/idea.h
similarity index 100%
rename from crypto/idea/idea.h
rename to include/openssl/idea.h
diff --git a/crypto/jpake/jpake.h b/include/openssl/jpake.h
similarity index 100%
rename from crypto/jpake/jpake.h
rename to include/openssl/jpake.h
diff --git a/crypto/krb5/krb5_asn.h b/include/openssl/krb5_asn.h
similarity index 100%
rename from crypto/krb5/krb5_asn.h
rename to include/openssl/krb5_asn.h
diff --git a/ssl/kssl.h b/include/openssl/kssl.h
similarity index 100%
rename from ssl/kssl.h
rename to include/openssl/kssl.h
diff --git a/crypto/lhash/lhash.h b/include/openssl/lhash.h
similarity index 100%
rename from crypto/lhash/lhash.h
rename to include/openssl/lhash.h
diff --git a/crypto/md2/md2.h b/include/openssl/md2.h
similarity index 100%
rename from crypto/md2/md2.h
rename to include/openssl/md2.h
diff --git a/crypto/md4/md4.h b/include/openssl/md4.h
similarity index 100%
rename from crypto/md4/md4.h
rename to include/openssl/md4.h
diff --git a/crypto/md5/md5.h b/include/openssl/md5.h
similarity index 100%
rename from crypto/md5/md5.h
rename to include/openssl/md5.h
diff --git a/crypto/mdc2/mdc2.h b/include/openssl/mdc2.h
similarity index 100%
rename from crypto/mdc2/mdc2.h
rename to include/openssl/mdc2.h
diff --git a/crypto/modes/modes.h b/include/openssl/modes.h
similarity index 100%
rename from crypto/modes/modes.h
rename to include/openssl/modes.h
diff --git a/crypto/objects/obj_mac.h b/include/openssl/obj_mac.h
similarity index 100%
rename from crypto/objects/obj_mac.h
rename to include/openssl/obj_mac.h
diff --git a/crypto/objects/objects.h b/include/openssl/objects.h
similarity index 100%
rename from crypto/objects/objects.h
rename to include/openssl/objects.h
diff --git a/crypto/ocsp/ocsp.h b/include/openssl/ocsp.h
similarity index 100%
rename from crypto/ocsp/ocsp.h
rename to include/openssl/ocsp.h
diff --git a/crypto/opensslv.h b/include/openssl/opensslv.h
similarity index 100%
rename from crypto/opensslv.h
rename to include/openssl/opensslv.h
diff --git a/crypto/ossl_typ.h b/include/openssl/ossl_typ.h
similarity index 100%
rename from crypto/ossl_typ.h
rename to include/openssl/ossl_typ.h
diff --git a/crypto/pem/pem.h b/include/openssl/pem.h
similarity index 100%
rename from crypto/pem/pem.h
rename to include/openssl/pem.h
diff --git a/crypto/pem/pem2.h b/include/openssl/pem2.h
similarity index 100%
rename from crypto/pem/pem2.h
rename to include/openssl/pem2.h
diff --git a/crypto/pkcs12/pkcs12.h b/include/openssl/pkcs12.h
similarity index 100%
rename from crypto/pkcs12/pkcs12.h
rename to include/openssl/pkcs12.h
diff --git a/crypto/pkcs7/pkcs7.h b/include/openssl/pkcs7.h
similarity index 100%
rename from crypto/pkcs7/pkcs7.h
rename to include/openssl/pkcs7.h
diff --git a/crypto/pqueue/pqueue.h b/include/openssl/pqueue.h
similarity index 100%
rename from crypto/pqueue/pqueue.h
rename to include/openssl/pqueue.h
diff --git a/crypto/rand/rand.h b/include/openssl/rand.h
similarity index 100%
rename from crypto/rand/rand.h
rename to include/openssl/rand.h
diff --git a/crypto/rc2/rc2.h b/include/openssl/rc2.h
similarity index 100%
rename from crypto/rc2/rc2.h
rename to include/openssl/rc2.h
diff --git a/crypto/rc4/rc4.h b/include/openssl/rc4.h
similarity index 100%
rename from crypto/rc4/rc4.h
rename to include/openssl/rc4.h
diff --git a/crypto/rc5/rc5.h b/include/openssl/rc5.h
similarity index 100%
rename from crypto/rc5/rc5.h
rename to include/openssl/rc5.h
diff --git a/crypto/ripemd/ripemd.h b/include/openssl/ripemd.h
similarity index 100%
rename from crypto/ripemd/ripemd.h
rename to include/openssl/ripemd.h
diff --git a/crypto/rsa/rsa.h b/include/openssl/rsa.h
similarity index 100%
rename from crypto/rsa/rsa.h
rename to include/openssl/rsa.h
diff --git a/crypto/stack/safestack.h b/include/openssl/safestack.h
similarity index 100%
rename from crypto/stack/safestack.h
rename to include/openssl/safestack.h
diff --git a/crypto/seed/seed.h b/include/openssl/seed.h
similarity index 100%
rename from crypto/seed/seed.h
rename to include/openssl/seed.h
diff --git a/crypto/sha/sha.h b/include/openssl/sha.h
similarity index 100%
rename from crypto/sha/sha.h
rename to include/openssl/sha.h
diff --git a/crypto/srp/srp.h b/include/openssl/srp.h
similarity index 100%
rename from crypto/srp/srp.h
rename to include/openssl/srp.h
diff --git a/ssl/srtp.h b/include/openssl/srtp.h
similarity index 100%
rename from ssl/srtp.h
rename to include/openssl/srtp.h
diff --git a/ssl/ssl.h b/include/openssl/ssl.h
similarity index 100%
rename from ssl/ssl.h
rename to include/openssl/ssl.h
diff --git a/ssl/ssl2.h b/include/openssl/ssl2.h
similarity index 100%
rename from ssl/ssl2.h
rename to include/openssl/ssl2.h
diff --git a/ssl/ssl23.h b/include/openssl/ssl23.h
similarity index 100%
rename from ssl/ssl23.h
rename to include/openssl/ssl23.h
diff --git a/ssl/ssl3.h b/include/openssl/ssl3.h
similarity index 100%
rename from ssl/ssl3.h
rename to include/openssl/ssl3.h
diff --git a/crypto/stack/stack.h b/include/openssl/stack.h
similarity index 100%
rename from crypto/stack/stack.h
rename to include/openssl/stack.h
diff --git a/crypto/store/store.h b/include/openssl/store.h
similarity index 100%
rename from crypto/store/store.h
rename to include/openssl/store.h
diff --git a/crypto/symhacks.h b/include/openssl/symhacks.h
similarity index 100%
rename from crypto/symhacks.h
rename to include/openssl/symhacks.h
diff --git a/ssl/tls1.h b/include/openssl/tls1.h
similarity index 100%
rename from ssl/tls1.h
rename to include/openssl/tls1.h
diff --git a/crypto/ts/ts.h b/include/openssl/ts.h
similarity index 100%
rename from crypto/ts/ts.h
rename to include/openssl/ts.h
diff --git a/crypto/txt_db/txt_db.h b/include/openssl/txt_db.h
similarity index 100%
rename from crypto/txt_db/txt_db.h
rename to include/openssl/txt_db.h
diff --git a/crypto/ui/ui.h b/include/openssl/ui.h
similarity index 100%
rename from crypto/ui/ui.h
rename to include/openssl/ui.h
diff --git a/crypto/whrlpool/whrlpool.h b/include/openssl/whrlpool.h
similarity index 100%
rename from crypto/whrlpool/whrlpool.h
rename to include/openssl/whrlpool.h
diff --git a/crypto/x509/x509.h b/include/openssl/x509.h
similarity index 100%
rename from crypto/x509/x509.h
rename to include/openssl/x509.h
diff --git a/crypto/x509/x509_vfy.h b/include/openssl/x509_vfy.h
similarity index 100%
rename from crypto/x509/x509_vfy.h
rename to include/openssl/x509_vfy.h
diff --git a/crypto/x509v3/x509v3.h b/include/openssl/x509v3.h
similarity index 100%
rename from crypto/x509v3/x509v3.h
rename to include/openssl/x509v3.h
diff --git a/crypto/bf/bftest.c b/test/bftest.c
similarity index 100%
rename from crypto/bf/bftest.c
rename to test/bftest.c
diff --git a/crypto/bn/bntest.c b/test/bntest.c
similarity index 100%
rename from crypto/bn/bntest.c
rename to test/bntest.c
diff --git a/crypto/cast/casttest.c b/test/casttest.c
similarity index 100%
rename from crypto/cast/casttest.c
rename to test/casttest.c
diff --git a/crypto/constant_time_test.c b/test/constant_time_test.c
similarity index 100%
rename from crypto/constant_time_test.c
rename to test/constant_time_test.c
diff --git a/crypto/des/destest.c b/test/destest.c
similarity index 100%
rename from crypto/des/destest.c
rename to test/destest.c
diff --git a/crypto/dh/dhtest.c b/test/dhtest.c
similarity index 100%
rename from crypto/dh/dhtest.c
rename to test/dhtest.c
diff --git a/crypto/dsa/dsatest.c b/test/dsatest.c
similarity index 100%
rename from crypto/dsa/dsatest.c
rename to test/dsatest.c
diff --git a/crypto/ecdh/ecdhtest.c b/test/ecdhtest.c
similarity index 100%
rename from crypto/ecdh/ecdhtest.c
rename to test/ecdhtest.c
diff --git a/crypto/ecdsa/ecdsatest.c b/test/ecdsatest.c
similarity index 100%
rename from crypto/ecdsa/ecdsatest.c
rename to test/ecdsatest.c
diff --git a/crypto/ec/ectest.c b/test/ectest.c
similarity index 100%
rename from crypto/ec/ectest.c
rename to test/ectest.c
diff --git a/crypto/engine/enginetest.c b/test/enginetest.c
similarity index 100%
rename from crypto/engine/enginetest.c
rename to test/enginetest.c
diff --git a/crypto/evp/evp_extra_test.c b/test/evp_extra_test.c
similarity index 100%
rename from crypto/evp/evp_extra_test.c
rename to test/evp_extra_test.c
diff --git a/crypto/evp/evp_test.c b/test/evp_test.c
similarity index 100%
rename from crypto/evp/evp_test.c
rename to test/evp_test.c
diff --git a/crypto/evp/evptests.txt b/test/evptests.txt
similarity index 100%
rename from crypto/evp/evptests.txt
rename to test/evptests.txt
diff --git a/crypto/bn/exptest.c b/test/exptest.c
similarity index 100%
rename from crypto/bn/exptest.c
rename to test/exptest.c
diff --git a/engines/ccgost/gost2814789test.c b/test/gost2814789test.c
similarity index 100%
rename from engines/ccgost/gost2814789test.c
rename to test/gost2814789test.c
diff --git a/ssl/heartbeat_test.c b/test/heartbeat_test.c
similarity index 100%
rename from ssl/heartbeat_test.c
rename to test/heartbeat_test.c
diff --git a/crypto/hmac/hmactest.c b/test/hmactest.c
similarity index 100%
rename from crypto/hmac/hmactest.c
rename to test/hmactest.c
diff --git a/crypto/idea/ideatest.c b/test/ideatest.c
similarity index 100%
rename from crypto/idea/ideatest.c
rename to test/ideatest.c
diff --git a/crypto/jpake/jpaketest.c b/test/jpaketest.c
similarity index 100%
rename from crypto/jpake/jpaketest.c
rename to test/jpaketest.c
diff --git a/crypto/md2/md2test.c b/test/md2test.c
similarity index 100%
rename from crypto/md2/md2test.c
rename to test/md2test.c
diff --git a/crypto/md4/md4test.c b/test/md4test.c
similarity index 100%
rename from crypto/md4/md4test.c
rename to test/md4test.c
diff --git a/crypto/md5/md5test.c b/test/md5test.c
similarity index 100%
rename from crypto/md5/md5test.c
rename to test/md5test.c
diff --git a/crypto/mdc2/mdc2test.c b/test/mdc2test.c
similarity index 100%
rename from crypto/mdc2/mdc2test.c
rename to test/mdc2test.c
diff --git a/crypto/evp/p5_crpt2_test.c b/test/p5_crpt2_test.c
similarity index 100%
rename from crypto/evp/p5_crpt2_test.c
rename to test/p5_crpt2_test.c
diff --git a/crypto/rand/randtest.c b/test/randtest.c
similarity index 100%
rename from crypto/rand/randtest.c
rename to test/randtest.c
diff --git a/crypto/rc2/rc2test.c b/test/rc2test.c
similarity index 100%
rename from crypto/rc2/rc2test.c
rename to test/rc2test.c
diff --git a/crypto/rc4/rc4test.c b/test/rc4test.c
similarity index 100%
rename from crypto/rc4/rc4test.c
rename to test/rc4test.c
diff --git a/crypto/rc5/rc5test.c b/test/rc5test.c
similarity index 100%
rename from crypto/rc5/rc5test.c
rename to test/rc5test.c
diff --git a/crypto/ripemd/rmdtest.c b/test/rmdtest.c
similarity index 100%
rename from crypto/ripemd/rmdtest.c
rename to test/rmdtest.c
diff --git a/crypto/rsa/rsa_test.c b/test/rsa_test.c
similarity index 100%
rename from crypto/rsa/rsa_test.c
rename to test/rsa_test.c
diff --git a/crypto/sha/sha1test.c b/test/sha1test.c
similarity index 100%
rename from crypto/sha/sha1test.c
rename to test/sha1test.c
diff --git a/crypto/sha/sha256t.c b/test/sha256t.c
similarity index 100%
rename from crypto/sha/sha256t.c
rename to test/sha256t.c
diff --git a/crypto/sha/sha512t.c b/test/sha512t.c
similarity index 100%
rename from crypto/sha/sha512t.c
rename to test/sha512t.c
diff --git a/crypto/srp/srptest.c b/test/srptest.c
similarity index 100%
rename from crypto/srp/srptest.c
rename to test/srptest.c
diff --git a/ssl/ssltest.c b/test/ssltest.c
similarity index 100%
rename from ssl/ssltest.c
rename to test/ssltest.c
diff --git a/crypto/x509v3/v3nametest.c b/test/v3nametest.c
similarity index 100%
rename from crypto/x509v3/v3nametest.c
rename to test/v3nametest.c
diff --git a/crypto/whrlpool/wp_test.c b/test/wp_test.c
similarity index 100%
rename from crypto/whrlpool/wp_test.c
rename to test/wp_test.c
diff --git a/util/mkdef.pl b/util/mkdef.pl
index 1d47561..7f1c093 100755
--- a/util/mkdef.pl
+++ b/util/mkdef.pl
@@ -257,79 +257,79 @@
 %crypto_list=&load_numbers($crypto_num);
 $max_crypto = $max_num;
 
-my $ssl="ssl/ssl.h";
-$ssl.=" ssl/kssl.h";
-$ssl.=" ssl/tls1.h";
-$ssl.=" ssl/srtp.h";
+my $ssl="include/openssl/ssl.h";
+$ssl.=" include/openssl/kssl.h";
+$ssl.=" include/openssl/tls1.h";
+$ssl.=" include/openssl/srtp.h";
 
-my $crypto ="crypto/crypto.h";
+my $crypto ="include/openssl/crypto.h";
 $crypto.=" crypto/cryptlib.h";
 $crypto.=" crypto/o_dir.h";
 $crypto.=" crypto/o_str.h";
-$crypto.=" crypto/des/des.h" ; # unless $no_des;
-$crypto.=" crypto/idea/idea.h" ; # unless $no_idea;
-$crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4;
-$crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
-$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
-$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
-$crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
-$crypto.=" crypto/whrlpool/whrlpool.h" ;
-$crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
-$crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
-$crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
-$crypto.=" crypto/mdc2/mdc2.h" ; # unless $no_mdc2;
-$crypto.=" crypto/sha/sha.h" ; # unless $no_sha;
-$crypto.=" crypto/ripemd/ripemd.h" ; # unless $no_ripemd;
-$crypto.=" crypto/aes/aes.h" ; # unless $no_aes;
-$crypto.=" crypto/camellia/camellia.h" ; # unless $no_camellia;
-$crypto.=" crypto/seed/seed.h"; # unless $no_seed;
+$crypto.=" include/openssl/des.h" ; # unless $no_des;
+$crypto.=" include/openssl/idea.h" ; # unless $no_idea;
+$crypto.=" include/openssl/rc4.h" ; # unless $no_rc4;
+$crypto.=" include/openssl/rc5.h" ; # unless $no_rc5;
+$crypto.=" include/openssl/rc2.h" ; # unless $no_rc2;
+$crypto.=" include/openssl/blowfish.h" ; # unless $no_bf;
+$crypto.=" include/openssl/cast.h" ; # unless $no_cast;
+$crypto.=" include/openssl/whrlpool.h" ;
+$crypto.=" include/openssl/md2.h" ; # unless $no_md2;
+$crypto.=" include/openssl/md4.h" ; # unless $no_md4;
+$crypto.=" include/openssl/md5.h" ; # unless $no_md5;
+$crypto.=" include/openssl/mdc2.h" ; # unless $no_mdc2;
+$crypto.=" include/openssl/sha.h" ; # unless $no_sha;
+$crypto.=" include/openssl/ripemd.h" ; # unless $no_ripemd;
+$crypto.=" include/openssl/aes.h" ; # unless $no_aes;
+$crypto.=" include/openssl/camellia.h" ; # unless $no_camellia;
+$crypto.=" include/openssl/seed.h"; # unless $no_seed;
 
-$crypto.=" crypto/bn/bn.h";
-$crypto.=" crypto/rsa/rsa.h" ; # unless $no_rsa;
-$crypto.=" crypto/dsa/dsa.h" ; # unless $no_dsa;
-$crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
-$crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
-$crypto.=" crypto/ecdsa/ecdsa.h" ; # unless $no_ecdsa;
-$crypto.=" crypto/ecdh/ecdh.h" ; # unless $no_ecdh;
-$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
-$crypto.=" crypto/cmac/cmac.h" ;
+$crypto.=" include/openssl/bn.h";
+$crypto.=" include/openssl/rsa.h" ; # unless $no_rsa;
+$crypto.=" include/openssl/dsa.h" ; # unless $no_dsa;
+$crypto.=" include/openssl/dh.h" ; # unless $no_dh;
+$crypto.=" include/openssl/ec.h" ; # unless $no_ec;
+$crypto.=" include/openssl/ecdsa.h" ; # unless $no_ecdsa;
+$crypto.=" include/openssl/ecdh.h" ; # unless $no_ecdh;
+$crypto.=" include/openssl/hmac.h" ; # unless $no_hmac;
+$crypto.=" include/openssl/cmac.h" ;
 
-$crypto.=" crypto/engine/engine.h"; # unless $no_engine;
-$crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
-$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
-$crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
-$crypto.=" crypto/dso/dso.h" ; # unless $no_dso;
-$crypto.=" crypto/lhash/lhash.h" ; # unless $no_lhash;
-$crypto.=" crypto/conf/conf.h";
-$crypto.=" crypto/txt_db/txt_db.h";
+$crypto.=" include/openssl/engine.h"; # unless $no_engine;
+$crypto.=" include/openssl/stack.h" ; # unless $no_stack;
+$crypto.=" include/openssl/buffer.h" ; # unless $no_buffer;
+$crypto.=" include/openssl/bio.h" ; # unless $no_bio;
+$crypto.=" include/openssl/dso.h" ; # unless $no_dso;
+$crypto.=" include/openssl/lhash.h" ; # unless $no_lhash;
+$crypto.=" include/openssl/conf.h";
+$crypto.=" include/openssl/txt_db.h";
 
-$crypto.=" crypto/evp/evp.h" ; # unless $no_evp;
-$crypto.=" crypto/objects/objects.h";
-$crypto.=" crypto/pem/pem.h";
-#$crypto.=" crypto/meth/meth.h";
-$crypto.=" crypto/asn1/asn1.h";
-$crypto.=" crypto/asn1/asn1t.h";
-$crypto.=" crypto/asn1/asn1_mac.h";
-$crypto.=" crypto/err/err.h" ; # unless $no_err;
-$crypto.=" crypto/pkcs7/pkcs7.h";
-$crypto.=" crypto/pkcs12/pkcs12.h";
-$crypto.=" crypto/x509/x509.h";
-$crypto.=" crypto/x509/x509_vfy.h";
-$crypto.=" crypto/x509v3/x509v3.h";
-$crypto.=" crypto/ts/ts.h";
-$crypto.=" crypto/rand/rand.h";
-$crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
-$crypto.=" crypto/ocsp/ocsp.h";
-$crypto.=" crypto/ui/ui.h";
-$crypto.=" crypto/krb5/krb5_asn.h";
-#$crypto.=" crypto/store/store.h";
-$crypto.=" crypto/pqueue/pqueue.h";
-$crypto.=" crypto/cms/cms.h";
-$crypto.=" crypto/jpake/jpake.h";
-$crypto.=" crypto/srp/srp.h";
-$crypto.=" crypto/modes/modes.h";
+$crypto.=" include/openssl/evp.h" ; # unless $no_evp;
+$crypto.=" include/openssl/objects.h";
+$crypto.=" include/openssl/pem.h";
+#$crypto.=" include/openssl/meth.h";
+$crypto.=" include/openssl/asn1.h";
+$crypto.=" include/openssl/asn1t.h";
+$crypto.=" include/openssl/asn1_mac.h";
+$crypto.=" include/openssl/err.h" ; # unless $no_err;
+$crypto.=" include/openssl/pkcs7.h";
+$crypto.=" include/openssl/pkcs12.h";
+$crypto.=" include/openssl/x509.h";
+$crypto.=" include/openssl/x509_vfy.h";
+$crypto.=" include/openssl/x509v3.h";
+$crypto.=" include/openssl/ts.h";
+$crypto.=" include/openssl/rand.h";
+$crypto.=" include/openssl/comp.h" ; # unless $no_comp;
+$crypto.=" include/openssl/ocsp.h";
+$crypto.=" include/openssl/ui.h";
+$crypto.=" include/openssl/krb5_asn.h";
+#$crypto.=" include/openssl/store.h";
+$crypto.=" include/openssl/pqueue.h";
+$crypto.=" include/openssl/cms.h";
+$crypto.=" include/openssl/jpake.h";
+$crypto.=" include/openssl/srp.h";
+$crypto.=" include/openssl/modes.h";
 
-my $symhacks="crypto/symhacks.h";
+my $symhacks="include/openssl/symhacks.h";
 
 my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
 my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
diff --git a/util/mkstack.pl b/util/mkstack.pl
index 6e6741f..0739027 100755
--- a/util/mkstack.pl
+++ b/util/mkstack.pl
@@ -3,7 +3,7 @@
 # Search out "DECLARE_STACK_OF()" # declarations in .h and .c files,
 # and create corresponding macro declarations for crypto/stack/safestack.h.
 
-my $safestack = "crypto/stack/safestack.h";
+my $safestack = "include/openssl/safestack.h";
 my $do_write = 0;
 
 foreach ( @ARGV ) {
@@ -15,7 +15,7 @@
 my @asn1setlst;
 my @p12stklst;
 my @lhashlst;
-my @source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>);
+my @source = (<include/openssl/*.h>, <crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>);
 foreach $file (@source) {
     next if -l $file;