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
|
|
|
|
|
2007-11-14 23:11:07 +00:00
|
|
|
include $(TOPDIR)/include/host.mk
|
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
|
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
|
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)
|
2010-09-06 02:15:46 +00:00
|
|
|
OPKG:= \
|
2014-09-16 11:56:19 +00:00
|
|
|
IPKG_NO_SCRIPT=1 \
|
2015-06-01 06:15:39 +00:00
|
|
|
IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
|
2007-11-14 23:11:07 +00:00
|
|
|
IPKG_INSTROOT="$(TARGET_DIR)" \
|
2015-06-01 06:15:39 +00:00
|
|
|
IPKG_CONF_DIR="$(TMP_DIR)" \
|
2007-11-14 23:11:07 +00:00
|
|
|
IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
|
2010-09-06 02:15:46 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/opkg \
|
2010-09-12 22:04:09 +00:00
|
|
|
-f $(TOPDIR)/repositories.conf \
|
2010-09-06 02:15:46 +00:00
|
|
|
--force-depends \
|
2010-09-07 21:22:07 +00:00
|
|
|
--force-overwrite \
|
2010-09-12 22:04:09 +00:00
|
|
|
--force-postinstall \
|
2015-06-01 06:15:39 +00:00
|
|
|
--cache $(DL_DIR) \
|
2015-09-14 16:57:03 +00:00
|
|
|
--lists-dir $(LISTS_DIR) \
|
2010-09-12 22:04:09 +00:00
|
|
|
--offline-root $(TARGET_DIR) \
|
|
|
|
--add-dest root:/ \
|
|
|
|
--add-arch all:100 \
|
|
|
|
--add-arch $(ARCH_PACKAGES):200
|
2007-11-14 23:11:07 +00:00
|
|
|
|
|
|
|
define Profile
|
|
|
|
$(eval $(call Profile/Default))
|
|
|
|
$(eval $(call Profile/$(1)))
|
2010-04-27 22:16:40 +00:00
|
|
|
ifeq ($(USER_PROFILE),)
|
|
|
|
USER_PROFILE:=$(1)
|
2007-11-14 23:11:07 +00:00
|
|
|
endif
|
|
|
|
$(1)_NAME:=$(NAME)
|
|
|
|
$(1)_PACKAGES:=$(PACKAGES)
|
2015-01-10 18:19:59 +00:00
|
|
|
PROFILE_NAMES += $(1)
|
2007-11-14 23:11:07 +00:00
|
|
|
PROFILE_LIST += \
|
|
|
|
echo '$(1):'; [ -z '$(NAME)' ] || echo ' $(NAME)'; echo ' Packages: $(PACKAGES)';
|
|
|
|
endef
|
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/target.mk
|
|
|
|
|
2015-09-10 11:06:42 +00:00
|
|
|
staging_dir/host/.prereq-build: include/prereq-build.mk
|
|
|
|
mkdir -p tmp
|
|
|
|
rm -f tmp/.host.mk
|
|
|
|
@$(_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)
|
|
|
|
|
2010-04-27 22:16:40 +00:00
|
|
|
BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(USER_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
|
|
|
|
rm -rf $(TARGET_DIR)
|
2015-06-01 06:15:39 +00:00
|
|
|
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
|
2011-09-09 17:25:20 +00:00
|
|
|
if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
|
|
|
|
echo "Package list missing or not up-to-date, generating it.";\
|
|
|
|
$(MAKE) package_index; \
|
|
|
|
else \
|
|
|
|
mkdir -p $(TARGET_DIR)/tmp; \
|
2015-05-27 11:22:20 +00:00
|
|
|
$(OPKG) update || true; \
|
2011-09-09 17:25:20 +00:00
|
|
|
fi
|
2007-01-10 21:52:28 +00:00
|
|
|
$(MAKE) package_install
|
2010-04-27 22:16:40 +00:00
|
|
|
ifneq ($(USER_FILES),)
|
2007-01-10 21:52:28 +00:00
|
|
|
$(MAKE) copy_files
|
|
|
|
endif
|
|
|
|
$(MAKE) package_postinst
|
|
|
|
$(MAKE) build_image
|
2012-01-24 09:47:20 +00:00
|
|
|
|
2010-09-12 22:04:09 +00:00
|
|
|
package_index: FORCE
|
2007-01-10 21:52:28 +00:00
|
|
|
@echo
|
|
|
|
@echo Building package index...
|
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
|
2015-05-27 11:22:20 +00:00
|
|
|
$(OPKG) update || true
|
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)
|
2011-09-09 17:25:20 +00:00
|
|
|
rm -f $(TARGET_DIR)/usr/lib/opkg/lists/*
|
2007-01-10 21:52:28 +00:00
|
|
|
|
|
|
|
copy_files: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Copying extra files
|
2012-12-02 12:20:43 +00:00
|
|
|
@$(call file_copy,$(USER_FILES)/*,$(TARGET_DIR)/)
|
2007-01-10 21:52:28 +00:00
|
|
|
|
|
|
|
package_postinst: FORCE
|
2010-09-06 02:15:46 +00:00
|
|
|
@echo
|
|
|
|
@echo Cleaning up
|
|
|
|
@rm -f $(TARGET_DIR)/tmp/opkg.lock
|
2007-01-10 21:52:28 +00:00
|
|
|
@echo
|
|
|
|
@echo Activating init scripts
|
2014-09-16 11:56:19 +00:00
|
|
|
@mkdir -p $(TARGET_DIR)/etc/rc.d
|
2007-11-14 23:11:07 +00:00
|
|
|
@( \
|
2009-04-21 11:20:25 +00:00
|
|
|
cd $(TARGET_DIR); \
|
2014-09-16 11:56:19 +00:00
|
|
|
for script in ./usr/lib/opkg/info/*.postinst; do \
|
|
|
|
IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
|
|
|
|
done || true \
|
2007-01-10 21:52:28 +00:00
|
|
|
)
|
2014-08-31 11:06:31 +00:00
|
|
|
rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
|
2011-08-01 23:58:11 +00:00
|
|
|
$(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
|
2007-01-10 21:52:28 +00:00
|
|
|
|
|
|
|
build_image: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Building images...
|
2012-01-24 09:47:20 +00:00
|
|
|
$(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 \
|
|
|
|
$(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
image:
|
2015-01-10 18:19:59 +00:00
|
|
|
ifneq ($(PROFILE),)
|
|
|
|
ifeq ($(filter $(PROFILE),$(PROFILE_NAMES)),)
|
|
|
|
@echo 'Profile "$(PROFILE)" does not exist!'
|
|
|
|
@echo 'Use "make info" to get a list of available profile names.'
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
endif
|
2010-04-27 22:16:40 +00:00
|
|
|
(unset PROFILE FILES PACKAGES MAKEFLAGS; \
|
|
|
|
$(MAKE) _call_image \
|
|
|
|
$(if $(PROFILE),USER_PROFILE="$(PROFILE)") \
|
|
|
|
$(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
|
|
|
|
2007-01-10 21:52:28 +00:00
|
|
|
.SILENT: help info image
|
2007-11-14 23:11:07 +00:00
|
|
|
|