| [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
|
|---|
| [9967d6c] | 9 | GMAKE_INV= ${GMAKE_FMK} V=99
|
|---|
| [6d5c7cc] | 10 |
|
|---|
| [9967d6c] | 11 | all verbose: .prereq_done
|
|---|
| [8eab46d] | 12 | @${GMAKE_INV} all
|
|---|
| [6d5c7cc] | 13 |
|
|---|
| [4d98ec5] | 14 | v: .prereq_done
|
|---|
| [6857f83] | 15 | (echo; echo "Build started on $$(LC_ALL=C LANGUAGE=C TZ=UTC date)"; \
|
|---|
| [56309566] | 16 | set -x; ${GMAKE_FMK} V=99 all) 2>&1 | tee -a make.log
|
|---|
| [aaafd63] | 17 |
|
|---|
| [29b8d3d] | 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 ' oldconfig - Update current config utilising a provided .configs base'
|
|---|
| 30 | @echo ' allmodconfig - New config selecting modules when possible'
|
|---|
| 31 | @echo ' allnoconfig - New config where all options are answered with no'
|
|---|
| 32 | @echo ''
|
|---|
| [ed52222] | 33 | @echo 'Help targets:'
|
|---|
| 34 | @echo ' help - Print this help text'
|
|---|
| 35 | @echo ' pkg-help - Print help about selectively compiling single packages'
|
|---|
| 36 | @echo ' dev-help - Print help for developers / package maintainers'
|
|---|
| 37 | @echo ''
|
|---|
| [29b8d3d] | 38 | @echo 'Other generic targets:'
|
|---|
| 39 | @echo ' all - Build everything as specified in .config'
|
|---|
| 40 | @echo ' (default if .config exists)'
|
|---|
| 41 | @echo ' v - Same as "all" but with logging to make.log enabled'
|
|---|
| [ed52222] | 42 |
|
|---|
| 43 | pkg-help:
|
|---|
| [29b8d3d] | 44 | @echo 'Package specific targets (use with "package=<pkg-name>" parameter):'
|
|---|
| 45 | @echo ' fetch - Download the necessary distfile'
|
|---|
| 46 | @echo ' extract - Same as "fetch", but also extract the distfile'
|
|---|
| 47 | @echo ' patch - Same as "extract", but also patch the source'
|
|---|
| [c64ea5f] | 48 | @echo ' build - Same as "patch", but also build the binaries'
|
|---|
| 49 | @echo ' fake - Same as "build", but also install the binaries'
|
|---|
| 50 | @echo ' package - Same as "fake", but also create the ipkg package'
|
|---|
| [ed52222] | 51 | @echo ''
|
|---|
| 52 | @echo 'Short package rebuilding guide:'
|
|---|
| 53 | @echo ' run "make package=<pkgname> clean" to remove all generated binaries'
|
|---|
| 54 | @echo ' run "make package=<pkgname> package" to build everything and create the ipkg'
|
|---|
| 55 | @echo ''
|
|---|
| 56 | @echo 'BEWARE: as for now, this does not resolve package dependencies!'
|
|---|
| 57 |
|
|---|
| 58 | dev-help:
|
|---|
| 59 | @echo 'Fast way of updating package patches:'
|
|---|
| 60 | @echo ' run "make package=<pkgname> clean" to start with a good base'
|
|---|
| 61 | @echo ' run "make package=<pkgname> patch" to fetch, unpack and patch the source'
|
|---|
| 62 | @echo ' edit the package sources at build_dir/<pkgname>/<pkgname>-<version>'
|
|---|
| 63 | @echo ' run "make package=<pkgname> update-patches to update the existing patches (if any)'
|
|---|
| 64 | @echo ''
|
|---|
| 65 | @echo 'Each changed patches will be opened with your $$EDITOR,'
|
|---|
| 66 | @echo 'so you can add a description and verify the changes.'
|
|---|
| 67 |
|
|---|
| [29b8d3d] | 68 |
|
|---|
| [4d98ec5] | 69 | clean: .prereq_done
|
|---|
| [8eab46d] | 70 | @${GMAKE_INV} clean
|
|---|
| [6d5c7cc] | 71 |
|
|---|
| [4d98ec5] | 72 | config: .prereq_done
|
|---|
| [0af9d4d] | 73 | @${GMAKE_INV} config
|
|---|
| [6d5c7cc] | 74 |
|
|---|
| [554e292] | 75 | oldconfig: .prereq_done
|
|---|
| [0af9d4d] | 76 | @${GMAKE_INV} oldconfig
|
|---|
| [554e292] | 77 |
|
|---|
| [4d98ec5] | 78 | cleandir: .prereq_done
|
|---|
| [8eab46d] | 79 | @${GMAKE_INV} cleandir
|
|---|
| [41be261] | 80 | @-rm -rf lbin
|
|---|
| [4d98ec5] | 81 | @-rm -f make.log .prereq_done
|
|---|
| [6d5c7cc] | 82 |
|
|---|
| [4d98ec5] | 83 | distclean: .prereq_done
|
|---|
| [8eab46d] | 84 | @${GMAKE_INV} distclean
|
|---|
| [41be261] | 85 | @-rm -rf lbin
|
|---|
| [4d98ec5] | 86 | @-rm -f make.log .prereq_done
|
|---|
| [6d5c7cc] | 87 |
|
|---|
| [4d98ec5] | 88 | image_clean: .prereq_done
|
|---|
| [8eab46d] | 89 | @${GMAKE_INV} image_clean
|
|---|
| [6d5c7cc] | 90 |
|
|---|
| [4d98ec5] | 91 | menuconfig: .prereq_done
|
|---|
| [0af9d4d] | 92 | @${GMAKE_INV} menuconfig
|
|---|
| [6d5c7cc] | 93 |
|
|---|
| [da78ea0] | 94 | allnoconfig: .prereq_done
|
|---|
| [0af9d4d] | 95 | @${GMAKE_INV} allnoconfig
|
|---|
| [da78ea0] | 96 |
|
|---|
| [4fb7485] | 97 | allmodconfig: .prereq_done
|
|---|
| [0af9d4d] | 98 | @${GMAKE_INV} allmodconfig
|
|---|
| [4fb7485] | 99 |
|
|---|
| [6435191] | 100 | snapshotconfig: .prereq_done
|
|---|
| [0af9d4d] | 101 | @${GMAKE_INV} snapshotconfig
|
|---|
| [6435191] | 102 |
|
|---|
| [4d98ec5] | 103 | package_index: .prereq_done
|
|---|
| [8eab46d] | 104 | @${GMAKE_INV} package_index
|
|---|
| [6d5c7cc] | 105 |
|
|---|
| [4d98ec5] | 106 | target_clean: .prereq_done
|
|---|
| [8eab46d] | 107 | @${GMAKE_INV} target_clean
|
|---|
| [6d5c7cc] | 108 |
|
|---|
| [4d98ec5] | 109 | world: .prereq_done
|
|---|
| [8eab46d] | 110 | @${GMAKE_INV} world
|
|---|
| [6d5c7cc] | 111 |
|
|---|
| [d813884] | 112 | prereq:
|
|---|
| [4d98ec5] | 113 | @rm -f .prereq_done
|
|---|
| 114 | @${MAKE} .prereq_done
|
|---|
| 115 |
|
|---|
| [d813884] | 116 | prereq-noerror:
|
|---|
| [4d98ec5] | 117 | @rm -f .prereq_done
|
|---|
| 118 | @${MAKE} .prereq_done NO_ERROR=1
|
|---|
| [4ed535c] | 119 |
|
|---|
| 120 | NO_ERROR=0
|
|---|
| [4d98ec5] | 121 | .prereq_done:
|
|---|
| 122 | @-rm -rf .prereq_done lbin
|
|---|
| [86dab31] | 123 | @if ! bash --version 2>&1 | fgrep 'GNU bash' >/dev/null 2>&1; then \
|
|---|
| 124 | echo "FreeWRT requires GNU bash to be installed, sorry."; \
|
|---|
| 125 | exit 1; \
|
|---|
| 126 | fi
|
|---|
| [41be261] | 127 | @mkdir lbin
|
|---|
| [003e3c1] | 128 | @if which nonexistent 2>&1 | grep -q '^no '; then \
|
|---|
| [2856f83] | 129 | cp scripts/which.mac lbin/which; \
|
|---|
| 130 | chmod 555 lbin/which; \
|
|---|
| [6d5c7cc] | 131 | else \
|
|---|
| [2856f83] | 132 | ln -s $$(which which) lbin/which; \
|
|---|
| [6d5c7cc] | 133 | fi
|
|---|
| [2856f83] | 134 | @if ! lbin/which md5sum >/dev/null 2>&1; then \
|
|---|
| [6d5c7cc] | 135 | cp scripts/md5sum.bsd lbin/md5sum; \
|
|---|
| 136 | chmod 555 lbin/md5sum; \
|
|---|
| 137 | fi
|
|---|
| [453e855] | 138 | @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
|
|---|
| [7d9827e] | 139 | @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| [230f0f6] | 140 | @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
|
|---|
| [7d9827e] | 141 | @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
|
|---|
| [2242649] | 142 | -e 's!mirbsd!openbsd!g' \
|
|---|
| 143 | )" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 144 | @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
|
|---|
| [2242649] | 145 | -e 's/sparc.*/sparc/' \
|
|---|
| 146 | -e 's/arm.*/arm/g' \
|
|---|
| 147 | -e 's/m68k.*/m68k/' \
|
|---|
| 148 | -e 's/ppc/powerpc/g' \
|
|---|
| 149 | -e 's/v850.*/v850/g' \
|
|---|
| 150 | -e 's/sh[234]/sh/' \
|
|---|
| 151 | -e 's/mips-.*/mips/' \
|
|---|
| 152 | -e 's/mipsel-.*/mipsel/' \
|
|---|
| 153 | -e 's/cris.*/cris/' \
|
|---|
| 154 | -e 's/i[3-9]86/i386/' \
|
|---|
| 155 | )" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 156 | @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
|
|---|
| [b84b14f] | 157 | @x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \
|
|---|
| 158 | ${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \
|
|---|
| [8e62bd6] | 159 | 2>/dev/null | sed 's/^P://')"; y='${CFLAGS}'; echo \
|
|---|
| 160 | "HOSTCFLAGS:=$${x:-$${y:--O2}}" | sed 's/ *$$//' >>lbin/prereq.mk
|
|---|
| [6857f83] | 161 | @echo 'LANGUAGE:=C' >>lbin/prereq.mk
|
|---|
| [7d9827e] | 162 | @echo 'LC_ALL:=C' >>lbin/prereq.mk
|
|---|
| [230f0f6] | 163 | @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
|
|---|
| [7d9827e] | 164 | @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
|
|---|
| 165 | @echo "_PATH:=$$PATH" >>lbin/prereq.mk
|
|---|
| [230f0f6] | 166 | @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
|
|---|
| [7d9827e] | 167 | @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| [453e855] | 168 | @TOPDIR=$$(readlink -nf .); \
|
|---|
| [22f6577] | 169 | printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
|
|---|
| [453e855] | 170 | "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
|
|---|
| [32396b1] | 171 | @env NO_ERROR=${NO_ERROR} BASH="$$(lbin/which bash)" \
|
|---|
| 172 | CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
|
|---|
| 173 | bash ${_PX} scripts/scan-tools.sh
|
|---|
| [7d8cbbb2] | 174 | @cc='${CC}'; if test x"$$cc" = x"gcc"; then \
|
|---|
| 175 | ln -s $$(lbin/which "$$cc") lbin/gcc; \
|
|---|
| 176 | else \
|
|---|
| 177 | ( echo "#!$$(lbin/which bash)"; \
|
|---|
| [604531a] | 178 | echo "export PATH=$$PATH"; \
|
|---|
| [7d8cbbb2] | 179 | echo "exec $$cc" '"$$@"' ) >lbin/gcc; \
|
|---|
| 180 | chmod 555 lbin/gcc; \
|
|---|
| 181 | fi
|
|---|
| [0af9d4d] | 182 | @${GMAKE_INV} tools/install-lbin
|
|---|
| [bc1387d] | 183 | @echo '===> Prerequisites checked successfully.'
|
|---|
| [41be261] | 184 | @touch $@
|
|---|
| [d813884] | 185 |
|
|---|
| 186 | .PHONY: prereq prereq-noerror
|
|---|