add support for per-package prereq checks, run global prereq checks before (menu...
[openwrt.git] / Makefile
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 # Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name>
5 #
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
8 #
9
10 RELEASE:=Kamikaze
11 #VERSION:=2.0 # uncomment for final release
12
13 #--------------------------------------------------------------
14 # Just run 'make menuconfig', configure stuff, then run 'make'.
15 # You shouldn't need to mess with anything beyond this point...
16 #--------------------------------------------------------------
17 TOPDIR=${shell pwd}
18 export TOPDIR
19 include $(TOPDIR)/include/verbose.mk
20
21 OPENWRTVERSION:=$(RELEASE)
22 ifneq ($(VERSION),)
23 OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
24 else
25 REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
26 ifneq ($(REV),)
27 OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
28 endif
29 endif
30 export OPENWRTVERSION
31
32 all: world
33
34 ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo)
35 .pkginfo: FORCE
36 .config: FORCE
37 endif
38
39 .pkginfo:
40 @echo Collecting package info...
41 @-for dir in package/*/; do \
42 echo Source-Makefile: $${dir}Makefile; \
43 $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \
44 done > $@
45
46 .config.in: .pkginfo
47 @./scripts/gen_menuconfig.pl < $< > $@ || rm -f $@
48
49 pkginfo-clean: FORCE
50 -rm -f .pkginfo .config.in
51
52 ./scripts/config/mconf: .config.in
53 @$(MAKE) -C scripts/config all
54
55 ./scripts/config/conf: .config.in
56 @$(MAKE) -C scripts/config conf
57
58 config: ./scripts/config/conf FORCE
59 $< Config.in
60
61 defconfig: ./scripts/config/conf FORCE
62 touch .config
63 $< -D .config Config.in
64
65 oldconfig: ./scripts/config/conf FORCE
66 $< -o Config.in
67
68 menuconfig: ./scripts/config/mconf FORCE
69 $< Config.in
70
71 config-clean: FORCE
72 $(NO_TRACE_MAKE) -C scripts/config clean
73
74 package/%: .pkginfo FORCE
75 $(MAKE) -C package $(patsubst package/%,%,$@)
76
77 target/%: .pkginfo FORCE
78 $(MAKE) -C target $(patsubst target/%,%,$@)
79
80 toolchain/%: FORCE
81 $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
82
83 .config: ./scripts/config/conf
84 @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
85 @$< -D .config Config.in &> /dev/null
86
87 .prereq-build: $(TOPDIR)/include/prereq-build.mk
88 @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
89 echo "Prerequisite check failed. Use FORCE=1 to override."; \
90 false; \
91 }
92 @touch $@
93
94 .prereq-packages: $(TOPDIR)/include/prereq.mk .pkginfo .config
95 @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
96 echo "Prerequisite check failed. Use FORCE=1 to override."; \
97 false; \
98 }
99 @touch $@
100
101 prereq: .prereq-build .prereq-packages FORCE
102
103 download: .config FORCE
104 $(MAKE) toolchain/download
105 $(MAKE) package/download
106 $(MAKE) target/download
107
108 ifeq ($(FORCE),)
109 .config ./scripts/config/conf ./scripts/config/mconf: .prereq-build
110 world: .prereq-packages
111 endif
112
113 world: .config FORCE
114 $(MAKE) toolchain/install
115 $(MAKE) target/compile
116 $(MAKE) package/compile
117 $(MAKE) package/install
118 $(MAKE) target/install
119
120 clean: FORCE
121 rm -rf build_* bin
122
123 dirclean: clean
124 rm -rf staging_dir_* toolchain_build_*
125
126 distclean: dirclean config-clean
127 rm -rf dl .*config* .pkg* .prereq
128
129
130 .SILENT: clean dirclean distclean config-clean download world
131 .PHONY: FORCE
132 FORCE:
This page took 0.046264 seconds and 5 git commands to generate.