| 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} --no-print-directory |
|---|
| 10 |
|
|---|
| 11 |
all: .prereq_done |
|---|
| 12 |
@${GMAKE_INV} all |
|---|
| 13 |
|
|---|
| 14 |
v: .prereq_done |
|---|
| 15 |
(echo; echo "Build started on $$(LC_ALL=C TZ=UTC date)"; set -x; \ |
|---|
| 16 |
${GMAKE_FMK} all V=99) 2>&1 | tee -a make.log |
|---|
| 17 |
|
|---|
| 18 |
help: |
|---|
| 19 |
@echo 'Cleaning targets:' |
|---|
| 20 |
@echo ' clean - Remove bin and build_dir directories' |
|---|
| 21 |
@echo ' cleandir - Same as "clean", but also remove built toolchain' |
|---|
| 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 ' allmodconfig - New config selecting modules when possible' |
|---|
| 30 |
@echo ' allnoconfig - New config where all options are answered with no' |
|---|
| 31 |
@echo '' |
|---|
| 32 |
@echo 'Other generic targets:' |
|---|
| 33 |
@echo ' all - Build everything as specified in .config' |
|---|
| 34 |
@echo ' (default if .config exists)' |
|---|
| 35 |
@echo ' v - Same as "all" but with logging to make.log enabled' |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
verbose: .prereq_done |
|---|
| 39 |
@${GMAKE_FMK} all V=99 |
|---|
| 40 |
|
|---|
| 41 |
clean: .prereq_done |
|---|
| 42 |
@${GMAKE_INV} clean |
|---|
| 43 |
|
|---|
| 44 |
cleanbuild: .prereq_done |
|---|
| 45 |
@${GMAKE_INV} cleanbuild |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
config: .prereq_done |
|---|
| 49 |
@${GMAKE_INV} config |
|---|
| 50 |
|
|---|
| 51 |
cleandir: .prereq_done |
|---|
| 52 |
@${GMAKE_INV} cleandir |
|---|
| 53 |
@-rm -rf lbin |
|---|
| 54 |
@-rm -f make.log .prereq_done |
|---|
| 55 |
|
|---|
| 56 |
distclean: .prereq_done |
|---|
| 57 |
@${GMAKE_INV} distclean |
|---|
| 58 |
@-rm -rf lbin |
|---|
| 59 |
@-rm -f make.log .prereq_done |
|---|
| 60 |
|
|---|
| 61 |
image_clean: .prereq_done |
|---|
| 62 |
@${GMAKE_INV} image_clean |
|---|
| 63 |
|
|---|
| 64 |
menuconfig: .prereq_done |
|---|
| 65 |
@${GMAKE_INV} menuconfig |
|---|
| 66 |
|
|---|
| 67 |
allnoconfig: .prereq_done |
|---|
| 68 |
@${GMAKE_INV} allnoconfig |
|---|
| 69 |
|
|---|
| 70 |
allmodconfig: .prereq_done |
|---|
| 71 |
@${GMAKE_INV} allmodconfig |
|---|
| 72 |
|
|---|
| 73 |
snapshotconfig: .prereq_done |
|---|
| 74 |
@${GMAKE_INV} snapshotconfig |
|---|
| 75 |
|
|---|
| 76 |
package_index: .prereq_done |
|---|
| 77 |
@${GMAKE_INV} package_index |
|---|
| 78 |
|
|---|
| 79 |
target_clean: .prereq_done |
|---|
| 80 |
@${GMAKE_INV} target_clean |
|---|
| 81 |
|
|---|
| 82 |
world: .prereq_done |
|---|
| 83 |
@${GMAKE_INV} world |
|---|
| 84 |
|
|---|
| 85 |
allpackages: .prereq_done |
|---|
| 86 |
@${GMAKE_INV} allpackages |
|---|
| 87 |
|
|---|
| 88 |
prereq: |
|---|
| 89 |
@rm -f .prereq_done |
|---|
| 90 |
@${MAKE} .prereq_done |
|---|
| 91 |
|
|---|
| 92 |
prereq-noerror: |
|---|
| 93 |
@rm -f .prereq_done |
|---|
| 94 |
@${MAKE} .prereq_done NO_ERROR=1 |
|---|
| 95 |
|
|---|
| 96 |
NO_ERROR=0 |
|---|
| 97 |
.prereq_done: |
|---|
| 98 |
@-rm -rf .prereq_done lbin |
|---|
| 99 |
@if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \ |
|---|
| 100 |
echo "FreeWRT requires GNU bash to be installed, sorry."; \ |
|---|
| 101 |
exit 1; \ |
|---|
| 102 |
fi |
|---|
| 103 |
@mkdir lbin |
|---|
| 104 |
@if which nonexistent 2>&1 | grep -q '^no '; then \ |
|---|
| 105 |
cp scripts/which.mac lbin/which; \ |
|---|
| 106 |
chmod 555 lbin/which; \ |
|---|
| 107 |
else \ |
|---|
| 108 |
ln -s $$(which which) lbin/which; \ |
|---|
| 109 |
fi |
|---|
| 110 |
@if lbin/which gmake >/dev/null 2>&1; then \ |
|---|
| 111 |
ln -s $$(lbin/which gmake) lbin/gmake; \ |
|---|
| 112 |
else \ |
|---|
| 113 |
ln -s $$(lbin/which make) lbin/gmake; \ |
|---|
| 114 |
fi |
|---|
| 115 |
@if ! lbin/which md5sum >/dev/null 2>&1; then \ |
|---|
| 116 |
cp scripts/md5sum.bsd lbin/md5sum; \ |
|---|
| 117 |
chmod 555 lbin/md5sum; \ |
|---|
| 118 |
fi |
|---|
| 119 |
@if test x"$$(uname)" = x"MirBSD"; then \ |
|---|
| 120 |
sed -e 's!@@FromOS@@!MirBSD!g' -e 's!@@ToOS@@!OpenBSD!g' \ |
|---|
| 121 |
-e "s!@@PROG@@!$$(lbin/which uname)!g" \ |
|---|
| 122 |
<scripts/uname.fake >lbin/uname; \ |
|---|
| 123 |
chmod 555 lbin/uname; \ |
|---|
| 124 |
fi |
|---|
| 125 |
@echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk |
|---|
| 126 |
@echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk |
|---|
| 127 |
@echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk |
|---|
| 128 |
@echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \ |
|---|
| 129 |
-e 's!mirbsd!openbsd!g' \ |
|---|
| 130 |
)" >>lbin/prereq.mk |
|---|
| 131 |
@echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \ |
|---|
| 132 |
-e 's/sparc.*/sparc/' \ |
|---|
| 133 |
-e 's/arm.*/arm/g' \ |
|---|
| 134 |
-e 's/m68k.*/m68k/' \ |
|---|
| 135 |
-e 's/ppc/powerpc/g' \ |
|---|
| 136 |
-e 's/v850.*/v850/g' \ |
|---|
| 137 |
-e 's/sh[234]/sh/' \ |
|---|
| 138 |
-e 's/mips-.*/mips/' \ |
|---|
| 139 |
-e 's/mipsel-.*/mipsel/' \ |
|---|
| 140 |
-e 's/cris.*/cris/' \ |
|---|
| 141 |
-e 's/i[3-9]86/i386/' \ |
|---|
| 142 |
)" >>lbin/prereq.mk |
|---|
| 143 |
@echo 'HOSTCC:=${CC}' >>lbin/prereq.mk |
|---|
| 144 |
@x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \ |
|---|
| 145 |
${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \ |
|---|
| 146 |
2>/dev/null | sed 's/^P://')"; \ |
|---|
| 147 |
echo "HOSTCFLAGS:=$${x:--O2 ${CFLAGS}}" | sed 's/ *$$//' \ |
|---|
| 148 |
>>lbin/prereq.mk |
|---|
| 149 |
@echo 'LC_ALL:=C' >>lbin/prereq.mk |
|---|
| 150 |
@echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk |
|---|
| 151 |
@echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk |
|---|
| 152 |
@echo "_PATH:=$$PATH" >>lbin/prereq.mk |
|---|
| 153 |
@echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk |
|---|
| 154 |
@echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk |
|---|
| 155 |
@TOPDIR=$$(readlink -nf .); \ |
|---|
| 156 |
printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \ |
|---|
| 157 |
"1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk |
|---|
| 158 |
@env NO_ERROR=${NO_ERROR} bash scripts/scan-tools.sh |
|---|
| 159 |
@ln -s $$(lbin/which ${CC}) lbin/gcc |
|---|
| 160 |
@${GMAKE_INV} tools/install-lbin |
|---|
| 161 |
@echo '===> Prerequisites checked successfully.' |
|---|
| 162 |
@touch $@ |
|---|
| 163 |
|
|---|
| 164 |
.PHONY: prereq prereq-noerror |
|---|