Steps for porting the OpenSSL For Android
1) Android NDK (latest is recommended)
2) Cygwin with shell support for windows
1) Download the latest open ssl code from the http://www.openssl.org/
2) Unzip the file and configure for the android by executing the Configure command
You can remove the modules which you want by adding those directives in the Configure command
./Configure linux-generic32 no-idea no-bf no-cast no-seed no-md2 -DL_ENDIAN
3) Create an updated android-config.mk file which contains the CFLAG and DEPFLAG of the makefile in the root (first) folder. Make sure to add all the -D flags to LOCAL_CFLAGS, except -DTERMIO; include -DOPENSSL_NO_HW in addition to these. Anyway its better to include all the -DOPENSSL_NO_xxx flags as well, but it not important as those will be replicated in the file crypto/opensslconf.h when ./Configure is executed.
4) Copy the new LICENSE file from OpenSSL distribution as NOTICE.
Create an empty MODULE_LICENSE_BSD_LIKE file
5)You may delete the following directories along with their contents,
since we won't use these (any more):
MacOS Netware VMS apps/demoCA apps/set bugs certs crypto/bf crypto/cast \
crypto/cms crypto/idea crypto/md2 crypto/rc5 crypto/seed demos doc \
engines ms os2 perl shlib test times tools util
Also you may delete the following files:
CHANGES CHANGES.SSLeay ChangeLog.0_9_7-stable_not-in-head \
ChangeLog.0_9_7-stable_not-in-head_FIPS Configure FAQ INSTALL \
INSTALL.DJGPP INSTALL.MacOS INSTALL.NW INSTALL.OS2 INSTALL.VMS \
INSTALL.W32 INSTALL.W64 INSTALL.WCE LICENSE Makefile Makefile.bak \
Makefile.org Makefile.shared NEWS PROBLEMS README README.ASN1 \
README.ENGINE apps/CA.pl.bak config crypto/opensslconf.h.bak \
install.com makevms.com openssl.doxy openssl.spec
If any modules is required for your project specific purpose retain those folders.
6) Go to include/openssl. There's a bunch of symlinks here. Since symlinks
can be a special case for version control, replace them by regular files:
for l in *.h; do cp $l copy_$l; rm $l; mv copy_$l $l; done
Some symlinks will remain, pointing to files that don't exit
(you deleted those in step d). Delete the symlinks.
7) Create Android.mk files based on those you find in the previous OpenSSL port:
For the latter three, merge in any substantial changes between the
corresponding Makefiles in the OpenSSL distribution (apps/Makefile,
crypto/Makefile, crypto/*/Makefile, ssl/Makefile).
Don't forget to update the directory name for OpenSSL in these files
and whereever else it is used.
Check the makefiles and add if we have any missed files. Don't add all the missed files as it may cause redefinition error during linking.
Don't blindly copy the android.mk makefiles from the existing android ported code. Some files need to be added if missing from the new makefiles.
8) Generate the asm files for your particular architecture type using the perl scripts which are already present in the asm folders of the OpenSSL.
Ex: # Generate asm
perl crypto/aes/asm/aes-armv4.pl > crypto/aes/asm/aes-armv4.S
perl crypto/bn/asm/armv4-mont.pl > crypto/bn/asm/armv4-mont.S
perl crypto/sha/asm/sha1-armv4-large.pl > crypto/sha/asm/sha1-armv4-large.S
perl crypto/sha/asm/sha256-armv4.pl > crypto/sha/asm/sha256-armv4.S
perl crypto/sha/asm/sha512-armv4.pl > crypto/sha/asm/sha512-armv4.S
9) During facing compilation issue, we may have to
a) Change the include path of the header files in the source (.c or .cpp) files.
b) Disable some of the mains for the removed modules of those #defines are not properly enabled
Ex: #if 0 /* ANDROID */
For removing the ts_main in the ..../openssl/apps/progs.h
c) May face some of the undefined reference errors, search in the source files for the definition where it is present and include in compilation if required or else if that module has been removed then comment it.
10) If compilation is gone through you will find the .so files got generated.
Happy porting :).
Credit to the below guy