root/branches/freewrt_1_0/Makefile

Revision 3098, 5.5 kB (checked in by tg, 2 years ago)

replicate r3096, as it's needed here too

Line 
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         @if which nonexistent 2>&1 | grep -q '^no '; then \
106                 cp scripts/which.mac lbin/which; \
107                 chmod 555 lbin/which; \
108         else \
109                 ln -s $$(which which) lbin/which; \
110         fi
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 \
117                 cp scripts/md5sum.bsd lbin/md5sum; \
118                 chmod 555 lbin/md5sum; \
119         fi
120         @if test x"$$(uname)" = x"MirBSD"; then \
121                 sed -e 's!@@FromOS@@!MirBSD!g' -e 's!@@ToOS@@!OpenBSD!g' \
122                     -e "s!@@PROG@@!$$(lbin/which uname)!g" \
123                     <scripts/uname.fake >lbin/uname; \
124                 chmod 555 lbin/uname; \
125         fi
126         @echo "TOPDIR:=$$(readlink -nf .)" >lbin/prereq.mk
127         @echo "BASH:=$$(lbin/which bash)" >>lbin/prereq.mk
128         @echo 'GMAKE:=$${TOPDIR}/lbin/gmake' >>lbin/prereq.mk
129         @echo "GNU_HOST_NAME:=$$(${CC} -dumpmachine | sed \
130             -e 's!mirbsd!openbsd!g' \
131             )" >>lbin/prereq.mk
132         @echo "HOST_ARCH:=$$(${CC} -dumpmachine | sed -e s'/-.*//' \
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
144         @echo 'HOSTCC:=${CC}' >>lbin/prereq.mk
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://')"; \
148             echo "HOSTCFLAGS:=$${x:--O2 ${CFLAGS}}" | sed 's/ *$$//' \
149             >>lbin/prereq.mk
150         @echo 'LC_ALL:=C' >>lbin/prereq.mk
151         @echo 'MAKE:=$${GMAKE}' >>lbin/prereq.mk
152         @echo "OStype:=$$(env NOFAKE=yes uname)" >>lbin/prereq.mk
153         @echo "_PATH:=$$PATH" >>lbin/prereq.mk
154         @echo "PATH:=\$${TOPDIR}/lbin:$$PATH" >>lbin/prereq.mk
155         @echo "SHELL:=$$(lbin/which bash)" >>lbin/prereq.mk
156         @TOPDIR=$$(readlink -nf .); \
157             printf '%s\n%s\nwq\n' ",g#$$TOPDIR#s##\$${TOPDIR}#g" \
158             "1s#^.*\$$#TOPDIR:=$$TOPDIR#" | ed -s lbin/prereq.mk
159         @env NO_ERROR=${NO_ERROR} bash scripts/scan-tools.sh
160         @ln -s $$(lbin/which ${CC}) lbin/gcc
161         @${GMAKE_INV} tools/install-lbin
162         @echo '===> Prerequisites checked successfully.'
163         @touch $@
164
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         @echo 'package/base-files/.svn/entries' >>_pax.flst
177         @echo 'toolchain/gcc/.svn/entries' >>_pax.flst
178
179 targz: _tarball
180         @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
181             gzip -n9 >freewrt.tar.gz
182         @rm -f _pax*
183
184 tarbgz2: _tarball
185         @./_pax -w -b 512 -d -M dist -P -t -v -x ustar <_pax.flst | \
186             bzip2 --best >freewrt.tar.bz2
187         @rm -f _pax*
188
189 .PHONY: prereq prereq-noerror _tarball targz tarbz2
Note: See TracBrowser for help on using the browser.