| 1 | # DebWrt - Debian on Embedded devices |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net> |
|---|
| 4 | # |
|---|
| 5 | # This program is free software: you can redistribute it and/or modify |
|---|
| 6 | # it under the terms of the GNU General Public License as published by |
|---|
| 7 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 8 | # (at your option) any later version. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU General Public License |
|---|
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | OPENWRT_PATCHES_DIR=$(TOPDIR)/openwrt/patches |
|---|
| 19 | |
|---|
| 20 | openwrt/all: openwrt/build |
|---|
| 21 | $(MAKE) -C $(TOPDIR) openwrt/deliver |
|---|
| 22 | touch $@ |
|---|
| 23 | |
|---|
| 24 | openwrt/build: openwrt/prepare |
|---|
| 25 | ifeq ("$(origin V)", "command line") |
|---|
| 26 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) $(CONFIG_OPENWRT_MAKE_OPTIONS) V=$(V) |
|---|
| 27 | else |
|---|
| 28 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) $(CONFIG_OPENWRT_MAKE_OPTIONS) |
|---|
| 29 | endif |
|---|
| 30 | touch $@ |
|---|
| 31 | |
|---|
| 32 | openwrt/download: |
|---|
| 33 | ifeq ("$(origin V)", "command line") |
|---|
| 34 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) download V=$(V) |
|---|
| 35 | else |
|---|
| 36 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) download |
|---|
| 37 | endif |
|---|
| 38 | touch $@ |
|---|
| 39 | |
|---|
| 40 | openwrt/prepare: \ |
|---|
| 41 | openwrt/checkout \ |
|---|
| 42 | openwrt/patch \ |
|---|
| 43 | openwrt/files-copy \ |
|---|
| 44 | plugins/apply-openwrt \ |
|---|
| 45 | openwrt/merge-config \ |
|---|
| 46 | openwrt/download-link \ |
|---|
| 47 | # end openwrt/prepare: |
|---|
| 48 | touch $@ |
|---|
| 49 | |
|---|
| 50 | openwrt/merge-config: .config $(OPENWRT_BUILD_DIR)/.config openwrt/checkout openwrt/patch |
|---|
| 51 | mkdir -p $(TMP_DIR) |
|---|
| 52 | # Copy default OpenWrt settings |
|---|
| 53 | cp $(CONFIG_DIR)/openwrt.defconfig $(TMP_DIR)/.config_openwrt |
|---|
| 54 | # Merge default OpenWrt settings with DebWrt menu config settings |
|---|
| 55 | #cat .config | grep -v -e CONFIG_TARGET_BOARD -e "^#" >> $(TMP_DIR)/.config_openwrt |
|---|
| 56 | cat .config | grep -v -e CONFIG_TARGET_BOARD >> $(TMP_DIR)/.config_openwrt |
|---|
| 57 | # Merge default and menu settings with possibly altered settings in make menuconfig in OpenWrt |
|---|
| 58 | # note: settings manually made in OpenWrt menu config will be included! |
|---|
| 59 | touch $(OPENWRT_BUILD_DIR)/.config |
|---|
| 60 | cp $(OPENWRT_BUILD_DIR)/.config $(OPENWRT_BUILD_DIR)/.config.org |
|---|
| 61 | $(SCRIPT_KCONFIG) + $(OPENWRT_BUILD_DIR)/.config.org $(TMP_DIR)/.config_openwrt > $(OPENWRT_BUILD_DIR)/.config |
|---|
| 62 | # Filter out config options unknown to OpenWrt (e.g. pure kernel known options) / clean up OpenWrt config |
|---|
| 63 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) defconfig |
|---|
| 64 | # Save .config to OpenWrt build-dir. During the OpenWrt build the .config kernel options are |
|---|
| 65 | # merged with the OpenWrt's default kernel options for the target. In this phase any DebWrt/OpenWrt |
|---|
| 66 | # specific options in the .config file are filtered out. See include/kernel-defaults.mk from OpenWrt. |
|---|
| 67 | cp .config $(OPENWRT_BUILD_DIR)/.config.debwrt |
|---|
| 68 | touch $@ |
|---|
| 69 | |
|---|
| 70 | $(OPENWRT_BUILD_DIR)/.config: openwrt/checkout |
|---|
| 71 | [ ! -f $@ ] && touch $(OPENWRT_BUILD_DIR)/.config |
|---|
| 72 | |
|---|
| 73 | openwrt/download-link: openwrt/checkout |
|---|
| 74 | ifneq ($(OPENWRT_DOWNLOAD_DIR),) |
|---|
| 75 | cd $(OPENWRT_BUILD_DIR) && if [ -d $(OPENWRT_DOWNLOAD_DIR) -a ! -e dl ]; then ln -snf $(OPENWRT_DOWNLOAD_DIR) dl; fi |
|---|
| 76 | endif |
|---|
| 77 | touch $@ |
|---|
| 78 | |
|---|
| 79 | openwrt/patch: openwrt/checkout |
|---|
| 80 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 81 | < $(PATCHES_DIR_OPENWRT)/001_disable_all_openwrt_packages |
|---|
| 82 | ifeq ($(IS_OPENWRT_TRUNK),y) |
|---|
| 83 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 84 | < $(PATCHES_DIR_OPENWRT)/trunk/002_install_kernel_modules_and_merge_debwrt_config |
|---|
| 85 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 86 | < $(PATCHES_DIR_OPENWRT)/trunk/005_make_empty_rootfs |
|---|
| 87 | #patch -d $(OPENWRT_BUILD_DIR) -p 1 -N < $(PATCHES_DIR_OPENWRT)/trunk/006_reverse-changeset27849-changes.patch |
|---|
| 88 | else ifeq ($(IS_OPENWRT_BACKFIRE),y) |
|---|
| 89 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 90 | < $(PATCHES_DIR_OPENWRT)/backfire/002_install_kernel_modules_and_merge_debwrt_config |
|---|
| 91 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 92 | < $(PATCHES_DIR_OPENWRT)/backfire/005_make_empty_rootfs |
|---|
| 93 | endif |
|---|
| 94 | #patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 95 | < $(PATCHES_DIR_OPENWRT)/003_set_kernel_version |
|---|
| 96 | patch -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 97 | < $(PATCHES_DIR_OPENWRT)/004_save_environment_variables |
|---|
| 98 | touch $@ |
|---|
| 99 | |
|---|
| 100 | openwrt/unpatch: openwrt/checkout |
|---|
| 101 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 102 | < $(PATCHES_DIR_OPENWRT)/001_disable_all_openwrt_packages |
|---|
| 103 | ifeq ($(IS_OPENWRT_TRUNK),y) |
|---|
| 104 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 105 | < $(PATCHES_DIR_OPENWRT)/trunk/002_install_kernel_modules_and_merge_debwrt_config |
|---|
| 106 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 107 | < $(PATCHES_DIR_OPENWRT)/trunk/005_make_empty_rootfs |
|---|
| 108 | #-patch -R -d $(OPENWRT_BUILD_DIR) -p 1 -N < $(PATCHES_DIR_OPENWRT)/trunk/006_reverse-changeset27849-changes.patch |
|---|
| 109 | else ifeq ($(IS_OPENWRT_BACKFIRE),y) |
|---|
| 110 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 111 | < $(PATCHES_DIR_OPENWRT)/backfire/002_install_kernel_modules_and_merge_debwrt_config |
|---|
| 112 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 113 | < $(PATCHES_DIR_OPENWRT)/backfire/005_make_empty_rootfs |
|---|
| 114 | endif |
|---|
| 115 | #-patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 116 | < $(PATCHES_DIR_OPENWRT)/003_set_kernel_version |
|---|
| 117 | -patch -R -d $(OPENWRT_BUILD_DIR) -p 0 -N \ |
|---|
| 118 | < $(PATCHES_DIR_OPENWRT)/004_save_environment_variables |
|---|
| 119 | touch $@ |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | openwrt/files-copy: openwrt/patch |
|---|
| 123 | cd $(FILES_DIR_OPENWRT) && find -type f | while read f; do \ |
|---|
| 124 | mkdir -p $(OPENWRT_BUILD_DIR)/$$(dirname $$f); \ |
|---|
| 125 | cp -v $$f $(OPENWRT_BUILD_DIR)/$$(dirname $$f) ;\ |
|---|
| 126 | done |
|---|
| 127 | touch $@ |
|---|
| 128 | |
|---|
| 129 | $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp: |
|---|
| 130 | openwrt/checkout: $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp |
|---|
| 131 | rm -rf $(OPENWRT_BUILD_DIR) |
|---|
| 132 | mkdir -p $(OPENWRT_BUILD_DIR) |
|---|
| 133 | ifeq ($(IS_OPENWRT_TRUNK),y) |
|---|
| 134 | cd $(OPENWRT_BUILD_DIR) && \ |
|---|
| 135 | svn co svn://svn.openwrt.org/openwrt/trunk/ . |
|---|
| 136 | else ifeq ($(IS_OPENWRT_BACKFIRE),y) |
|---|
| 137 | cd $(OPENWRT_BUILD_DIR) && \ |
|---|
| 138 | svn co svn://svn.openwrt.org/openwrt/branches/backfire/ . |
|---|
| 139 | else |
|---|
| 140 | cd $(OPENWRT_BUILD_DIR) && \ |
|---|
| 141 | svn co -r $(OPENWRT_REVISION) svn://svn.openwrt.org/openwrt/trunk/ . |
|---|
| 142 | endif |
|---|
| 143 | touch $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp |
|---|
| 144 | touch $@ |
|---|
| 145 | |
|---|
| 146 | openwrt/update: openwrt/checkout |
|---|
| 147 | cd $(OPENWRT_BUILD_DIR) && svn update |
|---|
| 148 | |
|---|
| 149 | openwrt/menuconfig: openwrt/prepare |
|---|
| 150 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) menuconfig |
|---|
| 151 | |
|---|
| 152 | # Tune kernel configuration |
|---|
| 153 | openwrt/kernel_menuconfig: openwrt/prepare |
|---|
| 154 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) kernel_menuconfig |
|---|
| 155 | rm -f openwrt/build |
|---|
| 156 | |
|---|
| 157 | openwrt/clean: |
|---|
| 158 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) clean V=$(V) |
|---|
| 159 | |
|---|
| 160 | openwrt/dirclean: |
|---|
| 161 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) dirclean V=$(V) |
|---|
| 162 | |
|---|
| 163 | openwrt/distclean: |
|---|
| 164 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) distclean V=$(V) |
|---|
| 165 | |
|---|
| 166 | openwrt/debwrt-clean: |
|---|
| 167 | rm -rf $(OPENWRT_BUILD_DIR) |
|---|
| 168 | rm -f openwrt/checkout |
|---|
| 169 | rm -f openwrt/patch |
|---|
| 170 | rm -f openwrt/copy-files |
|---|