From 590f3a78b2d64ef1beb71129feca3db24c710a25 Mon Sep 17 00:00:00 2001 From: Qi-rui Chen Date: Fri, 1 Mar 2019 00:28:13 +0000 Subject: Fix libmodplug to build on Linux (#5397) * Update libmodplug to build on linux * [libmodplug] Patch instead of changing downloading source * [libmodplug] Keep original source instead of using fork --- .../001-automagically-define-modplug-static.patch | 13 ++++++++ ports/libmodplug/002-detect_sinf.patch | 35 ++++++++++++++++++++++ ports/libmodplug/CONTROL | 2 +- .../automagically-define-modplug-static.patch | 13 -------- ports/libmodplug/portfile.cmake | 35 ++++++++++++++-------- 5 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 ports/libmodplug/001-automagically-define-modplug-static.patch create mode 100644 ports/libmodplug/002-detect_sinf.patch delete mode 100644 ports/libmodplug/automagically-define-modplug-static.patch diff --git a/ports/libmodplug/001-automagically-define-modplug-static.patch b/ports/libmodplug/001-automagically-define-modplug-static.patch new file mode 100644 index 000000000..d0df45473 --- /dev/null +++ b/ports/libmodplug/001-automagically-define-modplug-static.patch @@ -0,0 +1,13 @@ +diff --git a/src/modplug.h b/src/modplug.h +index 3ffbf9d..fd19ae5 100644 +--- a/src/modplug.h ++++ b/src/modplug.h +@@ -11,6 +11,8 @@ + extern "C" { + #endif + ++#define MODPLUG_STATIC ++ + #if defined(_WIN32) || defined(__CYGWIN__) + # if defined(MODPLUG_BUILD) && defined(DLL_EXPORT) /* building libmodplug as a dll for windows */ + # define MODPLUG_EXPORT __declspec(dllexport) diff --git a/ports/libmodplug/002-detect_sinf.patch b/ports/libmodplug/002-detect_sinf.patch new file mode 100644 index 000000000..784e2e663 --- /dev/null +++ b/ports/libmodplug/002-detect_sinf.patch @@ -0,0 +1,35 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2ada51b..468f1a3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,6 +4,7 @@ project(libmodplug) + add_definitions(-DMODPLUG_BUILD) + + include (CheckFunctionExists) ++include (CheckIncludeFile) + + include_directories(AFTER + src +@@ -11,6 +12,10 @@ include_directories(AFTER + ${PROJECT_BINARY_DIR} + ) + ++if (UNIX) ++ set (CMAKE_REQUIRED_LIBRARIES m) ++endif() ++ + if (WIN32) + add_definitions(-D_USE_MATH_DEFINES) + add_definitions(-DNOMINMAX) +@@ -44,6 +49,11 @@ if (WIN32 AND NOT (MINGW OR MSYS)) + "Compilation may fail if inttypes.h is not natively supported by the compiler." + "You can get inttypes.h from http://code.google.com/p/msinttypes/") + endif() ++else() ++ check_include_file("stdint.h" HAVE_STDINT) ++ if (HAVE_STDINT) ++ add_definitions(-DHAVE_STDINT_H) ++ endif() + endif() + + check_function_exists("setenv" HAVE_SETENV) diff --git a/ports/libmodplug/CONTROL b/ports/libmodplug/CONTROL index e0cc81a3b..2a6cb4638 100644 --- a/ports/libmodplug/CONTROL +++ b/ports/libmodplug/CONTROL @@ -1,3 +1,3 @@ Source: libmodplug -Version: 0.8.9.0-1 +Version: 0.8.9.0-4 Description: The ModPlug mod file playing library. diff --git a/ports/libmodplug/automagically-define-modplug-static.patch b/ports/libmodplug/automagically-define-modplug-static.patch deleted file mode 100644 index eaa7e6ca6..000000000 --- a/ports/libmodplug/automagically-define-modplug-static.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/libmodplug/modplug.h b/libmodplug/modplug.h -index 3ffbf9d..fd19ae5 100644 ---- a/libmodplug/modplug.h -+++ b/libmodplug/modplug.h -@@ -11,6 +11,8 @@ - extern "C" { - #endif - -+#define MODPLUG_STATIC -+ - #if defined(_WIN32) || defined(__CYGWIN__) - # if defined(MODPLUG_BUILD) && defined(DLL_EXPORT) /* building libmodplug as a dll for windows */ - # define MODPLUG_EXPORT __declspec(dllexport) diff --git a/ports/libmodplug/portfile.cmake b/ports/libmodplug/portfile.cmake index bac734084..287616088 100644 --- a/ports/libmodplug/portfile.cmake +++ b/ports/libmodplug/portfile.cmake @@ -1,14 +1,30 @@ - set(MODPLUG_HASH 5a39f5913d07ba3e61d8d5afdba00b70165da81d) + include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libmodplug-${MODPLUG_HASH}) -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/Konstanty/libmodplug/archive/${MODPLUG_HASH}.zip" - FILENAME "libmodplug-${MODPLUG_HASH}.zip" - SHA512 71b1314c44c98694c66ac17b638e997b99abc1ad61f7ac2e971000bdd4276d50d538259f4ee4dd39a3f672d28d3d322a32c83a9be0b1ffe5099ecc81273b5b55) -vcpkg_extract_source_archive(${ARCHIVE}) +if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + vcpkg_from_github(ARCHIVE + OUT_SOURCE_PATH SOURCE_PATH + REPO Konstanty/libmodplug + REF ${MODPLUG_HASH} + SHA512 c43bb3190b62c3a4e3636bba121b5593bbf8e6577ca9f2aa04d90b03730ea7fb590e640cdadeb565758b92e81187bc456e693fe37f1f4deace9b9f37556e3ba1 + PATCHES + "001-automagically-define-modplug-static.patch" + "002-detect_sinf.patch" + ) +else() + vcpkg_from_github(ARCHIVE + OUT_SOURCE_PATH SOURCE_PATH + REPO JackBister/libmodplug + REF ${MODPLUG_HASH} + SHA512 c43bb3190b62c3a4e3636bba121b5593bbf8e6577ca9f2aa04d90b03730ea7fb590e640cdadeb565758b92e81187bc456e693fe37f1f4deace9b9f37556e3ba1 + PATCHES + "002-detect_sinf.patch" + ) +endif() + vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA) + vcpkg_install_cmake() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) @@ -19,11 +35,6 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin) file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/modplug.dll ${CURRENT_PACKAGES_DIR}/debug/bin/modplug.dll) vcpkg_copy_pdbs() -else() - vcpkg_apply_patches( - SOURCE_PATH ${CURRENT_PACKAGES_DIR}/include - PATCHES - ${CMAKE_CURRENT_LIST_DIR}/automagically-define-modplug-static.patch) endif() file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libmodplug) -- cgit v1.2.3