Skip to content

Commit

Permalink
Add Android.mk and Application.mk to build using android NDK
Browse files Browse the repository at this point in the history
  • Loading branch information
cawka committed Jun 29, 2015
1 parent 9425e16 commit 069b3c4
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -217,3 +217,7 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

# Android NDK build files
libs/
obj/
16 changes: 16 additions & 0 deletions jni/Android.mk
@@ -0,0 +1,16 @@
LOCAL_PATH := $(call my-dir)

CRYPTOPP_SRC_FILES := 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp asn.cpp authenc.cpp base32.cpp base64.cpp basecode.cpp bfinit.cpp blowfish.cpp blumshub.cpp camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp channels.cpp cmac.cpp cpu.cpp crc.cpp cryptlib_bds.cpp cryptlib.cpp default.cpp des.cpp dessp.cpp dh2.cpp dh.cpp dll.cpp dsa.cpp eax.cpp ec2n.cpp eccrypto.cpp ecp.cpp elgamal.cpp emsa2.cpp eprecomp.cpp esign.cpp files.cpp filters.cpp fips140.cpp fipsalgt.cpp gcm.cpp gf2_32.cpp gf256.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp hex.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp integer.cpp iterhash.cpp luc.cpp mars.cpp marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp network.cpp oaep.cpp osrng.cpp panama.cpp pch.cpp pkcspad.cpp polynomi.cpp pssr.cpp pubkey.cpp queue.cpp rabin.cpp randpool.cpp rc2.cpp rc5.cpp rc6.cpp rdtables.cpp rijndael.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp seal.cpp seed.cpp serpent.cpp sha3.cpp shacal2.cpp sha.cpp sharkbox.cpp shark.cpp simple.cpp skipjack.cpp socketft.cpp sosemanuk.cpp square.cpp squaretb.cpp strciphr.cpp tea.cpp tftables.cpp tiger.cpp tigertab.cpp trdlocal.cpp ttmac.cpp twofish.cpp vmac.cpp wait.cpp wake.cpp whrlpool.cpp winpipes.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp zinflate.cpp zlib.cpp

include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_shared
LOCAL_SRC_FILES := $(addprefix ../,$(CRYPTOPP_SRC_FILES))
LOCAL_CFLAGS := -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_SSSE3 -DCRYPTOPP_DISABLE_AESNI
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp_static
LOCAL_SRC_FILES := $(addprefix ../,$(CRYPTOPP_SRC_FILES))
LOCAL_CFLAGS := -DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_SSSE3 -DCRYPTOPP_DISABLE_AESNI
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..
include $(BUILD_STATIC_LIBRARY)
6 changes: 6 additions & 0 deletions jni/Application.mk
@@ -0,0 +1,6 @@
APP_ABI := all

APP_MODULES := cryptopp_static cryptopp_shared

APP_STL := gnustl_shared
APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti
48 changes: 48 additions & 0 deletions jni/README.md
@@ -0,0 +1,48 @@
Android NDK build files
=======================

CryptoPP library can be independently built using just one command:

cd <cryptopp-folder>
ndk-build

This will build shared library in `libs/` and static library in `obj/`.

It is also possible to integrate CryptoPP into applications build process.
For example, if application source has the following structure:

├── AndroidManifest.xml
├── java
│   ├── ...
│   └── ...
├── jni
│   ├── Android.mk
│   └── Application.mk
└── res
   ├── ...
   └── ...

- Copy CryptoPP source code (or create git submodule) in `jni/cryptopp`

In jni/Android.mk ,add

include $(LOCAL_PATH)/cryptopp/jni/Android.mk

- In application's `Android.mk` add the desired version of the library to `LOCAL_(STATIC|SHARED)_LIBRARIES`.
For shared version:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := my-local-module
LOCAL_SHARED_LIBRARIES := cryptopp_shared ...
include $(BUILD_SHARED_LIBRARY)

For static version:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := my-local-module
LOCAL_STATIC_LIBRARIES := cryptopp_static ...
include $(BUILD_SHARED_LIBRARY)

0 comments on commit 069b3c4

Please sign in to comment.