| [00ed4e2] | 1 | # $FreeWRT$
|
|---|
| [6d5c7cc] | 2 | #-
|
|---|
| [00ed4e2] | 3 | # This file is part of the FreeWRT project. FreeWRT is copyrighted
|
|---|
| 4 | # material, please see the LICENCE file in the top-level directory
|
|---|
| [93f20e7] | 5 | # or at http://www.freewrt.org/licence for details.
|
|---|
| [6d5c7cc] | 6 |
|
|---|
| 7 | GMAKE?= $(PWD)/lbin/gmake
|
|---|
| [db5651c] | 8 | GMAKE_FMK= ${GMAKE} -f $(PWD)/mk/build.mk
|
|---|
| [4d98ec5] | 9 | GMAKE_INV= ${GMAKE_FMK} --no-print-directory
|
|---|
| [6d5c7cc] | 10 |
|
|---|
| [4d98ec5] | 11 | all: .prereq_done
|
|---|
| [8eab46d] | 12 | @${GMAKE_INV} all
|
|---|
| [6d5c7cc] | 13 |
|
|---|
| [4d98ec5] | 14 | v: .prereq_done
|
|---|
| [acf89eb] | 15 | (echo; echo "Build started on $$(LC_ALL=C TZ=UTC date)"; set -x; \
|
|---|
| [4d98ec5] | 16 | ${GMAKE_FMK} all V=99) 2>&1 | tee -a make.log
|
|---|
| [71b4d1c] | 17 |
|
|---|
| [1d73b8a] | 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'
|
|---|
| [3f0223f] | 36 | @echo ' targz|tarbz2 - Create a distribution tarball (runs distclean)'
|
|---|
| [1d73b8a] | 37 |
|
|---|
| 38 |
|
|---|
| [4d98ec5] | 39 | verbose: .prereq_done
|
|---|
| 40 | @${GMAKE_FMK} all V=99
|
|---|
| [aaafd63] | 41 |
|
|---|
| [4d98ec5] | 42 | clean: .prereq_done
|
|---|
| [8eab46d] | 43 | @${GMAKE_INV} clean
|
|---|
| [6d5c7cc] | 44 |
|
|---|
| [34ca3ff] | 45 | cleanbuild: .prereq_done
|
|---|
| 46 | @${GMAKE_INV} cleanbuild
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| [4d98ec5] | 49 | config: .prereq_done
|
|---|
| [8eab46d] | 50 | @${GMAKE_INV} config
|
|---|
| [6d5c7cc] | 51 |
|
|---|
| [4d98ec5] | 52 | cleandir: .prereq_done
|
|---|
| [8eab46d] | 53 | @${GMAKE_INV} cleandir
|
|---|
| [41be261] | 54 | @-rm -rf lbin
|
|---|
| [4d98ec5] | 55 | @-rm -f make.log .prereq_done
|
|---|
| [6d5c7cc] | 56 |
|
|---|
| [4d98ec5] | 57 | distclean: .prereq_done
|
|---|
| [8eab46d] | 58 | @${GMAKE_INV} distclean
|
|---|
| [41be261] | 59 | @-rm -rf lbin
|
|---|
| [3f0223f] | 60 | @-rm -f make.log .prereq_done _pax* freewrt.tar.*
|
|---|
| [6d5c7cc] | 61 |
|
|---|
| [4d98ec5] | 62 | image_clean: .prereq_done
|
|---|
| [8eab46d] | 63 | @${GMAKE_INV} image_clean
|
|---|
| [6d5c7cc] | 64 |
|
|---|
| [4d98ec5] | 65 | menuconfig: .prereq_done
|
|---|
| [8eab46d] | 66 | @${GMAKE_INV} menuconfig
|
|---|
| [6d5c7cc] | 67 |
|
|---|
| [dc07088] | 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 |
|
|---|
| [4d98ec5] | 77 | package_index: .prereq_done
|
|---|
| [8eab46d] | 78 | @${GMAKE_INV} package_index
|
|---|
| [6d5c7cc] | 79 |
|
|---|
| [4d98ec5] | 80 | target_clean: .prereq_done
|
|---|
| [8eab46d] | 81 | @${GMAKE_INV} target_clean
|
|---|
| [6d5c7cc] | 82 |
|
|---|
| [4d98ec5] | 83 | world: .prereq_done
|
|---|
| [8eab46d] | 84 | @${GMAKE_INV} world
|
|---|
| [6d5c7cc] | 85 |
|
|---|
| [ce136e7] | 86 | allpackages: .prereq_done
|
|---|
| 87 | @${GMAKE_INV} allpackages
|
|---|
| [dc07088] | 88 |
|
|---|
| [d813884] | 89 | prereq:
|
|---|
| [4d98ec5] | 90 | @rm -f .prereq_done
|
|---|
| 91 | @${MAKE} .prereq_done
|
|---|
| 92 |
|
|---|
| [d813884] | 93 | prereq-noerror:
|
|---|
| [4d98ec5] | 94 | @rm -f .prereq_done
|
|---|
| 95 | @${MAKE} .prereq_done NO_ERROR=1
|
|---|
| [4ed535c] | 96 |
|
|---|
| 97 | NO_ERROR=0
|
|---|
| [4d98ec5] | 98 | .prereq_done:
|
|---|
| 99 | @-rm -rf .prereq_done lbin
|
|---|
| [86dab31] | 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
|
|---|
| [41be261] | 104 | @mkdir lbin
|
|---|
| [003e3c1] | 105 | @if which nonexistent 2>&1 | grep -q '^no '; then \
|
|---|
| [2856f83] | 106 | cp scripts/which.mac lbin/which; \
|
|---|
| 107 | chmod 555 lbin/which; \
|
|---|
| [6d5c7cc] | 108 | else \
|
|---|
| [2856f83] | 109 | ln -s $$(which which) lbin/which; \
|
|---|
| [6d5c7cc] | 110 | fi
|
|---|
| [2856f83] | 111 | @if lbin/which gmake >/dev/null 2>&1; then \
|
|---|
| 112 | ln -s $$(lbin/which gmake) lbin/gmake; \
|
|---|
| 113 | else \
|
|---|
| 114 | ln -s $$(lbin/which make) lbin/gmake; \
|
|---|
| 115 | fi
|
|---|
| 116 | @if ! lbin/which md5sum >/dev/null 2>&1; then \
|
|---|
| [6d5c7cc] | 117 | cp scripts/md5sum.bsd lbin/md5sum; \
|
|---|
| 118 | chmod 555 lbin/md5sum; \
|
|---|
| 119 | fi
|
|---|
| [b84b14f] | 120 | @if test x"$$(uname)" = x"MirBSD"; then \
|
|---|
| 121 | sed -e 's!@@FromOS@@!MirBSD!g' -e 's!@@ToOS@@!OpenBSD!g' \
|
|---|
| [2856f83] | 122 | -e "s!@@PROG@@!$$(lbin/which uname)!g" \
|
|---|
| [b84b14f] | 123 | <scripts/uname.fake >lbin/uname; \
|
|---|
| 124 | chmod 555 lbin/uname; \
|
|---|
| 125 | fi
|
|---|
| [453e855] | 126 | @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
|
|---|
| [7d9827e] | 127 | @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| [230f0f6] | 128 | @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
|
|---|
| [7d9827e] | 129 | @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
|
|---|
| [2242649] | 130 | -e 's!mirbsd!openbsd!g' \
|
|---|
| 131 | )" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 132 | @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
|
|---|
| [2242649] | 133 | -e 's/sparc.*/sparc/' \
|
|---|
| 134 | -e 's/arm.*/arm/g' \
|
|---|
| 135 | -e 's/m68k.*/m68k/' \
|
|---|
| 136 | -e 's/ppc/powerpc/g' \
|
|---|
| 137 | -e 's/v850.*/v850/g' \
|
|---|
| 138 | -e 's/sh[234]/sh/' \
|
|---|
| 139 | -e 's/mips-.*/mips/' \
|
|---|
| 140 | -e 's/mipsel-.*/mipsel/' \
|
|---|
| 141 | -e 's/cris.*/cris/' \
|
|---|
| 142 | -e 's/i[3-9]86/i386/' \
|
|---|
| 143 | )" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 144 | @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
|
|---|
| [b84b14f] | 145 | @x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \
|
|---|
| 146 | ${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \
|
|---|
| 147 | 2>/dev/null | sed 's/^P://')"; \
|
|---|
| [7d9827e] | 148 | echo "HOSTCFLAGS:=$${x:--O2 ${CFLAGS}}" | sed 's/ *$$//' \
|
|---|
| [b84b14f] | 149 | >>lbin/prereq.mk
|
|---|
| [7d9827e] | 150 | @echo 'LC_ALL:=C' >>lbin/prereq.mk
|
|---|
| [230f0f6] | 151 | @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
|
|---|
| [7d9827e] | 152 | @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
|
|---|
| 153 | @echo "_PATH:=$$PATH" >>lbin/prereq.mk
|
|---|
| [230f0f6] | 154 | @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 155 | @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| [453e855] | 156 | @TOPDIR=$$(readlink -nf .); \
|
|---|
| [0438188] | 157 | printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
|
|---|
| [453e855] | 158 | "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
|
|---|
| [4ed535c] | 159 | @env NO_ERROR=${NO_ERROR} bash scripts/scan-tools.sh
|
|---|
| [2856f83] | 160 | @ln -s $$(lbin/which ${CC}) lbin/gcc
|
|---|
| [a7b530b] | 161 | @${GMAKE_INV} tools/install-lbin
|
|---|
| [bc1387d] | 162 | @echo '===> Prerequisites checked successfully.'
|
|---|
| [41be261] | 163 | @touch $@
|
|---|
| [d813884] | 164 |
|
|---|
| [3f0223f] | 165 | _tarball: .prereq_done
|
|---|
| 166 | @rm -f _pax*
|
|---|
| 167 | @${GMAKE_INV} tools/paxmirabilis-compile
|
|---|
| 168 | @install -c -m 555 tools_build/paxmirabilis/pax _pax
|
|---|
| 169 | @${GMAKE_INV} distclean
|
|---|
| 170 | @-rm -rf lbin
|
|---|
| 171 | @-rm -f make.log .prereq_done freewrt.tar.*
|
|---|
| 172 | @find . | \
|
|---|
| 173 | grep -v -e '^\.$$' -e '^\./_pax' -e '/\.svn' | \
|
|---|
| 174 | sed -e 's^\./' | \
|
|---|
| 175 | sort >_pax.flst
|
|---|
| 176 |
|
|---|
| 177 | targz: _tarball
|
|---|
| 178 | @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
|
|---|
| 179 | gzip -n9 >freewrt.tar.gz
|
|---|
| 180 | @rm -f _pax*
|
|---|
| 181 |
|
|---|
| 182 | tarbgz2: _tarball
|
|---|
| 183 | @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
|
|---|
| 184 | bzip2 --best >freewrt.tar.bz2
|
|---|
| 185 | @rm -f _pax*
|
|---|
| 186 |
|
|---|
| 187 | .PHONY: prereq prereq-noerror _tarball targz tarbz2
|
|---|