aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a12e3ea49a64d7337e648ac89e00655bf624e81b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Makefile for OpenWrt
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

TOPDIR:=${CURDIR}
LC_ALL:=C
LANG:=C
export TOPDIR LC_ALL LANG

empty:=
space:= $(empty) $(empty)
$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt directory must not include any spaces))

world:

include $(TOPDIR)/include/host.mk

ifneq ($(OPENWRT_BUILD),1)
  _SINGLE=export MAKEFLAGS=$(space);

  override OPENWRT_BUILD=1
  export OPENWRT_BUILD
  GREP_OPTIONS=
  export GREP_OPTIONS
  include $(TOPDIR)/include/debug.mk
  include $(TOPDIR)/include/depends.mk
  include $(TOPDIR)/include/toplevel.mk
else
  include rules.mk
  include $(INCLUDE_DIR)/depends.mk
  include $(INCLUDE_DIR)/subdir.mk
  include target/Makefile
  include package/Makefile
  include tools/Makefile
  include toolchain/Makefile

$(toolchain/stamp-install): $(tools/stamp-install)
$(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared
$(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
$(package/stamp-install): $(package/stamp-compile)
$(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)

printdb:
	@true

prepare: $(target/stamp-compile)

clean: FORCE
	rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)

dirclean: clean
	rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
	rm -rf $(TMP_DIR)

ifndef DUMP_TARGET_DB
$(BUILD_DIR)/.prepared: Makefile
	@mkdir -p $$(dirname $@)
	@touch $@

tmp/.prereq_packages: .config
	unset ERROR; \
	for package in $(sort $(prereq-y) $(prereq-m)); do \
		$(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
	done; \
	if [ -n "$$ERROR" ]; then \
		echo "Package prerequisite check failed."; \
		false; \
	fi
	touch $@
endif

# check prerequisites before starting to build
prereq: $(target/stamp-prereq) tmp/.prereq_packages
	@if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
		echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
		echo '       The missing file will cause configure scripts to fail during compilation.'; \
		echo '       Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
		exit 1; \
	fi

prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
	$(_SINGLE)$(SUBMAKE) -r package/index

.PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean

endif
>\ -m $$(($(subst k, * 1024,$(IMAGE_SIZE)))) \ -f $(IMAGE_KERNEL) \ -a 4 -f $(IMAGE_ROOTFS) endef define Build/loader-common rm -rf $@.src $(MAKE) -C lzma-loader \ PKG_BUILD_DIR="$@.src" \ TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \ BOARD="$(BOARDNAME)" PLATFORM="$(PLATFORM)" \ LZMA_TEXT_START=0x82000000 LOADADDR=$(KERNEL_LOADADDR) \ $(1) compile loader.$(LOADER_TYPE) mv "$@.$(LOADER_TYPE)" "$@" rm -rf $@.src endef define Build/loader-kernel $(call Build/loader-common,LOADER_DATA="$@") endef define Build/relocate-kernel rm -rf $@.relocate $(CP) ../../generic/image/relocate $@.relocate $(MAKE) -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS) ( \ dd if=$@.relocate/loader.bin bs=32 conv=sync && \ perl -e '@s = stat("$@"); print pack("V", @s[7])' && \ cat $@ \ ) > $@.new mv $@.new $@ rm -rf $@.relocate endef define Build/elx-header $(eval hw_id=$(word 1,$(1))) $(eval xor_pattern=$(word 2,$(1))) ( \ echo -ne "\x00\x00\x00\x00\x00\x00\x00\x03" | \ dd bs=42 count=1 conv=sync; \ hw_id="$(hw_id)"; \ echo -ne "\x$${hw_id:0:2}\x$${hw_id:2:2}\x$${hw_id:4:2}\x$${hw_id:6:2}" | \ dd bs=20 count=1 conv=sync; \ echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \ dd bs=8 count=1 conv=sync; \ echo -ne "$$($(STAGING_DIR_HOST)/bin/mkhash md5 $@ | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \ dd bs=58 count=1 conv=sync; \ ) > $(KDIR)/tmp/$(DEVICE_NAME).header $(call Build/xor-image,-p $(xor_pattern) -x) cat $(KDIR)/tmp/$(DEVICE_NAME).header $@ > $@.new mv $@.new $@ rm -rf $(KDIR)/tmp/$(DEVICE_NAME).header endef define Build/umedia-header fix-u-media-header -T 0x46 -B $(1) -i $@ -o $@.new && mv $@.new $@ endef define Build/edimax-header $(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o $@.new $(1) @mv $@.new $@ endef define Build/poray-header $(STAGING_DIR_HOST)/bin/mkporayfw $(1) -f $@ -o $@.new mv $@.new $@ endef define Build/wrg-header mkwrgimg -i $@ -d "/dev/mtdblock/2" -s $(1) -o $@.new mv $@.new $@ endef # combine kernel and rootfs into one image # mkdlinkfw <type> <optional extra arguments to mkdlinkfw binary> define Build/mkdlinkfw -$(STAGING_DIR_HOST)/bin/mkdlinkfw \ -k $(IMAGE_KERNEL) \ -r $(IMAGE_ROOTFS) \ -o $@ \ $(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \ -s $(DLINK_FIRMWARE_SIZE) endef define Build/mkdlinkfw-factory -$(STAGING_DIR_HOST)/bin/mkdlinkfw \ -m $(DLINK_ROM_ID) -f $(DLINK_FAMILY_MEMBER) \ -F $@ \ -o $@.new \ $(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \ -s $(DLINK_FIRMWARE_SIZE) mv $@.new $@ endef define Build/zyimage $(STAGING_DIR_HOST)/bin/zyimage $(1) $@ endef define Build/sercom-seal $(STAGING_DIR_HOST)/bin/mksercommfw \ -i $@ \ -b $(SERCOMM_HWID) \ -r $(SERCOMM_HWVER) \ -v $(SERCOMM_SWVER) \ $(1) endef define Build/sercom-footer $(call Build/sercom-seal,-f) endef define Build/fonfxcimage uimage_padhdr -i $@ -o $@.new mv $@.new $@ endef ifeq ($(SUBTARGET),rt288x) include rt288x.mk endif ifeq ($(SUBTARGET),rt305x) include rt305x.mk endif ifeq ($(SUBTARGET),rt3883) include rt3883.mk endif ifeq ($(SUBTARGET),mt7620) include mt7620.mk endif ifeq ($(SUBTARGET),mt7621) include mt7621.mk endif ifeq ($(SUBTARGET),mt76x8) include mt76x8.mk endif $(eval $(call BuildImage))