diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 0de34d58f..12f709caf 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -20,6 +20,8 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() +find_package(PkgConfig) + if (NOT SKIPQT EQUAL 1) if(APPLE AND EXISTS /usr/local/opt/qt5) # Homebrew installs Qt5 (up to at least 5.11.0) in @@ -46,7 +48,6 @@ if (NOT SKIPQT EQUAL 1) endforeach() endif (NOT SKIPQT EQUAL 1) -find_package(PkgConfig) if (NOT SKIPBT EQUAL 1) pkg_search_module(BLUEZ QUIET bluez) endif (NOT SKIPBT EQUAL 1) @@ -102,6 +103,19 @@ if (NOT SKIPREADLINE EQUAL 1) endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES) endif (NOT SKIPREADLINE EQUAL 1) +if (NOT SKIPJANSSONSYSTEM EQUAL 1) + pkg_check_modules(PC_JANSSON QUIET jansson) + find_path(JANSSON_INCLUDE_DIRS + NAMES jansson.h + HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS}) + find_library(JANSSON_LIBRARIES + NAMES jansson libjansson + HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS}) + if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES) + set(JANSSON_FOUND ON) + endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES) +endif (NOT SKIPJANSSONSYSTEM EQUAL 1) + if(ANDROID) set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2) ExternalProject_Add(bzip2 @@ -118,12 +132,18 @@ if(ANDROID) 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) +else() + find_package (BZip2 REQUIRED) +endif(ANDROID) + +if (NOT SKIPWHEREAMISYSTEM EQUAL 1) + find_path(WHEREAMI_INCLUDE_DIRS whereami.h) + find_library(WHEREAMI_LIBRARIES whereami) + if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES) + set(WHEREAMI_FOUND ON) + endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES) +endif (NOT SKIPWHEREAMISYSTEM EQUAL 1) add_subdirectory(${PM3_ROOT}/client/deps deps) @@ -308,6 +328,11 @@ if (NOT SKIPBT EQUAL 1) endif (BLUEZ_FOUND) endif(NOT SKIPBT EQUAL 1) +if (JANSSON_FOUND) + set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) + set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK}) +endif (JANSSON_FOUND) + if (NOT SKIPPYTHON EQUAL 1) if (PYTHON3EMBED_FOUND) add_definitions(-DHAVE_PYTHON) @@ -329,13 +354,17 @@ if (NOT SKIPREADLINE EQUAL 1) set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK}) endif (READLINE_FOUND) 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) +if (WHEREAMI_FOUND) + set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) + set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK}) +endif (WHEREAMI_FOUND) + message("===================================================================") if (SKIPQT EQUAL 1) message("GUI support: skipped") @@ -357,6 +386,16 @@ else (SKIPBT EQUAL 1) endif (BLUEZ_FOUND) endif(SKIPBT EQUAL 1) +if (SKIPJANSSONSYSTEM EQUAL 1) + message("Jansson library: local library forced") +else (SKIPJANSSONSYSTEM EQUAL 1) + if (JANSSON_FOUND) + message("Jansson library: system library found") + else (JANSSON_FOUND) + message("Jansson library: system library not found, using local library") + endif (JANSSON_FOUND) +endif (SKIPJANSSONSYSTEM EQUAL 1) + if (SKIPPYTHON EQUAL 1) message("Python3 library: skipped") else (SKIPPYTHON EQUAL 1) @@ -378,6 +417,16 @@ else (SKIPREADLINE EQUAL 1) message("Readline library: Readline not found, disabled") endif (READLINE_FOUND) endif(SKIPREADLINE EQUAL 1) + +if (SKIPWHEREAMISYSTEM EQUAL 1) + message("Whereami library: local library forced") +else (SKIPWHEREAMISYSTEM EQUAL 1) + if (WHEREAMI_FOUND) + message("Whereami library: system library found") + else (WHEREAMI_FOUND) + message("Whereami library: system library not found, using local library") + endif (WHEREAMI_FOUND) +endif (SKIPWHEREAMISYSTEM EQUAL 1) message("===================================================================") add_executable(proxmark3 @@ -421,25 +470,30 @@ endif (NOT APPLE) find_library(pm3rrg_rdv4_cliparser REQUIRED) -find_library(pm3rrg_rdv4_jansson REQUIRED) find_library(pm3rrg_rdv4_tinycbor REQUIRED) find_library(pm3rrg_rdv4_lua REQUIRED) find_library(pm3rrg_rdv4_mbedtls REQUIRED) find_library(pm3rrg_rdv4_reveng REQUIRED) find_library(pm3rrg_rdv4_hardnested REQUIRED) -find_library(pm3rrg_rdv4_whereami REQUIRED) + +if (NOT JANSSON_FOUND) + find_library(pm3rrg_rdv4_jansson REQUIRED) + set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK}) +endif (NOT JANSSON_FOUND) +if (NOT WHEREAMI_FOUND) + find_library(pm3rrg_rdv4_whereami REQUIRED) + set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK}) +endif (NOT WHEREAMI_FOUND) target_link_libraries(proxmark3 PRIVATE m pm3rrg_rdv4_mbedtls pm3rrg_rdv4_cliparser - pm3rrg_rdv4_jansson pm3rrg_rdv4_lua pm3rrg_rdv4_tinycbor pm3rrg_rdv4_amiibo pm3rrg_rdv4_reveng pm3rrg_rdv4_hardnested - pm3rrg_rdv4_whereami ${ADDITIONAL_LNK}) if (NOT SKIPPTHREAD EQUAL 1) diff --git a/common_arm/ldscript.common b/common_arm/ldscript.common index c1fb5e848..443d9825d 100644 --- a/common_arm/ldscript.common +++ b/common_arm/ldscript.common @@ -9,7 +9,7 @@ ms of the GNU GPL, version 2 or, ----------------------------------------------------------------------------- */ -stacksize = DEFINED(stacksize) ? stacksize : 6K; +stacksize = DEFINED(stacksize) ? stacksize : 9K; commonareasize = 0x20; /* AT91SAM7S256 has 256k Flash and 64k RAM */ diff --git a/doc/md/Development/Makefile-vs-CMake.md b/doc/md/Development/Makefile-vs-CMake.md index 6c2432c70..98a7b0dde 100644 --- a/doc/md/Development/Makefile-vs-CMake.md +++ b/doc/md/Development/Makefile-vs-CMake.md @@ -16,8 +16,7 @@ At the moment both are maintained because they don't perfectly overlap yet. | verbose | V=1 | VERBOSE=1 | | | warnings management | yes (1) | **no** | (1) cf Makefile.defs | | compilation | in place | in build dir | | -| user `CFLAGS`/`LDFLAGS` | honored (1) | **no/auto?** | (1) also `LDLIBS` and `INCLUDES_CLIENT` as envvars for more tuning | -| `PKG_CONFIG_ENV` | yes | **no/auto?** | | +| user `CFLAGS`/`LDFLAGS` | envvars honored (1) | envvars honored (2) | (1) also `LDLIBS` and `INCLUDES_CLIENT` for more tuning (2) only at first cmake call | | Mingw gnu printf | `_ISOC99_SOURCE` | `_ISOC99_SOURCE` | and in cbor.h: `__attribute__((format (__MINGW_PRINTF_FORMAT, 2, 3)))`| | C++ | c++11 | gnu++14 | | | dep amiibo | in_deps | in_deps | | @@ -27,28 +26,28 @@ At the moment both are maintained because they don't perfectly overlap yet. | bluez detection | pc | pkg_search_module | | | `SKIPBT` | yes | yes | | | dep bzip2 | sys | sys | | -| bzip2 detection | **none** | **none**, Android:gitclone | | +| bzip2 detection | **none** | find_package, Android:gitclone | | | dep cliparser | in_deps | in_deps | | | dep hardnested | in_deps | in_deps | | -| hardn arch autodetect | (1) | (2) | (1) uname -m == 86 or amd64; gcc -E -mavx512f? +-AVX512 (2) CMAKE_SYSTEM_PROCESSOR == x86 or x86_64 or i686 or AMD64 (always incl. AVX512) | +| hardn arch autodetect | `uname -m` =? 86 or amd64; `$(CC) -E -mavx512f`? +AVX512` | `CMAKE_SYSTEM_PROCESSOR` =? x86 or x86_64 or i686 or AMD64 (1) | (1) currently it always includes AVX512 on Intel arch | | `cpu_arch` | yes | **no/auto?** | e.g. `cpu_arch=generic` for cross-compilation -| dep jansson | sys / in_deps | **in_deps only** | | -| jansson detection | pc | **none** | | -| `SKIPJANSSONSYSTEM` | yes | **no** | | +| dep jansson | sys / in_deps | sys / in_deps | | +| jansson detection | pc | pc/find* | | +| `SKIPJANSSONSYSTEM` | yes | yes | | | dep lua | sys / in_deps(1) | **in_deps only**(2) | (1) manual def of `LUAPLATFORM` for mingw/macosx/linux (2) manual, different?, for Android too | | lua detection | pc | **none** | | | `SKIPLUASYSTEM` | yes | **no** | | -| lualibs/pm3_cmd.lua | yes | **add_custom_command used?** | -| lualibs/mfc_default_keys.lua | yes | **add_custom_command used?** | -| dep lz4 | | | (in_common) not yet used, future | +| lualibs/pm3_cmd.lua | yes | add_custom_command **but unused** | | +| lualibs/mfc_default_keys.lua | yes | add_custom_command **but unused** | | +| dep lz4 | | | (in_common) not yet used, future. See `get_lz4.sh` for upstream fetch & patch | | dep libm | sys | sys | | -| libm detection | none | **none/auto?** | | +| libm detection | **none** | **none** (1) | (1) cf https://cmake.org/pipermail/cmake/2019-March/069168.html ? | | dep mbedtls | in_common | in_common | no sys lib: missing support for CMAC in def conf (btw no .pc available) | | dep python3 | opt, sys, <3.8 & 3.8 | opt, sys, <3.8 & 3.8 | | | python3 detection | pc | pkg_search_module | | | `SKIPPYTHON` | yes | yes | | | dep pthread | sys | sys | | -| pthread detection | **none** | **none** | | +| pthread detection | **none** | **none** (1) | (1) cf https://stackoverflow.com/questions/1620918/cmake-and-libpthread ? | | `SKIPPTHREAD` | yes | yes | e.g. for termux | | dep Qt | opt, sys, Qt5 & Qt4 | opt, sys, Qt5 | | | Qt detection | pc(qt5)/pc(qt4)/`QTDIR`(1) (2) | find_package(qt5) (3) | (1) if `QTDIR`: hardcode path (2) OSX: pkg-config hook for Brew (3) OSX: add search path| @@ -59,9 +58,9 @@ At the moment both are maintained because they don't perfectly overlap yet. | dep reveng | in_deps | in_deps | | | `SKIPREVENGTEST` | yes(1) | **no**(2) | (1) e.g. if cross-compilation (2) tests aren't compiled/ran with cmake | | dep tinycbor | in_deps | in_deps | | -| dep whereami | sys / in_deps | **in_deps only** | | -| whereami detection | **search /usr/include/whereami.h** | **none** | no .pc available | -| `SKIPWHEREAMISYSTEM` | yes | **no** | | +| dep whereami | sys / in_deps | sys / in_deps | | +| whereami detection | **search /usr/include/whereami.h** | find* | no .pc available | +| `SKIPWHEREAMISYSTEM` | yes | yes | | | version | mkversion | mkversion | | | install | yes (1) | **no** | (1) supports `DESTDIR`, `PREFIX`, `UDEV_PREFIX`. Installs resources as well, `INSTALL*RELPATH` | | deb | no | partial? | |