diff --git a/.gitattributes b/.gitattributes index bf8e7a047..3e1e18918 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -version.mk export-subst +version.cmake export-subst kernel export-ignore README export-ignore README-4.5 export-ignore diff --git a/squashfs-tools/CMakeLists.txt b/squashfs-tools/CMakeLists.txt new file mode 100644 index 000000000..b6941994c --- /dev/null +++ b/squashfs-tools/CMakeLists.txt @@ -0,0 +1,223 @@ +cmake_minimum_required(VERSION 3.13.4) + +project( + squashfs-tools + LANGUAGES C + VERSION 4.6.1 +) + +######## User defined variables & options +set(COMP_DEFAULT "zstd" CACHE STRING "Default compressor") +option(GZIP_SUPPORT "Build with gzip support" ON) +option(XZ_SUPPORT "Build with xz support" ON) +option(XZ_EXTENDED_OPTIONS "Build with xz extended option support" ON) +option(LZO_SUPPORT "Build with lzo support" ON) +option(LZ4_SUPPORT "Build with lz4 support" ON) +option(ZSTD_SUPPORT "Build with zstd support" ON) +option(XATTR_SUPPORT "Build with xattr support" ON) +option(XATTR_DEFAULT "xattrs to be stored by Mksquashfs and extracted by Unsquashfs by default" ON) +option(REPRODUCIBLE_DEFAULT "Reproducible builds by default" ON) +option(USE_PREBUILT_MANPAGES "Use the pre-built manpages by default" ON) +# Note: LZMA1 compression support not implemented [FIXME maybe] +################ + +include(version.cmake) +# Example values for HASH and FULLDATE +#set(HASH "d8cb82d9") +#set(FULLDATE "2023-03-01 20:53:37 +0000") +separate_arguments(FULLDATE) +list(GET FULLDATE 0 DATE) + +if(DEFINED ENV{RELEASE_VERSION} AND DEFINED ENV{RELEASE_DATE}) + # GET RELEASE_VERSION AND RELEASE_DATE from environment + add_definitions(-DDATE="$ENV{RELEASE_DATE}") + add_definitions(-DVERSION="$ENV{RELEASE_VERSION}") +else() + if(${HASH} STREQUAL "$Format:%h$") + execute_process(COMMAND git show -s --pretty=format:%ci OUTPUT_VARIABLE FULLDATE) + separate_arguments(FULLDATE) + list(GET FULLDATE 0 DATE) + execute_process(COMMAND git show -s --pretty=format:%h OUTPUT_VARIABLE HASH) + endif() + add_definitions(-DDATE="${DATE}") + add_definitions(-DVERSION="${PROJECT_VERSION}-${HASH}") + string(REGEX MATCH ^[0-9]+ YEAR ${DATE}) +endif() +add_definitions(-DYEAR="${YEAR}") + +include(CheckSymbolExists) +include(GNUInstallDirs) + +set(mksquashfs_SOURCES + mksquashfs.c + read_fs.c + action.c + swap.c + pseudo.c + compressor.c + sort.c + progressbar.c + info.c + restore.c + process_fragments.c + caches-queues-lists.c + reader.c + tar.c + date.c +) + +set(unsquashfs_SOURCES + unsquashfs.c + unsquash-1.c + unsquash-2.c + unsquash-3.c + unsquash-4.c + unsquash-123.c + unsquash-34.c + unsquash-1234.c + unsquash-12.c + swap.c + compressor.c + unsquashfs_info.c + date.c +) + +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH}) + +set(COMPRESSORS "") +if(GZIP_SUPPORT) + find_package(ZLIB REQUIRED) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} gzip_wrapper.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} gzip_wrapper.c) + add_definitions(-DGZIP_SUPPORT) + set(COMPRESSORS ${COMPRESSORS} gzip) +endif() + +if(XZ_SUPPORT) + find_package(LibLZMA REQUIRED) + if(XZ_EXTENDED_OPTIONS) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} xz_wrapper_extended.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} xz_wrapper_extended.c) + else() + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} xz_wrapper.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} xz_wrapper.c) + endif() + add_definitions(-DXZ_SUPPORT) + set(COMPRESSORS ${COMPRESSORS} xz) +endif() + +if(LZO_SUPPORT) + find_package(LZO REQUIRED) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} lzo_wrapper.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} lzo_wrapper.c) + add_definitions(-DLZO_SUPPORT) + set(COMPRESSORS ${COMPRESSORS} lzo) +endif() + +if(LZ4_SUPPORT) + find_package(LZ4 REQUIRED) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} lz4_wrapper.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} lz4_wrapper.c) + add_definitions(-DLZ4_SUPPORT) + set(COMPRESSORS ${COMPRESSORS} lz4) +endif() + +if(ZSTD_SUPPORT) + find_package(ZSTD REQUIRED) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} zstd_wrapper.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} zstd_wrapper.c) + add_definitions(-DZSTD_SUPPORT) + set(COMPRESSORS ${COMPRESSORS} zstd) +endif() + +if(XATTR_SUPPORT) + find_package(Xattr REQUIRED) + set(mksquashfs_SOURCES ${mksquashfs_SOURCES} xattr.c read_xattrs.c tar_xattr.c pseudo_xattr.c) + set(unsquashfs_SOURCES ${unsquashfs_SOURCES} unsquashfs_xattr.c read_xattrs.c) + add_definitions(-DXATTR_SUPPORT) + if(XATTR_DEFAULT) + add_definitions(-DXATTR_DEFAULT) + endif() +endif() + +if(REPRODUCIBLE_DEFAULT) + add_definitions(-DREPRODUCIBLE_DEFAULT) +endif() + +if(USE_PREBUILT_MANPAGES) + set(USE_PREBUILT_MANPAGES "y") +endif() + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) +find_library(MATH_LIBRARY m REQUIRED) + +add_definitions(-D_GNU_SOURCE) + +if(COMPRESSORS STREQUAL "") + message(FATAL_ERROR "No compressor selected ! Select one or more of GZIP, LZMA, XZ, LZO, LZ4 or ZSTD !") +endif() + +if(COMP_DEFAULT STREQUAL "") + message(FATAL_ERROR "COMP_DEFAULT must be set to a compressor !") +endif() + +if(${COMP_DEFAULT} IN_LIST COMPRESSORS) + add_definitions(-DCOMP_DEFAULT="${COMP_DEFAULT}") +else() + message(FATAL_ERROR "COMP_DEFAULT is set to ${COMP_DEFAULT}, which isn't selected to be built !") +endif() + +add_executable(mksquashfs ${mksquashfs_SOURCES}) +add_executable(unsquashfs ${unsquashfs_SOURCES}) + +target_include_directories(mksquashfs + PRIVATE + ${PROJECT_SOURCE_DIR} + ${ZLIB_INCLUDE_DIRS} + ${LIBLZMA_INCLUDE_DIRS} + ${LZO_INCLUDE_DIR} + ${LZ4_INCLUDE_DIR} + ${ZSTD_INCLUDE_DIR} + ${XATTR_INCLUDE_DIRS} +) + +target_include_directories(unsquashfs + PRIVATE + ${PROJECT_SOURCE_DIR} + ${ZLIB_INCLUDE_DIRS} + ${LIBLZMA_INCLUDE_DIRS} + ${LZO_INCLUDE_DIR} + ${LZ4_INCLUDE_DIR} + ${ZSTD_INCLUDE_DIR} + ${XATTR_INCLUDE_DIRS} +) + +target_link_libraries(mksquashfs + PRIVATE + Threads::Threads + m + ${ZLIB_LIBRARIES} + ${LIBLZMA_LIBRARIES} + ${LZO_LIBRARIES} + ${LZ4_LIBRARY} + ${ZSTD_LIBRARIES} + ${XATTR_LIBRARIES} +) +target_link_libraries(unsquashfs + PRIVATE + Threads::Threads + m + ${ZLIB_LIBRARIES} + ${LIBLZMA_LIBRARIES} + ${LZO_LIBRARIES} + ${LZ4_LIBRARY} + ${ZSTD_LIBRARIES} + ${XATTR_LIBRARIES} +) + +install(TARGETS unsquashfs mksquashfs DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(CODE "execute_process(COMMAND ln -fs ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/unsquashfs ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/sqfscat)") +install(CODE "execute_process(COMMAND ln -fs ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/mksquashfs ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/sqfstar)") +install(CODE "execute_process(COMMAND ${CMAKE_SOURCE_DIR}/../generate-manpages/install-manpages.sh ${CMAKE_SOURCE_DIR}/.. ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_MANDIR}/man1 ${USE_PREBUILT_MANPAGES})") + diff --git a/squashfs-tools/Makefile b/squashfs-tools/Makefile deleted file mode 100755 index a1a5ae7c0..000000000 --- a/squashfs-tools/Makefile +++ /dev/null @@ -1,479 +0,0 @@ -############################################### -# Build options # -############################################### -# -# Edit the following definitions to customise the build, or run -# "CONFIG=1 make" with the build options below to customise the build on -# the command line. -# -ifndef CONFIG -############# Building gzip support ########### -# -# Gzip support is by default enabled, and the compression type default -# (COMP_DEFAULT) is gzip. -# -# If you don't want/need gzip support then comment out the GZIP SUPPORT line -# below, and change COMP_DEFAULT to one of the compression types you have -# selected. -# -# Obviously, you must select at least one of the available gzip, xz, lzo, -# lz4, zstd or lzma (deprecated) compression types. -# -GZIP_SUPPORT = 1 - -########### Building XZ support ############# -# -# LZMA2 compression. -# -# XZ Utils liblzma (http://tukaani.org/xz/) is supported -# -# Development packages (libraries and header files) should be -# supported by most modern distributions. Please refer to -# your distribution package manager. -# -# To build install the library and uncomment -# the XZ_SUPPORT line below. -# -#XZ_SUPPORT = 1 - -# Enable support for OpenWrt extended compression options by uncommenting -# next line. Do not do this unless you understand the implications. -#XZ_EXTENDED_OPTIONS = 1 - - -############ Building LZO support ############## -# -# The LZO library (http://www.oberhumer.com/opensource/lzo/) is supported. -# -# Development packages (libraries and header files) should be -# supported by most modern distributions. Please refer to -# your distribution package manager. -# -# To build install the library and uncomment -# the LZO_SUPPORT line below. -# -#LZO_SUPPORT = 1 - - -########### Building LZ4 support ############# -# -# Yann Collet's LZ4 tools are supported -# LZ4 homepage: https://lz4.github.io/lz4/ -# LZ4 source repository: https://github.com/lz4/lz4/ -# -# Development packages (libraries and header files) should be -# supported by most modern distributions. Please refer to -# your distribution package manager. -# -# To build install and uncomment -# the LZ4_SUPPORT line below. -# -#LZ4_SUPPORT = 1 - - -########### Building ZSTD support ############ -# -# The ZSTD library is supported -# ZSTD homepage: https://facebook.github.io/zstd/ -# ZSTD source repository: https://github.com/facebook/zstd -# -# Development packages (libraries and header files) should be -# supported by most modern distributions. Please refer to -# your distribution package manager. -# -# To build install the library and uncomment -# the ZSTD_SUPPORT line below. -# -#ZSTD_SUPPORT = 1 - - -######## Specifying default compression ######## -# -# The next line specifies which compression algorithm is used by default -# in Mksquashfs. Obviously the compression algorithm must have been -# selected to be built -# -COMP_DEFAULT = gzip - - -############################################### -# Extended attribute (XATTRs) build options # -############################################### -# -# Building XATTR support for Mksquashfs and Unsquashfs -# -# If your C library or build/target environment doesn't support XATTRs then -# comment out the next line to build Mksquashfs and Unsquashfs without XATTR -# support -XATTR_SUPPORT = 1 - -# Select whether you wish xattrs to be stored by Mksquashfs and extracted -# by Unsquashfs by default. If selected users can disable xattr support by -# using the -no-xattrs option -# -# If unselected, Mksquashfs/Unsquashfs won't store and extract xattrs by -# default. Users can enable xattrs by using the -xattrs option. -XATTR_DEFAULT = 1 - - -############################################### -# Reproducible Image options # -############################################### -# -# Select whether you wish reproducible builds by default. If selected users -# can disable reproducible builds using the not-reproducible option. -# If not selected, users can enable reproducible builds using the -# -reproducible option -REPRODUCIBLE_DEFAULT = 1 - -############################################### -# Manpage generation # -############################################### -# -# If help2man is available on the system, on installation, the Makefile -# will try to generate "custom" manpages from the built squashfs-tools. -# -# If the squashfs-tools have been cross-compiled, or for any other -# reason they're not executable, this will generate errors at -# installation and the install script will fall back to using -# pre-built manpages. -# -# Change next variable to "y" to use the pre-built manpages by default, -# and not attempt to generate "custom" manpages. This will eliminate -# errors and warnings at install time. -USE_PREBUILT_MANPAGES=n - -############################################### -# INSTALL PATHS # -############################################### -# -# Alter INSTALL_* to install binaries and manpages -# elsewhere. -# -# To skip building and installing manpages, -# unset INSTALL_MANPAGES_DIR or set to "" -# -INSTALL_PREFIX = /usr/local -INSTALL_DIR = $(INSTALL_PREFIX)/bin -INSTALL_MANPAGES_DIR = $(INSTALL_PREFIX)/man/man1 - -############################################### -# Obsolete options # -############################################### - -########### Building LZMA support ############# -# -# LZMA1 compression. -# -# LZMA1 compression is obsolete, and the newer and better XZ (LZMA2) -# compression should be used in preference. -# -# Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK -# (http://www.7-zip.org/sdk.html) are supported -# -# To build using XZ Utils liblzma - install the library and uncomment -# the LZMA_XZ_SUPPORT line below. -# -# To build using the LZMA SDK (4.65 used in development, other versions may -# work) - download and unpack it, uncomment and set LZMA_DIR to unpacked source, -# and uncomment the LZMA_SUPPORT line below. -# -#LZMA_XZ_SUPPORT = 1 -#LZMA_SUPPORT = 1 -#LZMA_DIR = ../../../../LZMA/lzma465 -else -GZIP_SUPPORT ?= 1 -ZX_SUPPORT ?= 0 -LZO_SUPPORT ?= 0 -LZ4_SUPPORT ?= 0 -ZSTD_SUPPORT ?= 0 -COMP_DEFAULT ?= gzip -XATTR_SUPPORT ?= 1 -XATTR_DEFAULT ?= 1 -REPRODUCIBLE_DEFAULT ?= 1 -USE_PREBUILT_MANPAGES ?= 1 -INSTALL_PREFIX ?= /usr/local -INSTALL_DIR ?= $(INSTALL_PREFIX)/bin -INSTALL_MANPAGES_DIR ?= $(INSTALL_PREFIX)/man/man1 -LZMA_XZ_SUPPORT ?= 0 -LZMA_SUPPORT ?= 0 -LZMA_DIR ?= ../../../../LZMA/lzma465 -XZ_EXTENDED_OPTIONS ?= 0 -endif - - -############################################### -# End of BUILD options section # -############################################### -# -INCLUDEDIR = -I. - -MKSQUASHFS_OBJS = mksquashfs.o read_fs.o action.o swap.o pseudo.o compressor.o \ - sort.o progressbar.o info.o restore.o process_fragments.o \ - caches-queues-lists.o reader.o tar.o date.o - -UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \ - unsquash-4.o unsquash-123.o unsquash-34.o unsquash-1234.o unsquash-12.o \ - swap.o compressor.o unsquashfs_info.o date.o - -CFLAGS ?= -O2 -CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \ - -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \ - -Wall - -LIBS = -lpthread -lm -ifeq ($(GZIP_SUPPORT),1) -CFLAGS += -DGZIP_SUPPORT -MKSQUASHFS_OBJS += gzip_wrapper.o -UNSQUASHFS_OBJS += gzip_wrapper.o -LIBS += -lz -COMPRESSORS += gzip -endif - -ifeq ($(LZMA_SUPPORT),1) -LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \ - $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o -INCLUDEDIR += -I$(LZMA_DIR)/C -CFLAGS += -DLZMA_SUPPORT -MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS) -UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS) -COMPRESSORS += lzma -endif - -ifeq ($(LZMA_XZ_SUPPORT),1) -CFLAGS += -DLZMA_SUPPORT -MKSQUASHFS_OBJS += lzma_xz_wrapper.o -UNSQUASHFS_OBJS += lzma_xz_wrapper.o -LIBS += -llzma -COMPRESSORS += lzma -endif - -ifeq ($(XZ_SUPPORT),1) -CFLAGS += -DXZ_SUPPORT -ifeq ($(XZ_EXTENDED_OPTIONS),1) -MKSQUASHFS_OBJS += xz_wrapper_extended.o -UNSQUASHFS_OBJS += xz_wrapper_extended.o -else -MKSQUASHFS_OBJS += xz_wrapper.o -UNSQUASHFS_OBJS += xz_wrapper.o -endif -LIBS += -llzma -COMPRESSORS += xz -endif - -ifeq ($(LZO_SUPPORT),1) -CFLAGS += -DLZO_SUPPORT -MKSQUASHFS_OBJS += lzo_wrapper.o -UNSQUASHFS_OBJS += lzo_wrapper.o -LIBS += -llzo2 -COMPRESSORS += lzo -endif - -ifeq ($(LZ4_SUPPORT),1) -CFLAGS += -DLZ4_SUPPORT -MKSQUASHFS_OBJS += lz4_wrapper.o -UNSQUASHFS_OBJS += lz4_wrapper.o -LIBS += -llz4 -COMPRESSORS += lz4 -endif - -ifeq ($(ZSTD_SUPPORT),1) -CFLAGS += -DZSTD_SUPPORT -MKSQUASHFS_OBJS += zstd_wrapper.o -UNSQUASHFS_OBJS += zstd_wrapper.o -LIBS += -lzstd -COMPRESSORS += zstd -endif - -ifeq ($(XATTR_SUPPORT),1) -ifeq ($(XATTR_DEFAULT),1) -CFLAGS += -DXATTR_SUPPORT -DXATTR_DEFAULT -else -CFLAGS += -DXATTR_SUPPORT -endif -MKSQUASHFS_OBJS += xattr.o read_xattrs.o tar_xattr.o pseudo_xattr.o -UNSQUASHFS_OBJS += read_xattrs.o unsquashfs_xattr.o -endif - -ifeq ($(REPRODUCIBLE_DEFAULT),1) -CFLAGS += -DREPRODUCIBLE_DEFAULT -endif - -# -# If LZMA_SUPPORT is specified then LZMA_DIR must be specified too -# -ifeq ($(LZMA_SUPPORT),1) -ifndef LZMA_DIR -$(error "LZMA_SUPPORT requires LZMA_DIR to be also defined") -endif -endif - -# -# Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified -# -ifeq ($(LZMA_XZ_SUPPORT),1) -ifeq ($(LZMA_SUPPORT),1) -$(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified") -endif -endif - -# -# At least one compressor must have been selected -# -ifndef COMPRESSORS -$(error "No compressor selected! Select one or more of GZIP, LZMA, XZ, LZO, \ - LZ4 or ZSTD!") -endif - -# -# COMP_DEFAULT should be defined -# -ifndef COMP_DEFAULT -$(error "COMP_DEFAULT must be set to a compressor!") -endif - -# -# COMP_DEFAULT must be a selected compressor -# -ifeq (, $(findstring $(COMP_DEFAULT), $(COMPRESSORS))) -$(error "COMP_DEFAULT is set to ${COMP_DEFAULT}, which isn't selected to be \ - built!") -endif - -# -# Get VERSION and DATE for Mksquashfs/Unsquashfs version strings. -# -# If RELEASE_VERSION/RELEASE_DATE set, use them. -# -# If not set, this is a development version, therefore -# -# If this source has been exported by "git archive" use automatically -# expanded strings. -# -# Otherwise ask git for the details from current HEAD. -# -include version.mk - -ifdef RELEASE_VERSION -VERSION := $(RELEASE_VERSION) -DATE := $(RELEASE_DATE) -else -ifeq ($(HASH),$Format:%h$) -VERSION := 4.6.1-$(shell git show -s --pretty=format:%h) -DATE := $(firstword $(subst -,/,$(shell git show -s --pretty=format:%ci))) -else -VERSION := 4.6.1-$(HASH) -DATE := $(firstword $(FULLDATE)) -endif -endif - -YEAR := $(firstword $(subst /, , $(DATE))) - -CFLAGS += -DVERSION=\"$(VERSION)\" -DDATE=\"$(DATE)\" -DYEAR=\"$(YEAR)\" - -.PHONY: all -all: mksquashfs unsquashfs - -mksquashfs: $(MKSQUASHFS_OBJS) - $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(MKSQUASHFS_OBJS) $(LIBS) -o $@ - ln -sf mksquashfs sqfstar - -mksquashfs.o: Makefile mksquashfs.c squashfs_fs.h squashfs_swap.h mksquashfs.h \ - sort.h pseudo.h compressor.h xattr.h action.h mksquashfs_error.h progressbar.h \ - info.h caches-queues-lists.h read_fs.h restore.h process_fragments.h - -reader.o: squashfs_fs.h mksquashfs.h caches-queues-lists.h progressbar.h \ - mksquashfs_error.h pseudo.h sort.h - -read_fs.o: read_fs.c squashfs_fs.h squashfs_swap.h compressor.h xattr.h \ - mksquashfs_error.h mksquashfs.h - -sort.o: sort.c squashfs_fs.h mksquashfs.h sort.h mksquashfs_error.h progressbar.h - -swap.o: swap.c - -pseudo.o: pseudo.c pseudo.h mksquashfs_error.h progressbar.h - -pseudo_xattr.o: pseudo_xattr.c xattr.h mksquashfs_error.h progressbar.h - -compressor.o: Makefile compressor.c compressor.h squashfs_fs.h - -xattr.o: xattr.c squashfs_fs.h squashfs_swap.h mksquashfs.h xattr.h mksquashfs_error.h \ - progressbar.h - -read_xattrs.o: read_xattrs.c squashfs_fs.h squashfs_swap.h xattr.h error.h - -action.o: action.c squashfs_fs.h mksquashfs.h action.h mksquashfs_error.h - -progressbar.o: progressbar.c mksquashfs_error.h - -info.o: info.c squashfs_fs.h mksquashfs.h mksquashfs_error.h progressbar.h \ - caches-queues-lists.h - -restore.o: restore.c caches-queues-lists.h squashfs_fs.h mksquashfs.h mksquashfs_error.h \ - progressbar.h info.h - -process_fragments.o: process_fragments.c process_fragments.h - -caches-queues-lists.o: caches-queues-lists.c mksquashfs_error.h caches-queues-lists.h - -tar.o: tar.h - -tar_xattr.o: tar.h xattr.h - -date.o: date.h error.h - -gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h - -lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h - -lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h - -lzo_wrapper.o: lzo_wrapper.c squashfs_fs.h lzo_wrapper.h compressor.h - -lz4_wrapper.o: lz4_wrapper.c squashfs_fs.h lz4_wrapper.h compressor.h - -xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h - -xz_wrapper_extended.o: xz_wrapper_extended.c squashfs_fs.h xz_wrapper.h compressor.h - -unsquashfs: $(UNSQUASHFS_OBJS) - $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@ - ln -sf unsquashfs sqfscat - -unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \ - squashfs_compat.h xattr.h read_fs.h compressor.h unsquashfs_error.h - -unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h unsquashfs_error.h - -unsquash-2.o: unsquashfs.h unsquash-2.c squashfs_fs.h squashfs_compat.h unsquashfs_error.h - -unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h unsquashfs_error.h - -unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \ - read_fs.h unsquashfs_error.h - -unsquash-123.o: unsquashfs.h unsquash-123.c squashfs_fs.h squashfs_compat.h unsquashfs_error.h - -unsquash-34.o: unsquashfs.h unsquash-34.c unsquashfs_error.h - -unsquash-1234.o: unsquash-1234.c unsquashfs_error.h - -unsquash-12.o: unsquash-12.c unsquashfs.h - -unsquashfs_xattr.o: unsquashfs_xattr.c unsquashfs.h squashfs_fs.h xattr.h unsquashfs_error.h - -unsquashfs_info.o: unsquashfs.h squashfs_fs.h unsquashfs_error.h - -.PHONY: clean -clean: - -rm -f *.o mksquashfs unsquashfs sqfstar sqfscat *.1 - -.PHONY: install -install: mksquashfs unsquashfs - mkdir -p $(INSTALL_DIR) - cp mksquashfs $(INSTALL_DIR) - cp unsquashfs $(INSTALL_DIR) - ln -fs unsquashfs $(INSTALL_DIR)/sqfscat - ln -fs mksquashfs $(INSTALL_DIR)/sqfstar - ../generate-manpages/install-manpages.sh $(shell pwd)/.. "$(INSTALL_MANPAGES_DIR)" "$(USE_PREBUILT_MANPAGES)" diff --git a/squashfs-tools/cmake/FindLZ4.cmake b/squashfs-tools/cmake/FindLZ4.cmake new file mode 100644 index 000000000..f86b0da99 --- /dev/null +++ b/squashfs-tools/cmake/FindLZ4.cmake @@ -0,0 +1,41 @@ +# Source: https://raw.githubusercontent.com/facebook/hhvm/master/CMake/FindLZ4.cmake +# Finds liblz4. +# +# This module defines: +# LZ4_FOUND +# LZ4_INCLUDE_DIR +# LZ4_LIBRARY +# + +find_path(LZ4_INCLUDE_DIR NAMES lz4.h) +find_library(LZ4_LIBRARY NAMES lz4) + +# fb-mysql requires LZ4F_resetDecompressionContext() which was added in v1.8.0 +if (LZ4_LIBRARY) + include(CheckCSourceRuns) + set(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${LZ4_LIBRARY}) + check_c_source_runs(" +#include +int main() { + int good = (LZ4_VERSION_MAJOR > 1) || + ((LZ4_VERSION_MAJOR == 1) && (LZ4_VERSION_MINOR >= 8)); +return !good; +}" LZ4_GOOD_VERSION) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_LIBRARIES) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LZ4 DEFAULT_MSG + LZ4_LIBRARY LZ4_INCLUDE_DIR LZ4_GOOD_VERSION) + +if (NOT LZ4_FOUND) + message(STATUS "Using third-party bundled LZ4") +else() + message(STATUS "Found LZ4: ${LZ4_LIBRARY}") +endif (NOT LZ4_FOUND) + +mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY) + diff --git a/squashfs-tools/cmake/FindLZO.cmake b/squashfs-tools/cmake/FindLZO.cmake new file mode 100644 index 000000000..18cde4856 --- /dev/null +++ b/squashfs-tools/cmake/FindLZO.cmake @@ -0,0 +1,31 @@ +# Source: https://raw.githubusercontent.com/veyon/veyon/master/cmake/modules/FindLZO.cmake +# Find liblzo2 +# LZO_FOUND - system has the LZO library +# LZO_INCLUDE_DIR - the LZO include directory +# LZO_LIBRARIES - The libraries needed to use LZO + +if(LZO_INCLUDE_DIR AND LZO_LIBRARIES) + # in cache already + set(LZO_FOUND TRUE) +else() + find_path(LZO_INCLUDE_DIR NAMES lzo/lzo1x.h) + + find_library(LZO_LIBRARIES NAMES lzo2) + + if(LZO_INCLUDE_DIR AND LZO_LIBRARIES) + set(LZO_FOUND TRUE) + endif() + + if(LZO_FOUND) + if(NOT LZO_FIND_QUIETLY) + message(STATUS "Found LZO: ${LZO_LIBRARIES}") + endif() + else() + if(LZO_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find LZO") + endif() + endif() + + mark_as_advanced(LZO_INCLUDE_DIR LZO_LIBRARIES) +endif() + diff --git a/squashfs-tools/cmake/FindXattr.cmake b/squashfs-tools/cmake/FindXattr.cmake new file mode 100644 index 000000000..4200eabe7 --- /dev/null +++ b/squashfs-tools/cmake/FindXattr.cmake @@ -0,0 +1,36 @@ +# Source: https://raw.githubusercontent.com/eiskaltdcpp/eiskaltdcpp/master/cmake/FindXattr.cmake +# - Try to find libattr library and headers +# Once done, this will define +# +# XATTR_FOUND - system has libattr +# XATTR_INCLUDE_DIRS - the libattr include directories +# XATTR_LIBRARIES - link these to use libattr + +FIND_PATH(XATTR_INCLUDE xattr.h + ${XATTR_PREFIX}/include/attr + /usr/include/attr +) + +FIND_LIBRARY(XATTR_LIB + NAMES + attr + PATHS + /usr/lib + ${XATTR_PREFIX}/lib +) + +IF(XATTR_INCLUDE AND XATTR_LIB) + SET(XATTR_FOUND TRUE) + SET(XATTR_INCLUDE_DIRS ${XATTR_INCLUDE}) + SET(XATTR_LIBRARIES ${XATTR_LIB}) +ELSE(XATTR_INCLUDE AND XATTR_LIB) + SET(XATTR_FOUND FALSE) + SET(XATTR_LIBRARIES "") +ENDIF(XATTR_INCLUDE AND XATTR_LIB) + +MARK_AS_ADVANCED( XATTR_LIB XATTR_INCLUDE ) + +IF(NOT XATTR_FOUND AND NOT XATTR_FIND_QUIETLY AND XATTR_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Xattr library!") +ENDIF(NOT XATTR_FOUND AND NOT XATTR_FIND_QUIETLY AND XATTR_FIND_REQUIRED) + diff --git a/squashfs-tools/cmake/FindZSTD.cmake b/squashfs-tools/cmake/FindZSTD.cmake new file mode 100644 index 000000000..d04a0bfc7 --- /dev/null +++ b/squashfs-tools/cmake/FindZSTD.cmake @@ -0,0 +1,31 @@ +# Based on: https://raw.githubusercontent.com/veyon/veyon/master/cmake/modules/FindLZO.cmake +# Find libzstd +# ZSTD_FOUND - system has the ZSTD library +# ZSTD_INCLUDE_DIR - the ZSTD include directory +# ZSTD_LIBRARIES - The libraries needed to use ZSTD + +if(ZSTD_INCLUDE_DIR AND ZSTD_LIBRARIES) + # in cache already + set(ZSTD_FOUND TRUE) +else() + find_path(ZSTD_INCLUDE_DIR NAMES zstd.h) + + find_library(ZSTD_LIBRARIES NAMES zstd) + + if(ZSTD_INCLUDE_DIR AND ZSTD_LIBRARIES) + set(ZSTD_FOUND TRUE) + endif() + + if(ZSTD_FOUND) + if(NOT ZSTD_FIND_QUIETLY) + message(STATUS "Found ZSTD: ${ZSTD_LIBRARIES}") + endif() + else() + if(ZSTD_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find ZSTD") + endif() + endif() + + mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARIES) +endif() + diff --git a/squashfs-tools/version.cmake b/squashfs-tools/version.cmake new file mode 100644 index 000000000..e32417799 --- /dev/null +++ b/squashfs-tools/version.cmake @@ -0,0 +1,2 @@ +set(HASH "$Format:%h$") +set(FULLDATE "$Format:%ci$") diff --git a/squashfs-tools/version.mk b/squashfs-tools/version.mk deleted file mode 100644 index cc7dedfea..000000000 --- a/squashfs-tools/version.mk +++ /dev/null @@ -1,2 +0,0 @@ -HASH := $Format:%h$ -FULLDATE := $Format:%ci$