| 1 | # Makefile for OpenWrt |
| 2 | # |
| 3 | # Copyright (C) 2007 OpenWrt.org |
| 4 | # |
| 5 | # This is free software, licensed under the GNU General Public License v2. |
| 6 | # See /LICENSE for more information. |
| 7 | # |
| 8 | |
| 9 | TOPDIR:=${CURDIR} |
| 10 | LC_ALL:=C |
| 11 | LANG:=C |
| 12 | export TOPDIR LC_ALL LANG |
| 13 | |
| 14 | world: |
| 15 | |
| 16 | include $(TOPDIR)/include/host.mk |
| 17 | |
| 18 | ifneq ($(OPENWRT_BUILD),1) |
| 19 | # XXX: these three lines are normally defined by rules.mk |
| 20 | # but we can't include that file in this context |
| 21 | empty:= |
| 22 | space:= $(empty) $(empty) |
| 23 | _SINGLE=export MAKEFLAGS=$(space); |
| 24 | |
| 25 | override OPENWRT_BUILD=1 |
| 26 | export OPENWRT_BUILD |
| 27 | GREP_OPTIONS= |
| 28 | export GREP_OPTIONS |
| 29 | include $(TOPDIR)/include/debug.mk |
| 30 | include $(TOPDIR)/include/depends.mk |
| 31 | include $(TOPDIR)/include/toplevel.mk |
| 32 | else |
| 33 | include rules.mk |
| 34 | include $(INCLUDE_DIR)/depends.mk |
| 35 | include $(INCLUDE_DIR)/subdir.mk |
| 36 | include target/Makefile |
| 37 | include package/Makefile |
| 38 | include tools/Makefile |
| 39 | include toolchain/Makefile |
| 40 | |
| 41 | $(toolchain/stamp-install): $(tools/stamp-install) |
| 42 | $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared |
| 43 | $(package/stamp-compile): $(target/stamp-compile) |
| 44 | $(package/stamp-install): $(package/stamp-compile) |
| 45 | $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install) |
| 46 | |
| 47 | printdb: |
| 48 | @true |
| 49 | |
| 50 | prepare: $(target/stamp-compile) |
| 51 | |
| 52 | clean: FORCE |
| 53 | $(_SINGLE)$(SUBMAKE) target/linux/clean |
| 54 | rm -rf $(BUILD_DIR) $(BIN_DIR) $(BUILD_LOG_DIR) |
| 55 | |
| 56 | dirclean: clean |
| 57 | rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN) |
| 58 | rm -rf $(TMP_DIR) |
| 59 | |
| 60 | ifndef DUMP_TARGET_DB |
| 61 | $(BUILD_DIR)/.prepared: Makefile |
| 62 | @mkdir -p $$(dirname $@) |
| 63 | @touch $@ |
| 64 | |
| 65 | tmp/.prereq_packages: .config |
| 66 | unset ERROR; \ |
| 67 | for package in $(sort $(prereq-y) $(prereq-m)); do \ |
| 68 | $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \ |
| 69 | done; \ |
| 70 | if [ -n "$$ERROR" ]; then \ |
| 71 | echo "Package prerequisite check failed."; \ |
| 72 | false; \ |
| 73 | fi |
| 74 | touch $@ |
| 75 | endif |
| 76 | |
| 77 | # check prerequisites before starting to build |
| 78 | prereq: $(target/stamp-prereq) tmp/.prereq_packages |
| 79 | @if [ ! -f "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" ]; then \ |
| 80 | echo 'ERROR: Missing site config for target "$(REAL_GNU_TARGET_NAME)" !'; \ |
| 81 | echo ' The missing file will cause configure scripts to fail during compilation.'; \ |
| 82 | echo ' Please provide a "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" file and restart the build.'; \ |
| 83 | exit 1; \ |
| 84 | fi |
| 85 | |
| 86 | prepare: .config $(tools/stamp-install) $(toolchain/stamp-install) |
| 87 | world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE |
| 88 | $(_SINGLE)$(SUBMAKE) -r package/index |
| 89 | |
| 90 | # update all feeds, re-create index files, install symlinks |
| 91 | package/symlinks: |
| 92 | $(SCRIPT_DIR)/feeds update -a |
| 93 | $(SCRIPT_DIR)/feeds install -a |
| 94 | |
| 95 | # re-create index files, install symlinks |
| 96 | package/symlinks-install: |
| 97 | $(SCRIPT_DIR)/feeds update -i |
| 98 | $(SCRIPT_DIR)/feeds install -a |
| 99 | |
| 100 | # remove all symlinks, don't touch ./feeds |
| 101 | package/symlinks-clean: |
| 102 | $(SCRIPT_DIR)/feeds uninstall -a |
| 103 | |
| 104 | .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean |
| 105 | |
| 106 | endif |
| 107 | |