1 ###############################################
2 # Compression build options #
3 ###############################################
6 ############# Building gzip support ###########
8 # Gzip support is by default enabled, and the compression type default
9 # (COMP_DEFAULT) is gzip.
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
15 # Obviously, you must select at least one of the available gzip, lzma, lzo
20 ########### Building XZ support #############
24 # XZ Utils liblzma (http://tukaani.org/xz/) is supported
26 # Development packages (libraries and header files) should be
27 # supported by most modern distributions. Please refer to
28 # your distribution package manager.
30 # To build install the library and uncomment
31 # the XZ_SUPPORT line below.
36 ############ Building LZO support ##############
38 # The LZO library (http://www.oberhumer.com/opensource/lzo/) is supported.
40 # Development packages (libraries and header files) should be
41 # supported by most modern distributions. Please refer to
42 # your distribution package manager.
44 # To build install the library and uncomment
45 # the XZ_SUPPORT line below.
50 ########### Building LZ4 support #############
52 # Yann Collet's LZ4 tools are supported
53 # LZ4 homepage: http://fastcompression.blogspot.com/p/lz4.html
54 # LZ4 source repository: http://code.google.com/p/lz4
56 # Development packages (libraries and header files) should be
57 # supported by most modern distributions. Please refer to
58 # your distribution package manager.
60 # To build install and uncomment
61 # the LZ4_SUPPORT line below.
66 ########### Building ZSTD support ############
68 # The ZSTD library is supported
69 # ZSTD homepage: http://zstd.net
70 # ZSTD source repository: https://github.com/facebook/zstd
72 # Development packages (libraries and header files) should be
73 # supported by most modern distributions. Please refer to
74 # your distribution package manager.
76 # To build install the library and uncomment
77 # the XZ_SUPPORT line below.
82 ######## Specifying default compression ########
84 # The next line specifies which compression algorithm is used by default
85 # in Mksquashfs. Obviously the compression algorithm must have been
86 # selected to be built
91 ###############################################
92 # Extended attribute (XATTRs) build options #
93 ###############################################
95 # Building XATTR support for Mksquashfs and Unsquashfs
97 # If your C library or build/target environment doesn't support XATTRs then
98 # comment out the next line to build Mksquashfs and Unsquashfs without XATTR
102 # Select whether you wish xattrs to be stored by Mksquashfs and extracted
103 # by Unsquashfs by default. If selected users can disable xattr support by
104 # using the -no-xattrs option
106 # If unselected, Mksquashfs/Unsquashfs won't store and extract xattrs by
107 # default. Users can enable xattrs by using the -xattrs option.
111 ###############################################
112 # Reproducible Image options #
113 ###############################################
115 # Select whether you wish reproducible builds by default. If selected users
116 # can disable reproducible builds using the not-reproducible option.
117 # If not selected, users can enable reproducible builds using the
118 # -reproducible option
119 REPRODUCIBLE_DEFAULT = 1
122 ###############################################
124 ###############################################
126 ########### Building LZMA support #############
130 # LZMA1 compression is obsolete, and the newer and better XZ (LZMA2)
131 # compression should be used in preference.
133 # Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK
134 # (http://www.7-zip.org/sdk.html) are supported
136 # To build using XZ Utils liblzma - install the library and uncomment
137 # the LZMA_XZ_SUPPORT line below.
139 # To build using the LZMA SDK (4.65 used in development, other versions may
140 # work) - download and unpack it, uncomment and set LZMA_DIR to unpacked source,
141 # and uncomment the LZMA_SUPPORT line below.
145 #LZMA_DIR = ../../../../LZMA/lzma465
147 ###############################################
148 # End of BUILD options section #
149 ###############################################
152 INSTALL_DIR = /usr/local/bin
154 MKSQUASHFS_OBJS = mksquashfs.o read_fs.o action.o swap.o pseudo.o compressor.o \
155 sort.o progressbar.o read_file.o info.o restore.o process_fragments.o \
156 caches-queues-lists.o
158 UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \
159 unsquash-4.o unsquash-123.o unsquash-34.o swap.o compressor.o unsquashfs_info.o
162 CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
163 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \
167 ifeq ($(GZIP_SUPPORT),1)
168 CFLAGS += -DGZIP_SUPPORT
169 MKSQUASHFS_OBJS += gzip_wrapper.o
170 UNSQUASHFS_OBJS += gzip_wrapper.o
175 ifeq ($(LZMA_SUPPORT),1)
176 LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \
177 $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o
178 INCLUDEDIR += -I$(LZMA_DIR)/C
179 CFLAGS += -DLZMA_SUPPORT
180 MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
181 UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
185 ifeq ($(LZMA_XZ_SUPPORT),1)
186 CFLAGS += -DLZMA_SUPPORT
187 MKSQUASHFS_OBJS += lzma_xz_wrapper.o
188 UNSQUASHFS_OBJS += lzma_xz_wrapper.o
193 ifeq ($(XZ_SUPPORT),1)
194 CFLAGS += -DXZ_SUPPORT -I$(LZMA_LIBDIR)/include
195 MKSQUASHFS_OBJS += xz_wrapper.o
196 UNSQUASHFS_OBJS += xz_wrapper.o
197 LIBS += $(LZMA_LIBDIR)/lib/liblzma.a
201 ifeq ($(LZO_SUPPORT),1)
202 CFLAGS += -DLZO_SUPPORT -I $(LZO_LIBDIR)/include
203 MKSQUASHFS_OBJS += lzo_wrapper.o
204 UNSQUASHFS_OBJS += lzo_wrapper.o
205 LIBS += $(LZO_LIBDIR)/lib/liblzo2.a
209 ifeq ($(LZ4_SUPPORT),1)
210 CFLAGS += -DLZ4_SUPPORT -I $(LZ4_LIBDIR)/include
211 MKSQUASHFS_OBJS += lz4_wrapper.o
212 UNSQUASHFS_OBJS += lz4_wrapper.o
213 LIBS += $(LZ4_LIBDIR)/lib/liblz4.a
217 ifeq ($(ZSTD_SUPPORT),1)
218 CFLAGS += -DZSTD_SUPPORT -I $(ZSTD_LIBDIR)/include
219 MKSQUASHFS_OBJS += zstd_wrapper.o
220 UNSQUASHFS_OBJS += zstd_wrapper.o
221 LIBS += $(ZSTD_LIBDIR)/lib/libzstd.a
225 ifeq ($(XATTR_SUPPORT),1)
226 ifeq ($(XATTR_DEFAULT),1)
227 CFLAGS += -DXATTR_SUPPORT -DXATTR_DEFAULT
229 CFLAGS += -DXATTR_SUPPORT
231 MKSQUASHFS_OBJS += xattr.o read_xattrs.o
232 UNSQUASHFS_OBJS += read_xattrs.o unsquashfs_xattr.o
235 ifeq ($(REPRODUCIBLE_DEFAULT),1)
236 CFLAGS += -DREPRODUCIBLE_DEFAULT
240 # If LZMA_SUPPORT is specified then LZMA_DIR must be specified too
242 ifeq ($(LZMA_SUPPORT),1)
244 $(error "LZMA_SUPPORT requires LZMA_DIR to be also defined")
249 # Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified
251 ifeq ($(LZMA_XZ_SUPPORT),1)
252 ifeq ($(LZMA_SUPPORT),1)
253 $(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified")
258 # At least one compressor must have been selected
261 $(error "No compressor selected! Select one or more of GZIP, LZMA, XZ, LZO, \
266 # COMP_DEFAULT should be defined
269 $(error "COMP_DEFAULT must be set to a compressor!")
273 # COMP_DEFAULT must be a selected compressor
275 ifeq (, $(findstring $(COMP_DEFAULT), $(COMPRESSORS)))
276 $(error "COMP_DEFAULT is set to ${COMP_DEFAULT}, which isn't selected to be \
281 all: mksquashfs unsquashfs
283 mksquashfs: $(MKSQUASHFS_OBJS)
284 $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(MKSQUASHFS_OBJS) $(LIBS) -o $@
286 mksquashfs.o: Makefile mksquashfs.c squashfs_fs.h squashfs_swap.h mksquashfs.h \
287 sort.h pseudo.h compressor.h xattr.h action.h error.h progressbar.h \
288 info.h caches-queues-lists.h read_fs.h restore.h process_fragments.h
290 read_fs.o: read_fs.c squashfs_fs.h squashfs_swap.h compressor.h xattr.h \
293 sort.o: sort.c squashfs_fs.h mksquashfs.h sort.h error.h progressbar.h
297 pseudo.o: pseudo.c pseudo.h error.h progressbar.h
299 compressor.o: Makefile compressor.c compressor.h squashfs_fs.h
301 xattr.o: xattr.c squashfs_fs.h squashfs_swap.h mksquashfs.h xattr.h error.h \
304 read_xattrs.o: read_xattrs.c squashfs_fs.h squashfs_swap.h xattr.h error.h
306 action.o: action.c squashfs_fs.h mksquashfs.h action.h error.h
308 progressbar.o: progressbar.c error.h
310 read_file.o: read_file.c error.h
312 info.o: info.c squashfs_fs.h mksquashfs.h error.h progressbar.h \
313 caches-queues-lists.h
315 restore.o: restore.c caches-queues-lists.h squashfs_fs.h mksquashfs.h error.h \
318 process_fragments.o: process_fragments.c process_fragments.h
320 caches-queues-lists.o: caches-queues-lists.c error.h caches-queues-lists.h
322 gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h
324 lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h
326 lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h
328 lzo_wrapper.o: lzo_wrapper.c squashfs_fs.h lzo_wrapper.h compressor.h
330 lz4_wrapper.o: lz4_wrapper.c squashfs_fs.h lz4_wrapper.h compressor.h
332 xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h
334 unsquashfs: $(UNSQUASHFS_OBJS)
335 $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@
337 unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \
338 squashfs_compat.h xattr.h read_fs.h compressor.h
340 unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h
342 unsquash-2.o: unsquashfs.h unsquash-2.c squashfs_fs.h squashfs_compat.h
344 unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h
346 unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \
349 unsquash-123.o: unsquashfs.h unsquash-123.c squashfs_fs.h squashfs_compat.h
351 unsquash-34.o: unsquashfs.h unsquash-34.c
353 unsquashfs_xattr.o: unsquashfs_xattr.c unsquashfs.h squashfs_fs.h xattr.h
355 unsquashfs_info.o: unsquashfs.h squashfs_fs.h
359 -rm -f *.o mksquashfs unsquashfs
362 install: mksquashfs unsquashfs
363 mkdir -p $(INSTALL_DIR)
364 cp mksquashfs $(INSTALL_DIR)
365 cp unsquashfs $(INSTALL_DIR)