trivial changes
[librecmc/librecmc.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
18 all: world
19
20 SHELL:=/usr/bin/env bash
21 export LC_ALL=C
22 export LANG=C
23 export TOPDIR=${CURDIR}
24 ifeq ($(KBUILD_VERBOSE),99)
25   MAKE:=3>/dev/null $(MAKE)
26 endif
27 export IS_TTY=$(shell tty -s && echo 1 || echo 0)
28
29 include $(TOPDIR)/include/verbose.mk
30
31 OPENWRTVERSION:=$(RELEASE)
32 ifneq ($(VERSION),)
33   OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
34 else
35   REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
36   ifneq ($(REV),)
37     OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
38   endif
39 endif
40 export OPENWRTVERSION
41
42 ifneq ($(shell ./scripts/timestamp.pl -p tmp/.pkginfo package scripts include),tmp/.pkginfo)
43   tmp/.pkginfo: FORCE
44 endif
45
46 ifneq ($(shell ./scripts/timestamp.pl -p tmp/.targetinfo target/linux scripts include),tmp/.targetinfo)
47   tmp/.targetinfo: FORCE
48 endif
49
50 ifeq ($(FORCE),)
51   .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
52   world: tmp/.prereq-packages tmp/.prereq-target
53 endif
54
55 tmp/.pkginfo:
56         @mkdir -p tmp
57         @echo Collecting package info...
58         @-for dir in package/*/; do \
59                 [ -f "$${dir}/Makefile" ] || continue; \
60                 echo Source-Makefile: $${dir}Makefile; \
61                 $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir 3>/dev/null || echo "ERROR: please fix $${dir}Makefile" >&2; \
62                 echo; \
63         done > $@
64
65 tmp/.targetinfo:
66         @mkdir -p tmp
67         @echo Collecting target info...
68         @-for dir in target/linux/*/; do \
69                 [ -f "$${dir}/Makefile" ] || continue; \
70                 ( cd "$$dir"; $(NO_TRACE_MAKE) --no-print-dir DUMP=1 3>/dev/null || echo "ERROR: please fix $${dir}Makefile" >&2 ); \
71                 echo; \
72         done > $@
73
74 tmpinfo-clean: FORCE
75         @-rm -rf tmp/.pkginfo tmp/.targetinfo
76
77 tmp/.config.in: tmp/.pkginfo
78         @./scripts/gen_package_config.pl < $< > $@ || rm -f $@
79
80 tmp/.config-target.in: tmp/.targetinfo
81         @./scripts/gen_target_config.pl < $< > $@ || rm -f $@
82
83 .config: ./scripts/config/conf tmp/.config.in tmp/.config-target.in
84         @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
85         @$< -D .config Config.in &> /dev/null
86
87 scripts/config/mconf:
88         @$(MAKE) -C scripts/config all
89
90 scripts/config/conf:
91         @$(MAKE) -C scripts/config conf
92
93 config: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
94         $< Config.in
95
96 config-clean: FORCE
97         $(NO_TRACE_MAKE) -C scripts/config clean
98
99 defconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
100         touch .config
101         $< -D .config Config.in
102
103 oldconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
104         $< -o Config.in
105
106 menuconfig: scripts/config/mconf tmp/.config.in tmp/.config-target.in FORCE
107         $< Config.in
108
109 package/%: tmp/.pkginfo tmp/.targetinfo FORCE
110         $(MAKE) -C package $(patsubst package/%,%,$@)
111
112 target/%: tmp/.pkginfo tmp/.targetinfo FORCE
113         $(MAKE) -C target $(patsubst target/%,%,$@)
114
115 tools/%: FORCE
116         $(MAKE) -C tools $(patsubst tools/%,%,$@)
117
118 toolchain/%: tmp/.targetinfo FORCE
119         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
120
121 tmp/.prereq-build: include/prereq-build.mk
122         @mkdir -p tmp
123         @rm -f tmp/.host.mk
124         @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
125                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
126                 false; \
127         }
128         @touch $@
129
130 tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
131         @mkdir -p tmp
132         @rm -f tmp/.host.mk
133         @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
134                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
135                 false; \
136         }
137         @touch $@
138
139 tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
140         @mkdir -p tmp
141         @rm -f tmp/.host.mk
142         @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
143                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
144                 false; \
145         }
146         @touch $@
147
148 prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
149
150 download: .config FORCE
151         $(MAKE) tools/download
152         $(MAKE) toolchain/download
153         $(MAKE) package/download
154         $(MAKE) target/download
155
156 world: .config FORCE
157         $(MAKE) tools/install
158         $(MAKE) toolchain/install
159         $(MAKE) target/compile
160         $(MAKE) package/compile
161         $(MAKE) package/install
162         $(MAKE) target/install
163         $(MAKE) package/index
164
165 clean: FORCE
166         rm -rf build_* bin tmp
167
168 dirclean: clean
169         rm -rf staging_dir_* toolchain_build_* tool_build
170
171 distclean: dirclean config-clean
172         rm -rf dl
173
174 .SILENT: clean dirclean distclean config-clean download world
175 FORCE: ;
176 .PHONY: FORCE
177 %: ;