2010-03-10 00:11:58 +01:00
|
|
|
#
|
|
|
|
# Macro that builds the needed Makefile target to create a root
|
|
|
|
# filesystem image.
|
|
|
|
#
|
|
|
|
# The following variable must be defined before calling this macro
|
|
|
|
#
|
|
|
|
# ROOTFS_$(FSTYPE)_CMD, the command that generates the root
|
|
|
|
# filesystem image. A single command is allowed. The filename of the
|
|
|
|
# filesystem image that it must generate is $$@.
|
|
|
|
#
|
|
|
|
# The following variables can optionaly be defined
|
|
|
|
#
|
|
|
|
# ROOTFS_$(FSTYPE)_DEPENDENCIES, the list of dependencies needed to
|
|
|
|
# build the root filesystem (usually host tools)
|
|
|
|
#
|
|
|
|
# ROOTFS_$(FSTYPE)_PRE_GEN_HOOKS, a list of hooks to call before
|
|
|
|
# generating the filesystem image
|
|
|
|
#
|
2015-07-31 10:23:20 +02:00
|
|
|
# ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after
|
|
|
|
# generating the filesystem image
|
|
|
|
#
|
linux: add support for initramfs
In Buildroot, the kernel is built and installed *before* the root
filesystems are built. This allows the root filesystem to correctly
contain the kernel modules that have been installed.
However, in the initramfs case, the root filesystem is part of the
kernel. Therefore, the kernel should be built *after* the root
filesystem (which, in the initramfs case simply builds a text file
listing all files/directories/devices/symlinks that should be part of
the initramfs). However, this isn't possible as the initramfs text
file would lack all kernel modules.
So, the solution choosen here is to keep the normal order: kernel is
built before the root filesystem is generated, and to add a little
quirk to retrigger a kernel compilation after the root filesystem
generation.
To do so, we add a ROOTFS_$(FSTYPE)_POST_TARGETS variable to the
fs/common.mk infrastructure. This allows individual filesystems to set
a target name that we should depend on *after* generating the root
filesystem itself (contrary to normal ROOTFS_$(FSTYPE)_DEPENDENCIES,
on which we depend *before* generating the root filesystem).
The initramfs code in fs/initramfs/initramfs.mk uses this to add a
dependency on 'linux26-rebuild-with-initramfs'.
In linux/linux.mk, we do various things :
* If BR2_TARGET_ROOTFS_INITRAMFS is enabled (i.e if initramfs is
enabled as a root filesystem type), then we create an empty
rootfs.initramfs file (remember that at this point, the root
filesystem hasn't been generated) and we adjust the kernel
configuration to include an initramfs. Of course, in the initial
kernel build, this initramfs will be empty.
* In the linux26-rebuild-with-initramfs target, we retrigger a
compilation of the kernel image, after removing the initramfs in
the kernel sources to make sure it gets properly rebuilt (we've
experienced cases were modifying the rootfs.initramfs file wouldn't
retrigger the generation of the initramfs at the kernel level).
This is fairly quirky, but initramfs really is a special case, so in
one way or another, we need a little quirk to solve its specialness.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2010-06-13 19:19:38 +02:00
|
|
|
# ROOTFS_$(FSTYPE)_POST_TARGETS, the list of targets that should be
|
|
|
|
# run after running the main filesystem target. This is useful for
|
|
|
|
# initramfs, to rebuild the kernel once the initramfs is generated.
|
|
|
|
#
|
2010-03-10 00:11:58 +01:00
|
|
|
# In terms of configuration option, this macro assumes that the
|
|
|
|
# BR2_TARGET_ROOTFS_$(FSTYPE) config option allows to enable/disable
|
|
|
|
# the generation of a filesystem image of a particular type. If
|
2016-05-08 05:27:48 +02:00
|
|
|
# the configuration options BR2_TARGET_ROOTFS_$(FSTYPE)_GZIP,
|
2010-03-10 00:11:58 +01:00
|
|
|
# BR2_TARGET_ROOTFS_$(FSTYPE)_BZIP2 or
|
|
|
|
# BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
|
|
|
|
# macro will automatically generate a compressed filesystem image.
|
|
|
|
|
|
|
|
FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
|
2011-03-02 14:52:54 +01:00
|
|
|
FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
|
2013-03-13 03:28:16 +01:00
|
|
|
ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
|
2014-10-25 20:29:31 +02:00
|
|
|
$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
|
2013-04-12 09:14:18 +02:00
|
|
|
USERS_TABLE = $(BUILD_DIR)/_users_table.txt
|
2014-04-20 19:33:09 +02:00
|
|
|
ROOTFS_USERS_TABLES = $(call qstrip,$(BR2_ROOTFS_USERS_TABLES))
|
2010-03-10 00:11:58 +01:00
|
|
|
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 21:12:24 +02:00
|
|
|
# Since this function will be called from within an $(eval ...)
|
|
|
|
# all variable references except the arguments must be $$-quoted.
|
2010-03-10 00:11:58 +01:00
|
|
|
define ROOTFS_TARGET_INTERNAL
|
|
|
|
|
2010-11-19 15:05:20 +01:00
|
|
|
# extra deps
|
2014-01-22 21:59:41 +01:00
|
|
|
ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs \
|
2015-07-21 17:36:07 +02:00
|
|
|
$$(if $$(PACKAGES_USERS)$$(ROOTFS_USERS_TABLES),host-mkpasswd)
|
2013-11-07 00:12:32 +01:00
|
|
|
|
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
|
|
|
|
ROOTFS_$(2)_COMPRESS_EXT = .gz
|
|
|
|
ROOTFS_$(2)_COMPRESS_CMD = gzip -9 -c
|
|
|
|
endif
|
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
|
|
|
|
ROOTFS_$(2)_COMPRESS_EXT = .bz2
|
|
|
|
ROOTFS_$(2)_COMPRESS_CMD = bzip2 -9 -c
|
|
|
|
endif
|
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
|
|
|
|
ROOTFS_$(2)_DEPENDENCIES += host-lzma
|
|
|
|
ROOTFS_$(2)_COMPRESS_EXT = .lzma
|
|
|
|
ROOTFS_$(2)_COMPRESS_CMD = $$(LZMA) -9 -c
|
|
|
|
endif
|
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZO),y)
|
|
|
|
ROOTFS_$(2)_DEPENDENCIES += host-lzop
|
|
|
|
ROOTFS_$(2)_COMPRESS_EXT = .lzo
|
|
|
|
ROOTFS_$(2)_COMPRESS_CMD = $$(LZOP) -9 -c
|
|
|
|
endif
|
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_XZ),y)
|
2015-03-09 10:34:13 +01:00
|
|
|
ROOTFS_$(2)_DEPENDENCIES += host-xz
|
2013-11-07 00:12:32 +01:00
|
|
|
ROOTFS_$(2)_COMPRESS_EXT = .xz
|
2014-06-04 08:33:17 +02:00
|
|
|
ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
|
2013-11-07 00:12:32 +01:00
|
|
|
endif
|
2010-11-19 15:05:20 +01:00
|
|
|
|
2014-02-14 10:55:06 +01:00
|
|
|
$$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
|
2013-01-20 15:03:13 +01:00
|
|
|
@$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
|
|
|
|
$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),$$(call $$(hook))$$(sep))
|
|
|
|
rm -f $$(FAKEROOT_SCRIPT)
|
|
|
|
rm -f $$(TARGET_DIR_WARNING_FILE)
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 21:12:24 +02:00
|
|
|
rm -f $$(USERS_TABLE)
|
2016-06-07 22:09:41 +02:00
|
|
|
echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
|
2015-02-24 16:47:34 +01:00
|
|
|
echo "set -e" >> $$(FAKEROOT_SCRIPT)
|
2014-06-08 22:02:23 +02:00
|
|
|
echo "chown -h -R 0:0 $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
|
2016-01-21 22:23:36 +01:00
|
|
|
ifneq ($$(ROOTFS_USERS_TABLES),)
|
|
|
|
cat $$(ROOTFS_USERS_TABLES) >> $$(USERS_TABLE)
|
|
|
|
endif
|
2016-06-06 22:43:39 +02:00
|
|
|
$$(call PRINTF,$$(PACKAGES_USERS)) >> $$(USERS_TABLE)
|
2016-01-21 22:23:36 +01:00
|
|
|
PATH=$$(BR_PATH) $$(TOPDIR)/support/scripts/mkusers $$(USERS_TABLE) $$(TARGET_DIR) >> $$(FAKEROOT_SCRIPT)
|
2013-01-20 15:03:13 +01:00
|
|
|
ifneq ($$(ROOTFS_DEVICE_TABLES),)
|
|
|
|
cat $$(ROOTFS_DEVICE_TABLES) > $$(FULL_DEVICE_TABLE)
|
|
|
|
ifeq ($$(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
|
2016-06-06 22:43:39 +02:00
|
|
|
$$(call PRINTF,$$(PACKAGES_DEVICES_TABLE)) >> $$(FULL_DEVICE_TABLE)
|
2012-01-11 18:53:38 +01:00
|
|
|
endif
|
2016-06-06 22:43:39 +02:00
|
|
|
$$(call PRINTF,$$(PACKAGES_PERMISSIONS_TABLE)) >> $$(FULL_DEVICE_TABLE)
|
2013-01-20 15:03:13 +01:00
|
|
|
echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
|
2010-03-10 00:11:58 +01:00
|
|
|
endif
|
2016-07-03 17:08:19 +02:00
|
|
|
$$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_FAKEROOT_SCRIPT)),\
|
|
|
|
echo "echo '$$(TERM_BOLD)>>> Executing fakeroot script $$(s)$$(TERM_RESET)'" >> $$(FAKEROOT_SCRIPT); \
|
|
|
|
echo $$(s) $$(TARGET_DIR) $$(BR2_ROOTFS_POST_SCRIPT_ARGS) >> $$(FAKEROOT_SCRIPT)$$(sep))
|
2016-06-06 22:43:39 +02:00
|
|
|
$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
|
2013-01-20 15:03:13 +01:00
|
|
|
chmod a+x $$(FAKEROOT_SCRIPT)
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 21:12:24 +02:00
|
|
|
PATH=$$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT)
|
|
|
|
$$(INSTALL) -m 0644 support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE)
|
2013-01-20 15:03:13 +01:00
|
|
|
-@rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE)
|
2013-11-07 00:12:32 +01:00
|
|
|
ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),)
|
infra: consistently use double dollar signs inside inner-xxx-targets
The inner-xxx-targets in the buildroot package infrastructures are
evaluated using $(eval) which causes variable references to be a bit
different than in regular make code. As we want most references to be
expanded only at the time of the $(eval) we should not use standard
references $(VAR) but rather use double dollar signs $$(VAR). This includes
function references like $(call), $(subst), etc. The only exception is the
reference to pkgdir/pkgname and numbered variables, which are parameters to
the inner block: $(1), $(2), etc.
This patch introduces consistent usage of double-dollar signs throughout the
different inner-xxx-targets blocks.
In some cases, this would potentially cause circular references, in
particular when the value of HOST_FOO_VAR would be obtained from the
corresponding FOO_VAR if HOST_FOO_VAR is not defined. In these cases, a test
is added to check for a host package (the only case where such constructions
are relevant; these are not circular).
Benefits of these changes are:
- behavior of variables is now again as expected. For example, setting
$(2)_VERSION = virtual in pkg-virtual.mk will effectively work, while
originally it would cause very odd results.
- The output of 'make printvars' is now much more useful. This target shows
the value of all variables, and the expression that led to that value.
However, if the expression was coming from an inner-xxx-targets block, and
was using single dollar signs, it would show in printvars as
VAR = value (value)
while if double dollar signs are used, it would effectively look like
VAR = value (actual expression)
as is intended.
This improvement is for example effective for FOO_DL_VERSION, FOO_RAWNAME,
FOO_SITE_METHOD and FOO_MAKE.
The correctness of this patch has been verified using 'make printvars',
'make manual' and 'make legal-info' before and after applying this patch,
and comparing the output.
Insight-provided-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2014-06-11 21:12:24 +02:00
|
|
|
PATH=$$(BR_PATH) $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT)
|
2013-01-22 02:03:43 +01:00
|
|
|
endif
|
2015-07-31 10:23:20 +02:00
|
|
|
$$(foreach hook,$$(ROOTFS_$(2)_POST_GEN_HOOKS),$$(call $$(hook))$$(sep))
|
2010-03-10 00:11:58 +01:00
|
|
|
|
2010-11-19 15:01:13 +01:00
|
|
|
rootfs-$(1)-show-depends:
|
2013-01-20 15:03:13 +01:00
|
|
|
@echo $$(ROOTFS_$(2)_DEPENDENCIES)
|
2010-05-13 19:20:21 +02:00
|
|
|
|
2013-01-20 15:03:13 +01:00
|
|
|
rootfs-$(1): $$(BINARIES_DIR)/rootfs.$(1) $$(ROOTFS_$(2)_POST_TARGETS)
|
2010-03-10 00:11:58 +01:00
|
|
|
|
2015-04-12 18:37:46 +02:00
|
|
|
.PHONY: rootfs-$(1) rootfs-$(1)-show-depends
|
|
|
|
|
2010-03-10 00:11:58 +01:00
|
|
|
ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
|
2014-02-14 10:55:06 +01:00
|
|
|
TARGETS_ROOTFS += rootfs-$(1)
|
2015-04-26 11:50:59 +02:00
|
|
|
PACKAGES += $$(filter-out rootfs-%,$$(ROOTFS_$(2)_DEPENDENCIES))
|
2010-03-10 00:11:58 +01:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
define ROOTFS_TARGET
|
2014-12-09 16:14:31 +01:00
|
|
|
$(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)))
|
2010-03-10 22:11:21 +01:00
|
|
|
endef
|
2010-03-10 22:30:06 +01:00
|
|
|
|
2013-09-03 10:45:41 +02:00
|
|
|
include $(sort $(wildcard fs/*/*.mk))
|