2013-02-13 08:58:25 +00:00
|
|
|
# Greatly modified OpenWRT Image Builder Makefile
|
2013-02-11 03:52:16 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2007-2010 OpenWrt.org
|
2013-02-13 08:58:25 +00:00
|
|
|
# Copyright (C) 2013 Project Gluon
|
2013-02-11 03:52:16 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2013-02-17 15:30:59 +00:00
|
|
|
all: image
|
2013-02-11 22:06:19 +00:00
|
|
|
|
|
|
|
include ${CURDIR}/gluon.mk
|
|
|
|
|
2013-02-11 03:52:16 +00:00
|
|
|
include $(TOPDIR)/include/host.mk
|
2013-02-13 08:58:25 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
PACKAGE_DIR := $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
|
|
|
|
BIN_DIR := $(GLUON_IMAGEDIR)/$(BOARD)/$(PROFILE)
|
|
|
|
|
|
|
|
PROFILE_BUILDDIR := $(BOARD_BUILDDIR)/$(PROFILE)
|
2013-02-13 09:32:35 +00:00
|
|
|
PROFILE_KDIR := $(PROFILE_BUILDDIR)/kernel
|
|
|
|
|
2013-02-13 08:58:25 +00:00
|
|
|
TMP_DIR := $(PROFILE_BUILDDIR)/tmp
|
|
|
|
TARGET_DIR := $(PROFILE_BUILDDIR)/root
|
|
|
|
|
2013-02-11 03:52:16 +00:00
|
|
|
include $(INCLUDE_DIR)/debug.mk
|
|
|
|
include $(INCLUDE_DIR)/depends.mk
|
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/version.mk
|
|
|
|
|
2013-02-11 22:06:19 +00:00
|
|
|
REVISION:=$(shell $(GLUON_BUILDERDIR)/openwrt_rev.sh $(GLUONDIR))
|
2013-02-11 03:52:16 +00:00
|
|
|
export REVISION
|
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/package-ipkg.mk
|
|
|
|
|
|
|
|
# override variables from rules.mk
|
|
|
|
OPKG:= \
|
2013-02-13 08:58:25 +00:00
|
|
|
IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
|
2013-02-11 03:52:16 +00:00
|
|
|
IPKG_INSTROOT="$(TARGET_DIR)" \
|
2013-02-13 08:58:25 +00:00
|
|
|
IPKG_CONF_DIR="$(TMP_DIR)" \
|
2013-02-11 03:52:16 +00:00
|
|
|
IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
|
|
|
|
$(STAGING_DIR_HOST)/bin/opkg \
|
2013-02-13 08:58:25 +00:00
|
|
|
-f $(BOARD_BUILDDIR)/opkg.conf \
|
2013-02-11 03:52:16 +00:00
|
|
|
--force-depends \
|
|
|
|
--force-overwrite \
|
|
|
|
--force-postinstall \
|
2013-02-13 08:58:25 +00:00
|
|
|
--cache $(TMP_DIR)/dl \
|
2013-02-11 03:52:16 +00:00
|
|
|
--offline-root $(TARGET_DIR) \
|
|
|
|
--add-dest root:/ \
|
|
|
|
--add-arch all:100 \
|
|
|
|
--add-arch $(ARCH_PACKAGES):200
|
|
|
|
|
|
|
|
define Profile
|
|
|
|
$(eval $(call Profile/Default))
|
|
|
|
$(eval $(call Profile/$(1)))
|
2013-02-13 08:58:25 +00:00
|
|
|
ifeq ($(PROFILE),)
|
|
|
|
PROFILE:=$(1)
|
2013-02-11 03:52:16 +00:00
|
|
|
endif
|
|
|
|
$(1)_NAME:=$(NAME)
|
|
|
|
$(1)_PACKAGES:=$(PACKAGES)
|
|
|
|
endef
|
|
|
|
|
|
|
|
include $(INCLUDE_DIR)/target.mk
|
|
|
|
|
2013-02-18 23:12:23 +00:00
|
|
|
define GluonProfile
|
|
|
|
GLUON_$(1)_DEFAULT_PACKAGES := $(2)
|
|
|
|
endef
|
|
|
|
|
|
|
|
include $(GLUONDIR)/profiles.mk
|
|
|
|
|
|
|
|
# Generate Gluon package list
|
|
|
|
$(eval $(call merge-lists,GLUON_PACKAGES,GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
|
2013-02-11 03:52:16 +00:00
|
|
|
|
2013-02-17 15:30:59 +00:00
|
|
|
image/%:: FORCE
|
|
|
|
$(MAKE) assemble_image PROFILE="$(patsubst image/%,%,$@)"
|
|
|
|
|
2013-02-17 23:39:44 +00:00
|
|
|
assemble_image: FORCE
|
2013-02-13 08:58:25 +00:00
|
|
|
rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
|
2013-02-13 07:38:14 +00:00
|
|
|
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp
|
|
|
|
$(OPKG) update
|
2013-02-11 03:52:16 +00:00
|
|
|
$(MAKE) package_install
|
|
|
|
$(MAKE) build_image
|
|
|
|
|
2013-02-18 20:16:10 +00:00
|
|
|
define EnableInitscript
|
2013-02-19 00:38:49 +00:00
|
|
|
( \
|
2013-02-18 20:16:10 +00:00
|
|
|
grep '#!/bin/sh /etc/rc.common' $(1) >/dev/null && \
|
2013-02-19 00:38:49 +00:00
|
|
|
IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $(1) enable || \
|
2013-02-18 20:16:10 +00:00
|
|
|
true \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2013-02-19 00:38:49 +00:00
|
|
|
define FileOrigin
|
|
|
|
$(firstword $(shell $(OPKG) search $(1)))
|
|
|
|
endef
|
|
|
|
|
|
|
|
enable_initscripts: FORCE
|
|
|
|
cd $(TARGET_DIR) && ( \
|
|
|
|
$(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
|
|
|
|
$(if $(filter $(ENABLE_INITSCRIPTS_FROM),$(call FileOrigin,$(script))),$(call EnableInitscript,$(script));) \
|
|
|
|
) : \
|
|
|
|
)
|
|
|
|
|
2013-02-11 03:52:16 +00:00
|
|
|
package_install: FORCE
|
|
|
|
$(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
|
|
|
|
$(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
|
2013-02-19 00:38:49 +00:00
|
|
|
|
2013-02-18 23:12:23 +00:00
|
|
|
$(OPKG) install $(DEFAULT_PACKAGES) $($(PROFILE)_PACKAGES)
|
2013-02-19 00:38:49 +00:00
|
|
|
$(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM=%
|
|
|
|
|
2013-02-18 23:12:23 +00:00
|
|
|
$(OPKG) install $(GLUON_PACKAGES)
|
2013-02-19 00:38:49 +00:00
|
|
|
$(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM="$(GLUON_PACKAGES)"
|
|
|
|
|
2013-02-18 20:16:10 +00:00
|
|
|
rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
|
2013-02-11 03:52:16 +00:00
|
|
|
|
|
|
|
copy_files: FORCE
|
|
|
|
@echo Copying extra files
|
|
|
|
@( cd $(USER_FILES); find -type f ) | \
|
|
|
|
( cd $(TARGET_DIR); while :; do \
|
|
|
|
read FILE; \
|
|
|
|
[ -z "$$FILE" ] && break; \
|
|
|
|
[ -L "$$FILE" ] || continue; \
|
|
|
|
echo "Removing symlink $(TARGET_DIR)/$$FILE"; \
|
|
|
|
rm -f "$$FILE"; \
|
|
|
|
done; )
|
|
|
|
$(CP) $(USER_FILES)/* $(TARGET_DIR)/
|
|
|
|
|
2013-02-13 07:38:14 +00:00
|
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
|
2013-02-11 03:52:16 +00:00
|
|
|
build_image: FORCE
|
|
|
|
@echo
|
|
|
|
@echo Building images...
|
2013-02-13 09:32:35 +00:00
|
|
|
|
|
|
|
rm -rf $(PROFILE_KDIR)
|
|
|
|
cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
|
|
|
|
|
2013-02-13 07:38:14 +00:00
|
|
|
$(call Image/mkfs/prepare)
|
|
|
|
$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX="gluon-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))" \
|
2013-02-13 09:32:35 +00:00
|
|
|
PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"
|
2013-02-11 03:52:16 +00:00
|
|
|
|
2013-02-17 23:39:44 +00:00
|
|
|
image: FORCE
|
2013-02-18 23:12:23 +00:00
|
|
|
$(MAKE) image/$(PROFILE) OPENWRT_VERBOSE="$(OPENWRT_VERBOSE)"
|
2013-02-11 03:52:16 +00:00
|
|
|
|
2013-02-13 08:58:25 +00:00
|
|
|
.SILENT: prepare image
|
2013-02-11 03:52:16 +00:00
|
|
|
|