77660bb8d7e11ed8d8dababd146ea6759a1bcce9
[openwrt.git] / Makefile
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   override OPENWRT_BUILD=1
20   export OPENWRT_BUILD
21   include $(TOPDIR)/include/debug.mk
22   include $(TOPDIR)/include/depends.mk
23   include $(TOPDIR)/include/toplevel.mk
24 else
25   include rules.mk
26   include $(INCLUDE_DIR)/depends.mk
27   include $(INCLUDE_DIR)/subdir.mk
28   include target/Makefile
29   include package/Makefile
30   include tools/Makefile
31   include toolchain/Makefile
32
33 $(toolchain/stamp-install): $(tools/stamp-install)
34 $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared
35 $(package/stamp-cleanup): $(target/stamp-compile)
36 $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
37 $(package/stamp-install): $(package/stamp-compile)
38 $(package/stamp-rootfs-prepare): $(package/stamp-install)
39 $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install) $(package/stamp-rootfs-prepare)
40
41 $(BUILD_DIR)/.prepared: Makefile
42         @mkdir -p $$(dirname $@)
43         @touch $@
44
45 clean: FORCE
46         rm -rf $(BUILD_DIR) $(BIN_DIR)
47         $(MAKE) target/linux/clean
48
49 dirclean: clean
50         rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST)
51         rm -rf $(TMP_DIR)
52
53 # check prerequisites before starting to build
54 prereq: $(package/stamp-prereq) $(target/stamp-prereq) ;
55
56 prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
57 world: prepare $(target/stamp-compile) $(package/stamp-cleanup) $(package/stamp-compile) $(package/stamp-install) $(package/stamp-rootfs-prepare) $(target/stamp-install) FORCE
58         $(MAKE) package/index
59
60 package/symlinks:
61         $(SCRIPT_DIR)/feeds update
62         cd package; ln -sf ../feeds/packages openwrt-packages
63
64 .PHONY: clean dirclean prereq prepare world package/symlinks
65
66 endif