| 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} 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 | 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 ''
|
|---|
| 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 ''
|
|---|
| 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'
|
|---|
| 42 |
|
|---|
| 43 | pkg-help:
|
|---|
| 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'
|
|---|
| 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'
|
|---|
| 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 |
|
|---|
| 68 |
|
|---|
| 69 | clean: .prereq_done
|
|---|
| 70 | @${GMAKE_INV} clean
|
|---|
| 71 |
|
|---|
| 72 | config: .prereq_done
|
|---|
| 73 | @${GMAKE_INV} config
|
|---|
| 74 |
|
|---|
| 75 | oldconfig: .prereq_done
|
|---|
| 76 | @${GMAKE_INV} oldconfig
|
|---|
| 77 |
|
|---|
| 78 | cleandir: .prereq_done
|
|---|
| 79 | @${GMAKE_INV} cleandir
|
|---|
| 80 | @-rm -rf lbin
|
|---|
| 81 | @-rm -f make.log .prereq_done
|
|---|
| 82 |
|
|---|
| 83 | distclean: .prereq_done
|
|---|
| 84 | @${GMAKE_INV} distclean
|
|---|
| 85 | @-rm -rf lbin
|
|---|
| 86 | @-rm -f make.log .prereq_done
|
|---|
| 87 |
|
|---|
| 88 | image_clean: .prereq_done
|
|---|
| 89 | @${GMAKE_INV} image_clean
|
|---|
| 90 |
|
|---|
| 91 | menuconfig: .prereq_done
|
|---|
| 92 | @${GMAKE_INV} menuconfig
|
|---|
| 93 |
|
|---|
| 94 | allnoconfig: .prereq_done
|
|---|
| 95 | @${GMAKE_INV} allnoconfig
|
|---|
| 96 |
|
|---|
| 97 | allmodconfig: .prereq_done
|
|---|
| 98 | @${GMAKE_INV} allmodconfig
|
|---|
| 99 |
|
|---|
| 100 | snapshotconfig: .prereq_done
|
|---|
| 101 | @${GMAKE_INV} snapshotconfig
|
|---|
| 102 |
|
|---|
| 103 | package_index: .prereq_done
|
|---|
| 104 | @${GMAKE_INV} package_index
|
|---|
| 105 |
|
|---|
| 106 | target_clean: .prereq_done
|
|---|
| 107 | @${GMAKE_INV} target_clean
|
|---|
| 108 |
|
|---|
| 109 | world: .prereq_done
|
|---|
| 110 | @${GMAKE_INV} world
|
|---|
| 111 |
|
|---|
| 112 | prereq:
|
|---|
| 113 | @rm -f .prereq_done
|
|---|
| 114 | @${MAKE} .prereq_done
|
|---|
| 115 |
|
|---|
| 116 | prereq-noerror:
|
|---|
| 117 | @rm -f .prereq_done
|
|---|
| 118 | @${MAKE} .prereq_done NO_ERROR=1
|
|---|
| 119 |
|
|---|
| 120 | NO_ERROR=0
|
|---|
| 121 | .prereq_done:
|
|---|
| 122 | @-rm -rf .prereq_done lbin
|
|---|
| 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
|
|---|
| 127 | @mkdir lbin
|
|---|
| 128 | @if which nonexistent 2>&1 | grep -q '^no '; then \
|
|---|
| 129 | cp scripts/which.mac lbin/which; \
|
|---|
| 130 | chmod 555 lbin/which; \
|
|---|
| 131 | else \
|
|---|
| 132 | ln -s $$(which which) lbin/which; \
|
|---|
| 133 | fi
|
|---|
| 134 | @if ! lbin/which md5sum >/dev/null 2>&1; then \
|
|---|
| 135 | cp scripts/md5sum.bsd lbin/md5sum; \
|
|---|
| 136 | chmod 555 lbin/md5sum; \
|
|---|
| 137 | fi
|
|---|
| 138 | @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
|
|---|
| 139 | @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| 140 | @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
|
|---|
| 141 | @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
|
|---|
| 142 | -e 's!mirbsd!openbsd!g' \
|
|---|
| 143 | )" >>lbin/prereq.mk
|
|---|
| 144 | @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
|
|---|
| 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
|
|---|
| 156 | @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
|
|---|
| 157 | @x="$$(echo 'f:\n\techo P:$${CFLAGS}\n.include <bsd.prog.mk>' | \
|
|---|
| 158 | ${MAKE} -f - f EXPERIMENTAL=yes 2>/dev/null | grep '^P:' \
|
|---|
| 159 | 2>/dev/null | sed 's/^P://')"; y='${CFLAGS}'; echo \
|
|---|
| 160 | "HOSTCFLAGS:=$${x:-$${y:--O2}}" | sed 's/ *$$//' >>lbin/prereq.mk
|
|---|
| 161 | @echo 'LANGUAGE:=C' >>lbin/prereq.mk
|
|---|
| 162 | @echo 'LC_ALL:=C' >>lbin/prereq.mk
|
|---|
| 163 | @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
|
|---|
| 164 | @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
|
|---|
| 165 | @echo "_PATH:=$$PATH" >>lbin/prereq.mk
|
|---|
| 166 | @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
|
|---|
| 167 | @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
|
|---|
| 168 | @TOPDIR=$$(readlink -nf .); \
|
|---|
| 169 | printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
|
|---|
| 170 | "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
|
|---|
| 171 | @env NO_ERROR=${NO_ERROR} BASH="$$(lbin/which bash)" \
|
|---|
| 172 | CC='${CC}' CPPFLAGS='${CPPFLAGS}' \
|
|---|
| 173 | bash ${_PX} scripts/scan-tools.sh
|
|---|
| 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)"; \
|
|---|
| 178 | echo "export PATH=$$PATH"; \
|
|---|
| 179 | echo "exec $$cc" '"$$@"' ) >lbin/gcc; \
|
|---|
| 180 | chmod 555 lbin/gcc; \
|
|---|
| 181 | fi
|
|---|
| 182 | @${GMAKE_INV} tools/install-lbin
|
|---|
| 183 | @echo '===> Prerequisites checked successfully.'
|
|---|
| 184 | @touch $@
|
|---|
| 185 |
|
|---|
| 186 | .PHONY: prereq prereq-noerror
|
|---|