mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
Android cross-compilation to client cmake
This commit is contained in:
parent
94403bee59
commit
25fb6df229
3 changed files with 80 additions and 7 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Add Android cross-compilation to client cmake (@dxl, @doegox)
|
||||||
- Fix `emv scan` - now saves in current folder and uses unique names (@iceman1001)
|
- Fix `emv scan` - now saves in current folder and uses unique names (@iceman1001)
|
||||||
- Fix pm3.sh - parse COM ports larger than one digit (@doegox)
|
- Fix pm3.sh - parse COM ports larger than one digit (@doegox)
|
||||||
- Fix stack size and automatically use available space for BigBuf. Stack is now 5K (@slurdge)
|
- Fix stack size and automatically use available space for BigBuf. Stack is now 5K (@slurdge)
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
# On Proxspace 3.3 or less, you need to install cmake:
|
# On Proxspace 3.3 or less, you need to install cmake:
|
||||||
# pacman -S mingw-w64-x86_64-cmake
|
# pacman -S mingw-w64-x86_64-cmake
|
||||||
# /mingw64/bin/cmake -G"MSYS Makefiles" ..
|
# /mingw64/bin/cmake -G"MSYS Makefiles" ..
|
||||||
|
#
|
||||||
|
# Android cross-compilation:
|
||||||
|
# cmake \
|
||||||
|
# -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
|
||||||
|
# -DANDROID_ABI=armeabi-v7a \
|
||||||
|
# -DANDROID_NATIVE_API_LEVEL=android-19 \
|
||||||
|
# -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(proxmark3)
|
project(proxmark3)
|
||||||
|
@ -49,21 +56,75 @@ if (NOT SKIPPYTHON EQUAL 1)
|
||||||
pkg_search_module(PYTHON3EMBED QUIET python3-embed)
|
pkg_search_module(PYTHON3EMBED QUIET python3-embed)
|
||||||
endif (NOT SKIPPYTHON EQUAL 1)
|
endif (NOT SKIPPYTHON EQUAL 1)
|
||||||
|
|
||||||
|
# If build on android cross, we need to init source and build.
|
||||||
|
if (ANDROID)
|
||||||
|
set(CFLAGS_EXTERNAL_LIB CFLAGS=--target=${CMAKE_C_COMPILER_TARGET})
|
||||||
|
include(ExternalProject)
|
||||||
|
endif (ANDROID)
|
||||||
|
|
||||||
if (NOT SKIPREADLINE EQUAL 1)
|
if (NOT SKIPREADLINE EQUAL 1)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
|
find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include NO_DEFAULT_PATH)
|
||||||
endif (APPLE)
|
|
||||||
find_path(READLINE_INCLUDE_DIRS readline/readline.h)
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
|
find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib NO_DEFAULT_PATH)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
find_library(READLINE_LIBRARIES readline)
|
if (ANDROID)
|
||||||
|
ExternalProject_Add(ncurses
|
||||||
|
URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz
|
||||||
|
PREFIX deps/ncurses
|
||||||
|
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
|
||||||
|
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm
|
||||||
|
BUILD_IN_SOURCE ON
|
||||||
|
BUILD_COMMAND make -j2 libs
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD ON
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(ncurses configure build install)
|
||||||
|
|
||||||
|
ExternalProject_Add(readline
|
||||||
|
URL ftp://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz
|
||||||
|
PREFIX deps/readline
|
||||||
|
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
|
||||||
|
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --enable-static
|
||||||
|
BUILD_IN_SOURCE ON
|
||||||
|
BUILD_COMMAND make -j2
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD ON
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(readline configure build install)
|
||||||
|
set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
|
||||||
|
set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libncurses.a)
|
||||||
|
else (ANDROID)
|
||||||
|
find_path(READLINE_INCLUDE_DIRS readline/readline.h)
|
||||||
|
find_library(READLINE_LIBRARIES readline)
|
||||||
|
endif (ANDROID)
|
||||||
if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||||
set(READLINE_FOUND ON)
|
set(READLINE_FOUND ON)
|
||||||
endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
|
||||||
endif (NOT SKIPREADLINE EQUAL 1)
|
endif (NOT SKIPREADLINE EQUAL 1)
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||||
|
ExternalProject_Add(bzip2
|
||||||
|
GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
|
||||||
|
GIT_TAG platform-tools-30.0.2
|
||||||
|
PREFIX deps/bzip2
|
||||||
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
|
||||||
|
CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
|
||||||
|
BUILD_IN_SOURCE ON
|
||||||
|
BUILD_COMMAND make -C ${BZIP2_BUILD_DIR} -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} libbz2.a
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD ON
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(bzip2 configure build install)
|
||||||
|
set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||||
|
set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
|
||||||
|
else()
|
||||||
|
set(BZIP2_LIBRARIES bz2)
|
||||||
|
endif(ANDROID)
|
||||||
|
if (BZIP2_LIBRARIES)
|
||||||
|
set(BZIP2_FOUND ON)
|
||||||
|
endif (BZIP2_LIBRARIES)
|
||||||
|
|
||||||
add_subdirectory(${PM3_ROOT}/client/deps deps)
|
add_subdirectory(${PM3_ROOT}/client/deps deps)
|
||||||
|
|
||||||
set (TARGET_SOURCES
|
set (TARGET_SOURCES
|
||||||
|
@ -268,6 +329,12 @@ if (NOT SKIPREADLINE EQUAL 1)
|
||||||
set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
|
set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
|
||||||
endif (READLINE_FOUND)
|
endif (READLINE_FOUND)
|
||||||
endif(NOT SKIPREADLINE EQUAL 1)
|
endif(NOT SKIPREADLINE EQUAL 1)
|
||||||
|
if (BZIP2_FOUND)
|
||||||
|
set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
|
||||||
|
set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
|
||||||
|
else (BZIP2_FOUND)
|
||||||
|
message(FATAL_ERROR "Bzip2 not found")
|
||||||
|
endif (BZIP2_FOUND)
|
||||||
|
|
||||||
message("===================================================================")
|
message("===================================================================")
|
||||||
if (SKIPQT EQUAL 1)
|
if (SKIPQT EQUAL 1)
|
||||||
|
@ -320,6 +387,12 @@ add_executable(proxmark3
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
|
target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
|
||||||
|
if (ANDROID)
|
||||||
|
if (NOT SKIPREADLINE EQUAL 1)
|
||||||
|
add_dependencies(proxmark3 ncurses readline)
|
||||||
|
endif (NOT SKIPREADLINE EQUAL 1)
|
||||||
|
add_dependencies(proxmark3 bzip2)
|
||||||
|
endif (ANDROID)
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||||
|
@ -357,7 +430,6 @@ find_library(pm3rrg_rdv4_hardnested REQUIRED)
|
||||||
find_library(pm3rrg_rdv4_whereami REQUIRED)
|
find_library(pm3rrg_rdv4_whereami REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(proxmark3 PRIVATE
|
target_link_libraries(proxmark3 PRIVATE
|
||||||
bz2
|
|
||||||
m
|
m
|
||||||
pm3rrg_rdv4_mbedtls
|
pm3rrg_rdv4_mbedtls
|
||||||
pm3rrg_rdv4_cliparser
|
pm3rrg_rdv4_cliparser
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdio.h> // for Mingw readline
|
#include <stdio.h> // for Mingw readline
|
||||||
#include <ctype.h> // tolower
|
#include <ctype.h> // tolower
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifdef HAVE_READLINE
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue