0

I'm trying to compile modified squashfs tools from source code (GPL source). Installation 'readme' from original pack have notes that it can be built without needing to patch the kernel.(locally)

2. Building squashfs tools
The squashfs-tools directory contains the mksquashfs and unsquashfs programs. These can be made by typing make. The source files use a local copy of squashfs_fs.h (included in the kernel patches) allowing the tools to be made without needing to patch the kernel.

Executing make gives error: Makefile:2: *** Sqlzma is not defined. Stop. The sqlzma files, iclude sqlzma.h are located in another folder, 'sqlzma-3.4-457'. I assume, the problem may be related with links to those external files, but I'm not sure. I'm new to programming in general.

Makefile in 'squashfs-tools' folder:

ifndef Sqlzma
$(error Sqlzma is not defined)
endif

INSTALL_DIR = /usr/local/bin

INCLUDEDIR = .

CFLAGS := -I$(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -O2
ifdef UseDebugFlags
DebugFlags = -g -Wall -Wno-unused-variable -O0 -UNDEBUG
endif
CFLAGS += -I${Sqlzma} -D_REENTRANT -DNDEBUG ${DebugFlags}
LDFLAGS += -L${LzmaAlone} -L${LzmaC}

all: mksquashfs unsquashfs

mksquashfs: mksquashfs.o read_fs.o sort.o
    #$(CC) $(LDFLAGS) mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -lunlzma_r -llzma_r -lstdc++ -o $@
    g++ $(LDFLAGS) mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -lunlzma_r -llzma_r -lstdc++ -o $@

mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h \
    ${Sqlzma}/sqlzma.h ${Sqlzma}/sqmagic.h \
    ${LzmaAlone}/liblzma_r.a ${LzmaC}/libunlzma_r.a

read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h \
    ${Sqlzma}/sqlzma.h ${Sqlzma}/sqmagic.h

sort.o: sort.c squashfs_fs.h global.h sort.h

unsquashfs: unsquashfs.o
    $(CC) $(LDFLAGS) unsquashfs.o -lpthread -lm -lunlzma -lz -o $@

unsquashfs.o: unsquashfs.c squashfs_fs.h read_fs.h global.h \
    ${Sqlzma}/sqlzma.h ${Sqlzma}/sqmagic.h ${LzmaC}/libunlzma.a

clean:
    -rm -f *.o mksquashfs unsquashfs

install: mksquashfs unsquashfs
    mkdir -p $(INSTALL_DIR)
    cp mksquashfs unsquashfs $(INSTALL_DIR)

Makefile in "sqlzma-3.4-457" folder:


# Copyright (C) 2006-2008 Junjiro Okajima
# Copyright (C) 2006-2008 Tomas Matejicek, slax.org
#
# LICENSE follows the described ones in lzma and squashfs.

# $Id: Makefile,v 1.1.1.1 2010/11/11 13:20:13 nash Exp $

# paths
Sqlzma = ${CURDIR}

LzmaVer = lzma457
Lzma = ${Sqlzma}/${LzmaVer}
SqVer = squashfs3.4
Squashfs = ${Sqlzma}/${SqVer}
KVer = linux-2.6.27.4
SqFs = ${Squashfs}/kernel-patches/${KVer}/fs/squashfs
#KDir = /lib/modules/$(shell uname -r)/build
#KDir = ${SqFs}/../..

ifeq (${LzmaVer}, lzma443)
LzmaC = ${Lzma}/C/7zip/Compress/LZMA_C
LzmaAlone = ${Lzma}/C/7zip/Compress/LZMA_Alone
else
LzmaC = ${Lzma}/C/Compress/Lzma
LzmaAlone = ${Lzma}/CPP/7zip/Compress/LZMA_Alone
endif
SqTools = ${Squashfs}/squashfs-tools

# enable it if you want to add -g option when compiling
#UseDebugFlags = 1
#MyDebugFlags = -DSQUASHFS_TRACE
# disable it if you don't want to compile squashfs kernel module here
#BuildSquashfs = 1

export

all:
    ${MAKE} -C ${LzmaC} -f sqlzma.mk $@
    ${MAKE} -C ${LzmaAlone} -f sqlzma.mk $@
    #${MAKE} -C ${SqTools} $@

clean:
    ${MAKE} -C ${LzmaC} -f sqlzma.mk $@
    ${MAKE} -C ${LzmaAlone} -f sqlzma.mk $@
    #${MAKE} -C ${SqTools} $@
    ${RM} *~

########################################

-include priv.mk

ifdef BuildSquashfs
CONFIG_SQUASHFS = m
CONFIG_SQUASHFS_EMBEDDED =
CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE = 3
EXTRA_CFLAGS = -I${Sqlzma} -I${SqFs}/../../include -Wall -Werror
EXTRA_CFLAGS += -DCONFIG_SQUASHFS_MODULE -UCONFIG_SQUASHFS
EXTRA_CFLAGS += -UCONFIG_SQUASHFS_EMBEDDED -DCONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
# if you enabled CONFIG_PREEMPT, but want CPU to try concentrating
# the uncompression, then define UnsquashNoPreempt.
# if you don't define UnsquashNoPreempt, the behaviour follows
# the CONFIG_PREEMPT.
EXTRA_CFLAGS += -DUnsquashNoPreempt
export

# the environment variables are not inherited since 2.6.23
MAKE += SQLZMA_EXTRA_CFLAGS="$(shell echo ${EXTRA_CFLAGS} | sed -e 's/\"/\\\\\\"/g')"

all: all_sq

FORCE:
all_sq:
    ${MAKE} -C ${KDir} M=${SqFs} modules

clean: clean_sq
clean_sq:
    ${MAKE} -C ${KDir} M=${SqFs} clean
endif

########################################

load:
    for i in ${LzmaC}/kmod/unlzma.ko ${LzmaC}/kmod/sqlzma.ko \
        ${SqFs}/squashfs.ko; \
    do sudo insmod $$i; done

unload:
    -sudo rmmod squashfs sqlzma unlzma

Links to squashfs and sqlzma folders.

minto
  • 151
  • 2
  • 12
  • Set `Sqlzma` variable to the directory which contains `sqlzma.h` file. You may either set environment variable (via `Sqlzma=<...> make`) or Make variable (`make Sqlzma=<...>`). – Tsyvarev May 06 '19 at 17:03
  • The `sqlzma.h` file is two level up: `.../pkgs/sqlzma-3.4-457/sqlzma.h` vs `.../pkgs/squashfs3.4/squashfs-tools/Makefile` How to define `Sqlzma` variable to 'sqlzma-3.4-457' dir? – minto May 06 '19 at 20:34
  • Paste the directory instead of `<...>` in my previous comment. – Tsyvarev May 06 '19 at 20:37
  • this `Sqlzma = ${HOME}/path/to/the/sqlzma/dir/ make`? – minto May 06 '19 at 21:22
  • Just try. (But it should be no spaces around the `=` sign). – Tsyvarev May 06 '19 at 21:55
  • I tried 'make', it return: `make: *** No rule to make target '/liblzma_r.a', needed by 'mksquashfs.o'. Stop.` – minto May 07 '19 at 19:13
  • Oh, it seems want also variables `LzmaAlone` and `LzmaC` to be set too. The first one should point to the directory with the file `liblzma_r.a`, the second one - with the file `libunlzma_r.a`. – Tsyvarev May 07 '19 at 19:47
  • I forgot to add 'make' in variable after path in the code, but also with it added, command return `make: *** No rule to make target 'make/sqlzma.h', needed by 'mksquashfs.o'. Stop.` Regarding `liblzma_r.a` and `1libunlzma_r.a` files: I searched, but didn't find any dirs with these files. Perhaps, they should be created first? The 'sqlzma-3.4-457' directory also have Makefile inside. – minto May 07 '19 at 21:03
  • I just said what can be obtained from the Makefile you show. I don't know the details about the projects you use. – Tsyvarev May 07 '19 at 21:12

0 Answers0