diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/libirecovery | |
Diffstat (limited to 'vcpkg/ports/libirecovery')
| -rw-r--r-- | vcpkg/ports/libirecovery/001_fix_static_build.patch | 22 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/002_fix_api.patch | 24 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/003_fix_msvc.patch | 25 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/004_fix_tools_msvc.patch | 14 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/CMakeLists.txt | 125 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/portfile.cmake | 63 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/usage | 4 | ||||
| -rw-r--r-- | vcpkg/ports/libirecovery/vcpkg.json | 34 |
8 files changed, 311 insertions, 0 deletions
diff --git a/vcpkg/ports/libirecovery/001_fix_static_build.patch b/vcpkg/ports/libirecovery/001_fix_static_build.patch new file mode 100644 index 0000000..795bd07 --- /dev/null +++ b/vcpkg/ports/libirecovery/001_fix_static_build.patch @@ -0,0 +1,22 @@ +diff --git a/src/libirecovery.c b/src/libirecovery.c +index 6e7647b..45ff6f2 100644 +--- a/src/libirecovery.c ++++ b/src/libirecovery.c +@@ -470,6 +470,8 @@ static void _irecv_deinit(void) + static thread_once_t init_once = THREAD_ONCE_INIT; + static thread_once_t deinit_once = THREAD_ONCE_INIT; + ++#ifndef IRECV_STATIC // disable dll constructor ++ + #ifndef HAVE_ATTRIBUTE_CONSTRUCTOR + #if defined(__llvm__) || defined(__GNUC__) + #define HAVE_ATTRIBUTE_CONSTRUCTOR +@@ -505,6 +507,8 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) + #warning No compiler support for constructor/destructor attributes, some features might not be available. + #endif + ++#endif // disable dll constructor ++ + #ifdef HAVE_IOKIT + static int iokit_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, unsigned char * buffer, int size) + { diff --git a/vcpkg/ports/libirecovery/002_fix_api.patch b/vcpkg/ports/libirecovery/002_fix_api.patch new file mode 100644 index 0000000..ae02df6 --- /dev/null +++ b/vcpkg/ports/libirecovery/002_fix_api.patch @@ -0,0 +1,24 @@ +diff --git a/include/libirecovery.h b/include/libirecovery.h +index 33879a4..41fc8bb 100644 +--- a/include/libirecovery.h ++++ b/include/libirecovery.h +@@ -30,17 +30,13 @@ extern "C" { + #ifdef IRECV_STATIC + #define IRECV_API + #elif defined(_WIN32) +- #ifdef DLL_EXPORT ++ #ifdef IRECV_EXPORT + #define IRECV_API __declspec(dllexport) + #else + #define IRECV_API __declspec(dllimport) + #endif + #else +- #if __GNUC__ >= 4 +- #define IRECV_API __attribute__((visibility("default"))) +- #else +- #define IRECV_API +- #endif ++ #define IRECV_API __attribute__((visibility("default"))) + #endif + + enum irecv_mode { diff --git a/vcpkg/ports/libirecovery/003_fix_msvc.patch b/vcpkg/ports/libirecovery/003_fix_msvc.patch new file mode 100644 index 0000000..66852ec --- /dev/null +++ b/vcpkg/ports/libirecovery/003_fix_msvc.patch @@ -0,0 +1,25 @@ +diff --git a/src/libirecovery.c b/src/libirecovery.c +index 45ff6f2..d9ff1e6 100644 +--- a/src/libirecovery.c ++++ b/src/libirecovery.c +@@ -29,7 +29,9 @@ + #include <string.h> + #include <inttypes.h> + #include <ctype.h> ++#ifndef _MSC_VER + #include <unistd.h> ++#endif + #include <sys/stat.h> + + #include <libimobiledevice-glue/collection.h> +@@ -59,6 +61,10 @@ + + #include "libirecovery.h" + ++#ifdef _MSC_VER ++#define strcasecmp _stricmp ++#endif ++ + struct irecv_client_private { + int debug; + int usb_config; diff --git a/vcpkg/ports/libirecovery/004_fix_tools_msvc.patch b/vcpkg/ports/libirecovery/004_fix_tools_msvc.patch new file mode 100644 index 0000000..b29d98f --- /dev/null +++ b/vcpkg/ports/libirecovery/004_fix_tools_msvc.patch @@ -0,0 +1,14 @@ +diff --git a/tools/irecovery.c b/tools/irecovery.c +index 34e80bf..deffe89 100644 +--- a/tools/irecovery.c ++++ b/tools/irecovery.c +@@ -27,7 +27,9 @@ + + #include <stdio.h> + #include <stdlib.h> ++#ifndef _MSC_VER + #include <unistd.h> ++#endif + #include <string.h> + #include <getopt.h> + #include <inttypes.h> diff --git a/vcpkg/ports/libirecovery/CMakeLists.txt b/vcpkg/ports/libirecovery/CMakeLists.txt new file mode 100644 index 0000000..5345b32 --- /dev/null +++ b/vcpkg/ports/libirecovery/CMakeLists.txt @@ -0,0 +1,125 @@ +cmake_minimum_required(VERSION 3.15) +project(libirecovery C) + +option(BUILD_TOOLS "Build tools." OFF) + +include(GNUInstallDirs) + +file(GLOB_RECURSE LIBIRECOVERY_HEADER include/*.h) +file(GLOB_RECURSE LIBIRECOVERY_SOURCE src/*.c) + +set(DEFINITIONS) + +if(BUILD_SHARED_LIBS) + if(WIN32) + list(APPEND DEFINITIONS -DIRECV_EXPORT) + endif() +else() + list(APPEND DEFINITIONS -DIRECV_STATIC) +endif() + +if(APPLE) + list(APPEND DEFINITIONS -DHAVE_IOKIT) +endif() + +if(WIN32) + list(APPEND DEFINITIONS -D_CRT_SECURE_NO_WARNINGS) + list(APPEND DEFINITIONS -DWIN32_LEAN_AND_MEAN) + list(APPEND DEFINITIONS -DWIN32) +endif() + +find_package(unofficial-libimobiledevice-glue CONFIG REQUIRED) + +add_library(libirecovery ${LIBIRECOVERY_SOURCE}) +target_include_directories(libirecovery PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>" + "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" +) +target_compile_definitions(libirecovery PRIVATE ${DEFINITIONS}) +target_link_libraries(libirecovery + PRIVATE + unofficial::libimobiledevice-glue::libimobiledevice-glue +) +if(NOT WIN32 AND NOT APPLE) + find_package(PkgConfig REQUIRED) + pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) + target_link_libraries(libirecovery PRIVATE PkgConfig::libusb) +endif() +set_target_properties(libirecovery PROPERTIES OUTPUT_NAME irecovery-1.0) + +if(WIN32) + target_link_libraries(libirecovery PRIVATE Setupapi) +endif() + +if(APPLE) + target_link_libraries(libirecovery PRIVATE "-framework IOKit" "-framework CoreFoundation") +endif() + +install(TARGETS libirecovery EXPORT unofficial-libirecovery) + +install( + EXPORT unofficial-libirecovery + FILE unofficial-libirecovery-config.cmake + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-libirecovery" + NAMESPACE unofficial::libirecovery:: +) + +install( + FILES ${LIBIRECOVERY_HEADER} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +set(LIMD_GLUE_VERSION 1.0) +set(PACKAGE_NAME libirecovery) +set(PACKAGE_VERSION 1.0) +set(prefix "") +set(exec_prefix "\${prefix}") +set(libdir "\${prefix}/lib") +set(includedir "\${prefix}/include") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/libirecovery-1.0.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/libirecovery-1.0.pc" + @ONLY +) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/libirecovery-1.0.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) + +if(BUILD_TOOLS) + add_executable(irecovery "tools/irecovery.c") + target_compile_definitions(irecovery PRIVATE + -DPACKAGE_VERSION="1.1.0" + -DPACKAGE_URL="https://github.com/libimobiledevice/libirecovery" + -DPACKAGE_BUGREPORT="https://github.com/libimobiledevice/libirecovery/issues" + ) + if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(irecovery PRIVATE -DIRECV_STATIC) + endif() + if(WIN32) + target_compile_definitions(irecovery PRIVATE + -D_CRT_SECURE_NO_WARNINGS + -DWIN32_LEAN_AND_MEAN + -DWIN32 + ) + find_package(unofficial-getopt-win32 REQUIRED) + target_link_libraries(irecovery PRIVATE unofficial::getopt-win32::getopt Ws2_32) + endif() + if(APPLE) + target_compile_definitions(irecovery PRIVATE -DHAVE_IOKIT) + target_link_libraries(irecovery PRIVATE "-framework IOKit" "-framework CoreFoundation") + endif() + if(NOT WIN32 AND NOT APPLE) + find_package(PkgConfig REQUIRED) + pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) + target_link_libraries(irecovery PRIVATE PkgConfig::libusb) + endif() + find_package(PkgConfig REQUIRED) + pkg_check_modules(readline REQUIRED IMPORTED_TARGET readline) + target_link_libraries(irecovery PRIVATE libirecovery PkgConfig::readline) + install( + TARGETS irecovery + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) +endif() diff --git a/vcpkg/ports/libirecovery/portfile.cmake b/vcpkg/ports/libirecovery/portfile.cmake new file mode 100644 index 0000000..2ef67ed --- /dev/null +++ b/vcpkg/ports/libirecovery/portfile.cmake @@ -0,0 +1,63 @@ +vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO libimobiledevice/libirecovery
+ REF c7b488fbf2a9ab95e451df1319e68662fff7b9b7 # commits on 2023-05-13
+ SHA512 a8638b71789c0cedf5913a877ca42fef079c968592b6149dfa578d2dc7840f63c1d1fadd934d7cfbd5139cea2b3a4249886a88b69c3edb19dbd3f893c266f665
+ HEAD_REF master
+ PATCHES
+ 001_fix_static_build.patch
+ 002_fix_api.patch
+ 003_fix_msvc.patch
+ 004_fix_tools_msvc.patch
+)
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ tools BUILD_TOOLS
+)
+
+if("tools" IN_LIST FEATURES)
+ vcpkg_find_acquire_program(PKGCONFIG)
+ list(APPEND FEATURE_OPTIONS "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}")
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+)
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT})
+vcpkg_fixup_pkgconfig()
+if("tools" IN_LIST FEATURES)
+ vcpkg_copy_tools(TOOL_NAMES irecovery AUTO_CLEAN)
+endif()
+
+if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libirecovery.h"
+ "#ifdef IRECV_STATIC" "#if 1"
+ )
+else()
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libirecovery.h"
+ "#ifdef IRECV_STATIC" "#if 0"
+ )
+endif()
+
+file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" cmake_config)
+file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake"
+"include(CMakeFindDependencyMacro)
+find_dependency(unofficial-libimobiledevice-glue CONFIG)
+if(NOT WIN32 AND NOT APPLE)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+endif()
+${cmake_config}
+")
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
+file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
diff --git a/vcpkg/ports/libirecovery/usage b/vcpkg/ports/libirecovery/usage new file mode 100644 index 0000000..fbb5c01 --- /dev/null +++ b/vcpkg/ports/libirecovery/usage @@ -0,0 +1,4 @@ +libirecovery provides CMake targets: + + find_package(unofficial-libirecovery CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::libirecovery::libirecovery) diff --git a/vcpkg/ports/libirecovery/vcpkg.json b/vcpkg/ports/libirecovery/vcpkg.json new file mode 100644 index 0000000..ac8b919 --- /dev/null +++ b/vcpkg/ports/libirecovery/vcpkg.json @@ -0,0 +1,34 @@ +{ + "name": "libirecovery", + "version-date": "2023-05-13", + "port-version": 2, + "description": "Library and utility to talk to iBoot/iBSS via USB on Mac OS X, Windows, and Linux", + "homepage": "https://libimobiledevice.org/", + "license": "LGPL-2.1-or-later", + "supports": "!uwp", + "dependencies": [ + "libimobiledevice-glue", + { + "name": "libusb", + "platform": "!windows & !osx" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "tools": { + "description": "build command line tool", + "supports": "!android & !ios & !xbox", + "dependencies": [ + "getopt", + "readline" + ] + } + } +} |