Merge branch 'master' of git+ssh://openadk.org/git/openadk
[openadk.git] / Makefile
blob9959e316972ff495dea767cfc169db7aedbbbe52
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= ulimit -dS $(shell ulimit -dH >/dev/null 2>/dev/null ) >/dev/null 2>/dev/null;
6 all: .prereq_done
7 @${_UNLIMIT} ${GMAKE_INV} all
9 v: .prereq_done
10 @(echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C date)"; \
11 set -x; ${_UNLIMIT} ${GMAKE_FMK} VERBOSE=1 all) 2>&1 | tee -a make.log
13 help:
14 @echo 'Common targets:'
15 @echo ' switch TARGET=targetname - Backup current config and copy old saved target config'
16 @echo ' download - fetches all needed distfiles'
17 @echo 'Cleaning targets:'
18 @echo ' clean - Remove bin and build_dir directories'
19 @echo ' cleantarget - Same as "clean", but also remove toolchain for target'
20 @echo ' cleandir - Same as "clean", but also remove all built toolchains'
21 @echo ' cleankernel - Remove kernel dir, useful if you changed any kernel patches'
22 @echo ' distclean - Same as "cleandir", but also remove downloaded'
23 @echo ' distfiles and .config'
24 @echo ''
25 @echo 'Configuration targets:'
26 @echo ' config - Update current config utilising a line-oriented program'
27 @echo ' menuconfig - Update current config utilising a menu based program'
28 @echo ' (default when .config does not exist)'
29 @echo ' oldconfig - Update current config utilising a provided .configs base'
30 @echo ' wconfig - Same as "oldconfig", but also writes out hidden symbols'
31 @echo ' allmodconfig - New config selecting all packages as modules when possible'
32 @echo ' allconfig - New config selecting all packages when possible'
33 @echo ' allnoconfig - New config where all options are answered with no'
34 @echo ' kernelconfig - Modify the target kernel configuration'
35 @echo ''
36 @echo 'Help targets:'
37 @echo ' help - Print this help text'
38 @echo ' pkg-help - Print help about selectively compiling single packages'
39 @echo ' dev-help - Print help for developers / package maintainers'
40 @echo ''
41 @echo 'Other generic targets:'
42 @echo ' all - Build everything as specified in .config'
43 @echo ' (default if .config exists)'
44 @echo ' v - Same as "all" but with logging to make.log enabled'
46 pkg-help:
47 @echo 'Package specific targets (use with "package=<pkg-name>" parameter):'
48 @echo ' fetch - Download the necessary distfile'
49 @echo ' extract - Same as "fetch", but also extract the distfile'
50 @echo ' patch - Same as "extract", but also patch the source'
51 @echo ' build - Same as "patch", but also build the binaries'
52 @echo ' fake - Same as "build", but also install the binaries'
53 @echo ' package - Same as "fake", but also create the package'
54 @echo ' clean - Deinstall and remove the build area'
55 @echo ' distclean - Same as "clean", but also remove the distfiles'
56 @echo ''
57 @echo 'Short package rebuilding guide:'
58 @echo ' run "make package=<pkgname> clean" to remove all generated binaries'
59 @echo ' run "make package=<pkgname> package" to build everything and create the package(s)'
60 @echo ''
61 @echo 'This does not automatically resolve package dependencies!'
63 dev-help:
64 @echo 'Regenerate menu information via "make menu"'
65 @echo 'Regenerate dependency information via "make dep"'
66 @echo
67 @echo 'Fast way of updating package patches:'
68 @echo ' run "make package=<pkgname> clean" to start with a good base'
69 @echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source'
70 @echo ' edit the package sources at build_dir/w-<pkgname>-*/<pkgname>-<version>'
71 @echo ' run "make package=<pkgname> update-patches" to regenerate patch files'
72 @echo ''
73 @echo 'All changed patches will be opened with your $$EDITOR,'
74 @echo 'so you can add a description and verify the modifications.'
75 @echo ''
76 @echo 'Adding a new package:'
77 @echo 'make PKG=foo VER=1.0 newpackage'
79 clean: .prereq_done
80 -@rm -f nohup.out
81 @${GMAKE_INV} clean
83 config: .prereq_done
84 @${GMAKE_INV} _config W=
86 oldconfig: .prereq_done
87 @${GMAKE_INV} _config W=-o
89 wconfig: .prereq_done
90 @${GMAKE_INV} _config W=-A
92 download: .prereq_done
93 @${GMAKE_INV} toolchain/download
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 cleantarget targetclean: .prereq_done
104 -@${GMAKE_INV} cleantarget
105 @-rm -f make.log
107 distclean cleandist:
108 -@${GMAKE_INV} distclean
109 @-rm -f make.log .prereq_done
111 image: .prereq_done
112 @${GMAKE_INV} image
114 switch: .prereq_done
115 @${GMAKE_INV} switch
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} _config W=-n
135 allconfig: .prereq_done
136 @${GMAKE_INV} _mconfig W=-y RCONFIG=Config.in
138 allmodconfig: .prereq_done
139 @${GMAKE_INV} _mconfig W=-o RCONFIG=Config.in
141 package_index: .prereq_done
142 @${GMAKE_INV} package_index
144 bulk: .prereq_done
145 @${GMAKE_INV} bulk
147 bulkall: .prereq_done
148 @${GMAKE_INV} bulkall
150 bulkallmod: .prereq_done
151 @${GMAKE_INV} bulkallmod
153 menu: .prereq_done
154 @${GMAKE_INV} menu
156 dep: .prereq_done
157 @${GMAKE_INV} dep
159 world: .prereq_done
160 @${GMAKE_INV} world
162 prereq:
163 @rm -f .prereq_done
164 @${GMAKE} .prereq_done
166 prereq-noerror:
167 @rm -f .prereq_done
168 @${GMAKE} .prereq_done NO_ERROR=1
170 NO_ERROR=0
171 .prereq_done:
172 @-rm -rf .prereq_done
173 @if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \
174 echo "GNU bash needs to be installed."; \
175 exit 1; \
177 @if ! mksh -c 'echo $$KSH_VERSION' 2>&1 | fgrep 'MIRBSD' >/dev/null 2>&1; then \
178 echo "MirBSD ksh (mksh) needs to be installed."; \
179 exit 1; \
180 else \
181 if [ $$(mksh -c 'echo $$KSH_VERSION' |cut -d ' ' -f 3|sed "s#R##") -le 34 ]; then \
182 echo "MirBSD ksh is too old. R35 or higher needed."; \
183 exit 1; \
184 fi \
186 @if test x"$$(umask 2>/dev/null | sed 's/00*22/OK/')" != x"OK"; then \
187 echo >&2 Error: you must build with umask 022, sorry.; \
188 exit 1; \
190 @echo "TOPDIR:=$$(readlink -nf . 2>/dev/null || pwd -P)" >prereq.mk
191 @echo "BASH:=$$(which bash)" >>prereq.mk
192 @if [ -z "$$(which gmake 2>/dev/null )" ]; then \
193 echo "GMAKE:=$$(which make)" >>prereq.mk ;\
194 else \
195 echo "GMAKE:=$$(which gmake)" >>prereq.mk ;\
197 @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine)" >>prereq.mk
198 @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
199 -e 's/sparc.*/sparc/' \
200 -e 's/arm.*/arm/g' \
201 -e 's/m68k.*/m68k/' \
202 -e 's/ppc/powerpc/g' \
203 -e 's/v850.*/v850/g' \
204 -e 's/sh[234]/sh/' \
205 -e 's/mips-.*/mips/' \
206 -e 's/mipsel-.*/mipsel/' \
207 -e 's/cris.*/cris/' \
208 -e 's/i[3-9]86/i386/' \
209 )" >>prereq.mk
210 @echo 'HOSTCC:=${CC}' >>prereq.mk
211 @echo 'HOSTCFLAGS:=-O2' >>prereq.mk
212 @echo 'LANGUAGE:=C' >>prereq.mk
213 @echo 'LC_ALL:=C' >>prereq.mk
214 @echo 'MAKE:=$${GMAKE}' >>prereq.mk
215 @echo "OStype:=$$(env uname)" >>prereq.mk
216 @echo "_PATH:=$$PATH" >>prereq.mk
217 @echo "PATH:=\$${TOPDIR}/scripts:$$PATH" >>prereq.mk
218 @echo "SHELL:=$$(which bash)" >>prereq.mk
219 @env NO_ERROR=${NO_ERROR} BASH="$$(which bash)" \
220 CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
221 bash scripts/scan-tools.sh
222 @echo '===> Prerequisites checked successfully.'
223 @touch $@
225 .PHONY: prereq prereq-noerror