• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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######## Specifying default compression ########
79#
80# The next line specifies which compression algorithm is used by default
81# in Mksquashfs.  Obviously the compression algorithm must have been
82# selected to be built
83#
84COMP_DEFAULT = gzip
85
86###############################################
87#  Extended attribute (XATTRs) build options  #
88###############################################
89#
90# Building XATTR support for Mksquashfs and Unsquashfs
91#
92# If your C library or build/target environment doesn't support XATTRs then
93# comment out the next line to build Mksquashfs and Unsquashfs without XATTR
94# support
95XATTR_SUPPORT = 1
96
97# Select whether you wish xattrs to be stored by Mksquashfs and extracted
98# by Unsquashfs by default.  If selected users can disable xattr support by
99# using the -no-xattrs option
100#
101# If unselected, Mksquashfs/Unsquashfs won't store and extract xattrs by
102# default.  Users can enable xattrs by using the -xattrs option.
103XATTR_DEFAULT = 1
104
105
106###############################################
107#        End of BUILD options section         #
108###############################################
109
110INCLUDEDIR = -I.
111INSTALL_DIR = /usr/local/bin
112
113MKSQUASHFS_OBJS = mksquashfs.o read_fs.o action.o swap.o pseudo.o compressor.o \
114	sort.o progressbar.o read_file.o info.o restore.o process_fragments.o \
115	caches-queues-lists.o
116
117UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \
118	unsquash-4.o swap.o compressor.o unsquashfs_info.o
119
120CFLAGS ?= -O2
121CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
122	-D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \
123	-Wall
124
125LIBS = -lpthread -lm
126ifeq ($(GZIP_SUPPORT),1)
127CFLAGS += -DGZIP_SUPPORT
128MKSQUASHFS_OBJS += gzip_wrapper.o
129UNSQUASHFS_OBJS += gzip_wrapper.o
130LIBS += -lz
131COMPRESSORS += gzip
132endif
133
134ifeq ($(LZMA_SUPPORT),1)
135LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \
136	$(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o
137INCLUDEDIR += -I$(LZMA_DIR)/C
138CFLAGS += -DLZMA_SUPPORT
139MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
140UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
141COMPRESSORS += lzma
142endif
143
144ifeq ($(LZMA_XZ_SUPPORT),1)
145CFLAGS += -DLZMA_SUPPORT
146MKSQUASHFS_OBJS += lzma_xz_wrapper.o
147UNSQUASHFS_OBJS += lzma_xz_wrapper.o
148LIBS += -llzma
149COMPRESSORS += lzma
150endif
151
152ifeq ($(XZ_SUPPORT),1)
153CFLAGS += -DXZ_SUPPORT
154MKSQUASHFS_OBJS += xz_wrapper.o
155UNSQUASHFS_OBJS += xz_wrapper.o
156LIBS += -llzma
157COMPRESSORS += xz
158endif
159
160ifeq ($(LZO_SUPPORT),1)
161CFLAGS += -DLZO_SUPPORT
162ifdef LZO_DIR
163INCLUDEDIR += -I$(LZO_DIR)/include
164LZO_LIBDIR = -L$(LZO_DIR)/lib
165endif
166MKSQUASHFS_OBJS += lzo_wrapper.o
167UNSQUASHFS_OBJS += lzo_wrapper.o
168LIBS += $(LZO_LIBDIR) -llzo2
169COMPRESSORS += lzo
170endif
171
172ifeq ($(LZ4_SUPPORT),1)
173CFLAGS += -DLZ4_SUPPORT
174MKSQUASHFS_OBJS += lz4_wrapper.o
175UNSQUASHFS_OBJS += lz4_wrapper.o
176LIBS += -llz4
177COMPRESSORS += lz4
178endif
179
180ifeq ($(XATTR_SUPPORT),1)
181ifeq ($(XATTR_DEFAULT),1)
182CFLAGS += -DXATTR_SUPPORT -DXATTR_DEFAULT
183else
184CFLAGS += -DXATTR_SUPPORT
185endif
186MKSQUASHFS_OBJS += xattr.o read_xattrs.o
187UNSQUASHFS_OBJS += read_xattrs.o unsquashfs_xattr.o
188endif
189
190#
191# If LZMA_SUPPORT is specified then LZMA_DIR must be specified too
192#
193ifeq ($(LZMA_SUPPORT),1)
194ifndef LZMA_DIR
195$(error "LZMA_SUPPORT requires LZMA_DIR to be also defined")
196endif
197endif
198
199#
200# Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified
201#
202ifeq ($(LZMA_XZ_SUPPORT),1)
203ifeq ($(LZMA_SUPPORT),1)
204$(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified")
205endif
206endif
207
208#
209# At least one compressor must have been selected
210#
211ifndef COMPRESSORS
212$(error "No compressor selected! Select one or more of GZIP, LZMA, XZ, LZO or \
213	LZ4!")
214endif
215
216#
217# COMP_DEFAULT must be a selected compressor
218#
219ifeq (, $(findstring $(COMP_DEFAULT), $(COMPRESSORS)))
220$(error "COMP_DEFAULT is set to ${COMP_DEFAULT}, which  isn't selected to be \
221	built!")
222endif
223
224.PHONY: all
225all: mksquashfs unsquashfs
226
227mksquashfs: $(MKSQUASHFS_OBJS)
228	$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(MKSQUASHFS_OBJS) $(LIBS) -o $@
229
230mksquashfs.o: Makefile mksquashfs.c squashfs_fs.h squashfs_swap.h mksquashfs.h \
231	sort.h pseudo.h compressor.h xattr.h action.h error.h progressbar.h \
232	info.h caches-queues-lists.h read_fs.h restore.h process_fragments.h
233
234read_fs.o: read_fs.c squashfs_fs.h squashfs_swap.h compressor.h xattr.h \
235	error.h mksquashfs.h
236
237sort.o: sort.c squashfs_fs.h mksquashfs.h sort.h error.h progressbar.h
238
239swap.o: swap.c
240
241pseudo.o: pseudo.c pseudo.h error.h progressbar.h
242
243compressor.o: Makefile compressor.c compressor.h squashfs_fs.h
244
245xattr.o: xattr.c squashfs_fs.h squashfs_swap.h mksquashfs.h xattr.h error.h \
246	progressbar.h
247
248read_xattrs.o: read_xattrs.c squashfs_fs.h squashfs_swap.h xattr.h error.h
249
250action.o: action.c squashfs_fs.h mksquashfs.h action.h error.h
251
252progressbar.o: progressbar.c error.h
253
254read_file.o: read_file.c error.h
255
256info.o: info.c squashfs_fs.h mksquashfs.h error.h progressbar.h \
257	caches-queues-lists.h
258
259restore.o: restore.c caches-queues-lists.h squashfs_fs.h mksquashfs.h error.h \
260	progressbar.h info.h
261
262process_fragments.o: process_fragments.c process_fragments.h
263
264caches-queues-lists.o: caches-queues-lists.c error.h caches-queues-lists.h
265
266gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h
267
268lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h
269
270lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h
271
272lzo_wrapper.o: lzo_wrapper.c squashfs_fs.h lzo_wrapper.h compressor.h
273
274lz4_wrapper.o: lz4_wrapper.c squashfs_fs.h lz4_wrapper.h compressor.h
275
276xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h
277
278unsquashfs: $(UNSQUASHFS_OBJS)
279	$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@
280
281unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \
282	squashfs_compat.h xattr.h read_fs.h compressor.h
283
284unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h
285
286unsquash-2.o: unsquashfs.h unsquash-2.c squashfs_fs.h squashfs_compat.h
287
288unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h
289
290unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \
291	read_fs.h
292
293unsquashfs_xattr.o: unsquashfs_xattr.c unsquashfs.h squashfs_fs.h xattr.h
294
295unsquashfs_info.o: unsquashfs.h squashfs_fs.h
296
297.PHONY: clean
298clean:
299	-rm -f *.o mksquashfs unsquashfs
300
301.PHONY: install
302install: mksquashfs unsquashfs
303	mkdir -p $(INSTALL_DIR)
304	cp mksquashfs $(INSTALL_DIR)
305	cp unsquashfs $(INSTALL_DIR)
306