Home | History | Annotate | Download | only in squashfs-tools
      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 #
     18 GZIP_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 #
     84 COMP_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
     95 XATTR_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.
    103 XATTR_DEFAULT = 1
    104 
    105 
    106 ###############################################
    107 #        End of BUILD options section         #
    108 ###############################################
    109 
    110 INCLUDEDIR = -I.
    111 INSTALL_DIR = /usr/local/bin
    112 
    113 MKSQUASHFS_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 
    117 UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \
    118 	unsquash-4.o swap.o compressor.o unsquashfs_info.o
    119 
    120 CFLAGS ?= -O2
    121 CFLAGS += $(EXTRA_CFLAGS) $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 \
    122 	-D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" \
    123 	-Wall
    124 
    125 LIBS = -lpthread -lm
    126 ifeq ($(GZIP_SUPPORT),1)
    127 CFLAGS += -DGZIP_SUPPORT
    128 MKSQUASHFS_OBJS += gzip_wrapper.o
    129 UNSQUASHFS_OBJS += gzip_wrapper.o
    130 LIBS += -lz
    131 COMPRESSORS += gzip
    132 endif
    133 
    134 ifeq ($(LZMA_SUPPORT),1)
    135 LZMA_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
    137 INCLUDEDIR += -I$(LZMA_DIR)/C
    138 CFLAGS += -DLZMA_SUPPORT
    139 MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
    140 UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
    141 COMPRESSORS += lzma
    142 endif
    143 
    144 ifeq ($(LZMA_XZ_SUPPORT),1)
    145 CFLAGS += -DLZMA_SUPPORT
    146 MKSQUASHFS_OBJS += lzma_xz_wrapper.o
    147 UNSQUASHFS_OBJS += lzma_xz_wrapper.o
    148 LIBS += -llzma
    149 COMPRESSORS += lzma
    150 endif
    151 
    152 ifeq ($(XZ_SUPPORT),1)
    153 CFLAGS += -DXZ_SUPPORT
    154 MKSQUASHFS_OBJS += xz_wrapper.o
    155 UNSQUASHFS_OBJS += xz_wrapper.o
    156 LIBS += -llzma
    157 COMPRESSORS += xz
    158 endif
    159 
    160 ifeq ($(LZO_SUPPORT),1)
    161 CFLAGS += -DLZO_SUPPORT
    162 ifdef LZO_DIR
    163 INCLUDEDIR += -I$(LZO_DIR)/include
    164 LZO_LIBDIR = -L$(LZO_DIR)/lib
    165 endif
    166 MKSQUASHFS_OBJS += lzo_wrapper.o
    167 UNSQUASHFS_OBJS += lzo_wrapper.o
    168 LIBS += $(LZO_LIBDIR) -llzo2
    169 COMPRESSORS += lzo
    170 endif
    171 
    172 ifeq ($(LZ4_SUPPORT),1)
    173 CFLAGS += -DLZ4_SUPPORT
    174 MKSQUASHFS_OBJS += lz4_wrapper.o
    175 UNSQUASHFS_OBJS += lz4_wrapper.o
    176 LIBS += -llz4
    177 COMPRESSORS += lz4
    178 endif
    179 
    180 ifeq ($(XATTR_SUPPORT),1)
    181 ifeq ($(XATTR_DEFAULT),1)
    182 CFLAGS += -DXATTR_SUPPORT -DXATTR_DEFAULT
    183 else
    184 CFLAGS += -DXATTR_SUPPORT
    185 endif
    186 MKSQUASHFS_OBJS += xattr.o read_xattrs.o
    187 UNSQUASHFS_OBJS += read_xattrs.o unsquashfs_xattr.o
    188 endif
    189 
    190 #
    191 # If LZMA_SUPPORT is specified then LZMA_DIR must be specified too
    192 #
    193 ifeq ($(LZMA_SUPPORT),1)
    194 ifndef LZMA_DIR
    195 $(error "LZMA_SUPPORT requires LZMA_DIR to be also defined")
    196 endif
    197 endif
    198 
    199 #
    200 # Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified
    201 #
    202 ifeq ($(LZMA_XZ_SUPPORT),1)
    203 ifeq ($(LZMA_SUPPORT),1)
    204 $(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified")
    205 endif
    206 endif
    207 
    208 #
    209 # At least one compressor must have been selected
    210 #
    211 ifndef COMPRESSORS
    212 $(error "No compressor selected! Select one or more of GZIP, LZMA, XZ, LZO or \
    213 	LZ4!")
    214 endif
    215 
    216 #
    217 # COMP_DEFAULT must be a selected compressor
    218 #
    219 ifeq (, $(findstring $(COMP_DEFAULT), $(COMPRESSORS)))
    220 $(error "COMP_DEFAULT is set to ${COMP_DEFAULT}, which  isn't selected to be \
    221 	built!")
    222 endif
    223 
    224 .PHONY: all
    225 all: mksquashfs unsquashfs
    226 
    227 mksquashfs: $(MKSQUASHFS_OBJS)
    228 	$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(MKSQUASHFS_OBJS) $(LIBS) -o $@
    229 
    230 mksquashfs.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 
    234 read_fs.o: read_fs.c squashfs_fs.h squashfs_swap.h compressor.h xattr.h \
    235 	error.h mksquashfs.h
    236 
    237 sort.o: sort.c squashfs_fs.h mksquashfs.h sort.h error.h progressbar.h
    238 
    239 swap.o: swap.c
    240 
    241 pseudo.o: pseudo.c pseudo.h error.h progressbar.h
    242 
    243 compressor.o: Makefile compressor.c compressor.h squashfs_fs.h
    244 
    245 xattr.o: xattr.c squashfs_fs.h squashfs_swap.h mksquashfs.h xattr.h error.h \
    246 	progressbar.h
    247 
    248 read_xattrs.o: read_xattrs.c squashfs_fs.h squashfs_swap.h xattr.h error.h
    249 
    250 action.o: action.c squashfs_fs.h mksquashfs.h action.h error.h
    251 
    252 progressbar.o: progressbar.c error.h
    253 
    254 read_file.o: read_file.c error.h
    255 
    256 info.o: info.c squashfs_fs.h mksquashfs.h error.h progressbar.h \
    257 	caches-queues-lists.h
    258 
    259 restore.o: restore.c caches-queues-lists.h squashfs_fs.h mksquashfs.h error.h \
    260 	progressbar.h info.h
    261 
    262 process_fragments.o: process_fragments.c process_fragments.h
    263 
    264 caches-queues-lists.o: caches-queues-lists.c error.h caches-queues-lists.h
    265 
    266 gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h
    267 
    268 lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h
    269 
    270 lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h
    271 
    272 lzo_wrapper.o: lzo_wrapper.c squashfs_fs.h lzo_wrapper.h compressor.h
    273 
    274 lz4_wrapper.o: lz4_wrapper.c squashfs_fs.h lz4_wrapper.h compressor.h
    275 
    276 xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h
    277 
    278 unsquashfs: $(UNSQUASHFS_OBJS)
    279 	$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@
    280 
    281 unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \
    282 	squashfs_compat.h xattr.h read_fs.h compressor.h
    283 
    284 unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h
    285 
    286 unsquash-2.o: unsquashfs.h unsquash-2.c squashfs_fs.h squashfs_compat.h
    287 
    288 unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h
    289 
    290 unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \
    291 	read_fs.h
    292 
    293 unsquashfs_xattr.o: unsquashfs_xattr.c unsquashfs.h squashfs_fs.h xattr.h
    294 
    295 unsquashfs_info.o: unsquashfs.h squashfs_fs.h
    296 
    297 .PHONY: clean
    298 clean:
    299 	-rm -f *.o mksquashfs unsquashfs
    300 
    301 .PHONY: install
    302 install: mksquashfs unsquashfs
    303 	mkdir -p $(INSTALL_DIR)
    304 	cp mksquashfs $(INSTALL_DIR)
    305 	cp unsquashfs $(INSTALL_DIR)
    306