| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
GMAKE?= $(PWD)/lbin/gmake |
|---|
| 8 |
GMAKE_FMK= ${GMAKE} -f $(PWD)/mk/build.mk |
|---|
| 9 |
GMAKE_INV= ${GMAKE_FMK} V=99 |
|---|
| 10 |
|
|---|
| 11 |
all verbose: .prereq_done |
|---|
| 12 |
@${GMAKE_INV} all |
|---|
| 13 |
|
|---|
| 14 |
v: .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 |
|
|---|
| 19 |
v_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 |
|
|---|
| 23 |
slow: |
|---|
| 24 |
@(nohup make v_q 2>&- & while sleep 2; do tail -n 3 make.log; done; :) |
|---|
| 25 |
|
|---|
| 26 |
help: |
|---|
| 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 |
@echo ' targz|tarbz2 - Create a distribution tarball (runs distclean)' |
|---|
| 53 |
|
|---|
| 54 |
pkg-help: |
|---|
| 55 |
@echo 'Package specific targets (use with "package=<pkg-name>" parameter):' |
|---|
| 56 |
@echo ' fetch - Download the necessary distfile' |
|---|
| 57 |
@echo ' extract - Same as "fetch", but also extract the distfile' |
|---|
| 58 |
@echo ' patch - Same as "extract", but also patch the source' |
|---|
| 59 |
@echo ' build - Same as "patch", but also build the binaries' |
|---|
| 60 |
@echo ' fake - Same as "build", but also install the binaries' |
|---|
| 61 |
@echo ' package - Same as "fake", but also create the ipkg package' |
|---|
| 62 |
@echo ' clean - Deinstall and remove the build area' |
|---|
| 63 |
@echo ' distclean - Same as "clean", but also remove the distfiles' |
|---|
| 64 |
@echo '' |
|---|
| 65 |
@echo 'Short package rebuilding guide:' |
|---|
| 66 |
@echo ' run "make package=<pkgname> clean" to remove all generated binaries' |
|---|
| 67 |
@echo ' run "make package=<pkgname> package" to build everything and create the ipkg' |
|---|
| 68 |
@echo '' |
|---|
| 69 |
@echo 'This does not automatically resolve package dependencies!' |
|---|
| 70 |
|
|---|
| 71 |
dev-help: |
|---|
| 72 |
@echo 'Fast way of updating package patches:' |
|---|
| 73 |
@echo ' run "make package=<pkgname> clean" to start with a good base' |
|---|
| 74 |
@echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source' |
|---|
| 75 |
@echo ' edit the package sources at build_dir/w-<pkgname>-*/<pkgname>-<version>' |
|---|
| 76 |
@echo ' run "make package=<pkgname> update-patches to regenerate patch files' |
|---|
| 77 |
@echo '' |
|---|
| 78 |
@echo 'All changed patches will be opened with your $$EDITOR,' |
|---|
| 79 |
@echo 'so you can add a description and verify the modifications.' |
|---|
| 80 |
|
|---|
| 81 |
clean: .prereq_done |
|---|
| 82 |
-rm -f nohup.out |
|---|
| 83 |
@${GMAKE_INV} clean |
|---|
| 84 |
|
|---|
| 85 |
config: .prereq_done |
|---|
| 86 |
@${GMAKE_INV} _config W= |
|---|
| 87 |
|
|---|
| 88 |
oldconfig: .prereq_done |
|---|
| 89 |
@${GMAKE_INV} _config W=-o |
|---|
| 90 |
|
|---|
| 91 |
wconfig: .prereq_done |
|---|
| 92 |
@${GMAKE_INV} _config W=-A |
|---|
| 93 |
|
|---|
| 94 |
snapshotupdate: .prereq_done |
|---|
| 95 |
@${GMAKE_INV} _config W=-a |
|---|
| 96 |
|
|---|
| 97 |
cleandir: .prereq_done |
|---|
| 98 |
-@${GMAKE_INV} clean cleandir |
|---|
| 99 |
@-rm -rf lbin |
|---|
| 100 |
@-rm -f make.log .prereq_done |
|---|
| 101 |
|
|---|
| 102 |
distclean: .prereq_done |
|---|
| 103 |
-@${GMAKE_INV} clean cleandir distclean |
|---|
| 104 |
@-rm -rf lbin tools/paxmirabilis/*.o target/extra |
|---|
| 105 |
@-rm -f make.log .prereq_done _pax* freewrt.tar.* |
|---|
| 106 |
|
|---|
| 107 |
image_clean: .prereq_done |
|---|
| 108 |
@${GMAKE_INV} image_clean |
|---|
| 109 |
|
|---|
| 110 |
menuconfig: .prereq_done |
|---|
| 111 |
@${GMAKE_INV} menuconfig |
|---|
| 112 |
|
|---|
| 113 |
allnoconfig: .prereq_done |
|---|
| 114 |
@${GMAKE_INV} _config W=-n |
|---|
| 115 |
|
|---|
| 116 |
allmodconfig: .prereq_done |
|---|
| 117 |
@${GMAKE_INV} _mconfig W=-o RCONFIG=Config.in |
|---|
| 118 |
|
|---|
| 119 |
package_index: .prereq_done |
|---|
| 120 |
@${GMAKE_INV} package_index |
|---|
| 121 |
|
|---|
| 122 |
world: .prereq_done |
|---|
| 123 |
@${GMAKE_INV} world |
|---|
| 124 |
|
|---|
| 125 |
prereq: |
|---|
| 126 |
@rm -f .prereq_done |
|---|
| 127 |
@${MAKE} .prereq_done |
|---|
| 128 |
|
|---|
| 129 |
prereq-noerror: |
|---|
| 130 |
@rm -f .prereq_done |
|---|
| 131 |
@${MAKE} .prereq_done NO_ERROR=1 |
|---|
| 132 |
|
|---|
| 133 |
NO_ERROR=0 |
|---|
| 134 |
.prereq_done: |
|---|
| 135 |
@-rm -rf .prereq_done lbin |
|---|
| 136 |
@if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \ |
|---|
| 137 |
echo "FreeWRT requires GNU bash to be installed, sorry."; \ |
|---|
| 138 |
exit 1; \ |
|---|
| 139 |
fi |
|---|
| 140 |
@if test x"$$(umask 2>/dev/null | sed 's/00*22/OK/')" != x"OK"; then \ |
|---|
| 141 |
echo >&2 Error: you must build with “umask 022”, sorry.; \ |
|---|
| 142 |
exit 1; \ |
|---|
| 143 |
fi |
|---|
| 144 |
@mkdir lbin |
|---|
| 145 |
@if which nonexistent 2>&1 | grep -q '^no '; then \ |
|---|
| 146 |
cp scripts/which.mac lbin/which; \ |
|---|
| 147 |
chmod 555 lbin/which; \ |
|---|
| 148 |
else \ |
|---|
| 149 |
ln -s $$(which which) lbin/which; \ |
|---|
| 150 |
fi |
|---|
| 151 |
@if ! lbin/which md5sum >/dev/null 2>&1; then \ |
|---|
| 152 |
cp scripts/md5sum.bsd lbin/md5sum; \ |
|---|
| 153 |
chmod 555 lbin/md5sum; \ |
|---|
| 154 |
fi |
|---|
| 155 |
@echo "TOPDIR:=$$(readlink -nf . 2>/dev/null || pwd -P)" >lbin/prereq.mk |
|---|
| 156 |
@echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk |
|---|
| 157 |
@echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk |
|---|
| 158 |
@echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \ |
|---|
| 159 |
-e 's!mirbsd!openbsd!g' \ |
|---|
| 160 |
)" >>lbin/prereq.mk |
|---|
| 161 |
@echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \ |
|---|
| 162 |
-e 's/sparc.*/sparc/' \ |
|---|
| 163 |
-e 's/arm.*/arm/g' \ |
|---|
| 164 |
-e 's/m68k.*/m68k/' \ |
|---|
| 165 |
-e 's/ppc/powerpc/g' \ |
|---|
| 166 |
-e 's/v850.*/v850/g' \ |
|---|
| 167 |
-e 's/sh[234]/sh/' \ |
|---|
| 168 |
-e 's/mips-.*/mips/' \ |
|---|
| 169 |
-e 's/mipsel-.*/mipsel/' \ |
|---|
| 170 |
-e 's/cris.*/cris/' \ |
|---|
| 171 |
-e 's/i[3-9]86/i386/' \ |
|---|
| 172 |
)" >>lbin/prereq.mk |
|---|
| 173 |
@echo 'HOSTCC:=${CC}' >>lbin/prereq.mk |
|---|
| 174 |
@x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \ |
|---|
| 175 |
${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \ |
|---|
| 176 |
2>/dev/null | sed 's/^P://')"; y='${CFLAGS}'; echo \ |
|---|
| 177 |
"HOSTCFLAGS:=$${x:-$${y:--O2}}" | sed 's/ *$$//' >>lbin/prereq.mk |
|---|
| 178 |
@echo 'LANGUAGE:=C' >>lbin/prereq.mk |
|---|
| 179 |
@echo 'LC_ALL:=C' >>lbin/prereq.mk |
|---|
| 180 |
@echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk |
|---|
| 181 |
@echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk |
|---|
| 182 |
@echo "_PATH:=$$PATH" >>lbin/prereq.mk |
|---|
| 183 |
@echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk |
|---|
| 184 |
@echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk |
|---|
| 185 |
@env NO_ERROR=${NO_ERROR} BASH="$$(lbin/which bash)" \ |
|---|
| 186 |
CC='${CC}' CPPFLAGS='${CPPFLAGS}' \ |
|---|
| 187 |
bash ${_PX} scripts/scan-tools.sh |
|---|
| 188 |
@TOPDIR=$$(readlink -nf . 2>/dev/null || pwd -P); \ |
|---|
| 189 |
printf '%s\n%s\nwq\n' ",g |
|---|
| 190 |
"1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk |
|---|
| 191 |
@cc='${CC}'; if test x"$$cc" = x"gcc"; then \ |
|---|
| 192 |
ln -s $$(lbin/which "$$cc") lbin/gcc; \ |
|---|
| 193 |
else \ |
|---|
| 194 |
( echo "#!$$(lbin/which bash)"; \ |
|---|
| 195 |
echo "export PATH=$$PATH"; \ |
|---|
| 196 |
echo "exec $$cc" '"$$@"' ) >lbin/gcc; \ |
|---|
| 197 |
chmod 555 lbin/gcc; \ |
|---|
| 198 |
fi |
|---|
| 199 |
@${GMAKE_INV} tools/install-lbin |
|---|
| 200 |
@echo '===> Prerequisites checked successfully.' |
|---|
| 201 |
@touch $@ |
|---|
| 202 |
|
|---|
| 203 |
_tarball: .prereq_done |
|---|
| 204 |
rm -f _pax* |
|---|
| 205 |
${GMAKE_INV} tools/paxmirabilis-compile |
|---|
| 206 |
install -c -m 555 tools_build/paxmirabilis/pax _pax |
|---|
| 207 |
${GMAKE_INV} distclean |
|---|
| 208 |
-rm -rf lbin |
|---|
| 209 |
-rm -f make.log .prereq_done freewrt.tar.* |
|---|
| 210 |
find . | \ |
|---|
| 211 |
grep -v -e '^.$$' -e '^./_pax' -e '^./prefs\.mk$$' -e '/\.svn' | \ |
|---|
| 212 |
sed -e 's |
|---|
| 213 |
sort >_pax.flst |
|---|
| 214 |
echo 'package/base-files/.svn/entries' >>_pax.flst |
|---|
| 215 |
echo 'toolchain/gcc/.svn/entries' >>_pax.flst |
|---|
| 216 |
|
|---|
| 217 |
targz: _tarball |
|---|
| 218 |
./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \ |
|---|
| 219 |
gzip -n9 >freewrt.tar.gz |
|---|
| 220 |
rm -f _pax* |
|---|
| 221 |
|
|---|
| 222 |
tarbz2: _tarball |
|---|
| 223 |
./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \ |
|---|
| 224 |
bzip2 --best >freewrt.tar.bz2 |
|---|
| 225 |
rm -f _pax* |
|---|
| 226 |
|
|---|
| 227 |
.PHONY: prereq prereq-noerror _tarball targz tarbz2 |
|---|