add fw_printenv/fw_setenv
[openadk.git] / Makefile
blob5ee53356baa11eedb44f8292f67e58d1fa6171ed
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 _UNLIMIT= __limit=$$(ulimit -dH 2>/dev/null); \
5 test -n "$$__limit" && ulimit -Sd $$__limit; ulimit -n 1024;
7 all: .prereq_done checkreloc
8 @${_UNLIMIT} ${GMAKE_INV} all
10 v: .prereq_done
11 @(echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C date)"; \
12 set -x; ${_UNLIMIT} ${GMAKE_FMK} ADK_VERBOSE=1 all) 2>&1 | tee -a make.log
14 help:
15 @echo 'Configuration targets:'
16 @echo ' config - Update current config utilising a line-oriented program'
17 @echo ' menuconfig - Update current config utilising a menu based program'
18 @echo ' (default when .config does not exist)'
19 @echo ' oldconfig - Update current config utilising a provided .configs base'
20 @echo ' defconfig - New config with defaults'
21 @echo ' allmodconfig - New config selecting all symbols with m'
22 @echo ' allyesconfig - New config selecting all symbols with y'
23 @echo ' allnoconfig - New config where all options are answered with no'
24 @echo ''
25 @echo 'Help targets:'
26 @echo ' help - Print this help text'
27 @echo ' pkg-help - Print help about selectively compiling single packages'
28 @echo ' dev-help - Print help for developers / package maintainers'
29 @echo ''
30 @echo 'Common targets:'
31 @echo ' download - fetches all needed distfiles'
32 @echo ' kernelconfig - view the target kernel configuration'
33 @echo ''
34 @echo 'Cleaning targets:'
35 @echo ' clean - Remove firmware and build directories'
36 @echo ' cleandir - Same as "clean", but also remove all built toolchains'
37 @echo ' cleansystem - Same as "cleandir", but only remove active system'
38 @echo ' cleankernel - Remove kernel dir, useful if you changed any kernel patches'
39 @echo ' distclean - Same as "cleandir", but also remove downloaded'
40 @echo ' distfiles and .config'
41 @echo ''
42 @echo 'Other generic targets:'
43 @echo ' all - Build everything as specified in .config'
44 @echo ' (default if .config exists)'
45 @echo ' v - Same as "all" but with logging to make.log enabled'
47 pkg-help:
48 @echo 'Package specific targets (use with "package=<pkg-name>" parameter):'
49 @echo ' fetch - Download the necessary distfile'
50 @echo ' extract - Same as "fetch", but also extract the distfile'
51 @echo ' patch - Same as "extract", but also patch the source'
52 @echo ' build - Same as "patch", but also build the binaries'
53 @echo ' fake - Same as "build", but also install the binaries'
54 @echo ' package - Same as "fake", but also create the package'
55 @echo ' clean - Deinstall and remove the build area'
56 @echo ' distclean - Same as "clean", but also remove the distfiles'
57 @echo ''
58 @echo 'Short package rebuilding guide:'
59 @echo ' run "make package=<pkgname> clean" to remove all generated binaries'
60 @echo ' run "make package=<pkgname> package" to build everything and create the package(s)'
61 @echo ''
62 @echo 'This does not automatically resolve package dependencies!'
64 dev-help:
65 @echo 'Fast way of updating package patches:'
66 @echo ' run "make package=<pkgname> clean" to start with a good base'
67 @echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source'
68 @echo ' edit the package sources at build_dir/w-<pkgname>-*/<pkgname>-<version>'
69 @echo ' run "make package=<pkgname> update-patches" to regenerate patch files'
70 @echo ''
71 @echo 'All changed patches will be opened with your $$EDITOR,'
72 @echo 'so you can add a description and verify the modifications.'
73 @echo ''
74 @echo 'Adding a new package:'
75 @echo 'make PKG=foo VER=1.0 newpackage'
76 @echo 'Adding a new simple library package:'
77 @echo 'make PKG=foo VER=1.0 TYPE=lib newpackage'
78 @echo 'Adding a new simple program package:'
79 @echo 'make PKG=foo VER=1.0 TYPE=prog newpackage'
81 clean: .prereq_done
82 -@rm -f nohup.out
83 @${GMAKE_INV} clean
85 config: .prereq_done
86 @${GMAKE_INV} _config W=
88 oldconfig: .prereq_done
89 @${GMAKE_INV} _config W=--oldconfig
91 download: .prereq_done
92 @${GMAKE_INV} toolchain/download
93 @${GMAKE_INV} dep
94 @${GMAKE_INV} package/download
96 cleankernel kernelclean: .prereq_done
97 -@${GMAKE_INV} cleankernel
99 cleandir dirclean: .prereq_done
100 -@${GMAKE_INV} cleandir
101 @-rm -f make.log .prereq_done
103 cleansystem: .prereq_done
104 -@${GMAKE_INV} cleansystem
105 @-rm -f make.log .prereq_done
107 distclean cleandist:
108 -@${GMAKE_INV} distclean
109 @-rm -f make.log .prereq_done
111 image: .prereq_done
112 @${GMAKE_INV} image
114 targethelp: .prereq_done
115 @${GMAKE_INV} targethelp
117 kernelconfig: .prereq_done
118 @${GMAKE_INV} kernelconfig
120 newpackage: .prereq_done
121 @${GMAKE_INV} newpackage
123 image_clean imageclean cleanimage: .prereq_done
124 @${GMAKE_INV} image_clean
126 menuconfig: .prereq_done
127 @${GMAKE_INV} menuconfig
129 defconfig: .prereq_done
130 @${GMAKE_INV} defconfig
132 allnoconfig: .prereq_done
133 @${GMAKE_INV} KCONFIG_ALLCONFIG=all.config _config W=--allnoconfig
135 allyesconfig: .prereq_done
136 @${GMAKE_INV} KCONFIG_ALLCONFIG=all.config _config W=--allyesconfig
138 allmodconfig: .prereq_done
139 @${GMAKE_INV} KCONFIG_ALLCONFIG=all.config _config W=--allmodconfig
141 package_index: .prereq_done
142 @${GMAKE_INV} package_index
144 buildall: .prereq_done
145 @${GMAKE_INV} buildall
147 check: .prereq_done
148 @${GMAKE_INV} check
150 check-gcc: .prereq_done
151 @${GMAKE_INV} check-gcc
153 check-g++: .prereq_done
154 @${GMAKE_INV} check-g++
156 menu: .prereq_done
157 @${GMAKE_INV} menu
159 dep: .prereq_done
160 @${GMAKE_INV} dep
162 world: .prereq_done
163 @${GMAKE_INV} world
165 prereq:
166 @rm -f .prereq_done
167 @${GMAKE} .prereq_done
169 prereq-noerror:
170 @rm -f .prereq_done
171 @${GMAKE} .prereq_done NO_ERROR=1
173 NO_ERROR=0
174 .prereq_done:
175 @-rm -rf .prereq_done
176 @if ! bash --version 2>&1 | grep -F 'GNU bash' >/dev/null 2>&1; then \
177 echo "GNU bash needs to be installed."; \
178 exit 1; \
180 @echo "ADK_TOPDIR:=$$(readlink -nf . 2>/dev/null || pwd -P)" >prereq.mk
181 @echo "BASH:=$$(which bash)" >>prereq.mk
182 @if [ -z "$$(which gmake 2>/dev/null )" ]; then \
183 echo "GMAKE:=$$(which make)" >>prereq.mk ;\
184 else \
185 echo "GMAKE:=$$(which gmake)" >>prereq.mk ;\
187 @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine)" >>prereq.mk
188 @echo "ARCH_FOR_BUILD:=$$(${CC} -dumpmachine | sed \
189 -e 's/x86_64-linux-gnux32/x32/' \
190 -e s'/-.*//' \
191 -e 's/sparc.*/sparc/' \
192 -e 's/armeb.*/armeb/g' \
193 -e 's/arm.*/arm/g' \
194 -e 's/m68k.*/m68k/' \
195 -e 's/sh[234]/sh/' \
196 -e 's/mips-.*/mips/' \
197 -e 's/mipsel-.*/mipsel/' \
198 -e 's/i[3-9]86/x86/' \
199 )" >>prereq.mk
200 @echo 'HOST_CC:=${CC}' >>prereq.mk
201 @echo 'HOST_CXX:=${CXX}' >>prereq.mk
202 @echo 'LANGUAGE:=C' >>prereq.mk
203 @echo 'LC_ALL:=C' >>prereq.mk
204 @echo 'MAKE:=$${GMAKE}' >>prereq.mk
205 @echo "OStype:=$$(env uname)" >>prereq.mk
206 @echo "_PATH:=$$PATH" >>prereq.mk
207 @echo "PATH:=\$${ADK_TOPDIR}/scripts:/usr/sbin:$$PATH" >>prereq.mk
208 @echo "SHELL:=$$(which bash)" >>prereq.mk
209 @echo "GIT:=$$(which git 2>/dev/null)" >>prereq.mk
210 @env NO_ERROR=${NO_ERROR} BASH="$$(which bash)" \
211 CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
212 bash scripts/scan-tools.sh
213 @echo '===> Prerequisites checked successfully.'
214 @touch .adkinit
215 @touch $@
217 checkreloc:
218 @bash scripts/reloc.sh
220 .PHONY: prereq prereq-noerror checkreloc
221 # DO NOT DELETE