source: freewrt/Makefile@ 654cb9c

Last change on this file since 654cb9c was 654cb9c, checked in by Thorsten Glaser <tg@…>, 19 years ago

optimise

git-svn-id: svn://www.freewrt.org/trunk/freewrt@2631 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 6.9 KB
Line 
1# $FreeWRT$
2#-
3# This file is part of the FreeWRT project. FreeWRT is copyrighted
4# material, please see the LICENCE file in the top-level directory
5# or at http://www.freewrt.org/licence for details.
6
7GMAKE?= $(PWD)/lbin/gmake
8GMAKE_FMK= ${GMAKE} -f $(PWD)/mk/build.mk
9GMAKE_INV= ${GMAKE_FMK} V=99
10
11all verbose: .prereq_done
12 @${GMAKE_INV} all
13
14v: .prereq_done
15 @(echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C TZ=UTC date)"; \
16 set -x; ${GMAKE_FMK} V=99 all) 2>&1 | tee -a make.log
17
18# this is not to be called by the user
19v_q: .prereq_done
20 @(echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C TZ=UTC date)"; \
21 set -x; ${GMAKE_FMK} V=99 all) >>make.log 2>&1
22
23slow:
24 @(nohup make v_q 2>&- & while sleep 2; do tail -n 3 make.log; done; :)
25
26help:
27 @echo 'Cleaning targets:'
28 @echo ' clean - Remove bin and build_dir directories'
29 @echo ' cleandir - Same as "clean", but also remove built toolchain'
30 @echo ' distclean - Same as "cleandir", but also remove downloaded'
31 @echo ' distfiles and .config'
32 @echo ''
33 @echo 'Configuration targets:'
34 @echo ' config - Update current config utilising a line-oriented program'
35 @echo ' menuconfig - Update current config utilising a menu based program'
36 @echo ' (default when .config does not exist)'
37 @echo ' oldconfig - Update current config utilising a provided .configs base'
38 @echo ' wconfig - Same as "oldconfig", but also writes out hidden symbols'
39 @echo ' allmodconfig - New config selecting modules when possible'
40 @echo ' allnoconfig - New config where all options are answered with no'
41 @echo ''
42 @echo 'Help targets:'
43 @echo ' help - Print this help text'
44 @echo ' pkg-help - Print help about selectively compiling single packages'
45 @echo ' dev-help - Print help for developers / package maintainers'
46 @echo ''
47 @echo 'Other generic targets:'
48 @echo ' all - Build everything as specified in .config'
49 @echo ' (default if .config exists)'
50 @echo ' v - Same as "all" but with logging to make.log enabled'
51 @echo ' slow - Same, but with sparse output for slow serial lines'
52
53pkg-help:
54 @echo 'Package specific targets (use with "package=<pkg-name>" parameter):'
55 @echo ' fetch - Download the necessary distfile'
56 @echo ' extract - Same as "fetch", but also extract the distfile'
57 @echo ' patch - Same as "extract", but also patch the source'
58 @echo ' build - Same as "patch", but also build the binaries'
59 @echo ' fake - Same as "build", but also install the binaries'
60 @echo ' package - Same as "fake", but also create the ipkg package'
61 @echo ''
62 @echo 'Short package rebuilding guide:'
63 @echo ' run "make package=<pkgname> clean" to remove all generated binaries'
64 @echo ' run "make package=<pkgname> package" to build everything and create the ipkg'
65 @echo ''
66 @echo 'This does not automatically resolve package dependencies!'
67
68dev-help:
69 @echo 'Fast way of updating package patches:'
70 @echo ' run "make package=<pkgname> clean" to start with a good base'
71 @echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source'
72 @echo ' edit the package sources at build_dir/w-<pkgname>-*/<pkgname>-<version>'
73 @echo ' run "make package=<pkgname> update-patches to regenerate patch files'
74 @echo ''
75 @echo 'All changed patches will be opened with your $$EDITOR,'
76 @echo 'so you can add a description and verify the modifications.'
77
78clean: .prereq_done
79 -rm -f nohup.out
80 @${GMAKE_INV} clean
81
82config: .prereq_done
83 @${GMAKE_INV} _config W=
84
85oldconfig: .prereq_done
86 @${GMAKE_INV} _config W=-o
87
88wconfig: .prereq_done
89 @${GMAKE_INV} _config W=-A
90
91cleandir: .prereq_done
92 @${GMAKE_INV} cleandir
93 @-rm -rf lbin
94 @-rm -f make.log .prereq_done
95
96distclean: .prereq_done
97 @${GMAKE_INV} distclean
98 @-rm -rf lbin
99 @-rm -f make.log .prereq_done
100
101image_clean: .prereq_done
102 @${GMAKE_INV} image_clean
103
104menuconfig: .prereq_done
105 @${GMAKE_INV} menuconfig
106
107allnoconfig: .prereq_done
108 @${GMAKE_INV} _config W=-n
109
110allmodconfig: .prereq_done
111 @${GMAKE_INV} _mconfig W=-o RCONFIG=Config.in
112
113snapshotconfig: .prereq_done
114 @${GMAKE_INV} _mconfig W=-o RCONFIG=Config.in.snapshot
115
116package_index: .prereq_done
117 @${GMAKE_INV} package_index
118
119world: .prereq_done
120 @${GMAKE_INV} world
121
122prereq:
123 @rm -f .prereq_done
124 @${MAKE} .prereq_done
125
126prereq-noerror:
127 @rm -f .prereq_done
128 @${MAKE} .prereq_done NO_ERROR=1
129
130NO_ERROR=0
131.prereq_done:
132 @-rm -rf .prereq_done lbin
133 @if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \
134 echo "FreeWRT requires GNU bash to be installed, sorry."; \
135 exit 1; \
136 fi
137 @mkdir lbin
138 @if which nonexistent 2>&1 | grep -q '^no '; then \
139 cp scripts/which.mac lbin/which; \
140 chmod 555 lbin/which; \
141 else \
142 ln -s $$(which which) lbin/which; \
143 fi
144 @if ! lbin/which md5sum >/dev/null 2>&1; then \
145 cp scripts/md5sum.bsd lbin/md5sum; \
146 chmod 555 lbin/md5sum; \
147 fi
148 @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
149 @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
150 @if lbin/which mksh >/dev/null 2>&1; then \
151 echo "MBSH:=$$(lbin/which mksh)" >>lbin/prereq.mk; \
152 else \
153 echo "MBSH:=$$(lbin/which bash)" >>lbin/prereq.mk; \
154 fi
155 @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
156 @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
157 -e 's!mirbsd!openbsd!g' \
158 )" >>lbin/prereq.mk
159 @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
160 -e 's/sparc.*/sparc/' \
161 -e 's/arm.*/arm/g' \
162 -e 's/m68k.*/m68k/' \
163 -e 's/ppc/powerpc/g' \
164 -e 's/v850.*/v850/g' \
165 -e 's/sh[234]/sh/' \
166 -e 's/mips-.*/mips/' \
167 -e 's/mipsel-.*/mipsel/' \
168 -e 's/cris.*/cris/' \
169 -e 's/i[3-9]86/i386/' \
170 )" >>lbin/prereq.mk
171 @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
172 @x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \
173 ${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \
174 2>/dev/null | sed 's/^P://')"; y='${CFLAGS}'; echo \
175 "HOSTCFLAGS:=$${x:-$${y:--O2}}" | sed 's/ *$$//' >>lbin/prereq.mk
176 @echo 'LANGUAGE:=C' >>lbin/prereq.mk
177 @echo 'LC_ALL:=C' >>lbin/prereq.mk
178 @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
179 @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
180 @echo "_PATH:=$$PATH" >>lbin/prereq.mk
181 @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
182 @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
183 @TOPDIR=$$(readlink -nf .); \
184 printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
185 "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
186 @env NO_ERROR=${NO_ERROR} BASH="$$(lbin/which bash)" \
187 CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
188 bash ${_PX} scripts/scan-tools.sh
189 @cc='${CC}'; if test x"$$cc" = x"gcc"; then \
190 ln -s $$(lbin/which "$$cc") lbin/gcc; \
191 else \
192 ( echo "#!$$(lbin/which bash)"; \
193 echo "export PATH=$$PATH"; \
194 echo "exec $$cc" '"$$@"' ) >lbin/gcc; \
195 chmod 555 lbin/gcc; \
196 fi
197 @${GMAKE_INV} tools/install-lbin
198 @echo '===> Prerequisites checked successfully.'
199 @touch $@
200
201.PHONY: prereq prereq-noerror
Note: See TracBrowser for help on using the repository browser.