Add pkg-config support (Fixes #75)

This commit is contained in:
Cryptiiiic 2022-06-16 03:22:31 -07:00
parent f7fa07e2ba
commit b3f500cdd9
No known key found for this signature in database
GPG key ID: 6027B509EFE3A76B
8 changed files with 125 additions and 63 deletions

View file

@ -8,11 +8,11 @@ export BASE=${TMPDIR}/Builder/repos/futurerestore/
cd ${BASE} cd ${BASE}
ln -sf ${DEP_ROOT}/Linux_x86_64_Release/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/Linux_x86_64_Release/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-release-x86_64 make -j4 -l4 -C cmake-build-release-x86_64
cd ${BASE} cd ${BASE}
ln -sf ${DEP_ROOT}/Linux_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/Linux_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-debug-x86_64 make -j4 -l4 -C cmake-build-debug-x86_64
llvm-strip-13 -s cmake-build-release-x86_64/src/futurerestore llvm-strip-13 -s cmake-build-release-x86_64/src/futurerestore

View file

@ -7,19 +7,19 @@ export BASE=/Users/runner/work/futurerestore/futurerestore/
cd /Users/runner/work/futurerestore/futurerestore/ cd /Users/runner/work/futurerestore/futurerestore/
ln -sf ${DEP_ROOT}/macOS_x86_64_Release/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/macOS_x86_64_Release/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-release-x86_64 make -j4 -l4 -C cmake-build-release-x86_64
ln -sf ${DEP_ROOT}/macOS_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/macOS_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-debug-x86_64 make -j4 -l4 -C cmake-build-debug-x86_64
ln -sf ${DEP_ROOT}/macOS_arm64_Release/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/macOS_arm64_Release/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-arm64 -DARCH=arm64 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-arm64 -DARCH=arm64 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-release-arm64 make -j4 -l4 -C cmake-build-release-arm64
ln -sf ${DEP_ROOT}/macOS_arm64_Debug/{lib/,include/} ${DEP_ROOT}/ ln -sf ${DEP_ROOT}/macOS_arm64_Debug/{lib/,include/} ${DEP_ROOT}/
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-arm64 -DARCH=arm64 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-arm64 -DARCH=arm64 -DNO_PKGCFG
make -j4 -l4 -C cmake-build-debug-arm64 make -j4 -l4 -C cmake-build-debug-arm64
llvm-strip -s cmake-build-release-x86_64/src/futurerestore llvm-strip -s cmake-build-release-x86_64/src/futurerestore
llvm-strip -s cmake-build-release-arm64/src/futurerestore llvm-strip -s cmake-build-release-arm64/src/futurerestore

View file

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.22)
find_package(PkgConfig REQUIRED)
set(SUBPROJECT_BUILD 1) set(SUBPROJECT_BUILD 1)
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
if(NOT DEFINED NO_XCODE AND NOT DEFINED ENV{NO_XCODE}) if(NOT DEFINED NO_XCODE AND NOT DEFINED ENV{NO_XCODE})
@ -16,15 +17,17 @@ if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(ARCH "${CMAKE_SYSTEM_PROCESSOR}") set(ARCH "${CMAKE_SYSTEM_PROCESSOR}")
endif() endif()
endif() endif()
if("${ARCH}" STREQUAL "x86_64" OR "$ENV{ARCH}" STREQUAL "x86_64") if(NOT DEFINED MINVER OR NOT DEFINED "$ENV{MINVER}" AND DEFINED NO_PKGCFG AND "$ENV{NO_PKGCFG}" MATCHES "1")
set(MINVER -mmacosx-version-min=10.12) if("${ARCH}" STREQUAL "x86_64" OR "$ENV{ARCH}" STREQUAL "x86_64")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) set(MINVER -mmacosx-version-min=10.12)
else() set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
set(MINVER -mmacosx-version-min=11.0) else()
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) set(MINVER -mmacosx-version-min=11.0)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
endif()
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread -mrelax-all -std=gnu++20")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread -mrelax-all -std=gnu17")
elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux") elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-multiple-definition -pthread") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-multiple-definition -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -pthread")
@ -38,4 +41,5 @@ set(CMAKE_CXX_STANDARD 20)
project(futurerestore) project(futurerestore)
add_subdirectory(external/tsschecker) add_subdirectory(external/tsschecker)
add_subdirectory(external/idevicerestore) add_subdirectory(external/idevicerestore)
add_subdirectory(src) add_subdirectory(src)

View file

@ -48,6 +48,12 @@
If you want to build in release mode pass in the RELEASE=1 environment variable. If you want to build in release mode pass in the RELEASE=1 environment variable.
* Example: `RELEASE=1 ./build.sh -DARCH=x86_64` or `RELEASE=0 ./build.sh -DARCH=x86_64` * Example: `RELEASE=1 ./build.sh -DARCH=x86_64` or `RELEASE=0 ./build.sh -DARCH=x86_64`
If you want to disable pkg-config linking you can provide the `NO_PKGCFG` flag.
By default pkg-config linking is enabled. dep_root will be used when disabled.
* Example: `./build.sh -DARCH=x86_64 -DNO_PKGCFG`
* or `NO_PKGCFG=1 ./build.sh -DARCH=x86_64`
If you want to overwrite the compiler on mac you can provide `NO_XCODE` flag. If you want to overwrite the compiler on mac you can provide `NO_XCODE` flag.
* Example: `CC=gcc CXX=g++ ./build.sh -DARCH=x86_64 -DNO_XCODE` * Example: `CC=gcc CXX=g++ ./build.sh -DARCH=x86_64 -DNO_XCODE`
@ -58,5 +64,9 @@
* By default it will remove cmake and cache and reconfigure for each subsequent build. * By default it will remove cmake and cache and reconfigure for each subsequent build.
The compiled binary will be located at: The compiled binary will be located at:
* `cmake-build-release/src/futurerestore` for release build * `cmake-build-release/src/futurerestore` for release builds
* `cmake-build-debug/src/futurerestore` for debug builds * `cmake-build-debug/src/futurerestore` for debug builds
Otherwise you can install the binary via:
* `make -C cmake-build-release install` for release builds
* `make -C cmake-build-debug install` for debug builds

View file

@ -1,13 +1,26 @@
#!/bin/bash #!/usr/bin/env bash
which cmake >/dev/null
# if [[ "$?" -gt 0 ]]; then echo "[!] cmake not installed or not found, refusing to build!"; exit 1; fi
which make >/dev/null
if [[ "$?" -gt 0 ]]; then echo "[!] make not installed or not found, refusing to build!"; exit 1; fi
echo "[*] Building futurerestore"
export FR_INSTALL_DIR="/usr/local/bin"
if [[ -z "$NO_CLEAN" ]]; then rm -rf cmake-build-release cmake-build-debug; fi if [[ -z "$NO_CLEAN" ]]; then rm -rf cmake-build-release cmake-build-debug; fi
if [[ "$RELEASE" == "1" ]] if [[ "$RELEASE" == "1" ]]
then then
if [[ ! "$NO_CLEAN" == "1" ]]; then cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release $@; fi if [[ ! "$NO_CLEAN" == "1" ]]; then cmake -DCMAKE_INSTALL_PREFIX="${FR_INSTALL_DIR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release $@; fi
make -C cmake-build-release clean make -s -C cmake-build-release clean
make -C cmake-build-release make -s -C cmake-build-release
llvm-strip -s cmake-build-release/src/futurerestore if [[ "$?" -gt 0 ]]; then echo "[!] Failed to build futurerestore!"; exit 1; fi
which llvm-strip >/dev/null
if [[ "$?" -lt 1 ]]; then llvm-strip -s cmake-build-release/src/futurerestore; else echo "[!] llvm-strip not installed or not found, not stripping release binary."; fi
echo "[*] Run make -C cmake-build-release install, to install futurerestore or obtain the binary at cmake-build-release/src/futurerestore"
echo "[*] Successfully built futurerestore."
else else
if [[ ! "$NO_CLEAN" == "1" ]]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug $@ ; fi if [[ ! "$NO_CLEAN" == "1" ]]; then cmake -DCMAKE_INSTALL_PREFIX="${FR_INSTALL_DIR}" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug $@ ; fi
make -C cmake-build-debug clean make -s -C cmake-build-debug clean
make -C cmake-build-debug make -s -C cmake-build-debug
if [[ "$?" -gt 0 ]]; then echo "[!] Failed to build futurerestore!"; exit 1; fi
echo "[*] Run make -C cmake-build-debug install, to install futurerestore or obtain the binary at cmake-build-debug/src/futurerestore"
echo "[*] Successfully built futurerestore."
fi fi

@ -1 +1 @@
Subproject commit 78e077ccd41b5ee8d6c35702805a01a954d62cfc Subproject commit 4710028c9ebc5363847258055b539580a9db904f

2
external/tsschecker vendored

@ -1 +1 @@
Subproject commit ba70a6ad0c818b67028276c430ef221591692d2a Subproject commit 9f141b333befed9b45203a4f45e49707ec08ff24

View file

@ -1,51 +1,83 @@
project(futurerestore) project(futurerestore)
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG")
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
add_executable(futurerestore add_executable(futurerestore
main.cpp main.cpp
futurerestore.cpp) futurerestore.cpp)
target_include_directories(futurerestore PRIVATE target_include_directories(futurerestore PRIVATE
"${CMAKE_SOURCE_DIR}/dep_root/include"
"${CMAKE_SOURCE_DIR}/external/idevicerestore/src" "${CMAKE_SOURCE_DIR}/external/idevicerestore/src"
"${CMAKE_SOURCE_DIR}/external/tsschecker/external/jssy/jssy" "${CMAKE_SOURCE_DIR}/external/tsschecker/external/jssy/jssy"
"${CMAKE_SOURCE_DIR}/external/tsschecker/tsschecker") "${CMAKE_SOURCE_DIR}/external/tsschecker/tsschecker")
target_link_directories(futurerestore PRIVATE set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
"${CMAKE_SOURCE_DIR}/dep_root/lib" if(NOT DEFINED NO_PKGCFG AND NOT "$ENV{NO_PKGCFG}" MATCHES "1")
"${CMAKE_SOURCE_DIR}/dep_root/lib/xpwn" pkg_check_modules(DEPS REQUIRED
) libzip
target_link_libraries(futurerestore PRIVATE zlib
z libpng16
zip libcrypto
png16 libssl
crypto libplist-2.0
ssl libimobiledevice-glue-1.0
"-lgeneral" libimobiledevice-1.0
plist-2.0 libirecovery-1.0
fragmentzip libusbmuxd-2.0
img4tool libgeneral
common libcurl
xpwn libfragmentzip
insn libimg4tool
offsetfinder64 libinsn
ipatcher liboffsetfinder64
tsschecker libipatcher)
idevicerestore target_include_directories(futurerestore PRIVATE "${DEPS_INCLUDE_DIRS}")
jssy target_link_directories(futurerestore PRIVATE "${DEPS_LIBRARY_DIRS}")
curl target_link_libraries(futurerestore PRIVATE "${DEPS_LIBRARIES}" tsschecker idevicerestore)
imobiledevice-glue-1.0 else()
imobiledevice-1.0 target_include_directories(futurerestore PRIVATE
irecovery-1.0 "${CMAKE_SOURCE_DIR}/dep_root/include")
usbmuxd-2.0 target_link_directories(futurerestore PRIVATE
pthread) "${CMAKE_SOURCE_DIR}/dep_root/lib"
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") "${CMAKE_SOURCE_DIR}/dep_root/lib/xpwn"
)
target_link_libraries(futurerestore PRIVATE target_link_libraries(futurerestore PRIVATE
z
zip
png16
crypto
ssl
"-lgeneral"
plist-2.0
fragmentzip
img4tool
common
xpwn
insn
offsetfinder64
ipatcher
tsschecker
idevicerestore
jssy
curl
imobiledevice-glue-1.0
imobiledevice-1.0
irecovery-1.0
usbmuxd-2.0
pthread)
endif()
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(futurerestore PRIVATE
compression compression
"-framework CoreFoundation" "-framework CoreFoundation"
"-framework IOKit") "-framework IOKit")
else() else()
target_link_libraries(futurerestore PRIVATE target_link_libraries(futurerestore PRIVATE
usb-1.0 usb-1.0
dl dl
udev udev
lzfse) lzfse)
endif() endif()
execute_process(COMMAND git rev-list --count HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_COUNT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND git rev-list --count HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_COUNT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_SHA ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_SHA ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -55,3 +87,6 @@ add_definitions(
-DVERSION_COMMIT_COUNT="${VERSION_COMMIT_COUNT}" -DVERSION_COMMIT_COUNT="${VERSION_COMMIT_COUNT}"
-DVERSION_COMMIT_SHA="${VERSION_COMMIT_SHA}" -DVERSION_COMMIT_SHA="${VERSION_COMMIT_SHA}"
-DVERSION_RELEASE="${VERSION_RELEASE}") -DVERSION_RELEASE="${VERSION_RELEASE}")
install(TARGETS futurerestore
DESTINATION ${CMAKE_INSTALL_PREFIX})