1############################################### 2# Compression build options # 3############################################### 4# 5# 6############# Building gzip support ########### 7# 8# Gzip support is by default enabled, and the compression type default 9# (COMP_DEFAULT) is gzip. 10# 11# If you don't want/need gzip support then comment out the GZIP SUPPORT line 12# below, and change COMP_DEFAULT to one of the compression types you have 13# selected. 14# 15# Obviously, you must select at least one of the available gzip, lzma, lzo 16# compression types. 17# 18GZIP_SUPPORT = 1 19 20########### Building XZ support ############# 21# 22# LZMA2 compression. 23# 24# XZ Utils liblzma (http://tukaani.org/xz/) is supported 25# 26# To build using XZ Utils liblzma - install the library and uncomment 27# the XZ_SUPPORT line below. 28# 29#XZ_SUPPORT = 1 30 31 32############ Building LZO support ############## 33# 34# The LZO library (http://www.oberhumer.com/opensource/lzo/) is supported. 35# 36# To build using the LZO library - install the library and uncomment the 37# LZO_SUPPORT line below. If needed, uncomment and set LZO_DIR to the 38# installation prefix. 39# 40#LZO_SUPPORT = 1 41#LZO_DIR = /usr/local 42 43 44########### Building LZ4 support ############# 45# 46# Yann Collet's LZ4 tools are supported 47# LZ4 homepage: http://fastcompression.blogspot.com/p/lz4.html 48# LZ4 source repository: http://code.google.com/p/lz4 49# 50# To build configure the tools using cmake to build shared libraries, 51# install and uncomment 52# the LZ4_SUPPORT line below. 53# 54#LZ4_SUPPORT = 1 55 56 57########### Building LZMA support ############# 58# 59# LZMA1 compression. 60# 61# LZMA1 compression is deprecated, and the newer and better XZ (LZMA2) 62# compression should be used in preference. 63# 64# Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK 65# (http://www.7-zip.org/sdk.html) are supported 66# 67# To build using XZ Utils liblzma - install the library and uncomment 68# the LZMA_XZ_SUPPORT line below. 69# 70# To build using the LZMA SDK (4.65 used in development, other versions may 71# work) - download and unpack it, uncomment and set LZMA_DIR to unpacked source, 72# and uncomment the LZMA_SUPPORT line below. 73# 74#LZMA_XZ_SUPPORT = 1 75#LZMA_SUPPORT = 1 76#LZMA_DIR = ../../../../LZMA/lzma465 77 78########### Building ZSTD support ############ 79# 80# The ZSTD library is supported 81# ZSTD homepage: http://zstd.net 82# ZSTD source repository: https://github.com/facebook/zstd 83# 84# To build using the ZSTD library - install the library and uncomment the 85# ZSTD_SUPPORT line below. 86# 87#ZSTD_SUPPORT = 1 88 89######## Specifying default compression ######## 90# 91# The next line specifies which compression algorithm is used by default 92# in Mksquashfs. Obviously the compression algorithm must have been 93# selected to be built 94# 95COMP_DEFAULT = gzip 96 97############################################### 98# Extended attribute (XATTRs) build options # 99############################################### 100# 101# Building XATTR support for Mksquashfs and Unsquashfs 102# 103# If your C library or build/target environment doesn't support XATTRs then 104# comment out the next line to build Mksquashfs and Unsquashfs without XATTR 105# support 106XATTR_SUPPORT = 1 107 108# Select whether you wish xattrs to be stored by Mksquashfs and extracted 109# by Unsquashfs by default. If selected users can disable xattr support by 110# using the -no-xattrs option 111# 112# If unselected, Mksquashfs/Unsquashfs won't store and extract xattrs by 113# default. Users can enable xattrs by using the -xattrs option. 114XATTR_DEFAULT = 1 115 116 117############################################### 118# End of BUILD options section # 119############################################### 120 121INCLUDEDIR = -I. 122INSTALL_DIR = /usr/local/bin 123 124MKSQUASHFS_OBJS = mksquashfs.o read_fs.o action.o swap.o pseudo.o compressor.o \ 125 sort.o progressbar.o read_file.o info.o restore.o process_fragments.o \ 126 caches-queues-lists.o 127 128UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \ 129 unsquash-4.o swap.o compressor.o unsquashfs_info.o 130 131CFLAGS ?= -O2 132CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \ 133 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \ 134 -Wall 135 136LIBS = -lpthread -lm 137ifeq ($(GZIP_SUPPORT),1) 138CFLAGS += -DGZIP_SUPPORT 139MKSQUASHFS_OBJS += gzip_wrapper.o 140UNSQUASHFS_OBJS += gzip_wrapper.o 141LIBS += -lz 142COMPRESSORS += gzip 143endif 144 145ifeq ($(LZMA_SUPPORT),1) 146LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \ 147 $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o 148INCLUDEDIR += -I$(LZMA_DIR)/C 149CFLAGS += -DLZMA_SUPPORT 150MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS) 151UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS) 152COMPRESSORS += lzma 153endif 154 155ifeq ($(LZMA_XZ_SUPPORT),1) 156CFLAGS += -DLZMA_SUPPORT 157MKSQUASHFS_OBJS += lzma_xz_wrapper.o 158UNSQUASHFS_OBJS += lzma_xz_wrapper.o 159LIBS += -llzma 160COMPRESSORS += lzma 161endif 162 163ifeq ($(XZ_SUPPORT),1) 164CFLAGS += -DXZ_SUPPORT 165MKSQUASHFS_OBJS += xz_wrapper.o 166UNSQUASHFS_OBJS += xz_wrapper.o 167LIBS += -llzma 168COMPRESSORS += xz 169endif 170 171ifeq ($(LZO_SUPPORT),1) 172CFLAGS += -DLZO_SUPPORT 173ifdef LZO_DIR 174INCLUDEDIR += -I$(LZO_DIR)/include 175LZO_LIBDIR = -L$(LZO_DIR)/lib 176endif 177MKSQUASHFS_OBJS += lzo_wrapper.o 178UNSQUASHFS_OBJS += lzo_wrapper.o 179LIBS += $(LZO_LIBDIR) -llzo2 180COMPRESSORS += lzo 181endif 182 183ifeq ($(LZ4_SUPPORT),1) 184CFLAGS += -DLZ4_SUPPORT 185MKSQUASHFS_OBJS += lz4_wrapper.o 186UNSQUASHFS_OBJS += lz4_wrapper.o 187LIBS += -llz4 188COMPRESSORS += lz4 189endif 190 191ifeq ($(ZSTD_SUPPORT),1) 192CFLAGS += -DZSTD_SUPPORT 193MKSQUASHFS_OBJS += zstd_wrapper.o 194UNSQUASHFS_OBJS += zstd_wrapper.o 195LIBS += -lzstd 196COMPRESSORS += zstd 197endif 198 199ifeq ($(XATTR_SUPPORT),1) 200ifeq ($(XATTR_DEFAULT),1) 201CFLAGS += -DXATTR_SUPPORT -DXATTR_DEFAULT 202else 203CFLAGS += -DXATTR_SUPPORT 204endif 205MKSQUASHFS_OBJS += xattr.o read_xattrs.o 206UNSQUASHFS_OBJS += read_xattrs.o unsquashfs_xattr.o 207endif 208 209# 210# If LZMA_SUPPORT is specified then LZMA_DIR must be specified too 211# 212ifeq ($(LZMA_SUPPORT),1) 213ifndef LZMA_DIR 214$(error "LZMA_SUPPORT requires LZMA_DIR to be also defined") 215endif 216endif 217 218# 219# Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified 220# 221ifeq ($(LZMA_XZ_SUPPORT),1) 222ifeq ($(LZMA_SUPPORT),1) 223$(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified") 224endif 225endif 226 227# 228# At least one compressor must have been selected 229# 230ifndef COMPRESSORS 231$(error "No compressor selected! Select one or more of GZIP, LZMA, XZ, LZO or \ 232 LZ4!") 233endif 234 235# 236# COMP_DEFAULT must be a selected compressor 237# 238ifeq (, $(findstring $(COMP_DEFAULT), $(COMPRESSORS))) 239$(error "COMP_DEFAULT is set to ${COMP_DEFAULT}, which isn't selected to be \ 240 built!") 241endif 242 243.PHONY: all 244all: mksquashfs unsquashfs 245 246mksquashfs: $(MKSQUASHFS_OBJS) 247 $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(MKSQUASHFS_OBJS) $(LIBS) -o $@ 248 249mksquashfs.o: Makefile mksquashfs.c squashfs_fs.h squashfs_swap.h mksquashfs.h \ 250 sort.h pseudo.h compressor.h xattr.h action.h error.h progressbar.h \ 251 info.h caches-queues-lists.h read_fs.h restore.h process_fragments.h 252 253read_fs.o: read_fs.c squashfs_fs.h squashfs_swap.h compressor.h xattr.h \ 254 error.h mksquashfs.h 255 256sort.o: sort.c squashfs_fs.h mksquashfs.h sort.h error.h progressbar.h 257 258swap.o: swap.c 259 260pseudo.o: pseudo.c pseudo.h error.h progressbar.h 261 262compressor.o: Makefile compressor.c compressor.h squashfs_fs.h 263 264xattr.o: xattr.c squashfs_fs.h squashfs_swap.h mksquashfs.h xattr.h error.h \ 265 progressbar.h 266 267read_xattrs.o: read_xattrs.c squashfs_fs.h squashfs_swap.h xattr.h error.h 268 269action.o: action.c squashfs_fs.h mksquashfs.h action.h error.h 270 271progressbar.o: progressbar.c error.h 272 273read_file.o: read_file.c error.h 274 275info.o: info.c squashfs_fs.h mksquashfs.h error.h progressbar.h \ 276 caches-queues-lists.h 277 278restore.o: restore.c caches-queues-lists.h squashfs_fs.h mksquashfs.h error.h \ 279 progressbar.h info.h 280 281process_fragments.o: process_fragments.c process_fragments.h 282 283caches-queues-lists.o: caches-queues-lists.c error.h caches-queues-lists.h 284 285gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h 286 287lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h 288 289lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h 290 291lzo_wrapper.o: lzo_wrapper.c squashfs_fs.h lzo_wrapper.h compressor.h 292 293lz4_wrapper.o: lz4_wrapper.c squashfs_fs.h lz4_wrapper.h compressor.h 294 295xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h 296 297unsquashfs: $(UNSQUASHFS_OBJS) 298 $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@ 299 300unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \ 301 squashfs_compat.h xattr.h read_fs.h compressor.h 302 303unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h 304 305unsquash-2.o: unsquashfs.h unsquash-2.c squashfs_fs.h squashfs_compat.h 306 307unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h 308 309unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \ 310 read_fs.h 311 312unsquashfs_xattr.o: unsquashfs_xattr.c unsquashfs.h squashfs_fs.h xattr.h 313 314unsquashfs_info.o: unsquashfs.h squashfs_fs.h 315 316.PHONY: clean 317clean: 318 -rm -f *.o mksquashfs unsquashfs 319 320.PHONY: install 321install: mksquashfs unsquashfs 322 mkdir -p $(INSTALL_DIR) 323 cp mksquashfs $(INSTALL_DIR) 324 cp unsquashfs $(INSTALL_DIR) 325