| 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 |
|
|---|
| 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 | @echo ' targz|tarbz2 - Create a distribution tarball (runs distclean)'
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | verbose: .prereq_done
|
|---|
| 40 | @${GMAKE_FMK} all V=99
|
|---|
| 41 |
|
|---|
| 42 | clean: .prereq_done
|
|---|
| 43 | @${GMAKE_INV} clean
|
|---|
| 44 |
|
|---|
| 45 | cleanbuild: .prereq_done
|
|---|
| 46 | @${GMAKE_INV} cleanbuild
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | config: .prereq_done
|
|---|
| 50 | @${GMAKE_INV} config
|
|---|
| 51 |
|
|---|
| 52 | cleandir: .prereq_done
|
|---|
| 53 | @${GMAKE_INV} cleandir
|
|---|
| 54 | @-rm -rf lbin
|
|---|
| 55 | @-rm -f make.log .prereq_done
|
|---|
| 56 |
|
|---|
| 57 | distclean: .prereq_done
|
|---|
| 58 | @${GMAKE_INV} distclean
|
|---|
| 59 | @-rm -rf lbin
|
|---|
| 60 | @-rm -f make.log .prereq_done _pax* freewrt.tar.*
|
|---|
| 61 |
|
|---|
| 62 | image_clean: .prereq_done
|
|---|
| 63 | @${GMAKE_INV} image_clean
|
|---|
| 64 |
|
|---|
| 65 | menuconfig: .prereq_done
|
|---|
| 66 | @${GMAKE_INV} menuconfig
|
|---|
| 67 |
|
|---|
| 68 | allnoconfig: .prereq_done
|
|---|
| 69 | @${GMAKE_INV} allnoconfig
|
|---|
| 70 |
|
|---|
| 71 | allmodconfig: .prereq_done
|
|---|
| 72 | @${GMAKE_INV} allmodconfig
|
|---|
| 73 |
|
|---|
| 74 | snapshotconfig: .prereq_done
|
|---|
| 75 | @${GMAKE_INV} snapshotconfig
|
|---|
| 76 |
|
|---|
| 77 | package_index: .prereq_done
|
|---|
| 78 | @${GMAKE_INV} package_index
|
|---|
| 79 |
|
|---|
| 80 | target_clean: .prereq_done
|
|---|
| 81 | @${GMAKE_INV} target_clean
|
|---|
| 82 |
|
|---|
| 83 | world: .prereq_done
|
|---|
| 84 | @${GMAKE_INV} world
|
|---|
| 85 |
|
|---|
| 86 | allpackages: .prereq_done
|
|---|
| 87 | @${GMAKE_INV} allpackages
|
|---|
| 88 |
|
|---|
| 89 | prereq:
|
|---|
| 90 | @rm -f .prereq_done
|
|---|
| 91 | @${MAKE} .prereq_done
|
|---|
| 92 |
|
|---|
| 93 | prereq-noerror:
|
|---|
| 94 | @rm -f .prereq_done
|
|---|
| 95 | @${MAKE} .prereq_done NO_ERROR=1
|
|---|
| 96 |
|
|---|
| 97 | NO_ERROR=0
|
|---|
| 98 | .prereq_done:
|
|---|
| 99 | @-rm -rf .prereq_done lbin
|
|---|
| 100 | @if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \
|
|---|
| 101 | echo "FreeWRT requires GNU bash to be installed, sorry."; \
|
|---|
| 102 | exit 1; \
|
|---|
| 103 | fi
|
|---|
| 104 | @mkdir lbin
|
|---|
| 105 | @cp scripts/makeinfo lbin/makeinfo
|
|---|
| 106 | @if which nonexistent 2>&1 | grep -q '^no '; then \
|
|---|
| 107 | cp scripts/which.mac lbin/which; \
|
|---|
| 108 | chmod 555 lbin/which; \
|
|---|
| 109 | else \
|
|---|
| 110 | ln -s $$(which which) lbin/which; \
|
|---|
| 111 | fi
|
|---|
| 112 | @if lbin/which gmake >/dev/null 2>&1; then \
|
|---|
| 113 | ln -s $$(lbin/which gmake) lbin/gmake; \
|
|---|
| 114 | else \
|
|---|
| 115 | ln -s $$(lbin/which make) lbin/gmake; \
|
|---|
| 116 | fi
|
|---|
| 117 | @if ! lbin/which md5sum >/dev/null 2>&1; then \
|
|---|
| 118 | cp scripts/md5sum.bsd lbin/md5sum; \
|
|---|
| 119 | chmod 555 lbin/md5sum; \
|
|---|
| 120 | fi
|
|---|
| 121 | @if test x"$$(uname)" = x"MirBSD"; then \
|
|---|
| 122 | sed -e 's!@@FromOS@@!MirBSD!g' -e 's!@@ToOS@@!OpenBSD!g' \
|
|---|
| 123 | -e "s!@@PROG@@!$$(lbin/which uname)!g" \
|
|---|
| 124 | <scripts/uname.fake >lbin/uname; \
|
|---|
| 125 | chmod 555 lbin/uname; \
|
|---|
| 126 | fi
|
|---|
| 127 | @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
|
|---|
| 128 | @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| 129 | @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
|
|---|
| 130 | @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
|
|---|
| 131 | -e 's!mirbsd!openbsd!g' \
|
|---|
| 132 | )" >>lbin/prereq.mk
|
|---|
| 133 | @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
|
|---|
| 134 | -e 's/sparc.*/sparc/' \
|
|---|
| 135 | -e 's/arm.*/arm/g' \
|
|---|
| 136 | -e 's/m68k.*/m68k/' \
|
|---|
| 137 | -e 's/ppc/powerpc/g' \
|
|---|
| 138 | -e 's/v850.*/v850/g' \
|
|---|
| 139 | -e 's/sh[234]/sh/' \
|
|---|
| 140 | -e 's/mips-.*/mips/' \
|
|---|
| 141 | -e 's/mipsel-.*/mipsel/' \
|
|---|
| 142 | -e 's/cris.*/cris/' \
|
|---|
| 143 | -e 's/i[3-9]86/i386/' \
|
|---|
| 144 | )" >>lbin/prereq.mk
|
|---|
| 145 | @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
|
|---|
| 146 | @x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \
|
|---|
| 147 | ${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \
|
|---|
| 148 | 2>/dev/null | sed 's/^P://')"; \
|
|---|
| 149 | echo "HOSTCFLAGS:=$${x:--O2 -fcommon ${CFLAGS}}" | sed 's/ *$$//' \
|
|---|
| 150 | >>lbin/prereq.mk
|
|---|
| 151 | @echo 'LC_ALL:=C' >>lbin/prereq.mk
|
|---|
| 152 | @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
|
|---|
| 153 | @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
|
|---|
| 154 | @echo "_PATH:=$$PATH" >>lbin/prereq.mk
|
|---|
| 155 | @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
|
|---|
| 156 | @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| 157 | @TOPDIR=$$(readlink -nf .); \
|
|---|
| 158 | printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
|
|---|
| 159 | "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
|
|---|
| 160 | @env NO_ERROR=${NO_ERROR} bash scripts/scan-tools.sh
|
|---|
| 161 | @ln -s $$(lbin/which ${CC}) lbin/gcc
|
|---|
| 162 | @${GMAKE_INV} tools/install-lbin
|
|---|
| 163 | @echo '===> Prerequisites checked successfully.'
|
|---|
| 164 | @touch $@
|
|---|
| 165 |
|
|---|
| 166 | _tarball: .prereq_done
|
|---|
| 167 | @rm -f _pax*
|
|---|
| 168 | @${GMAKE_INV} tools/paxmirabilis-compile
|
|---|
| 169 | @install -c -m 555 tools_build/paxmirabilis/pax _pax
|
|---|
| 170 | @${GMAKE_INV} distclean
|
|---|
| 171 | @-rm -rf lbin
|
|---|
| 172 | @-rm -f make.log .prereq_done freewrt.tar.*
|
|---|
| 173 | @find . | \
|
|---|
| 174 | grep -v -e '^\.$$' -e '^\./_pax' -e '/\.svn' | \
|
|---|
| 175 | sed -e 's^\./' | \
|
|---|
| 176 | sort >_pax.flst
|
|---|
| 177 |
|
|---|
| 178 | targz: _tarball
|
|---|
| 179 | @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
|
|---|
| 180 | gzip -n9 >freewrt.tar.gz
|
|---|
| 181 | @rm -f _pax*
|
|---|
| 182 |
|
|---|
| 183 | tarbgz2: _tarball
|
|---|
| 184 | @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
|
|---|
| 185 | bzip2 --best >freewrt.tar.bz2
|
|---|
| 186 | @rm -f _pax*
|
|---|
| 187 |
|
|---|
| 188 | .PHONY: prereq prereq-noerror _tarball targz tarbz2
|
|---|