我尝试编译取消压缩来自 GPL 源的工具,源位于“squashfs-tools”目录中。执行时make
出现错误:Makefile:2: *** Sqlzma is not defined. Stop.
据我所知,sqlzma 文件(sqlzma.h?)位于另一个目录“sqlzma-3.4-457”中。
生成文件:
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)
“安装”自述文件中还有一小段说明:
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.
请指教如何编译 unsquashfs 和 mksquashfs 二进制文件(不影响我的 Ubuntu 16.04 安装)。
编辑:链接到来源。