root/branches/common-nfo/rules.mk

Revision 3486, 3.1 kB (checked in by tg, 1 year ago)

better, much much better

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 include $(TOPDIR)/lbin/prereq.mk
8 -include $(TOPDIR)/.config
9 -include ${TOPDIR}/prefs.mk
10
11 V:=99
12 export V
13
14 ifneq ($(V),0)
15 TRACE:=                 echo "---> "
16 START_TRACE:=           echo -n "---> "
17 END_TRACE:=             echo
18 else
19 START_TRACE:=           :
20 END_TRACE:=             :
21 TRACE:=                 :
22 endif
23
24 ifeq (${shell [ "$(V)" -ge 5 ] && echo 1},)
25 CMD_TRACE:=             :
26 PKG_TRACE:=             :
27 else
28 CMD_TRACE:=             echo -n
29 PKG_TRACE:=             echo "------> "
30 endif
31
32 ifeq (${shell [ "$(V)" -ge 10 ] && echo 1},)
33 EXTRA_MAKEFLAGS:=       -s
34 MAKE_TRACE:=            >/dev/null 2>&1 || { echo "Build failed. Please re-run make with V=99 to see what's going on"; false; }
35 else
36 MAKE_TRACE:=
37 EXTRA_MAKEFLAGS:=
38 TRACE:=                 :
39 PKG_TRACE:=             :
40 CMD_TRACE:=             :
41 START_TRACE:=           :
42 END_TRACE:=             :
43 endif
44
45 ifeq (${shell [ "$(V)" -ge 90 ] && echo 1},)
46 SET_DASHX:=             :
47 else
48 SET_DASHX:=             set -x
49 endif
50
51 # Strip off the annoying quoting
52 ARCH:=                  $(strip $(subst ",, $(FWRT_ARCH)))
53 TARGET_OPTIMIZATION:=   $(strip $(subst ",, $(FWRT_TARGET_OPTIMIZATION)))
54 FWRT_PREFIX:=           $(strip $(subst ",, $(FWRT_PREFIX)))
55 #"))"))"))"))")) # for vim's broken syntax highlighting :)
56
57 ifneq ($(strip ${FWRT_USE_CCACHE}),)
58 TARGET_COMPILER_PREFIX= ccache-
59 endif
60
61 include $(TOPDIR)/mk/vars.mk
62
63 TARGET_CC:=             $(strip ${TARGET_CC})
64 TARGET_CXX:=            $(strip ${TARGET_CXX})
65
66 ifeq ($(strip ${FWRT_JLEVEL}),-1)
67 MAKEFLAGS+=             -j
68 elifneq ($(strip ${FWRT_JLEVEL}),)
69 ifneq ($(strip ${FWRT_JLEVEL}),0)
70 ifneq ($(strip ${FWRT_JLEVEL}),1)
71 MAKEFLAGS+=             -j$(strip ${FWRT_JLEVEL})
72 endif
73 endif
74 endif
75
76 ifeq ($(strip ${FWRT_HAVE_DOT_CONFIG}),y)
77 # XXX derive these from FWRT_* vars
78 UNAME_S:=               Linux
79
80 ifeq ($(strip ${FWRT_LINUX_2_6_AR7}),y)
81 UNAME_R:=               2.6.21.1
82 else ifeq ($(strip ${FWRT_LINUX_2_6_BRCM_ASUS_WL500G_PREMIUM}),y)
83 UNAME_R:=               2.6.22.1
84 else ifeq ($(strip ${FWRT_LINUX_2_4}),y)
85 UNAME_R:=               2.4.34
86 else ifeq ($(strip ${FWRT_LINUX_2_6}),y)
87 UNAME_R:=               2.6.19.1
88 else
89 UNAME_R=                $(error Cannot determine target "uname -r" output)
90 endif
91
92 ifeq ($(strip ${FWRT_mipsel}),y)
93 UNAME_M:=               mips
94 else ifeq ($(strip ${FWRT_i386}),y)
95 UNAME_M:=               i386
96 else ifeq ($(strip ${FWRT_armeb}),y)
97 UNAME_M:=               arm
98 else ifeq ($(strip ${FWRT_arm}),y)
99 UNAME_M:=               arm
100 else ifeq ($(strip ${FWRT_avr32}),y)
101 UNAME_M:=               avr32
102 else ifeq ($(strip ${FWRT_cris}),y)
103 UNAME_M:=               cris
104 else ifeq ($(strip ${FWRT_powerpc}),y)
105 UNAME_M:=               powerpc
106 else
107 UNAME_M=                $(error Cannot determine target "uname -m" output)
108 endif
109
110 export UNAME_S UNAME_R UNAME_M
111 else    # ! ifeq ($(strip ${FWRT_HAVE_DOT_CONFIG}),y)
112 UNAME_S=                $(error This variable cannot be used without .config)
113 UNAME_R=                $(error This variable cannot be used without .config)
114 UNAME_M=                $(error This variable cannot be used without .config)
115 endif   # ! ifeq ($(strip ${FWRT_HAVE_DOT_CONFIG}),y)
116
117 export BASH HOSTCC HOSTCFLAGS MAKE LANGUAGE LC_ALL OStype PATH
118
119 HOSTCPPFLAGS?=
120 HOSTLDFLAGS?=
121
122 HOST_CFLAGS:=           ${HOSTCFLAGS}
123 TARGET_CFLAGS:=         $(strip -Os -fno-ident ${TARGET_CFLAGS} -fwrapv -fhonour-copts)
124 TARGET_CC:=             $(strip ${TARGET_CC})
125 TARGET_CXX:=            $(strip ${TARGET_CXX})
126
127 ifneq (${show},)
128 _show:
129         @echo '$($(show))'
130 endif
Note: See TracBrowser for help on using the browser.