aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/bzip2
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/bzip2
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/bzip2')
-rw-r--r--vcpkg/ports/bzip2/CMakeLists.txt45
-rw-r--r--vcpkg/ports/bzip2/bzip2.pc.in11
-rw-r--r--vcpkg/ports/bzip2/fix-import-export-macros.patch40
-rw-r--r--vcpkg/ports/bzip2/portfile.cmake57
-rw-r--r--vcpkg/ports/bzip2/usage4
-rw-r--r--vcpkg/ports/bzip2/vcpkg.json23
6 files changed, 180 insertions, 0 deletions
diff --git a/vcpkg/ports/bzip2/CMakeLists.txt b/vcpkg/ports/bzip2/CMakeLists.txt
new file mode 100644
index 0000000..95e269a
--- /dev/null
+++ b/vcpkg/ports/bzip2/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.5...3.29)
+project(bzip2 C)
+
+if(CMAKE_BUILD_TYPE STREQUAL Debug)
+ add_definitions(-DBZ_DEBUG) # enable extra assertions
+endif()
+
+set(BZ2_SOURCES
+ blocksort.c
+ huffman.c
+ crctable.c
+ randtable.c
+ compress.c
+ decompress.c
+ bzlib.c)
+
+add_library(bz2 ${BZ2_SOURCES})
+set_target_properties(bz2 PROPERTIES
+ DEBUG_POSTFIX d
+ VERSION "${BZ2_VERSION}"
+ SOVERSION 1.0)
+if(BUILD_SHARED_LIBS)
+ target_compile_definitions(bz2 PRIVATE -DBZ_BUILD_DLL)
+endif()
+
+if(MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
+endif()
+
+install(TARGETS bz2
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib)
+
+if(NOT BZIP2_SKIP_TOOLS)
+ add_executable(bzip2 bzip2.c ${BZ2_SOURCES})
+ add_executable(bzip2recover bzip2recover.c ${BZ2_SOURCES})
+ install(TARGETS bzip2 bzip2recover DESTINATION tools/bzip2)
+endif()
+
+if(NOT BZIP2_SKIP_HEADERS)
+ install(FILES bzlib.h DESTINATION include)
+endif()
diff --git a/vcpkg/ports/bzip2/bzip2.pc.in b/vcpkg/ports/bzip2/bzip2.pc.in
new file mode 100644
index 0000000..e8caf08
--- /dev/null
+++ b/vcpkg/ports/bzip2/bzip2.pc.in
@@ -0,0 +1,11 @@
+prefix=@BZIP2_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: bzip2
+Description: bzip2
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -l@bzname@
+Cflags: -I${includedir}
diff --git a/vcpkg/ports/bzip2/fix-import-export-macros.patch b/vcpkg/ports/bzip2/fix-import-export-macros.patch
new file mode 100644
index 0000000..fc67887
--- /dev/null
+++ b/vcpkg/ports/bzip2/fix-import-export-macros.patch
@@ -0,0 +1,40 @@
+diff --git a/bzlib.h b/bzlib.h
+index 8277123..84fbd0a 100644
+--- a/bzlib.h
++++ b/bzlib.h
+@@ -65,29 +65,23 @@ typedef
+ }
+ bz_stream;
+
+-
+-#ifndef BZ_IMPORT
+-#define BZ_EXPORT
+-#endif
+-
+ #ifndef BZ_NO_STDIO
+ /* Need a definitition for FILE */
+ #include <stdio.h>
+ #endif
+
+ #ifdef _WIN32
+-# include <windows.h>
+ # ifdef small
+ /* windows.h define small to char */
+ # undef small
+ # endif
+-# ifdef BZ_EXPORT
+-# define BZ_API(func) WINAPI func
+-# define BZ_EXTERN extern
++# define BZ_API(func) func
++# if defined(BZ_BUILD_DLL)
++# define BZ_EXTERN __declspec(dllexport)
++# elif defined(BZ_IMPORT)
++# define BZ_EXTERN __declspec(dllimport)
+ # else
+- /* import windows dll dynamically */
+-# define BZ_API(func) (WINAPI * func)
+-# define BZ_EXTERN
++# define BZ_EXTERN
+ # endif
+ #else
+ # define BZ_API(func) func
diff --git a/vcpkg/ports/bzip2/portfile.cmake b/vcpkg/ports/bzip2/portfile.cmake
new file mode 100644
index 0000000..d91aac6
--- /dev/null
+++ b/vcpkg/ports/bzip2/portfile.cmake
@@ -0,0 +1,57 @@
+vcpkg_download_distfile(ARCHIVE
+ URLS "https://sourceware.org/pub/bzip2/bzip2-${VERSION}.tar.gz"
+ "https://www.mirrorservice.org/sites/sourceware.org/pub/bzip2/bzip2-${VERSION}.tar.gz"
+ FILENAME "bzip2-${VERSION}.tar.gz"
+ SHA512 083f5e675d73f3233c7930ebe20425a533feedeaaa9d8cc86831312a6581cefbe6ed0d08d2fa89be81082f2a5abdabca8b3c080bf97218a1bd59dc118a30b9f3
+)
+
+vcpkg_extract_source_archive(
+ SOURCE_PATH
+ ARCHIVE "${ARCHIVE}"
+ PATCHES fix-import-export-macros.patch
+)
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ INVERTED_FEATURES
+ tool BZIP2_SKIP_TOOLS
+)
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ ${FEATURE_OPTIONS}
+ "-DBZ2_VERSION=${VERSION}"
+ OPTIONS_DEBUG
+ -DBZIP2_SKIP_HEADERS=ON
+ -DBZIP2_SKIP_TOOLS=ON
+)
+
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+
+file(READ "${CURRENT_PACKAGES_DIR}/include/bzlib.h" BZLIB_H)
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ string(REPLACE "defined(BZ_IMPORT)" "0" BZLIB_H "${BZLIB_H}")
+else()
+ string(REPLACE "defined(BZ_IMPORT)" "1" BZLIB_H "${BZLIB_H}")
+endif()
+file(WRITE "${CURRENT_PACKAGES_DIR}/include/bzlib.h" "${BZLIB_H}")
+
+if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+ set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}")
+ set(bzname bz2)
+ configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/bzip2.pc" @ONLY)
+endif()
+
+if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
+ set(BZIP2_PREFIX "${CURRENT_INSTALLED_DIR}/debug")
+ set(bzname bz2d)
+ configure_file("${CMAKE_CURRENT_LIST_DIR}/bzip2.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/bzip2.pc" @ONLY)
+endif()
+
+vcpkg_fixup_pkgconfig()
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
diff --git a/vcpkg/ports/bzip2/usage b/vcpkg/ports/bzip2/usage
new file mode 100644
index 0000000..084bf39
--- /dev/null
+++ b/vcpkg/ports/bzip2/usage
@@ -0,0 +1,4 @@
+The package bzip2 is compatible with built-in CMake targets:
+
+ find_package(BZip2 REQUIRED)
+ target_link_libraries(main PRIVATE BZip2::BZip2)
diff --git a/vcpkg/ports/bzip2/vcpkg.json b/vcpkg/ports/bzip2/vcpkg.json
new file mode 100644
index 0000000..1663999
--- /dev/null
+++ b/vcpkg/ports/bzip2/vcpkg.json
@@ -0,0 +1,23 @@
+{
+ "name": "bzip2",
+ "version-semver": "1.0.8",
+ "port-version": 6,
+ "description": "bzip2 is a freely available, patent free, high-quality data compressor. It typically compresses files to within 10% to 15% of the best available techniques (the PPM family of statistical compressors), whilst being around twice as fast at compression and six times faster at decompression.",
+ "homepage": "https://sourceware.org/bzip2/",
+ "documentation": "https://sourceware.org/bzip2/docs.html",
+ "license": "bzip2-1.0.6",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ }
+ ],
+ "default-features": [
+ "tool"
+ ],
+ "features": {
+ "tool": {
+ "description": "Builds bzip2 executable"
+ }
+ }
+}