summaryrefslogtreecommitdiffstats
path: root/target/ubifs/ubifsroot.mk
blob: b48e10fd148a125d4761da293dd9bd808ae4e7ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#############################################################
#
# Build the ubifs root filesystem image
#
#############################################################

UBIFS_OPTS := -e $(BR2_TARGET_ROOTFS_UBIFS_LEBSIZE) -c $(BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT) -m $(BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE)

UBIFS_BASE := $(call qstrip,$(BR2_TARGET_ROOTFS_UBIFS_OUTPUT))

ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_ZLIB),y)
UBIFS_OPTS += -x zlib
endif
ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_LZI),y)
UBIFS_OPTS += -x lzo
endif
ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_NONE),y)
UBIFS_OPTS += -x none
endif

UBIFS_ROOTFS_COMPRESSOR:=
UBIFS_ROOTFS_COMPRESSOR_EXT:=
UBIFS_ROOTFS_COMPRESSOR_PREREQ:=
ifeq ($(BR2_TARGET_ROOTFS_UBIFS_GZIP),y)
UBIFS_ROOTFS_COMPRESSOR:=gzip -9 -c
UBIFS_ROOTFS_COMPRESSOR_EXT:=gz
endif
ifeq ($(BR2_TARGET_ROOTFS_UBIFS_BZIP2),y)
UBIFS_ROOTFS_COMPRESSOR:=bzip2 -9 -c
UBIFS_ROOTFS_COMPRESSOR_EXT:=bz2
endif
ifeq ($(BR2_TARGET_ROOTFS_UBIFS_LZMA),y)
UBIFS_ROOTFS_COMPRESSOR:=$(LZMA) -9 -c
UBIFS_ROOTFS_COMPRESSOR_EXT:=lzma
UBIFS_ROOTFS_COMPRESSOR_PREREQ:= host-lzma
endif

ifneq ($(UBIFS_ROOTFS_COMPRESSOR),)
UBIFS_TARGET := $(UBIFS_BASE).$(UBIFS_ROOTFS_COMPRESSOR_EXT)
else
UBIFS_TARGET := $(UBIFS_BASE)
endif

$(UBIFS_BASE): host-fakeroot host-mtd makedevs
	# Use fakeroot to pretend all target binaries are owned by root
	rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
	touch $(BUILD_DIR)/.fakeroot.00000
	cat $(BUILD_DIR)/.fakeroot* > $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
	echo "chown -R 0:0 $(TARGET_DIR)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
ifneq ($(TARGET_DEVICE_TABLE),)
	# Use fakeroot to pretend to create all needed device nodes
	echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" \
		>> $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
endif
	# Use fakeroot so mkfs.ubifs believes the previous fakery
	echo "$(HOST_DIR)/usr/sbin/mkfs.ubifs -d $(TARGET_DIR) " \
		"$(UBIFS_OPTS) -o $(UBIFS_BASE)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
	chmod a+x $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
	$(HOST_DIR)/usr/bin/fakeroot -- $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))
	-@rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(UBIFS_TARGET))

ifneq ($(UBIFS_ROOTFS_COMPRESSOR),)
$(UBIFS_BASE).$(UBIFS_ROOTFS_COMPRESSOR_EXT): $(UBIFS_ROOTFS_COMPRESSOR_PREREQ) $(UBIFS_BASE)
	$(UBIFS_ROOTFS_COMPRESSOR) $(UBIFS_BASE) > $(UBIFS_TARGET)
endif

UBIFS_COPYTO := $(call qstrip,$(BR2_TARGET_ROOTFS_UBIFS_COPYTO))

ubifsroot: $(UBIFS_TARGET)
	@ls -l $(UBIFS_TARGET)
ifneq ($(UBIFS_COPYTO),)
	@cp -f $(UBIFS_TARGET) $(UBIFS_COPYTO)
endif

#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(BR2_TARGET_ROOTFS_UBIFS),y)
TARGETS+=ubifsroot
endif