]> Git Repo - buildroot-mgba.git/blame - fs/common.mk
package: indentation cleanup
[buildroot-mgba.git] / fs / common.mk
CommitLineData
21f3bcc1
TP
1#
2# Macro that builds the needed Makefile target to create a root
3# filesystem image.
4#
5# The following variable must be defined before calling this macro
6#
7# ROOTFS_$(FSTYPE)_CMD, the command that generates the root
8# filesystem image. A single command is allowed. The filename of the
9# filesystem image that it must generate is $$@.
10#
11# The following variables can optionaly be defined
12#
13# ROOTFS_$(FSTYPE)_DEPENDENCIES, the list of dependencies needed to
14# build the root filesystem (usually host tools)
15#
16# ROOTFS_$(FSTYPE)_PRE_GEN_HOOKS, a list of hooks to call before
17# generating the filesystem image
18#
f507921d
TP
19# ROOTFS_$(FSTYPE)_POST_TARGETS, the list of targets that should be
20# run after running the main filesystem target. This is useful for
21# initramfs, to rebuild the kernel once the initramfs is generated.
22#
21f3bcc1
TP
23# In terms of configuration option, this macro assumes that the
24# BR2_TARGET_ROOTFS_$(FSTYPE) config option allows to enable/disable
25# the generation of a filesystem image of a particular type. If
26# configura options BR2_TARGET_ROOTFS_$(FSTYPE)_GZIP,
27# BR2_TARGET_ROOTFS_$(FSTYPE)_BZIP2 or
28# BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
29# macro will automatically generate a compressed filesystem image.
30
31FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
4e005c47 32FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
402d1476 33ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
1769933d 34 $(BR2_ROOTFS_STATIC_DEVICE_TABLE))
1f3af04d 35USERS_TABLE = $(BUILD_DIR)/_users_table.txt
b019490a 36ROOTFS_USERS_TABLES = $(call qstrip,$(BR2_ROOTFS_USERS_TABLES))
21f3bcc1 37
54456cc6
TDS
38# Since this function will be called from within an $(eval ...)
39# all variable references except the arguments must be $$-quoted.
21f3bcc1
TP
40define ROOTFS_TARGET_INTERNAL
41
094b2938 42# extra deps
22cdb652 43ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs \
54456cc6 44 $$(if $$(PACKAGES_USERS),host-mkpasswd)
bd8ef7a0
AV
45
46ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
47ROOTFS_$(2)_COMPRESS_EXT = .gz
48ROOTFS_$(2)_COMPRESS_CMD = gzip -9 -c
49endif
50ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
51ROOTFS_$(2)_COMPRESS_EXT = .bz2
52ROOTFS_$(2)_COMPRESS_CMD = bzip2 -9 -c
53endif
54ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
55ROOTFS_$(2)_DEPENDENCIES += host-lzma
56ROOTFS_$(2)_COMPRESS_EXT = .lzma
57ROOTFS_$(2)_COMPRESS_CMD = $$(LZMA) -9 -c
58endif
59ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZO),y)
60ROOTFS_$(2)_DEPENDENCIES += host-lzop
61ROOTFS_$(2)_COMPRESS_EXT = .lzo
62ROOTFS_$(2)_COMPRESS_CMD = $$(LZOP) -9 -c
63endif
64ifeq ($$(BR2_TARGET_ROOTFS_$(2)_XZ),y)
bd8ef7a0 65ROOTFS_$(2)_COMPRESS_EXT = .xz
28b514a5 66ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
bd8ef7a0 67endif
094b2938 68
a2487758 69$$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
847895d2
AVEM
70 @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
71 $$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),$$(call $$(hook))$$(sep))
72 rm -f $$(FAKEROOT_SCRIPT)
73 rm -f $$(TARGET_DIR_WARNING_FILE)
54456cc6 74 rm -f $$(USERS_TABLE)
3fbd9887 75 echo "chown -h -R 0:0 $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
847895d2
AVEM
76ifneq ($$(ROOTFS_DEVICE_TABLES),)
77 cat $$(ROOTFS_DEVICE_TABLES) > $$(FULL_DEVICE_TABLE)
78ifeq ($$(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
79 printf '$$(subst $$(sep),\n,$$(PACKAGES_DEVICES_TABLE))' >> $$(FULL_DEVICE_TABLE)
2444085b 80endif
847895d2
AVEM
81 printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' >> $$(FULL_DEVICE_TABLE)
82 echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
21f3bcc1 83endif
b019490a 84ifneq ($$(ROOTFS_USERS_TABLES),)
54456cc6 85 cat $$(ROOTFS_USERS_TABLES) >> $$(USERS_TABLE)
b019490a 86endif
54456cc6
TDS
87 printf '$$(subst $$(sep),\n,$$(PACKAGES_USERS))' >> $$(USERS_TABLE)
88 PATH=$$(BR_PATH) $$(TOPDIR)/support/scripts/mkusers $$(USERS_TABLE) $$(TARGET_DIR) >> $$(FAKEROOT_SCRIPT)
847895d2
AVEM
89 echo "$$(ROOTFS_$(2)_CMD)" >> $$(FAKEROOT_SCRIPT)
90 chmod a+x $$(FAKEROOT_SCRIPT)
54456cc6
TDS
91 PATH=$$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT)
92 $$(INSTALL) -m 0644 support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE)
847895d2 93 -@rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE)
bd8ef7a0 94ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),)
54456cc6 95 PATH=$$(BR_PATH) $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT)
5419651b 96endif
21f3bcc1 97
0a0cb991 98rootfs-$(1)-show-depends:
847895d2 99 @echo $$(ROOTFS_$(2)_DEPENDENCIES)
949db6ac 100
847895d2 101rootfs-$(1): $$(BINARIES_DIR)/rootfs.$(1) $$(ROOTFS_$(2)_POST_TARGETS)
21f3bcc1
TP
102
103ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
a2487758 104TARGETS_ROOTFS += rootfs-$(1)
21f3bcc1
TP
105endif
106endef
107
108define ROOTFS_TARGET
109$(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)))
d2b07919 110endef
05852415 111
741cbccb 112include $(sort $(wildcard fs/*/*.mk))
This page took 0.231191 seconds and 4 git commands to generate.