root/trunk/freewrt/mk/build.mk

Revision 3781, 4.7 kB (checked in by n0-1, 4 months ago)

fix for systems with a shell-builtin ulimit only

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 TOPDIR=$(shell pwd)
8 export TOPDIR
9
10 ifneq ($(shell umask 2>/dev/null | sed 's/0*022/OK/'),OK)
11 $(error your umask is not 022)
12 endif
13
14 # FIXME: ugly double shell spawn - helps finding the shell-builtin ulimit
15 ifneq ($(shell echo $$(ulimit -d)),unlimited)
16 ifneq ($(shell if (( $$(ulimit -d) < 250000 )); then echo warn; else echo ok; fi),ok)
17 $(error your ulimit datasize is too small, use 250 MB or more)
18 endif
19 endif
20
21 CONFIG_CONFIG_IN = Config.in
22 CONFIG = tools/config
23
24 noconfig_targets:=      menuconfig \
25                         _config \
26                         _mconfig \
27                         tags
28
29 MAKECLEAN_SYMBOLS=      FWRT_ISOMATH FWRT_UNICODE _ FWRT_IPV6 FWRT_MANPAGES
30 POSTCONFIG=             @\
31         what=cleandir; \
32         for symbol in ${MAKECLEAN_SYMBOLS}; do \
33                 if [[ $$symbol = _ ]]; then \
34                         what=clean; \
35                         continue; \
36                 fi; \
37                 newval=$$(grep -e "^$$symbol=" -e "^\# $$symbol " .config); \
38                 oldval=$$(cat .cfg/"$$symbol" 2>&-); \
39                 [[ $$newval = $$oldval ]] && continue; \
40                 echo >&2 "WARNING: Options have changed, run 'make" \
41                     "$$what' first!"; \
42                 break; \
43         done
44
45 # Pull in the user's configuration file
46 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
47 -include $(TOPDIR)/.config
48 endif
49
50 ifeq ($(strip $(FWRT_HAVE_DOT_CONFIG)),y)
51 include $(TOPDIR)/rules.mk
52 include ${TOPDIR}/mk/split-cfg.mk
53
54 all: world
55
56 .NOTPARALLEL:
57 .PHONY: all world clean cleandir distclean image_clean
58
59 world: $(DISTDIR) $(BUILD_DIR) $(PACKAGE_DIR) ${TOPDIR}/.cfg/FWRT_HAVE_DOT_CONFIG
60         BASH='${BASH}' ${MBSH} ${TOPDIR}/scripts/scan-pkgs.sh
61 ifeq ($(strip ${FWRT_PACKAGE_BASE_FILES}),m)
62         $(MAKE) -f mk/build.mk tools/install toolchain/install target/config-prepare target/compile package/compile package_index
63 else
64         $(MAKE) -f mk/build.mk tools/install toolchain/install target/config-prepare target/compile package/compile root_clean package/install target/install package_index
65 endif
66
67 package_index:
68         -cd ${PACKAGE_DIR} && \
69             ${MBSH} ${TOPDIR}/scripts/ipkg-make-index.sh . >Packages
70 ifeq ($(strip ${FWRT_MANPAGES}),y)
71         -rm -f ${BIN_DIR}/htman/index.html
72         cp ${TOPDIR}/scripts/htmanidx.htm ${BIN_DIR}/htman/index.html
73         chmod -R g+w ${BIN_DIR}/htman
74 endif
75
76 $(DISTDIR):
77         mkdir -p $(DISTDIR)
78
79 $(BUILD_DIR):
80         mkdir -p $(BUILD_DIR)
81
82 $(PACKAGE_DIR):
83         mkdir -p ${PACKAGE_DIR}/.stamps
84
85 package/%: ${TOPDIR}/.cfg/FWRT_HAVE_DOT_CONFIG
86         @$(TRACE) $@
87         $(MAKE) -C package $(patsubst package/%,%,$@)
88
89 target/%: ${TOPDIR}/.cfg/FWRT_HAVE_DOT_CONFIG
90         @$(TRACE) $@
91         $(MAKE) -C target $(patsubst target/%,%,$@)
92
93 toolchain/%:
94         @$(TRACE) $@
95         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
96
97 tools/%:
98         @$(TRACE) $@
99         $(MAKE) -C tools $(patsubst tools/%,%,$@)
100
101 #############################################################
102 #
103 # Cleanup and misc junk
104 #
105 #############################################################
106 root_clean:
107         @$(TRACE) root_clean
108         rm -rf $(BUILD_DIR)/linux-*/root $(BUILD_DIR)/root
109
110 clean:
111         @$(TRACE) clean
112         $(MAKE) -C $(CONFIG) clean
113         rm -rf $(BUILD_DIR)/* $(BIN_DIR)/* ${TOPDIR}/.cfg
114         rm -f ${TOPDIR}/package/*/info.mk
115
116 cleandir:
117         @$(TRACE) cleandir
118         $(MAKE) -C $(CONFIG) clean
119         rm -rf $(BUILD_DIR)/* $(BIN_DIR)/* ${TOPDIR}/.cfg
120         rm -rf $(TOOLS_BUILD_DIR)/* $(TOOLCHAIN_BUILD_DIR)/* $(STAGING_PARENT)
121         rm -f .tmpconfig.h ${TOPDIR}/package/*/info.mk
122
123 distclean:
124         @$(TRACE) distclean
125         $(MAKE) -C $(CONFIG) clean
126         rm -rf $(BUILD_DIR) $(BIN_DIR) $(DISTDIR) ${TOPDIR}/.cfg
127         rm -rf $(TOOLS_BUILD_DIR) $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT)
128         rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
129
130 else # ifeq ($(strip $(FWRT_HAVE_DOT_CONFIG)),y)
131
132 include $(TOPDIR)/lbin/prereq.mk
133
134 all: menuconfig
135         @echo "Start the build with \"make\" or with \"make v\" to be verbose"
136
137 # configuration
138 # ---------------------------------------------------------------------------
139
140 $(CONFIG)/conf:
141         $(MAKE) -C $(CONFIG) conf
142 $(CONFIG)/mconf:
143         $(MAKE) -C $(CONFIG)
144
145 menuconfig: $(CONFIG)/mconf
146         -touch .config
147         $(CONFIG)/mconf $(CONFIG_CONFIG_IN)
148         ${POSTCONFIG}
149
150 _config: $(CONFIG)/conf
151         -touch .config
152         $(CONFIG)/conf ${W} $(CONFIG_CONFIG_IN)
153         ${POSTCONFIG}
154
155 # add patterns for config symbols to always restore from default here
156 RESTORE_PATTERNS := CCACHE FWRT_RUNTIME
157 .NOTPARALLEL: _mconfig
158 _mconfig: ${CONFIG}/conf _mconfig2 _config
159 _mconfig2: ${CONFIG}/conf
160         ${CONFIG}/conf -M ${RCONFIG}
161         ${MBSH} scripts/restore-defaultconf.sh ${RESTORE_PATTERNS}
162
163 tools/%:
164         $(MAKE) -C tools $(patsubst tools/%,%,$@)
165
166 distclean:
167         $(MAKE) -C $(CONFIG) clean
168         rm -rf $(BUILD_DIR) $(BIN_DIR) $(DISTDIR) ${TOPDIR}/.cfg tools_build
169         rm -rf $(TOOLS_BUILD_DIR) $(TOOLCHAIN_BUILD_DIR) $(STAGING_PARENT)
170         rm -f .config* .tmpconfig.h ${TOPDIR}/package/*/info.mk
171
172 endif # ifeq ($(strip $(FWRT_HAVE_DOT_CONFIG)),y)
173
Note: See TracBrowser for help on using the browser.