2007-11-14 23:11:07 +00:00
|
|
|
# Makefile for OpenWrt
|
2007-01-10 21:52:28 +00:00
|
|
|
#
|
2015-06-01 06:15:39 +00:00
|
|
|
# Copyright (C) 2007-2015 OpenWrt.org
|
2007-01-10 21:52:28 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
TOPDIR:=${CURDIR}
|
|
|
|
LC_ALL:=C
|
|
|
|
LANG:=C
|
|
|
|
export TOPDIR LC_ALL LANG
|
2012-04-26 17:53:56 +00:00
|
|
|
export OPENWRT_VERBOSE=s
|
2007-01-10 21:52:28 +00:00
|
|
|
all: help
|
|
|
|
|
2017-02-20 13:24:54 +00:00
|
|
|
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
ifneq ($(OPENWRT_BUILD),1)
|
|
|
|
override OPENWRT_BUILD=1
|
|
|
|
export OPENWRT_BUILD
|
2007-01-10 21:52:28 +00:00
|
|
|
endif
|
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
include rules.mk
|
|
|
|
include $(INCLUDE_DIR)/debug.mk
|
|
|
|
include $(INCLUDE_DIR)/depends.mk
|
2018-03-06 08:38:29 +00:00
|
|
|
include $(INCLUDE_DIR)/rootfs.mk
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2010-03-08 17:00:46 +00:00
|
|
|
include $(INCLUDE_DIR)/version.mk
|
|
|
|
export REVISION
|
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
define Helptext
|
|
|
|
Available Commands:
|
|
|
|
help: This help text
|
|
|
|
info: Show a list of available target profiles
|
|
|
|
clean: Remove images and temporary build files
|
|
|
|
image: Build an image (see below for more information).
|
|
|
|
|
|
|
|
Building images:
|
|
|
|
By default 'make image' will create an image with the default
|
|
|
|
target profile and package set. You can use the following parameters
|
|
|
|
to change that:
|
2012-01-24 09:47:20 +00:00
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
make image PROFILE="<profilename>" # override the default target profile
|
|
|
|
make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
|
|
|
|
make image FILES="<path>" # include extra files from <path>
|
2010-10-26 14:15:52 +00:00
|
|
|
make image BIN_DIR="<path>" # alternative output directory for the images
|
2016-01-03 14:44:56 +00:00
|
|
|
make image EXTRA_IMAGE_NAME="<string>" # Add this to the output image filename (sanitized)
|
2018-07-20 08:32:12 +00:00
|
|
|
|
|
|
|
Print manifest:
|
|
|
|
List "all" packages which get installed into the image.
|
|
|
|
You can use the following parameters:
|
|
|
|
|
|
|
|
make manifest PROFILE="<profilename>" # override the default target profile
|
|
|
|
make manifest PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
|
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
endef
|
|
|
|
$(eval $(call shexport,Helptext))
|
|
|
|
|
|
|
|
help: FORCE
|
|
|
|
echo "$$$(call shvar,Helptext)"
|
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
|
|
|
|
# override variables from rules.mk
|
|
|
|
PACKAGE_DIR:=$(TOPDIR)/packages
|
2015-09-14 16:57:03 +00:00
|
|
|
LISTS_DIR:=$(subst $(space),/,$(patsubst %,..,$(subst /,$(space),$(TARGET_DIR))))$(DL_DIR)
|
2018-03-06 08:38:29 +00:00
|
|
|
OPKG:=$(call opkg,$(TARGET_DIR)) \
|
2010-09-12 22:04:09 +00:00
|
|
|
-f $(TOPDIR)/repositories.conf \
|
2015-06-01 06:15:39 +00:00
|
|
|
--cache $(DL_DIR) \
|
2018-03-06 08:38:29 +00:00
|
|
|
--lists-dir $(LISTS_DIR)
|
2007-11-14 23:11:07 +00:00
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/target.mk
|
2016-05-13 14:32:23 +00:00
|
|
|
-include .profiles.mk
|
|
|
|
|
|
|
|
USER_PROFILE ?= $(firstword $(PROFILE_NAMES))
|
|
|
|
PROFILE_LIST = $(foreach p,$(PROFILE_NAMES), \
|
2019-03-06 13:45:15 +00:00
|
|
|
echo '$(patsubst DEVICE_%,%,$(p)):'; $(if $($(p)_NAME),echo ' $(subst ','"'"',$($(p)_NAME))'; ) echo ' Packages: $($(p)_PACKAGES)'; echo ' hasImageMetadata: $($(p)_HAS_IMAGE_METADATA)';\
|
2016-05-13 14:32:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
.profiles.mk: .targetinfo
|
2017-06-16 22:54:46 +00:00
|
|
|
@$(SCRIPT_DIR)/target-metadata.pl profile_mk $< '$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))' > $@
|
2007-11-14 23:11:07 +00:00
|
|
|
|
2015-09-10 11:06:42 +00:00
|
|
|
staging_dir/host/.prereq-build: include/prereq-build.mk
|
|
|
|
mkdir -p tmp
|
|
|
|
@$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
|
|
|
|
echo "Prerequisite check failed. Use FORCE=1 to override."; \
|
|
|
|
false; \
|
|
|
|
}
|
|
|
|
ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
|
|
|
|
@$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
|
|
|
|
echo "Preparation failed."; \
|
|
|
|
false; \
|
|
|
|
}
|
|
|
|
endif
|
|
|
|
touch $@
|
|
|
|
|
2010-04-27 22:16:40 +00:00
|
|
|
_call_info: FORCE
|
2007-11-14 23:11:07 +00:00
|
|
|
echo 'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
|
|
|
|
echo 'Default Packages: $(DEFAULT_PACKAGES)'
|
2007-01-10 21:52:28 +00:00
|
|
|
echo 'Available Profiles:'
|
|
|
|
echo; $(PROFILE_LIST)
|
|
|
|
|
2016-04-26 08:50:27 +00:00
|
|
|
BUILD_PACKAGES:=$(USER_PACKAGES) $(sort $(DEFAULT_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
|
2007-01-20 12:35:00 +00:00
|
|
|
# "-pkgname" in the package list means remove "pkgname" from the package list
|
2007-01-21 12:56:55 +00:00
|
|
|
BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
|
2010-09-08 00:36:35 +00:00
|
|
|
PACKAGES:=
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2015-09-10 11:06:42 +00:00
|
|
|
_call_image: staging_dir/host/.prereq-build
|
2010-04-27 22:16:40 +00:00
|
|
|
echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
|
2007-01-10 21:52:28 +00:00
|
|
|
echo 'Packages: $(BUILD_PACKAGES)'
|
|
|
|
echo
|
2018-03-06 08:38:29 +00:00
|
|
|
rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
|
2015-06-01 06:15:39 +00:00
|
|
|
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
|
2017-06-13 19:59:14 +00:00
|
|
|
$(MAKE) package_reload
|
2007-01-10 21:52:28 +00:00
|
|
|
$(MAKE) package_install
|
2018-03-06 08:38:29 +00:00
|
|
|
$(MAKE) -s prepare_rootfs
|
2016-08-01 16:26:05 +00:00
|
|
|
$(MAKE) -s build_image
|
|
|
|
$(MAKE) -s checksum
|
2012-01-24 09:47:20 +00:00
|
|
|
|
2018-07-20 08:32:12 +00:00
|
|
|
_call_manifest: FORCE
|
|
|
|
rm -rf $(TARGET_DIR)
|
|
|
|
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
|
2018-08-05 03:17:29 +00:00
|
|
|
$(MAKE) package_reload >/dev/null
|
|
|
|
$(MAKE) package_install >/dev/null
|
2018-07-20 08:32:12 +00:00
|
|
|
$(OPKG) list-installed
|
|
|
|
|
2010-09-12 22:04:09 +00:00
|
|
|
package_index: FORCE
|
2017-06-16 22:54:46 +00:00
|
|
|
@echo >&2
|
|
|
|
@echo Building package index... >&2
|
2015-06-01 06:15:39 +00:00
|
|
|
@mkdir -p $(TMP_DIR) $(TARGET_DIR)/tmp
|
2011-09-09 17:25:20 +00:00
|
|
|
(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
|
2015-07-14 09:57:45 +00:00
|
|
|
gzip -9nc Packages > Packages.gz \
|
2008-07-29 03:36:11 +00:00
|
|
|
) >/dev/null 2>/dev/null
|
2017-06-16 22:54:46 +00:00
|
|
|
$(OPKG) update >&2 || true
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2017-06-13 19:59:14 +00:00
|
|
|
package_reload:
|
|
|
|
if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
|
2017-06-16 22:54:46 +00:00
|
|
|
echo "Package list missing or not up-to-date, generating it." >&2 ;\
|
2017-06-13 19:59:14 +00:00
|
|
|
$(MAKE) package_index; \
|
|
|
|
else \
|
|
|
|
mkdir -p $(TARGET_DIR)/tmp; \
|
2017-06-16 22:54:46 +00:00
|
|
|
$(OPKG) update >&2 || true; \
|
2017-06-13 19:59:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
package_list: FORCE
|
|
|
|
@$(MAKE) -s package_reload
|
2017-06-16 23:24:43 +00:00
|
|
|
@$(OPKG) list --size 2>/dev/null
|
2017-06-13 19:59:14 +00:00
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
package_install: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Installing packages...
|
2014-08-05 11:24:24 +00:00
|
|
|
$(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/libc_*.ipk $(PACKAGE_DIR)/base/libc_*.ipk))
|
|
|
|
$(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/kernel_*.ipk $(PACKAGE_DIR)/base/kernel_*.ipk))
|
2010-09-06 02:15:46 +00:00
|
|
|
$(OPKG) install $(BUILD_PACKAGES)
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2018-03-06 08:38:29 +00:00
|
|
|
prepare_rootfs: FORCE
|
2007-01-10 21:52:28 +00:00
|
|
|
@echo
|
2018-03-06 08:38:29 +00:00
|
|
|
@echo Finalizing root filesystem...
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2018-03-06 08:38:29 +00:00
|
|
|
$(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
|
|
|
|
$(call prepare_rootfs,$(TARGET_DIR),$(USER_FILES))
|
2007-01-10 21:52:28 +00:00
|
|
|
|
|
|
|
build_image: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Building images...
|
2016-01-03 14:44:56 +00:00
|
|
|
$(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \
|
2012-01-24 09:47:20 +00:00
|
|
|
$(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
|
|
|
|
|
2016-07-26 13:05:35 +00:00
|
|
|
checksum: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Calculating checksums...
|
|
|
|
@$(call sha256sums,$(BIN_DIR))
|
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
clean:
|
2015-06-01 06:15:39 +00:00
|
|
|
rm -rf $(TMP_DIR) $(DL_DIR) $(TARGET_DIR) $(BIN_DIR)
|
2007-01-10 21:52:28 +00:00
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
|
2010-04-27 22:16:40 +00:00
|
|
|
info:
|
|
|
|
(unset PROFILE FILES PACKAGES MAKEFLAGS; $(MAKE) -s _call_info)
|
|
|
|
|
2016-07-21 11:41:20 +00:00
|
|
|
PROFILE_FILTER = $(filter DEVICE_$(PROFILE) $(PROFILE),$(PROFILE_NAMES))
|
|
|
|
|
2018-07-20 08:32:12 +00:00
|
|
|
_check_profile: FORCE
|
2015-01-10 18:19:59 +00:00
|
|
|
ifneq ($(PROFILE),)
|
2016-07-21 11:41:20 +00:00
|
|
|
ifeq ($(PROFILE_FILTER),)
|
2015-01-10 18:19:59 +00:00
|
|
|
@echo 'Profile "$(PROFILE)" does not exist!'
|
|
|
|
@echo 'Use "make info" to get a list of available profile names.'
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
endif
|
2018-07-20 08:32:12 +00:00
|
|
|
|
|
|
|
image:
|
|
|
|
$(MAKE) -s _check_profile
|
2010-04-27 22:16:40 +00:00
|
|
|
(unset PROFILE FILES PACKAGES MAKEFLAGS; \
|
2016-08-01 16:26:05 +00:00
|
|
|
$(MAKE) -s _call_image \
|
2016-07-21 11:41:20 +00:00
|
|
|
$(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
|
2010-04-27 22:16:40 +00:00
|
|
|
$(if $(FILES),USER_FILES="$(FILES)") \
|
2010-10-26 14:15:52 +00:00
|
|
|
$(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \
|
|
|
|
$(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)"))
|
2010-04-27 22:16:40 +00:00
|
|
|
|
2018-07-20 08:32:12 +00:00
|
|
|
manifest: FORCE
|
|
|
|
$(MAKE) -s _check_profile
|
|
|
|
(unset PROFILE FILES PACKAGES MAKEFLAGS; \
|
|
|
|
$(MAKE) -s _call_manifest \
|
|
|
|
$(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
|
|
|
|
$(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)"))
|
|
|
|
|
|
|
|
.SILENT: help info image manifest
|